




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、學生學籍管理詳細設計學號:姓名:班級:一、設計題目:學生學籍管理二:設計內容:設計GUI學生學籍管理界面,用戶可以加入學生信息,并對基本信息進行修 改,添加,查詢,刪除。三:設計要求:進行簡單的學生信息管理。四:總體設計(1)登陸界面的設計(2)主窗體的設計(3)添加學生信息窗體(4)查詢學生信息窗體(5)修改學生信息窗體(6)刪除學生信息窗體(7)事件響應的處理五:具體設計(1)程序結構的說明:A.入口 程序:student.java;B.登陸界面程序:mainframe.java;C.主窗體程序:interfac.java;D.添加信息窗口程序:tj.java;E.修改信息窗口程序:xg.
2、java;F.查詢信息窗口程序:cx.java;G.刪除信息窗口程序:sc.java;H.程序數據連接:DatabaseConn.java;(2)程序代碼及分析說明A.程序源代碼(已提交)B.Student.java 是程序的入口。使登錄窗口位于窗口中間,并且不可改變窗口 大小。C.mainframe.java 是程序的登陸窗體。輸入用戶名和密碼(用戶名和密碼在數 據庫的password表中)點擊“進入系統”,然后登陸界面消失;出現要操作的界 面(屏幕左上角)。D.tj.java是添加信息界面。添加基本信息后,點擊“添加信息”按鈕,將信息加入xinxi表中。E.xg.java 是修改信息界面。
3、輸入要修改的學號或姓名(兩者數其一或全部輸 入),并輸入所有信息,點擊“修改信息”按鈕(如果數據庫中不存在此學號, 則彈出對話框“無此學生信息”),若有則修改。F.sc.java是刪除信息界面。輸入要刪除的學生的學號,點擊“刪除信息”按鈕, 彈出確認刪除對話框,即可刪除該生信息。G.cx.java是查詢信息界面。輸入要查詢的學生學號,點擊“信息查詢”按鈕, 在相應的文本區里顯示查詢的信息。H:源代碼/student.java:程序的入口。初始化界面,使主界面位于屏幕中間,且用戶不能改變大小/功能:完成程序的執行順序 import javax.swing.UIManager;import jav
4、a.awt.*;import java.sql.*;/import screenpublic 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.ge
5、tSize(); if(frameSize.height>screenSize.height) frameSize.height=screenSize.height;if(frameSize.width>screenSize.width) frameSize.width=screenSize.width;frame.setLocation(screenSize.width-frameSize.width)/2,(screenSiz e.height-frameSize.height)/2);frame.setVisible(true);public static void main
6、(String口 args)tryUIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName( );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
7、 conn=null;private Statement stmt=null;private ResultSet rs=null;statictryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");/加載驅動catch(ClassNotFoundException e)。/創建數據庫連接對象public Connection getConnection()tryconn=DriverManager.getConnection("jdbc:odbc:stu",user,password); return conn;
8、catch(SQLException e) return null;public Statement createStat()tryconn=getConnection();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
9、 null;public void close()tryif(rs!=null)rs.close();if(stmt!=null)stmt.close();if(conn!=null) conn.close();catch(SQLException ex)ex.printStackTrace();/mainframe.javaimport java.awt.*;import java.awt.event.*;import javax.swing.*;implements ActionListenerimport java.sql.*;public class mainframe extends
10、 JFrame static mainframe s;static JPanel pan=new JPanel();static JLabe11abel1 = new 兒abel("用 戶)static JLabe11abel2 = new 兒abel("密 碼)static JTextField textField1 = new JTextField();static JPasswordField password = new JPasswordField();static JButton button1 = new JButton("進入系統");s
11、tatic JRadioButton radioButton1=new JRadioButton("管理員",true);/“管理員”初始狀態被選中static JRadioButton radioButton2=new JRadioButton("學生");static JRadioButton radioButton3=new JRadioButton("教師");ButtonGroup buttonGroup=new ButtonGroup();public mainframe()JLabel label=new JLabel(
12、new ImageIcon(" 圖片 44.jpg");label.setSize(400,400);pan.add(label);pan.setLayout(null);pan.setSize(400,400);this.setTitle("學籍管理系統");this.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
13、.setBounds(155,61,120,20);button1.setBounds(150,200,101,22);radioButton1.setBounds(105,120,80,20);radioButton2.setBounds(180,120,60,20);radioButton3.setBounds(240,120,60,20);buttonl.addActionListener(this);buttonGroup.add(radioButtonl);buttonGroup.add(radioButton2);buttonGroup.add(radioButton3);this
14、.add(radioButtonl);this.add(radioButton2);this.add(radioButton3);this.add(labell);this.add(label2);this.add(textFieldl);this.add(password);this.add(buttonl);this.add(pan);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true);public static void main(String口 args)new mainframe。;pu
15、blic void actionPerformed(ActionEvent e) if(radioButton1.isSelected()管理員&& if(textField1.getText().equals("syc")password.getText().equals("123") interfac b=new interfac(); this.dispose();/JOptionPane.showMessageDialog(null,"登陸成功");elseif("".equals(text
16、Field1.getText()|”.equals(password.getText() )JOptionPane.showMessageDialog(null,”用戶名或密碼不能為 空) elseJOptionPane.showMessageDialog(null,”用戶名或密碼輸入有誤) if(radioButton2.isSelected()/ 學生 tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriveL); catch (ClassNotFoundException ce) JOptionPane.showMessageDialog(s,
17、ce.getMessage(); try Connectioncon=DriverManager.getConnection("jdbc:odbc:stu","sa","");Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery("select * from password where用戶 名 = '"+textField1.getText()+"'and 密 碼 ='"+pass
18、word.getText()+"”');if(textField1.getText().equals("")|password.getText().equals("") JOptionPane.showMessageDialog(this,"用戶名或密碼不可為空!"); else if(rs.next() new interfac();else JOptionPane.showMessageDialog(this,"您的輸入有誤");/stmt.close();catch (SQLExceptio
19、n se)JOptionPane.showMessageDialog(s,se.getMessage();/interface.java import java.awt.*; import java.awt.event.*; import javax.swing.*;public class interfac extends JFrame implements ActionListener static JMenuBar jMenuBar = new JMenuBar();/static JMenu jMenuFile = new JMenu("文件");/static J
20、Menu jMenuExit = new JMenu("退出");static JMenuItem jMenuItem1 = new JMenuItem(" static JMenuItem jMenuItem2 = new JMenuItem(" static JMenuItem jMenuItem3 = new JMenuItem(" static JMenuItem jMenuItem4 = new JMenuItem("菜單條菜單項添加信息)/菜單子項修改信息)信息查詢");刪除信息)static static st
21、atic static static static兒abel label3 = new 兒abel(" 兒abel label4 = new 兒abel(" JButton button2 = new JButton(" JButton button3 = new JButton(" JButton button4 = new JButton("JButton button5 = new JButton("請選擇操作項");學籍管理系統");添加信息) 修改信息) 信息查詢");刪除信息)public i
22、nterfac()this.setTitle("學籍管理系統");this.setLayout(null);this.setSize(400,400);label3.setBounds(158,92,98,33);label3.setFont(new Font("Dialog",Font.PLAIN,15);label4.setFont(new Font("Dialog",Font.BOLD,20); label4.setBounds(157,37,280,40);button2.setBounds(74,136,97,33);but
23、ton3.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(label4);setJMenuBar(jMenuBar);jMenuFile.add(jMenuIteml);/ ”文件“菜單項中加入子菜單jMenuFile.add(jMenuItem2);jMenuFile.
24、add(jMenuItem3);jMenuFile.add(jMenuItem4);jMenuBar.add(jMenuFile);/ 將菜單項加入菜單條jMenuBar.add(jMenuExit);button2.addActionListener(this);/本窗 口 向按鈕事件源注冊button3.addActionListener(this);button4.addActionListener(this);button5.addActionListener(this);jMenuItem1.addActionListener(this);本窗 口 菜單子項注冊jMenuItem2.
25、addActionListener(this);jMenuItem3.addActionListener(this);jMenuItem4.addActionListener(this);jMenuExit.addActionListener(this);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);public static void main(String口 args)interfac a=new interfac();public void actionPerformed(ActionE
26、vent 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.getSource()=button3) tryxg a=new xg();catch(Exception ed)elseif(e.getSource()=jMenuItem3|e.getSource()=button4)try
27、 cx a=new cx(); catch(Exception ec) elseif(e.getSource()=jMenuItem4|e.getSource()=button5) try sc a=new sc();catch(Exception es) /tj.java 添加界面import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;public class tj extends JFrame implements ActionListener static tj s;static J
28、Labe11abel1 = new 兒abel("學號:");static JTextField textField1 = new JTextField("");static 兒abel label2 = new 兒abel("姓名:");static JTextField textField2 = new JTextField("");static 兒abel label3 = new 兒abel("性別:");static JTextField textField7=new JTextFie
29、ld("");static 兒abel label4 = new 兒abel("出生日期:");static JTextField textField3 = new JTextField("");static 兒abel label5 = new 兒abel("政治面貌:");static JTextField textField8=new JTextField("");static 兒abel label6 = new 兒abel("籍貫)static JTextField text
30、Field4 = new JTextField("");static 兒abel label7 = new 兒abel("系另U :");static JTextField textField9 = new JTextField("");static 兒abel label8 = new 兒abel("專業:");static JTextField textField5 = new JTextField("");static JButton buttonl = new JButton("
31、;增加");public tj()this.setTitle("增加學生信息)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, 2
32、5);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.setBounds(16
33、3, 94, 51,33);textField5.setBounds(190, 99, 178, 22);button1.setBounds(25,241,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.
34、add(textField3);this.add(textField4);this.add(textField5);this.add(textField7);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 Exception tj a= new tj();a.setDefaultC
35、loseOperation(JFrame.EXIT_ON_CLOSE);public void actionPerformed(ActionEvent e)事件處理程序if (e.getSource() = button1) tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver"); catch (ClassNotFoundException ce) JOptionPane.showMessageDialog(s,ce.getMessage(); try Connectioncon=DriverManager.getConnectio
36、n("jdbc:odbc:stu","sa","");Statement stmt = con.createStatement();ResultSet rs=stmt.executeQuery("select * from xinxi where 學號 ='"+textField1.getText()+皿);if(rs.next() JOptionPane.showMessageDialog(null,"此學號已經被注冊"); else stmt.execute("insert
37、 into xinxi (學號,姓名,性別,出生日期,政治面貌,籍貫,系別,專業)values ('"+textField1.getText()+"?"+textField2.getText()+"'J'+textField7.getText()+"?"+textField3.getText()+"?"+textField8.getText()+"'J'+textField4.getText()+"?"+textField9.getText()+
38、”':"+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 xg extends J
39、Frame implements ActionListenerstatic xg s;static JLabe11abel1 = new 兒abel("學號:");static JTextField textField1 = new JTextField("");static 兒abel label2 = new 兒abel("姓名:");static JTextField textField2 = new JTextField("");static 兒abel label3 = new 兒abel("性
40、別:");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
41、 label6 = new 兒abel("籍貫)static JTextField textField4 = new JTextField("");static 兒abel label7 = new 兒abel("系另U :");static JTextField textField9 = new JTextField("");static 兒abel label8 = new 兒abel("專業:");static JTextField textField5 = new JTextField("
42、;");static JButton button2=new JButton(" 修改"); public xg()this.setTitle("修改學生信息)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(2
43、41, 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);te
44、xtField9.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.add(label1);this.add(label2);this.add(label3);this.add(label4);this.add(label5);this.add(label6);this.add(label7);this.add(lab
45、el8);this.add(textField1);this.add(textField2);this.add(textField3);this.add(textField4);this.add(textField5);this.add(textField7);this.add(textField8);this.add(textField9);this.add(button2);this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);this.setVisible(true);public static void main(String口
46、args) throws Exceptionxg a=new xg();a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);一 一public void actionPerformed(ActionEvent e)/事件處理程序if(e.getSource()=button2)tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver"); catch (ClassNotFoundException ce) JOptionPane.showMessageDialog(s,ce.getMessag
47、e();try Connection con = DriverManager.getConnection("jdbc:odbc:stu","sa","");Statement stmt = con.createStatement();ResultSet rs=stmt.executeQuery("select * from xinxi where 學號 ='"+textField1.getText()+皿);if(textField1.getText().trim().equals(""
48、)學號不可為空!JOptionPane.showMessageDialog(this,”");else if(rs.next()updateSql="update xinxi姓名set 學號String ='"+textField1.getText()+"',IIItextField2.getText()+”',二"'+textField7.getText()+”', 出生日期二"'+textField3.getText()+"',政治面貌='"+te
49、xtField8.getText()+"',籍貫="textField4.getText()+"',系 別='"+textField9.getText()+"', 專業='"+textField5.getText()+ "”'trystmt.executeQuery(updateSql); catch(SQLException se) JOptionPane.showMessageDialog(null,”修改成功)catch(SQLException se)JOptionPa
50、ne.showMessageDialog(s,se.getMessage();/sc.java刪除界面import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;public class sc extends JFrame implements ActionListenerstatic sc s;static JLabe11abel1 = new 兒abel(" 學號:");static JTextField textField1 = new JTextField(&quo
51、t;");static 兒abel label2 = new 兒abel("姓名:");static JTextField textField2 = new JTextField("");static 兒abel label3 = new 兒abel("性別:");static JTextField textField7=new JTextField("");static 兒abel label4 = new 兒abel("出生日期:");static JTextField textF
52、ield3 = new JTextField("");static 兒abel label5 = new 兒abel("政治面貌:");static JTextField textField8=new JTextField("");static 兒abel label6 = new 兒abel("籍貫)static JTextField textField4 = new JTextField("");static 兒abel label7 = new 兒abel("系另U:");sta
53、tic JTextField textField9 = new JTextField("");static 兒abel label8 = new 兒abel("專業:");static JTextField textField5 = new JTextField("");static JButton button4=new JButton(" 刪除)public sc() throws Exceptionthis.setTitle("刪除學生信息)this.setLayout(null);this.setSize(
54、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.setB
55、ounds(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.setBounds(295,241,80,3
56、3);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.add(textField7);thi
57、s.add(textField8);this.add(textField9);this.add(button4);this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setVisible(true);public static void main(String口 args) throws Exception sc a= new sc();a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);一 一public void actionPerformed(ActionEvent e)/
58、sc if (e.getSource() = button4) tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");catch (ClassNotFoundException ce) JOptionPane.showMessageDialog(s,ce.getMessage(); try Connectioncon=DriverManager.getConnection("jdbc:odbc:stu","sa","");Statement stmt = con.crea
59、teStatement();ResultSet rs=stmt.executeQuery("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_O
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 預應力張拉方法
- 施工作業人員法律法規告知
- Brand KPIs for neobanking Banco Original in Brazil-英文培訓課件2025.4
- Brand KPIs for hotels:Best Western in the United States-英文培訓課件2025.5
- 雙頻共口徑高隔離陣列天線設計
- 汽車傳感器與檢測技術電子教案:空氣質量傳感器
- 房地產企業計稅成本的扣除變化分析
- 佛山新中源國際商務公寓營銷策劃報告41p
- 城鄉醫療住院管理制度
- 中考地理復習教案第9課時 東南亞南亞西亞歐洲西部極地地區
- 人行道欄桿計算
- 小學心理健康教育-我會舉手發言教學設計學情分析教材分析課后反思
- 東南大學高等數學實驗報告-2
- 江蘇省連云港市海州區2022-2023學年八年級下學期期末數學試題(含答案)
- 西師版小學數學-畢業總復習資料
- 氣瓶內殘液殘氣處理操作規程
- 關于英國物業收費的討論
- 《陋室銘》之托物言志學習課件
- 漢明碼編譯碼實驗新編
- 電大可編程控制器應用實訓 形考任務6
- 部編版《語文》三年級下冊全冊教案及反思
評論
0/150
提交評論