




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、学生学籍管理详细设计学号:姓名:班级:一、设计题目:学生学籍管理二:设计容:设计GUI学生学籍管理界面,用户可以加入学生信息,并对基本信息进行修改,添加,查询,删除。三:设计要求:进行简单的学生信息管理。四:总体设计(1)登陆界面的设计(2)主窗体的设计(3)添加学生信息窗体(4)查询学生信息窗体(5)修改学生信息窗体(6)删除学生信息窗体(7)事件响应的处理五:具体设计(1)程序结构的说明:入入口程序:student.java;登陆界面程序:mainframe.java;主窗体程序:interfac.java;添加信息窗口程序:tj.java;修改信息窗口程序:xg.java;查询信息窗口程
2、序:cx.java;删除信息窗口程序:sc.java;程序数据连接:DatabaseConn.java;(2)程序代码及分析说明程序源代码(已提交)Student.java是程序的入口。使登录窗口位于窗口中间,并且不可改变窗口大 小。mainframe.java是程序的登陆窗体。输入用户名和密码(用户名和密码在数 据库的password表中)点击进入系统”,然后登陆界面消失;出现要操作的 界面(屏幕左上角)。tj.java是添加信息界面。添加基本信息后,点击添加信息”按钮,将信息加 入xinxi表中。xg.java是修改信息界面。输入要修改的学号或姓名(两者数其一或全部输入), 并输入所有信息
3、,点击修改信息”按钮(如果数据库中不存在此学号,则弹出 对话框无此学生信息”),若有则修改。sc.java是删除信息界面。输入要删除的学生的学号,点击删除信息”按钮, 弹出确认删除对话框,即可删除该生信息。cxjava是查询信息界面。输入要查询的学生学号,点击信息查询”按钮, 在相应的文本区里显示查询的信息。H:源代码/student.java:程序的入口。初始化界面,使主界面位于屏幕中间,且用户不能 改变大小/功能:完成程序的执彳丁顺序import javax.swing.UIManager;import java.awt.*;import java.sql.*;/import screen
4、public class studentboolean packFrame=false;/JFrame frame=new JFrame();public student()mainframe frame=new mainframe();if(packFrame)frame.pack();else frame.validate();DimensionscreenSize=Toolkit.getDefaultToolkit().getScreenSize();Dimension frameSize=frame.getSize();if(frameSize.heightscreenSize.hei
5、ght)frameSize.height=screenSize.height;if(frameSize.widthscreenSize.width)frameSize.width=screenSize.width;frame.setLocation(screenSize.width-frameSize.width)/2,(screenSize.height-frameSize.height)/2);frame.setVisible(true);public static void main(String args)tryUIManager.setLookAndFeel(UIManager.ge
6、tSystemLookAndFeelClassName(); catch(Exception e) e.printStackTrace();new student();/数据库连接/package sql.database;import java.sql.*;public class DatabaseConnprivate static String user=”;private static String password = ”;private Connection conn = null;private Statement stmt=null;private ResultSet rs=n
7、ull;statictryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);/ 加载驱动catch(ClassNotFoundException e)创建数据库连接对象public Connection getConnection()tryconn = DriverManager.getConnection(jdbc:odbc:stu,user,password);return conn;catch(SQLException e)return null;public Statement createStat()tryconn=getConnection()
8、;stmt=conn.createStatement();return stmt;catch(SQLException e)return null;public ResultSet getRs(String sql) tryconn=getConnection();/.stmt=createStat();rs=stmt.executeQuery(sql);return rs;catch(SQLException e)return null;public void close()tryif(rs! = null)rs.close();if(stmt!=null)stmt.close();if(c
9、onn! = null)conn.close();catch(SQLException ex)ex.printStackTrace();/mainframe.javaimport java.awt.*;import java.awt.event.*;import javax.swing.*;import java.sql.*;public class mainframe extends JFrame implements ActionListenerstatic mainframe s;static JPanel pan = new JPanel();static 儿abel label1 =
10、 new JLabel(用 户”);static 儿abel label2 = new 儿abel(密 码”);static JTextField textFieldl = new JTextField();static JPasswordField password = new JPasswordField();static JButton button1 = new JButton(进入系统”);static JRadioButton radioButton1=new JRadioButton(”管理员二true);/管理员”初始状态被选中static JRadioButton radio
11、Button2=new JRadioButton(学生”);static JRadioButton radioButton3=new JRadioButton(教师”);ButtonGroup buttonGroup=new ButtonGroup();public mainframe()儿 abel label=new 儿 abel(new ImageIcon(图片 44.jpg);label.setSize(400,400);pan.add(label);pan.setLayout(null);pan.setSize(400,400);this.setTitle(-学籍管理系统);this
12、.setSize(400,400);this.setLayout(null);label1.setBounds(100,25,49,20);textField1.setBounds(155,24,120,20);label2.setBounds(100,62,49,20);password.setBounds(155,61,120,20);button1.setBounds(150,200,101,22);radioButton1.setBounds(105,120,80,20);radioButton2.setBounds(,120,60,20);radioButton3.setBounds
13、(240,120,60,20);button1.addActionListener(this);buttonGroup.add(radioButton1);buttonGroup.add(radioButton2);buttonGroup.add(radioButton3);this.add(radioButton1);this.add(radioButton2);this.add(radioButton3);this.add(label1);this.add(label2);this.add(textField1);this.add(password);this.add(button1);t
14、his.add(pan);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);public static void main(String args)new mainframe();public void actionPerformed(ActionEvent e)if(radioButton1.isSelected()/管 理员if(textField1.getText().equals(syc)&password.getText().equals(123”)interfac b=new inte
15、rfac();this.dispose();/JOptionPane.showMessageDialog(null,登陆成功);elseif(”.equals(textField1.getText()|.equals(password.getText() )(JOptionPane.showMessageDialog(null,”用户名或密码不能为空”);elseJOptionPane.showMessageDialog(null,用户名或密码输入有误);if(radioButton2.isSelected()/学 生tryClass.forName(sun.jdbc.odbc.JdbcOdb
16、cDriver);catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(s,ce.getMessage();tryConnectionconDriverManager.getConnection(jdbc:odbc:stu”,sa”,);Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery(select * from password where 用 户名=+textField1.getText() + and 密码= + passw
17、ord.getText() +”);if(textField1.getText().equals()|password.getText().equals()JOptionPane.showMessageDialog(this,用户名或密 码不可为空!);else if(rs.next() new interfac();elseJOptionPane.showMessageDialog(this,您的输入有误);/stmt.close();catch (SQLException se)JOptionPane.showMessageDialog(s,se.getMessage();/interfa
18、ce.javaimport java.awt.*;import java.awt.event.*;import javax.swing.*;public class interfac extends JFrame implements ActionListenerstatic JMenuBar jMenuBar = new JMenuBar();/ 菜单条static JMenu jMenuFile = new JMenu(文件);/菜单项static JMenu jMenuExit = new JMenu(退出);static JMenuItem jMenuItem1 = new JMenu
19、Item(添加信息);/菜单子项static JMenuItem jMenuItem2 = new JMenuItem(修改信息);static JMenuItem jMenuItem3 = new JMenuItem(信息查询);static JMenuItem jMenuItem4 = new JMenuItem(删除信息);static 儿abel label3 = new 儿abel(请选择操作项”); static 儿abel label4 = new 儿abel(学籍管理系统”); static JButton button2 = new JButton(添加信息”); stati
20、c JButton button3 = new JButton(修改信息”); static JButton button4 = new JButton(信息查询”); static JButton button5 = new JButton(删除信息”);public interfac()this.setTitle(-学籍管理系统);this.setLayout(null);this.setSize(400,400);label3.setBounds(158,92,98,33);label3.setFont(new Font(Dialog”,Font.PLAIN,15);label4.set
21、Font(new Font(Dialog,Font.BOLD,20);label4.setBounds(157,37,280,40);button2.setBounds(74,136,97,33);button3.setBounds(226,136,97,33);button4.setBounds(74,185,97,33);button5.setBounds(226,185,97,33);this.add(button2);this.add(button3);this.add(button4);this.add(button5);this.add(label3);this.add(label
22、4);setJMenuBar(jMenuBar);jMenuFile.add(jMenuIteml); 文件菜单项中加入子菜单jMenuFile.add(jMenuItem2);jMenuFile.add(jMenuItem3);jMenuFile.add(jMenuItem4);jMenuBar.add(jMenuFile);/将菜单项加入菜单条jMenuBar.add(jMenuExit);button2.addActionListener(this);/ 本窗口向按钮事件源注册button3.addActionListener(this);button4.addActionListene
23、r(this);button5.addActionListener(this);jMenuItem1.addActionListener(this);/ 本窗口菜单子项注册jMenuItem2.addActionListener(this);jMenuItem3.addActionListener(this);jMenuItem4.addActionListener(this);jMenuExit.addActionListener(this);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);p
24、ublic static void main(String args)interfac a = new interfac();public void actionPerformed(ActionEvent e) /按钮事件的处理if(e.getSource() = =jMenuExit)System.exit(0);else if(e.getSource() = =jMenuItem1|e.getSource() =button2)trytj a=new tj();catch(Exception ee) else if(e.getSource() = =jMenuItem2|e.getSour
25、ce() =button3)tryxg a = new xg();catch(Exception ed) elseif(e.getSource() = =jMenuItem3|e.getSource() =button4)trycx a = new cx();catch(Exception ec)elseif(e.getSource() = =jMenuItem4|e.getSource() =button5)trysc a=new sc();catch(Exception es)/tj.java添加界面import javax.swing.*;import java.awt.*;import
26、 java.awt.event.*;import java.sql.*;public class tj extends JFrame implements ActionListenerstatic tj s;static 儿 abel label1 = new 儿 abel(学号:);static JTextField textField1 = new JTextField();static 儿abel label2 = new JLabel(姓名:);static JTextField textField2 = new JTextField();static 儿abel label3 = n
27、ew JLabel(性别:);static JTextField textField7=new JTextField();static 儿abel label4 = new 儿abel(出生日期:);static JTextField textField3 = new JTextField();static 儿abel label5 = new 儿abel(政治面貌:);static JTextField textField8=new JTextField();static儿 abel label6 = new JLabel(籍贯”);static JTextField textField4
28、= new JTextField();static 儿abel label7 = new 儿abel(系别:);static JTextField textField9 = new JTextField();static 儿 abel label8 = new JLabel(专业:);static JTextField textField5 = new JTextField();static JButton button1 = new JButton(增加”);public tj()this.setTitle(-增加学生信息);this.setLayout(null);this.setSize
29、(400,400);label1.setBounds(30, 11, 51, 33);textField1.setBounds(86, 16, 74, 22);label2.setBounds(162, 11, 51, 33);textField2.setBounds(192, 16, 44, 22);label3.setBounds(241, 11, 70, 33);textField7.setBounds(275, 15, 50, 25);label4.setBounds(31, 53, 55, 33);textField3.setBounds(86, 58, 74, 22);label5
30、.setBounds(241, 53, 70, 33);textField8.setBounds(296, 57, 72, 25);label6.setBounds(163, 53, 26, 33);textField4.setBounds(191, 58, 44, 22);label7.setBounds(30, 94, 50, 33);textField9.setBounds(86,94,74,22);label8.setBounds(163, 94, 51, 33);textField5.setBounds(190, 99, 178, 22);button1.setBounds(25,2
31、41,80,33);button1.addActionListener(this);this.add(label1);this.add(label2);this.add(label3);this.add(label4);this.add(label5);this.add(label6);this.add(label7);this.add(label8);this.add(textField1);this.add(textField2);this.add(textField3);this.add(textField4);this.add(textField5);this.add(textFiel
32、d7);this.add(textField8);this.add(textField9);this.add(buttonl);this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);this.setVisible(true);public static void main(String args) throws Exceptiontj a= new tj();a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);public void actionPerformed(ActionEvent e)
33、/事件处理程序if (e.getSource() = button1)tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(s,ce.getMessage();tryConnectioncon=DriverManager.getConnection(jdbc:odbc:stu”,sa”,”);Statement stmt = con.createStatement();ResultSet rs=stmt.executeQuery(
34、select * from xinxi where 学号=+textField1.getText()+);if(rs.next()JOptionPane.showMessageDialog(null,此学号已经被注册);elsestmt.execute(insert into xinxi (学号,姓名,性别,出生日期,政治面貌,籍贯,系别,专业)values ( +textField1.getText() + +textField2.getText()+ ,+textField7.getText() + , +textField3.getText() + +textField8.getText
35、()+ ,+textField4.getText() + , +textField9.getText() + +textField5.getText() + );JOptionPane.showMessageDialog(null,添加信息成功);catch (SQLException se)JOptionPane.showMessageDialog(s,se.getMessage();/xg.java修改界面import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;public class
36、 xg extends JFrame implements ActionListenerstatic xg s;static 儿 abel label1 = new 儿 abel(学号:);static JTextField textField1 = new JTextField();static 儿abel label2 = new JLabel(姓名:);static JTextField textField2 = new JTextField();static 儿abel label3 = new JLabel(性别:);static JTextField textField7=new
37、JTextField();static 儿abel label4 = new 儿abel(出生日期:);static JTextField textField3 = new JTextField();static 儿abel label5 = new 儿abel(政治面貌:);static JTextField textField8=new JTextField();static儿 abel label6 = new JLabel(籍贯”);static JTextField textField4 = new JTextField();static 儿abel label7 = new 儿ab
38、el(系别:);static JTextField textField9 = new JTextField();static儿 abel label8 = new JLabel(专业:);static JTextField textField5 = new JTextField();static JButton button2=new JButton(修改”);public xg()this.setTitle(-修改学生信息”);this.setLayout(null);this.setSize(400,400);label1.setBounds(30, 11, 51, 33);textFie
39、ld1.setBounds(86, 16, 74, 22);label2.setBounds(162, 11, 51, 33);textField2.setBounds(192, 16, 44, 22);label3.setBounds(241, 11, 70, 33);textField7.setBounds(275, 15, 50, 25);label4.setBounds(31, 53, 55, 33);textField3.setBounds(86, 58, 74, 22);label5.setBounds(241, 53, 70, 33);textField8.setBounds(2
40、96, 57, 72, 25);label6.setBounds(163, 53, 26, 33);textField4.setBounds(191, 58, 44, 22);label7.setBounds(30, 94, 50, 33);textField9.setBounds(86,94,74,22);label8.setBounds(163, 94, 51, 33);textField5.setBounds(190, 99, 178, 22);button2.setBounds(115,241,80,33);button2.addActionListener(this);this.ad
41、d(label1);this.add(label2);this.add(label3);this.add(label4);this.add(label5);this.add(label6);this.add(label7);this.add(label8);this.add(textField1);this.add(textField2);this.add(textField3);this.add(textField4);this.add(textField5);this.add(textField7);this.add(textField8);this.add(textField9);thi
42、s.add(button2);this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);this.setVisible(true);public static void main(String args) throws Exceptionxg a = new xg();a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);public void actionPerformed(ActionEvent e)/事件处理程序if(e.getSource() =button2)tryClass.forNam
43、e(sun.jdbc.odbc.JdbcOdbcDriver);catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(s,ce.getMessage();tryConnection con = DriverManager.getConnection(jdbc:odbc:stu”,sa”,);Statement stmt = con.createStatement();ResultSet rs=stmt.executeQuery(select * from xinxi where 学号 =+textField1.getTex
44、t()+);if(textField1.getText().trim().equals()JOptionPane.showMessageDialog(this,学号不可为 空!);else if(rs.next()String updateSql = update xinxi set 学号 =+textField1.getText() + ,姓名=+textField2.getText() + , 性 别 =+textField7.getText() + ,出生日期=+textField3.getText() + ,政治面貌=+textField8.getText()+ ,籍贯= +textF
45、ield4.getText() + , 系=+textField9.getText() + ,专业=+textField5.getText()+ ;trystmt.executeQuery(updateSql);catch(SQLException se)JOptionPane.showMessageDialog(null,修改成功);catch(SQLException se)JOptionPane.showMessageDialog(s,se.getMessage();/sc.java删除界面import javax.swing.*;import java.awt.*;import jav
46、a.awt.event.*;import java.sql.*;public class sc extends JFrame implements ActionListenerstatic sc s;static 儿 abel label1 = new 儿 abel(学号:);static JTextField textField1 = new JTextField();static 儿abel label2 = new JLabel(姓名:);static JTextField textField2 = new JTextField();static 儿abel label3 = new J
47、Label(性别:);static JTextField textField7=new JTextField();static 儿abel label4 = new 儿abel(出生日期:);static JTextField textField3 = new JTextField();static 儿abel label5 = new 儿abel(政治面貌:);static JTextField textField8=new JTextField();static儿 abel label6 = new JLabel(籍贯”);static JTextField textField4 = ne
48、w JTextField();static 儿abel label7 = new 儿abel(系别:);static JTextField textField9 = new JTextField();static儿 abel label8 = new JLabel(专业:);static JTextField textField5 = new JTextField();static JButton button4=new JButton(删除”);public sc() throws Exceptionthis.setTitle(-删除学生信息);this.setLayout(null);th
49、is.setSize(400,400);label1.setBounds(30, 11, 51, 33);textField1.setBounds(86, 16, 74, 22);label2.setBounds(162, 11, 51, 33);textField2.setBounds(192, 16, 44, 22);label3.setBounds(241, 11, 70, 33);textField7.setBounds(275, 15, 50, 25);label4.setBounds(31, 53, 55, 33);textField3.setBounds(86, 58, 74,
50、22);label5.setBounds(241, 53, 70, 33);textField8.setBounds(296, 57, 72, 25);label6.setBounds(163, 53, 26, 33);textField4.setBounds(191, 58, 44, 22);label7.setBounds(30, 94, 50, 33);textField9.setBounds(86,94,74,22);label8.setBounds(163, 94, 51, 33);textField5.setBounds(190, 99, 178, 22);button4.setB
51、ounds(295,241,80,33);button4.addActionListener(this);this.add(label1);this.add(label2);this.add(label3);this.add(label4);this.add(label5);this.add(label6);this.add(label7);this.add(label8);this.add(textFieldl);this.add(textField2);this.add(textField3);this.add(textField4);this.add(textField5);this.a
52、dd(textField7);this.add(textField8);this.add(textField9);this.add(button4);this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);this.setVisible(true);public static void main(String args) throws Exceptionsc a= new sc();a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);public void actionPerformed(Act
53、ionEvent e)/scif (e.getSource() = button4)tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(s,ce.getMessage();tryConnectioncon=DriverManager.getConnection(jdbc:odbc:stu”,sa”,);Statement stmt = con.createStatement();ResultSet rs=stmt.execute
54、Query(select * from xinxi where 学 号=+textField1.getText() +);if(textField1.getText().trim().equals()JOptionPane.showMessageDialog(this,学号不可为 空!); else if(rs.next()JOptionPane.showConfirmDialog(null,确定要删除该信 息嘛? n删除的信息将不能恢复,继续?,删除 确定 ,JOptionPane.OK_CANCEL_OPTION);/,JOption.QUESTION_MESSAGE) = =0;stmt
55、.execute(delete from xinxi where 学号 =+textField1.getText() +);JOptionPane.showMessageDialog(null,删除信息成 功!);this.dispose();else JOptionPane.showMessageDialog(null,无此学号 对应信息,警告,JOptionPane.WARNING_MESSAGE);catch(Exception ed)JOptionPane.showMessageDialog(s,ed.getMessage();/cx.java查询界面import javax.swin
56、g.*;import java.awt.*;import java.awt.event.*;import java.sql.*;public class cx extends JFrame implements ActionListenerstatic cx s;static 儿 abel label1 = new 儿 abel(学号:);static JTextField textField1 = new JTextField();static 儿abel label2 = new JLabel(姓名:);static JTextField textField2 = new JTextFie
57、ld();static 儿abel label3 = new JLabel(性别:);static JTextField textField7=new JTextField();static 儿abel label4 = new 儿abel(出生日期:);static JTextField textField3 = new JTextField();static 儿abel label5 = new 儿abel(政治面貌:);static JTextField textField8=new JTextField();static儿 abel label6 = new JLabel(籍贯”);s
58、tatic JTextField textField4 = new JTextField();static 儿abel label7 = new 儿abel(系别:);static JTextField textField9 = new JTextField();static 儿 abel label8 = new JLabel(专业:);static JTextField textField5 = new JTextField();static JButton button3 = new JButton(查询”);public cx() throws Exceptionthis.setTit
59、le(-查询学生信息);this.setLayout(null);this.setSize(400,400);label1.setBounds(30, 11, 51, 33);textField1.setBounds(86, 16, 74, 22);label2.setBounds(162, 11, 51, 33);textField2.setBounds(192, 16, 44, 22);label3.setBounds(241, 11, 70, 33);textField7.setBounds(275, 15, 50, 25);label4.setBounds(31, 53, 55, 33);textField3.setBounds(86, 58, 74, 22);label5.setBounds(241, 53, 70, 33);textField8.setBounds(296, 57, 72, 25);label6.setBounds(163, 53, 26, 33);textField4.setBounds(191, 58, 44, 22);label7.setBounds(30, 94, 50, 33);textField9.setBounds(86,94,74,22);label8.set
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 期刊编辑的学术期刊版权风险管理考核试卷
- 建筑工程用机械设备的电气控制系统改进考核试卷
- 方便面生产设备的选型与使用维护考核试卷
- 增强现实教具探索考核试卷
- 掌握关键对话实现有效沟通考核试卷
- 信托在文化资产交易平台建设的投资管理与运营考核试卷
- 出租旧庙合同范本
- 别墅电梯保养合同范本
- 体育赛事策划及运营服务合同
- 会议组织及参展合同
- 医科大学新造校区二期工程环评报告公示
- JC-019粉煤灰检测报告
- VTE相关知识考核试题及答案
- 高中语文教学课例《沁园春长沙》课程思政核心素养教学设计及总结反思
- 三生公司奖金制度
- 神经病学-绪论课件
- 危险化学品全表
- 公路施工技术全套课件
- 胸痹心痛中医诊疗方案及临床路径
- 泛读2unit2-music
- 中学生防溺水安全教育课件(PPT 44页)
评论
0/150
提交评论