package stu;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class ModifyStudent extends JPanel implements ActionListener{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 修改界面
*/
StuBean modStu = new StuBean();
StuBean queryStu = new StuBean();
JTextField Snum,Sname,Sgrade,Sbirth;
JComboBox Smajor;
JRadioButton boy,girl;
ButtonGroup group = null;
JButton start,entry,reset;
JComboBox oldMess;
public ModifyStudent(){
String[] str={"computer","science","phics","china","network","par"};
Snum = new JTextField(20);
Sname = new JTextField(20);
Smajor = new JComboBox(str);
Sgrade = new JTextField(20);
Sbirth = new JTextField(20);
group = new ButtonGroup();
boy = new JRadioButton("male",true);
girl = new JRadioButton("female",false);
group.add(boy);
group.add(girl);
oldMess = new JComboBox();
start = new JButton("开始修改");
entry = new JButton("录入修改");
entry.setEnabled(false);
reset = new JButton("重置");
Snum.addActionListener(this);
start.addActionListener(this);
entry.addActionListener(this);
reset.addActionListener(this);
Box box0 = Box.createHorizontalBox();
JLabel label = new JLabel("学生信息修改",JLabel.CENTER);
label.setFont(new Font("黑体", Font.BOLD, 25));
box0.add(label);
Box box1 = Box.createHorizontalBox();
box1.add(new JLabel("学号:",JLabel.CENTER));
box1.add(Snum);
box1.add(start);
Box box2 = Box.createHorizontalBox();
box2.add(new JLabel("姓名:",JLabel.CENTER));
box2.add(Sname);
Box box3 = Box.createHorizontalBox();
box3.add(new JLabel("性别:",JLabel.CENTER));
box3.add(boy);
box3.add(girl);
Box box4 = Box.createHorizontalBox();
box4.add(new JLabel("专业:",JLabel.CENTER));
box4.add(Smajor);
Box box5 = Box.createHorizontalBox();
box5.add(new JLabel("年级:",JLabel.CENTER));
box5.add(Sgrade);
Box box6 = Box.createHorizontalBox();
box6.add(new JLabel("出生:",JLabel.CENTER));
box6.add(Sbirth);
Box boxH = Box.createVerticalBox();
boxH.add(box0);
boxH.add(box1);
boxH.add(box2);
boxH.add(box3);
boxH.add(box4);
boxH.add(box5);
boxH.add(box6);
boxH.add(Box.createVerticalGlue());
JPanel putButton = new JPanel();
putButton.add(entry);
putButton.add(reset);
JPanel messPanel = new JPanel();
messPanel.add(boxH);
messPanel.setBackground(Color.pink);
putButton.setBackground(Color.CYAN);
setLayout(new BorderLayout());
add(messPanel,BorderLayout.CENTER);
add(putButton,BorderLayout.SOUTH);
validate();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String number = Snum.getText();
String rs[] = new String[4];
rs = queryStu.stuSearch(number);
if(e.getSource() == start||e.getSource() == Snum){
oldMess.removeAllItems();
if(rs != null){
String q = "该生信息已存在,您想修改他(她)的基本信息吗?";
JOptionPane.showMessageDialog(this,q,"警告" ,JOptionPane.QUESTION_MESSAGE);
entry.setEnabled(true);
oldMess.addItem("姓名:"+rs[1]);
oldMess.addItem("专业:"+rs[4]);
oldMess.addItem("年级:"+rs[3]);
oldMess.addItem("生日:"+rs[4]);
if(rs[2].equals("male"))
boy.setSelected(true);
else
girl.setSelected(true);
}
else{
entry.setEnabled(false);
JOptionPane.showMessageDialog(this,"该学号不存在无法修改!","警告", JOptionPane.WARNING_MESSAGE);
clearMess();
}
}
else if(e.getSource() == entry){
if(rs != null){
String m = "基本信息将被修改!";
int ok = JOptionPane.showConfirmDialog(this,m,"确认",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if(ok == JOptionPane.YES_OPTION){
String name = Sname.getText();
String major = (String)Smajor.getSelectedItem();
String grade = Sgrade.getText();
String birth = Sbirth.getText();
String sex = null;
if(boy.isSelected())
sex = boy.getText();
if(girl.isSelected())
sex = girl.getText();
modStu.stuModify(number, name, sex, major, grade, birth);
}
else if(ok == JOptionPane.NO_OPTION){
entry.setEnabled(true);
}
}
else{
String w = "该学号没有基本信息,不能修改!";
JOptionPane.showMessageDialog(this, w, "警告",JOptionPane.WARNING_MESSAGE);
entry.setEnabled(false);
clearMess();
}
}
else if(e.getSource() == reset){
clearMess();
entry.setEnabled(false);
}
}
public void clearMess(){
Snum.setText(null);
Sname.setText(null);
Sgrade.setText(null);
Sbirth.setText(null);
oldMess.removeAllItems();
}
}
Eclipse连接Mysql数据库学生信息管理系统
5星 · 超过95%的资源 需积分: 50 171 浏览量
2013-03-19
17:11:05
上传
评论 41
收藏 511KB ZIP 举报
zkui5135
- 粉丝: 4
- 资源: 2
最新资源
- Win64OpenSSL-3-3-0.exe
- 课高分程设计-基于C++实现的民航飞行与地图简易管理系统-南京航空航天大学
- 航天器遥测数据故障检测系统python源码+文档说明+数据库(课程设计)
- 北京航空航天大学操作系统课设+ppt+实验报告
- 基于Vue+Echarts实现风力发电机中传感器的数据展示监控可视化系统+源代码+文档说明(高分课程设计)
- 基于单片机的风力发电机转速控制源码
- 基于C++实现的风力发电气动平衡监测系统+源代码+测量数据(高分课程设计)
- 毕业设计- 基于STM32F103C8T6 单片机,物联网技术的太阳能发电装置+源代码+文档说明+架构图+界面截图
- 基于 LSTM(长短期记忆)(即改进的循环神经网络)预测风力发电厂中风力涡轮机产生的功率+源代码+文档说明
- 基于stm32f103+空心杯电机+oled按键+运动算法
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
前往页