//作者:沈阳
//时间:2008年11月8日
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.sql.*;
/*-----------------------------------InformationUpdate--------------------------------*/
class InformationUpdate extends JFrame implements ActionListener{
int userPriority;
JPanel jpTop1 = new JPanel();
JPanel jpTop2 = new JPanel();
JPanel jpTop3 = new JPanel();
JPanel jpTop = new JPanel();
JPanel jpLeft1 = new JPanel();
JPanel jpLeft2 = new JPanel();
JPanel jpRight1 = new JPanel();
JPanel jpRight2 = new JPanel();
JPanel jpLeft = new JPanel();
JPanel jpRight = new JPanel();
JPanel jpCenter = new JPanel();
JButton jbuttonLeft1 = new JButton("修改学生信息");
JButton jbuttonLeft2 = new JButton("修改学生住址");
JButton jbuttonRight1 = new JButton(" 修改教师信息");
JButton jbuttonRight2 = new JButton("返 回 上 级");
///////////////////////////////////////////////////////////////////////////////////////////////////
InformationUpdate(int priority){
userPriority = priority;
Container container = this.getContentPane();
container.setLayout(new BorderLayout());
jpCenter.setLayout(new GridLayout(1,2));
jpLeft.setLayout(new GridLayout(2,1));
jpRight.setLayout(new GridLayout(2,1));
jpTop.setLayout(new GridLayout(3,1));
jbuttonLeft1.setPreferredSize(new Dimension(165,45));
jbuttonLeft2.setPreferredSize(new Dimension(165,45));
jbuttonRight1.setPreferredSize(new Dimension(165,45));
jbuttonRight2.setPreferredSize(new Dimension(165,45));
jbuttonLeft1.setFont(new java.awt.Font("Dialog",1,18));
jbuttonLeft2.setFont(new java.awt.Font("Dialog",1,18));
jbuttonRight1.setFont(new java.awt.Font("Dialog",1,18));
jbuttonRight2.setFont(new java.awt.Font("Dialog",1,18));
jpTop.add(jpTop1);
jpTop.add(jpTop2);
jpTop.add(jpTop3);
jpLeft1.add(jbuttonLeft1);
jpLeft2.add(jbuttonLeft2);
jpRight1.add(jbuttonRight1);
jpRight2.add(jbuttonRight2);
jpLeft.add(jpLeft1);
jpLeft.add(jpLeft2);
jpRight.add(jpRight1);
jpRight.add(jpRight2);
jpCenter.add(jpLeft);
jpCenter.add(jpRight);
jbuttonLeft1.addActionListener(this);
jbuttonLeft2.addActionListener(this);
jbuttonRight1.addActionListener(this);
jbuttonRight2.addActionListener(this);
container.add("North",jpTop);
container.add("Center",jpCenter);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screen.width - 450) / 2,(screen.height - 500) / 2);
setTitle("信息修改");
setResizable(false);
setSize(470,280);
setVisible(true);
}// end of InformationUpdate
public void actionPerformed(ActionEvent e){
if(e.getSource() == jbuttonLeft1){
dispose();
new ModifyStudent();
}
else if(e.getSource() == jbuttonLeft2){
dispose();
new ModifyAddress();
}
else if(e.getSource() == jbuttonRight1){
dispose();
new ModifyMaster();
}
else if(e.getSource() == jbuttonRight2){
dispose();
new MainWindow(userPriority);
}
}// end of actionPerformed
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*----------------------------------------ModifyStudent-------------------------------------------*/
class ModifyStudent extends JFrame implements ActionListener{
JButton ascertain = new JButton("确定");
JButton exit = new JButton("退出"); ///11.9----------------------------------------------------
JButton modifyPane = new JButton("更 改");
JButton jbContinue = new JButton("继 续");
JButton exitPane = new JButton("退 出");
JTextField txtInputNumber = new JTextField(15); //for query
JTextField txtNumber = new JTextField(15);
JTextField txtName = new JTextField(15);
JTextField txtAge = new JTextField(15);
JTextField txtSpeciality = new JTextField(15);
JTextField txtDepartment = new JTextField(15);
JTextField txtAcademy = new JTextField(15);
String sex;
ButtonGroup group=new ButtonGroup();
JRadioButton rabSexM = new JRadioButton("男",false);
JRadioButton rabSexF = new JRadioButton("女",false);
String inputNumber;
ModifyStudent(){
Container container = this.getContentPane();
container.setLayout(new BorderLayout());
JPanel jpInputNumber = new JPanel();
jpInputNumber = new JPanel(new FlowLayout(FlowLayout.LEFT));
jpInputNumber.add(new JLabel("输入学号"));
jpInputNumber.add(txtInputNumber);
ascertain.setPreferredSize(new Dimension(60,22));
exit.setPreferredSize(new Dimension(60,22)); //11.9-------------------------------------------
jpInputNumber.add(ascertain);
jpInputNumber.add(exit); //11.9----------------------------------------------------------------
JPanel jpTop1 = new JPanel();
JPanel jpTop = new JPanel();
jpTop.setLayout(new GridLayout(3,1));
jpTop.add(jpTop1);
jpTop.add(jpInputNumber);
txtInputNumber.addActionListener(this);
ascertain.addActionListener(this);
exit.addActionListener(this); //11.9----------------------------------------------
container.add("North",jpTop);
setSize(380,460);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screen.width - 370) / 2,(screen.height - 480) / 2);
setTitle("学生个人信息修改");
setResizable(false);
setVisible(true);
}//ModifyStudent
//--------------------------------actionPerformed-------------------------------------
public void actionPerformed(ActionEvent e){
if(e.getSource() == ascertain || e.getSource() == txtInputNumber){
if(txtInputNumber.getText().equals("")){
JOptionPane.showMessageDialog(null,"请输入学生学号!");
txtInputNumber.requestFocus();
}
else{
Statement stm = null;
ResultSet rs = null;
String stuNumber;
String stuName;
String stuSex;
String stuAge;
String stuSpeciality;
String stuDepartment;
String stuAcademy;
boolean flag = false;
inputNumber = txtInputNumber.getText();
ConnectServer.mainLink(); //建立和数据库的连接。
try{
stm = ConnectServer.con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = stm.executeQuery("select * from student");
while(rs.next()){ //****************only for test*****************
if( txtInputNumber.getText().trim().equals(rs.getString("stu_number"))){
flag = true;
stuNumber = rs.getString("stu_number");
stuName = rs.getString("stu_name");
stuSex = rs.getString("stu_sex");
stuAge = rs.getString("stu_age");
stuSpeciality = rs.getString("speciality");
stuDepartment = rs.getString("department");
stuAcademy = rs.getString("academy");
System.out.print(""+stuNumber+" "+stuName+" "+stuSex+" "+stuAge);//for test
System.out.println(" "+stuSpeciality+" "+stuDepartment+" "+stuAcademy);
txtNumber.setText(stuNumber);
txtName.setText(stuName);
if(stuSex.equals("男")){
rabSexM.setSelected(true);
}
else{
rabSexF.setSelected(true);
}
txtAge.setText(stuAge);
txtSpeciality.setText(stuSpeciality);
txtDepartment.setText(stuDepartment);
txtAcademy.setText(stuAcademy);
// txtNumber.setEditable(false); //学号也可变
}
}
stm.close(); //关闭数据库连接
ConnectServer.con.close();
inputNumber = txtInputNumber.getText();
}
catch(NumberFormatException ee){
JOptionPane.showMessageDialog(null,"年龄必须为正整数!");
txtAge.setText(""); //to clear the text.
txtAge.requestFocus();
txtAge.setSelectionStart(0);
txtAge.setSelectionEnd(txtAge.getText().l
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
2008_11_19_StudentInformation(最新).rar (36个子文件)
StudentInformation(最新)
StudentInformation
StudentInformation.jcu 2KB
StudentInformation.jcp 2KB
src
DataStatistical.java 8KB
InformationUpdate$ModifyStudent.class 8KB
InformationInquiry.java 24KB
ConnectServer.java 2KB
InformationDelete.java 5KB
DataEntry$EntryStudent.class 6KB
DataEntry.java 17KB
InformationDelete$1.class 1KB
BlurQuery.class 335B
InformationInquiry.class 3KB
DataEntry$EntryAddress.class 5KB
InformationUpdate$ModifyMaster.class 7KB
MainWindow.java 4KB
DataEntry$EntryMaster.class 5KB
InformationDelete.class 5KB
DataEntry.class 3KB
StudentInformation.class 309B
InformationInquiry$BlurQuery.class 9KB
Login.class 4KB
InformationUpdate.java 31KB
ExactQuery.class 7KB
MainWindow.class 4KB
InformationUpdate$ModifyAddress.class 7KB
ConnectServer.class 2KB
Login.java 4KB
InformationInquiry$ExactQuery.class 6KB
DataStatistical.class 6KB
MainWindow$NoticeInformation.class 478B
StudentInformation.java 275B
InformationUpdate.class 3KB
StudentInformation.jcd 50KB
StudentInformation.jcw 289B
classes
StudentInformation.class 754B
ConnectServer.class 1KB
共 36 条
- 1
shenyang_502
- 粉丝: 2
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论3