版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_40788630/article/details/83279032
一、课程模块——修改课程信息
具体代码如下:
package course;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import dao.CourseManager;
import dao.GradeManager;;;
public class Cupd extends Dialog implements ActionListener{
private Panel p1,p2,p3;
private Label lab1,lab2,lab3,lab4;
private TextField t1,t2,t3,t4;
private Button btn1,btn2;
public Cupd(Frame f,String title,boolean mo,CourseManager sm,int rowNo) {
super(f, title, mo);
p1= new Panel();
p1.setLayout(new GridLayout(4,1));
lab1=new Label("课程号");
lab2=new Label("课程名称");
lab3=new Label("课程类型");
lab4=new Label("课程内容");
p1.add(lab1);
p1.add(lab2);
p1.add(lab3);
p1.add(lab4);
this.add(p1, BorderLayout.WEST);
p2=new Panel();
p2.setLayout(new GridLayout(4, 1));
t1=new TextField((String)sm.getValueAt(rowNo, 0));
t1.setEditable(false);
t2=new TextField((String)sm.getValueAt(rowNo, 1));
t3=new TextField((String)sm.getValueAt(rowNo, 2));
t4=new TextField((String)sm.getValueAt(rowNo, 3));
p2.add(t1);
p2.add(t2);
p2.add(t3);
p2.add(t4);
this.add(p2, BorderLayout.CENTER);
//创建第三个面板,并添加两个按钮
p3=new Panel();
btn1=new Button("确定");
btn2=new Button("取消");
btn1.addActionListener(this);
btn2.addActionListener(this);
p3.add(btn1);
p3.add(btn2);
this.add(p3,BorderLayout.SOUTH);
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dim= tk.getScreenSize();
this.setBounds(300, 400, 200, 200);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==btn1) {
CourseManager sm2 = new CourseManager();//实例化业务处理类
String sql = "update course set cname=?,ctype=?,ccontent=? where cid=?";
String[] param=new String[] {t2.getText().trim(),t3.getText().trim(),t4.getText().trim(),t1.getText().trim()};
sm2.addCourse(sql, param);
this.dispose();
}else if(e.getSource()==btn2) {
this.dispose();
}
}
}
二、学生模块——修改学生信息
具体代码如下:
package student;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import dao.StudentManager;
public class Supd extends Dialog implements ActionListener{
private Panel p1,p2,p3;
private Label lab1,lab2,lab3,lab4,lab5,lab6;
private TextField t1,t2,t3,t4,t5,t6;
private Button btn1,btn2;
public Supd(Frame f,String title,boolean mo,StudentManager sm,int rowNo) {
super(f, title, mo);
p1= new Panel();
p1.setLayout(new GridLayout(6,1));
lab1=new Label("学号");
lab2=new Label("姓名");
lab3=new Label("性别");
lab4=new Label("年龄");
lab5=new Label("生日");
lab6=new Label("电话");
p1.add(lab1);
p1.add(lab2);
p1.add(lab3);
p1.add(lab4);
p1.add(lab5);
p1.add(lab6);
this.add(p1, BorderLayout.WEST);
p2=new Panel();
p2.setLayout(new GridLayout(6, 1));
t1=new TextField((String)sm.getValueAt(rowNo, 0));
t1.setEditable(false);
t2=new TextField((String)sm.getValueAt(rowNo, 1));
t3=new TextField((String)sm.getValueAt(rowNo, 2));
t4=new TextField((String)sm.getValueAt(rowNo, 3));
t5=new TextField((String)sm.getValueAt(rowNo, 4));
t6=new TextField((String)sm.getValueAt(rowNo, 5));
p2.add(t1);
p2.add(t2);
p2.add(t3);
p2.add(t4);
p2.add(t5);
p2.add(t6);
this.add(p2, BorderLayout.CENTER);
//创建第三个面板,并添加两个按钮
p3=new Panel();
btn1=new Button("确定");
btn2=new Button("取消");
btn1.addActionListener(this);
btn2.addActionListener(this);
p3.add(btn1);
p3.add(btn2);
this.add(p3,BorderLayout.SOUTH);
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dim= tk.getScreenSize();
this.setBounds(300, 400, 200, 200);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==btn1) {
StudentManager sm = new StudentManager();//实例化业务处理类
String sql = "update student set sname=?,ssex=?,sage=?,sbirthday=?,stel=? where sid=?";
String[] param=new String[] {t2.getText().trim(),t3.getText().trim(),t4.getText().trim(),t5.getText().trim(),t6.getText().trim(),t1.getText().trim()};
sm.addStudent(sql, param);
this.dispose();
}else if(e.getSource()==btn2) {
this.dispose();
}
}
}
三、成绩模块——修改成绩信息
具体代码如下:
package grade;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import dao.GradeManager;;
public class Gupd extends Dialog implements ActionListener{
private Panel p1,p2,p3;
private Label lab1,lab2,lab3,lab4;
private TextField t1,t2,t3,t4;
private Button btn1,btn2;
public Gupd(Frame f,String title,boolean mo,GradeManager sm,int rowNo) {
super(f, title, mo);
p1= new Panel();
p1.setLayout(new GridLayout(4,1));
lab1=new Label("学号");
lab2=new Label("课程号");
lab3=new Label("成绩");
lab4=new Label("学期");
p1.add(lab1);
p1.add(lab2);
p1.add(lab3);
p1.add(lab4);
this.add(p1, BorderLayout.WEST);
p2=new Panel();
p2.setLayout(new GridLayout(4, 1));
t1=new TextField((String)sm.getValueAt(rowNo, 0));
t1.setEditable(false);
t2=new TextField((String)sm.getValueAt(rowNo, 1));
t2.setEditable(false);
t3=new TextField((String)sm.getValueAt(rowNo, 2));
t4=new TextField((String)sm.getValueAt(rowNo, 3));
p2.add(t1);
p2.add(t2);
p2.add(t3);
p2.add(t4);
this.add(p2, BorderLayout.CENTER);
//创建第三个面板,并添加两个按钮
p3=new Panel();
btn1=new Button("确定");
btn2=new Button("取消");
btn1.addActionListener(this);
btn2.addActionListener(this);
p3.add(btn1);
p3.add(btn2);
this.add(p3,BorderLayout.SOUTH);
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dim= tk.getScreenSize();
this.setBounds(300, 400, 200, 200);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==btn1) {
GradeManager sm2 = new GradeManager();//实例化业务处理类
String sql = "update grade set gmark=?,gstate=? where gsid=? and gcid=?";
String[] param=new String[] {t3.getText().trim(),t4.getText().trim(),t1.getText().trim(),t2.getText().trim()};
sm2.addGrade(sql, param);
this.dispose();
}else if(e.getSource()==btn2) {
this.dispose();
}
}
}