




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、一個簡單的學生成績管理信息系統(tǒng)(Java)一個簡單的學生成績管理信息系統(tǒng)(Java)年月一個簡單的學生成績管理信息系統(tǒng)題目:數(shù)據(jù)庫要求:建立的數(shù)據(jù)庫中包含如下信息:學生學號、姓名、班級,語文、數(shù)學、英語 成績。至少要有 5 個班級,每個班級要有 10 名以上學生。使用.txt 格式文本表示各種表。 功能需求:能夠實現(xiàn)根據(jù)以下關鍵字查詢:學生姓名 、學號、班級、課程名稱。能夠實現(xiàn)按照單科成績、總成績、平均成績、學號排序。能夠實現(xiàn)學生信息的插入、刪除和修改。能夠查詢每個課程的最高分、最低分及相應學生姓名、班級和學號。能夠查詢每個班級某門課程的優(yōu)秀率(90 分及以上)、不及格率,并進行排 序。界面要
2、求:使用圖形界面實現(xiàn),要符合日常軟件使用規(guī)范來設計菜單和界面。年月一個簡單的學生成績管理信息系統(tǒng)題目:一、需求分析1、界面符合日常軟件使用規(guī)范,使用方便,外形簡潔美觀。2、功能需求存儲學生學號、姓名、班級,語文、數(shù)學、英語成績等信息,實現(xiàn)數(shù)據(jù)庫 的讀取與存入,數(shù)據(jù)項的記錄與修改,刪除等。二、設計思想1、類設計將添加數(shù)據(jù)、查詢數(shù)據(jù)、刪除數(shù)據(jù)、修改數(shù)據(jù)四個功能分別為四個類來實現(xiàn), 為了便于測試,每一個類都繼承了主窗口類 JFRAME,使得窗口可以獨自運行。INSERT 類設計功能組件 功能實現(xiàn) 實現(xiàn)過程6 個文本域、6 個標簽、1 個按鈕 添加數(shù)據(jù)對按鈕添加監(jiān)控,實現(xiàn)按鈕事件為獲取文本域中的信息,
3、并執(zhí)行SQL 的 INSERT 語句。QUERY 類設計功能組件 功能實現(xiàn) 實現(xiàn)過程5 個按鈕、三個單行文本組件、1 個下拉框、1 個多行文本按學號查詢、按姓名查詢、按班級查詢、按課程查詢、顯示全部 對按鈕添加監(jiān)控,共有五個監(jiān)控事件,前三個實現(xiàn)按鈕事件為先獲取文本域中的信息,根據(jù)對應查詢的要求執(zhí)行相應的 SQL 的 SELLECT 語句; 按課程查詢通過在下來框中選擇對應的選項,即查詢相應的課程;第五個查詢 按鈕將全部信息在多行文本框中輸出。MODIFY 類設計功能組件 功能實現(xiàn)6 個單行文本、6 個標簽、1 個按鈕 修改數(shù)據(jù)一、需求分析1、界面二、設計思想1、類設計功能組件 功能實現(xiàn)實現(xiàn)過程
4、與添加數(shù)據(jù)類似,對按鈕添加監(jiān)控,實現(xiàn)按鈕事件為獲取文本域 中的信息,并執(zhí)行 SQL 的 UPDATE 語句;不同的是以學號為主鍵進行查找并更新。DELETE 類設計功能組件 功能實現(xiàn) 實現(xiàn)過程1 個單行文本、1 個標簽、1 個按鈕、1 個多行文本 刪除數(shù)據(jù)與修改數(shù)據(jù)類似,對按鈕添加監(jiān)控,實現(xiàn)按鈕事件為獲取文本域中的學號信息,并執(zhí)行 SQL 的 DELETE 語句;不同的是以學號為主鍵進行查找并 將刪除信息輸出到文本框中。2、數(shù)據(jù)庫設計系統(tǒng)概念結構設計系統(tǒng)邏輯結構設計學生成績信息表字段名屬性類型空值約束條件學號ID文本not null主鍵姓名name文本從鍵班級class文本從簡語文Chines
5、e長整數(shù)英語English長整數(shù)成績查詢系統(tǒng)學號姓名班級語文數(shù)學英語實現(xiàn)過程與添加數(shù)據(jù)類似,對按鈕添加監(jiān)控,實現(xiàn)按鈕事件為獲取數(shù)學Maths長整數(shù)數(shù)據(jù)庫截圖3、主界面設計MAINFRAME 類設計功能組件 功能實現(xiàn) 實現(xiàn)過程4 個按鈕、1 個背景、2 個標簽文本、2 個面板 查詢數(shù)據(jù)、添加數(shù)據(jù)、刪除數(shù)據(jù)、修改數(shù)據(jù)對按鈕添加監(jiān)控,共有 4 個監(jiān)控事件,實現(xiàn)按鈕事件為創(chuàng)建對應功能的類對象,出現(xiàn)相應的功能窗口。三、運行截圖主界面數(shù)學Maths長整數(shù)數(shù)據(jù)庫截圖3、主界面設計功能組件 功能實添加數(shù)據(jù)查詢數(shù)據(jù)按學號查詢按姓名查詢按班級查詢添加數(shù)據(jù)查詢數(shù)據(jù)按姓名查詢按班級查詢按課程名稱查詢顯示所有信息按課程
6、名稱查詢顯示所有信息修改數(shù)據(jù)刪除數(shù)據(jù)四、實驗感想通過此次課程設計我學會了很多知識,將 Java 課上遺漏的知識又進一步補 上。實踐過程中遇到了很多困難,比如沒學過數(shù)據(jù)庫,SQL 語句不熟,對 eclipse 的使用很生疏等,因此花費了很多時間在前期準備工作上。即使如此, 也有一些功能尚未實現(xiàn),例如查詢優(yōu)秀率、最高分和最低分等,雖然比較簡單, 但由于時間問題還是沒來得及做。由于本次試驗的很多知識都是現(xiàn)學現(xiàn)用,以 致很多地方的代碼顯得累贅繁瑣。但總體上主要功能是實現(xiàn)了的,并且美化了 一下主界面??傊舜握n程設計讓我獲益匪淺,我將會繼續(xù)把它完善做好。修改數(shù)據(jù)刪除數(shù)據(jù)四、實驗感想五、源代碼清單Mai
7、nFrame 類 import javax.swing.*; import java.awt.*; import java.awt.event.*;public class MainFrame extends JFrameJButton insert,query,delete,modify; JPanel panel,panel1,panel2;public MainFrame()/ TODO Auto-generated method stub ImageIcon img=new ImageIcon(1.gif); JLabel text1,text2,picture=new JLabel(
8、img);JFrame frame=new JFrame(學生成績管理系統(tǒng)); insert=new JButton( 添 加 數(shù) 據(jù) ); insert.setBackground(Color.green); insert.addActionListener(new insertActionPerformed();query=new JButton( 查 詢 數(shù) 據(jù) ); query.addActionListener(new queryActionPerformed(); query.setBackground(Color.green);modify=new JButton( 修 改 數(shù)
9、據(jù) ); modify.setBackground(Color.green); modify.addActionListener(new modifyActionPerformed();delete=new JButton( 刪 除 數(shù) 據(jù) ); delete.setBackground(Color.green); delete.addActionListener(new deleteActionPerformed();frame.setSize(360,200); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container
10、contentPane=frame.getContentPane(); contentPane.setLayout(new BorderLayout();text1=new JLabel(歡迎用學生成績管理系統(tǒng),JLabel.CENTER);text1.setFont(new Font(宋體,Font.BOLD,24); text1.setForeground(Color.blue);text2=new JLabel(-192091班 羅斌制作);五、源代碼清單text2.setFont(new Font(TimesRoman,Font.ROMAN_BASELINE,14); panel1=n
11、ew JPanel();panel1.add(insert); panel1.add(query); panel2=new JPanel(); panel2.add(modify); panel2.add(delete); panel1.setOpaque(false); panel2.setOpaque(false); panel=new JPanel();panel.add(text2,BorderLayout.NORTH);panel.add(panel1,BorderLayout.NORTH); panel.add(panel2,BorderLayout.SOUTH); panel.s
12、etOpaque(false); contentPane.add(text1,BorderLayout.NORTH); contentPane.add(panel,BorderLayout.CENTER);frame.getLayeredPane().add(picture,new Integer(Integer.MIN_VALUE); Toolkit kit = Toolkit.getDefaultToolkit();Dimension screenSize = kit.getScreenSize();int screenWidth = screenSize.width/2; int scr
13、eenHeight = screenSize.height/2; int height = this.getHeight();int width = this.getWidth();picture.setBounds(0,0,360,360); (JPanel)contentPane).setOpaque(false);frame.setLocation(screenWidth-width/2, screenHeight-height/2); frame.setVisible(true);public class insertActionPerformed implements ActionL
14、istenerpublic void actionPerformed(ActionEvent e)new Insert().setVisible(true);public class modifyActionPerformed implements ActionListenerpublic void actionPerformed(ActionEvent e)text2.setFont(new Font(TimesRnew Modify().setVisible(true);public class queryActionPerformed implements ActionListenerp
15、ublic void actionPerformed(ActionEvent e)new Query().setVisible(true);public class deleteActionPerformed implements ActionListenerpublic void actionPerformed(ActionEvent e)new Delete().setVisible(true);public static void main(String args)new MainFrame();Insert 類import java.awt.*; import java.awt.eve
16、nt.*; import javax.swing.*; import java.sql.*;public class Insert extends JFrameJTextField input1,input2,input3,input4,input5,input6; JLabel label1,label2,label3,label4,label5;JButton button;static Statement st;statictryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);Connectioncon=DriverManager.getConne
17、ction(jdbc:odbc:student);st=con.createStatement();catch(Exception e)new Modify().setVisible(true);ResultSet rs;public Insert()input1=new JTextField(15); input2=new JTextField(15); input3=new JTextField(15); input4=new JTextField(15); input5=new JTextField(15); input6=new JTextField(15); JPanel panel
18、=new JPanel();panel.setLayout(new GridLayout(6,2);panel.add(new JLabel(學號),BorderLayout.CENTER); panel.add(input1);panel.add(new JLabel(姓名),BorderLayout.CENTER); panel.add(input2);panel.add(new JLabel(班級),BorderLayout.CENTER);panel.add(input3);panel.add(new JLabel(語文),BorderLayout.CENTER);panel.add(
19、input4); panel.add(new JLabel(英語); panel.add(input5); panel.add(new JLabel(數(shù)學); panel.add(input6);button=new JButton( 添 加 ); button.addActionListener(new mysql(); Container container=getContentPane(); container.add(panel,BorderLayout.CENTER); container.add(button,BorderLayout.SOUTH); setTitle(添加數(shù)據(jù)窗口
20、);setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(250,250);Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screenSize = kit.getScreenSize(); int screenWidth = screenSize.width/2;int screenHeight = screenSize.height/2;int height = this.getHeight(); int width = this.getWidth();setLocat
21、ion(screenWidth-width/2, screenHeight-height/2); setVisible(true);class mysql implements ActionListenerResultSet rs;public void actionPerformed(ActionEvent e)tryString number=input1.getText().trim(); String name=input2.getText().trim(); String clas=input3.getText().trim(); String temp=input4.getText
22、();int chinese=Integer.parseInt(temp); temp=input4.getText();int english=Integer.parseInt(temp); temp=input4.getText();int maths=Integer.parseInt(temp);if(number.equals()|name.equals()| clas.equals()|temp.equals()JOptionPane.showMessageDialog(Insert.this,請重新輸入,提示對話框,1);elseString sql=insert into Sco
23、reInfo(ID,name,class,Chinese,English,Maths) values(+number+,+name+,+clas+,+chinese+,+english+,+maths+);st.executeUpdate(sql);JOptionPane.showMessageDialog(Insert.this, 數(shù)據(jù)添加成功,提示對話框,1);input1.setText();input2.setText();input3.setText();input4.setText();input5.setText();input6.setText();catch(Exceptio
24、n ee)Query 類import java.awt.*;import javax.swing.event.*; import java.awt.event.*; import javax.swing.*;public void actionPerformed(Acimport java.sql.*;public class Query extends JFrame JTextArea show;JButton button1,button2,button3,button4,button5; JTextField field1,field2,field3;JComboBox comoBox;
25、static Statement st;statictryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);Connectioncon=DriverManager.getConnection(jdbc:odbc:student);st=con.createStatement();catch(Exception e)public Query()show=new JTextArea(5,10); button1=new JButton(顯示所有信息);button1.addActionListener(new Mysql1(); Container conta
26、iner=getContentPane(); container.setLayout(new BorderLayout(); JPanel panel=new JPanel();JPanel mainpanel=new JPanel();button2=new JButton(按學號查詢); button2.addActionListener(new Mysql2(); panel.add(button2);field1=new JTextField(7); panel.add(field1); panel.setVisible(true); mainpanel.add(panel);butt
27、on3=new JButton(按姓名查詢); button3.addActionListener(new Mysql3(); panel.add(button3);field2=new JTextField(6); panel.add(field2); panel.setVisible(true); mainpanel.add(panel);import java.sql.*;button4=new JButton(按班級查詢); button4.addActionListener(new Mysql4(); panel.add(button4);field3=new JTextField(
28、6); panel.add(field3); panel.setVisible(true); mainpanel.add(panel);String items=請選擇,語文,英語,數(shù)學; comoBox=new JComboBox(items);button5=new JButton(按課程名稱查詢);button5.addActionListener(new Mysql5(); panel.add(button5);panel.add(comoBox); panel.setVisible(true); mainpanel.add(panel);panel=new JPanel(); pan
29、el.add(button1);container.add(mainpanel,BorderLayout.NORTH); container.add(panel,BorderLayout.SOUTH);container.add(new JScrollPane(show),BorderLayout.CENTER); setTitle( 查 詢 數(shù) 據(jù) ); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(750,400);Toolkit kit = Toolkit.getDefaultToolkit(); Dimension
30、 screenSize = kit.getScreenSize(); int screenWidth = screenSize.width/2;int screenHeight = screenSize.height/2;int height = this.getHeight(); int width = this.getWidth();setLocation(screenWidth-width/2, screenHeight-height/2); setVisible(true);class Mysql1 implements ActionListenerpublic void action
31、Performed(ActionEvent e)tryString sql=select * from ScoreInfo; ResultSet rs=st.executeQuery(sql); show.setText();button4=new JButton(按班級查詢); 姓名show.append(序號班級語文學號英語數(shù)學+n);while(rs.next()show.append(rs.getInt(1)+ show.append(rs.getString(2)+););show.append(rs.getString(3)+show.append(rs.getString(4)+
32、 show.append(rs.getInt(5)+);););show.append(rs.getInt(6)+ show.append(rs.getInt(7)+n););catch(Exception ee)class Mysql2 implements ActionListenerpublic void actionPerformed(ActionEvent e)tryString ss=field1.getText().trim();String sql=select * from ScoreInfo where ID=+ss+;ResultSet rs=st.executeQuer
33、y(sql);show.setText();姓名show.append(序號班級語文學號英語數(shù)學+n);while(rs.next()show.append(rs.getInt(1)+ show.append(rs.getString(2)+ show.append(rs.getString(3)+ show.append(rs.getString(4)+ show.append(rs.getInt(5)+ show.append(rs.getInt(6)+ show.append(rs.getInt(7)+n);););););););catch(Exception ee)show.appe
34、nd(序號學號數(shù)學+n);shclass Mysql3 implements ActionListenerpublic void actionPerformed(ActionEvent e)tryString ss=field2.getText().trim();String sql=select * from ScoreInfo where name=+ss+;ResultSet rs=st.executeQuery(sql);show.setText();姓名show.append(序號班級語文學號英語數(shù)學+n);while(rs.next()show.append(rs.getInt(1
35、)+ show.append(rs.getString(2)+ show.append(rs.getString(3)+ show.append(rs.getString(4)+ show.append(rs.getInt(5)+ show.append(rs.getInt(6)+ show.append(rs.getInt(7)+n);););););););catch(Exception ee)class Mysql4 implements ActionListenerpublic void actionPerformed(ActionEvent e)tryString ss=field3
36、.getText().trim();String sql=select * from ScoreInfo where class=+ss+;ResultSet rs=st.executeQuery(sql);show.setText();姓名show.append(序號班級語文學號英語數(shù)學+n);while(rs.next()show.append(rs.getInt(1)+ show.append(rs.getString(2)+););class Mysql3 implements Actionshow.append(rs.getString(3)+ show.append(rs.getS
37、tring(4)+ show.append(rs.getInt(5)+ show.append(rs.getInt(6)+ show.append(rs.getInt(7)+n);););););catch(Exception ee)class Mysql5 implements ActionListenerpublic void actionPerformed(ActionEvent e)tryString sql=;String ss=comoBox.getSelectedItem().toString();if(ss.equals(語文)sql=select ID,name,class,
38、Chinese from ScoreInfo ;show.setText();姓名show.append(序號班級語文+n);學號else if(ss.equals(英語)sql=select ID,name,class,English from ScoreInfo ;show.setText();姓名show.append(序號班級英語 +n);學號else if(ss.equals(數(shù)學)sql=select ID,name,class,Maths from ScoreInfo ;show.setText();姓名show.append(序號班級數(shù)學+n);學號ResultSet rs=s
39、t.executeQuery(sql);int i=0;while(rs.next()i+;show.append(rs.getString(3)+ show.append(+i+rs.getString(1)+);););show.append(rs.getString(2)+ show.append(rs.getString(3)+ show.append(rs.getInt(4)+n);catch(Exception ee)Modify 類 import java.awt.*; import java.awt.event.*; import javax.swing.*; import j
40、ava.sql.*;public class Modify extends JFrameJTextField input1,input2,input3,input4,input5,input6; JLabel label1,label2,label3,label4,label5;JButton button;static Statement st;statictryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);Connectioncon=DriverManager.getConnection(jdbc:odbc:student);st=con.crea
41、teStatement();catch(Exception e)ResultSet rs;public Modify()input1=new JTextField(15); input2=new JTextField(15); input3=new JTextField(15); input4=new JTextField(15); input5=new JTextField(15); input6=new JTextField(15); JPanel panel=new JPanel();panel.setLayout(new GridLayout(6,2);show.append(+i+r
42、s.getStrpanel.add(new JLabel(學號); panel.add(input1); panel.add(new JLabel(姓名); panel.add(input2); panel.add(new JLabel(班級); panel.add(input3); panel.add(new JLabel(語文); panel.add(input4); panel.add(new JLabel(英語); panel.add(input5); panel.add(new JLabel(數(shù)學); panel.add(input6);button=new JButton( 修 改
43、 ); button.addActionListener(new mysql(); Container container=getContentPane(); container.add(panel,BorderLayout.CENTER); container.add(button,BorderLayout.SOUTH); setTitle(修改數(shù)據(jù)窗口);setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(300,150);Toolkit kit = Toolkit.getDefaultToolkit(); Dimensio
44、n screenSize = kit.getScreenSize(); int screenWidth = screenSize.width/2;int screenHeight = screenSize.height/2;int height = this.getHeight(); int width = this.getWidth();setLocation(screenWidth-width/2, screenHeight-height/2); setVisible(true);class mysql implements ActionListenerpublic void action
45、Performed(ActionEvent e)tryString number=input1.getText().trim(); String name=input2.getText().trim(); String clas=input3.getText().trim(); String temp=input4.getText();int chinese=Integer.parseInt(temp); temp=input4.getText();int english=Integer.parseInt(temp); temp=input4.getText();panel.add(new J
46、Label(學號); int maths=Integer.parseInt(temp);if(number.equals()JOptionPane.showMessageDialog(Modify.this,學號不能為空!,提示對話框,1);elsetryStringsql=updateScoreInfoset name=+name+,class=+clas+,Chinese=+chinese+,English=+english+,Maths=+maths+ where ID=+number+;st.executeUpdate(sql);JOptionPane.showMessageDialo
47、g(Modify.this,數(shù)據(jù)修改成功,提示對話框,1);input1.setText();input2.setText();input3.setText();input4.setText();input5.setText();input6.setText();catch(Exception ee)JOptionPane.showMessageDialog(Modify.this,請確認需要修改的 學號是否存在,提示對話框,1);System.out.println(ee);catch(Exception eee)System.out.println(eee);Delete 類import java.awt.*;import java.awt.event.*;int maths=Integer.parseInt(temimport javax.swing.*;import java.sql.*;public class Delete extends JFrameJButton search; JTextField input; JTextArea show;Connection con; Statement st;public Delete()JPanel p=new JPanel(); s
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中考語文一輪復習:應用文 練習題(含答案)
- 電梯清洗抱閘施工方案
- 2025年中考語文寫作復習:備考作文主題《山花爛漫時》演繹張桂梅的“燃燈精神”
- 石材露臺改造施工方案
- 市政防滑路面施工方案
- 2025年法律援助測試題及答案
- 低介電常數(shù)聚酰亞胺
- 4年級下冊英語手抄報1到5單元
- 4-庚氧基-1-丁醇用途
- 鋼塑門施工方案
- SL176-2007《水利水電工程施工質量檢驗與評定規(guī)程》
- 挖掘機液壓原理動作分解
- 腹部CT應用入門
- 2019版外研社高中英語選擇性必修二Unit 1 Growing up 單詞表
- 路基接觸網(wǎng)基礎技術交底
- (高清版)輻射供暖供冷技術規(guī)程JGJ142-2012
- JTT 1295—2019道路大型物件運輸規(guī)范_(高清-最新)
- 土壤固化土施工技術導則
- VAR模型Johansen協(xié)整檢驗在eviews中的具體操作步驟及結果解釋
- 冷凍面團項目市場分析
- 加油站法律法規(guī)符合性評價
評論
0/150
提交評論