java項(xiàng)目(學(xué)生成績(jī)管理系統(tǒng))_第1頁
java項(xiàng)目(學(xué)生成績(jī)管理系統(tǒng))_第2頁
java項(xiàng)目(學(xué)生成績(jī)管理系統(tǒng))_第3頁
java項(xiàng)目(學(xué)生成績(jī)管理系統(tǒng))_第4頁
java項(xiàng)目(學(xué)生成績(jī)管理系統(tǒng))_第5頁
已閱讀5頁,還剩23頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

/《Java程序設(shè)計(jì)實(shí)訓(xùn)》學(xué)生成績(jī)管理系統(tǒng)設(shè)計(jì)數(shù)據(jù)庫:CREATEDATABASE學(xué)生成績(jī)管理系統(tǒng)〔1教師信息表創(chuàng)建:createtable教師信息表<教師IDvarchar<8>primarykey,教師姓名varchar<8>notnullunique,登錄密碼varchar<8>notnull,>〔2學(xué)籍信息表創(chuàng)建:createtable學(xué)籍信息表<學(xué)號(hào)varchar<15>primarykey,姓名varchar<8>notnull,年齡varchar<10>,出生日期varchar<10>,性別varchar<4>,班級(jí)varchar<8>notnull,專業(yè)varchar<5>,民族varchar<10>,登錄密碼varchar<6>notnull>〔3成績(jī)信息表創(chuàng)建:createtable成績(jī)信息表<學(xué)號(hào)varchar<15>,計(jì)算機(jī)網(wǎng)絡(luò)varchar<8>,計(jì)算機(jī)專業(yè)英語smallint,計(jì)算機(jī)信息技術(shù)基礎(chǔ)smallint,Java程序設(shè)計(jì)smallint,數(shù)據(jù)庫應(yīng)用實(shí)訓(xùn)教程smallint,高等數(shù)學(xué)smallint,Xmlsmallint,>概要結(jié)構(gòu)分析:學(xué)生成績(jī)管理系統(tǒng)登錄界面學(xué)生成績(jī)管理系統(tǒng)登錄界面添加學(xué)生信息查看學(xué)生成績(jī)查看學(xué)生信息查看學(xué)生成績(jī)查看學(xué)生信息刪除學(xué)生信息修改學(xué)生信息添加學(xué)生成績(jī)添加學(xué)生信息學(xué)生登錄教師登錄添加學(xué)生信息查看學(xué)生成績(jī)查看學(xué)生信息查看學(xué)生成績(jī)查看學(xué)生信息刪除學(xué)生信息修改學(xué)生信息添加學(xué)生成績(jī)添加學(xué)生信息學(xué)生登錄教師登錄1.登錄界面和主界面importjavax.swing.*;import;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;classmyConnection{ResultSetre;publicmyConnection<>{}publicResultSetgetResult<Stringsql>{try{Class.forName<"sun.jdbc.odbc.JdbcOdbcDriver">; Connectionconn=DriverManager.getConnection<"jdbc:odbc:學(xué)生成績(jī)管理系統(tǒng)","ww","123">; Statementstmt=conn.createStatement<ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE>; ResultSetre=stmt.executeQuery<sql>;returnre;}catch<Exceptione>{ System.out.println<"getResult"+e.toString<>>;returnnull;}}publicbooleanexecuteSql<Stringsql>{try{Class.forName<"sun.jdbc.odbc.JdbcOdbcDriver">; Connectionconn=DriverManager.getConnection<"jdbc:odbc:學(xué)生成績(jī)管理系統(tǒng)","ww","123">; Statementstmt=conn.createStatement<>; stmt.executeUpdate<sql>; mit<>;returntrue;}catch<Exceptione>{ System.out.println<"executeSql"+e.toString<>>;returnfalse;}}}classstuMainFrameextendsJFrameimplementsActionListener{JMenuBarjmb=newJMenuBar<>;Message=newJMenu<"信息">; JMenuScore=newJMenu<"查詢">; JMenuItemItem1=newJMenuItem<"添加學(xué)生信息">; JMenuItemmName=newJMenuItem<"學(xué)生成績(jī)查詢">; JMenuItemmScore=newJMenuItem<"按成績(jī)查詢">; JMenuItemmNam1=newJMenuItem<"查詢學(xué)生信息">; JLabellabel=newJLabel<>;publicstuMainFrame<>{ImageIconicon=newImageIcon<"src/images/1.jpg">;label.setIcon<icon>;label.setBounds<0,0,icon.getIconWidth<>,icon.getIconHeight<>>; add<label>; setSize<label.getWidth<>,label.getHeight<>>;this.setJMenuBar<jmb>;jmb.add<Message>;jmb.add<Score>;Message.add<Item1>;Score.add<mNam1>;Score.add<mName>;Score.add<mScore>;Item1.addActionListener<this>;mName.addActionListener<this>;mScore.addActionListener<this>;mNam1.addActionListener<this>;}publicvoidactionPerformed<ActionEvente> {if<e.getSource<>==Item1> {newaddForm<>.setVisible<true>;}elseif<e.getSource<>==mName> {dispose<>;newScore1<>.setVisible<true>;}elseif<e.getSource<>==mScore> {newscoreQueryForm<>.setVisible<true>;} elseif<e.getSource<>==mNam1> {dispose<>;newSerch1<>.setVisible<true>;}}}classmainFrameextendsJFrameimplementsActionListener{ JLabellabel=newJLabel<>; JMenuBarmBar=newJMenuBar<>; JPanelp=newJPanel<>;privateJMenumSystem,mOperate,mQuery,mHelp,myMenuUser;privateJMenuItemmFile,mNew,mOpen,mExit,mAdd,mDel,mModify,mName,miShow,mScore,mAbout,miUser,mAddSc; publicmainFrame<> { this.setJMenuBar<mBar>; ImageIconicon=newImageIcon<"src/images/1.jpg">;label.setIcon<icon>;label.setBounds<0,0,icon.getIconWidth<>,icon.getIconHeight<>>; add<label>; setSize<label.getWidth<>,label.getHeight<>>;myMenuUser=newJMenu<"用戶">;miUser=newJMenuItem<"編輯用戶">;myMenuUser.add<miUser>;mSystem=newJMenu<"系統(tǒng)">;mOperate=newJMenu<"數(shù)據(jù)操作">;mQuery=newJMenu<"查詢">;mHelp=newJMenu<"幫助">;mBar.add<mSystem>;mBar.add<mOperate>;mBar.add<mQuery>;mBar.add<mHelp>;mBar.add<myMenuUser>;mFile=newJMenuItem<"文件">;mNew=newJMenuItem<"新建">;mOpen=newJMenuItem<"打開">;mExit=newJMenuItem<"退出">;mSystem.add<mFile>;mSystem.add<mNew>;mSystem.add<mOpen>;mSystem.addSeparator<>;mSystem.add<mExit>;mAdd=newJMenuItem<"添加基本信息">;mAddSc=newJMenuItem<"添加成績(jī)信息">;mDel=newJMenuItem<"刪除">;mModify=newJMenuItem<"修改">;mOperate.add<mAdd>;mOperate.add<mAddSc>;mOperate.add<mDel>;mOperate.add<mModify>;mName=newJMenuItem<"查詢學(xué)生信息">;mScore=newJMenuItem<"查詢學(xué)生成績(jī)">;miShow=newJMenuItem<"全部顯示">;mQuery.add<mName>;mQuery.add<mScore>;mQuery.addSeparator<>;mQuery.add<miShow>;mAbout=newJMenuItem<"軟件信息">;mHelp.add<mAbout>;mExit.addActionListener<this>;mAdd.addActionListener<this>;mDel.addActionListener<this>;mModify.addActionListener<this>;mName.addActionListener<this>;mScore.addActionListener<this>;mAbout.addActionListener<this>;miShow.addActionListener<this>;miUser.addActionListener<this>;mAddSc.addActionListener<this>;}publicvoidactionPerformed<ActionEvente>{if<e.getSource<>==mExit>{ dispose<>;newCJ<>.setVisible<true>;}elseif<e.getSource<>==mAbout>{ JOptionPane.showMessageDialog<this,"學(xué)生成績(jī)管理系統(tǒng)\n\n電信學(xué)院\n\n20XX3月","軟件信息",JOptionPane.INFORMATION_MESSAGE>;}elseif<e.getSource<>==mAdd>{ dispose<>;newaddForm<>.setVisible<true>;}elseif<e.getSource<>==mAddSc>{ dispose<>;newaddScore<>.setVisible<true>;}elseif<e.getSource<>==mDel>{ dispose<>;newdeleteForm<>.setVisible<true>;}elseif<e.getSource<>==mName>{ dispose<>;newSerch<>.setVisible<true>;}elseif<e.getSource<>==mScore>{ dispose<>;newScore<>.setVisible<true>;}elseif<e.getSource<>==mModify>{newmodifyForm<>.setVisible<true>;}elseif<e.getSource<>==miUser>{newuserFrame<>.setVisible<true>;}elseif<e.getSource<>==miShow>{newfreshTable<>.setVisible<true>;}}}classCJextendsJFrameimplementsActionListener{ JLabelt1=newJLabel<"ID號(hào):">; JLabelt3=newJLabel<"密碼:">; JLabellabel=newJLabel<>;publicStringzh=null; JTextFieldt2=newJTextField<null,15>; JTextFieldt4=newJPasswordField<null,15>; JRadioButtonb=newJRadioButton<"教師">; JRadioButtonb1=newJRadioButton<"學(xué)生">; JButtonjB1=newJButton<"登錄">; JButtonjB2=newJButton<"取消">;publicCJ<>{super<"學(xué)生生成績(jī)管理系統(tǒng)">; setLayout<null>;jB1.setBounds<110,170,60,20>;jB1.setBackground<Color.red>; add<jB1>;jB2.setBounds<210,170,60,20>;jB2.setBackground<Color.red>; add<jB2>;t1.setBounds<90,50,80,35>; add<t1>;t2.setBounds<120,50,150,35>; add<t2>;t3.setBounds<90,100,80,35>; add<t3>;t4.setBounds<120,100,150,35>; add<t4>;b.setBounds<200,20,70,30>;b1.setBounds<120,20,70,30>; ButtonGroupbg=newButtonGroup<>;b.setSelected<false>;b1.setSelected<true>;b1.setSelected<false>; add<b>;bg.add<b>;add<b1>;bg.add<b1>;b.setContentAreaFilled<false>;b1.setContentAreaFilled<false>;ImageIconicon=newImageIcon<"src/images/a.jpg">;label.setIcon<icon>;label.setBounds<0,0,icon.getIconWidth<>,icon.getIconHeight<>>;add<label>;setSize<label.getWidth<>,label.getHeight<>>;setResizable<false>;setVisible<true>;setLocation<300,300>;setDefaultCloseOperation<JFrame.EXIT_ON_CLOSE>;jB1.addActionListener<this>;jB2.addActionListener<this>;}publicvoidactionPerformed<ActionEvente>{if<e.getSource<>==jB2>{ System.exit<0>;}elseif<e.getSource<>==jB1>{ Stringusername,password; username=t2.getText<>; password=t4.getText<>;if<b.isSelected<>>{if<username.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"請(qǐng)輸入用戶名","溫馨提示",JOptionPane.INFORMATION_MESSAGE>; }elseif<password.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"請(qǐng)輸入密碼","溫馨提示",JOptionPane.INFORMATION_MESSAGE>; }else{ myConnectionconn=newmyConnection<>; ResultSetrs; String sql="select*from教師信息表where教師ID='"+username.toString<>+"'and登錄密碼='"+password.toString<>+"'";try{ rs=conn.getResult<sql>; rs.last<>;if<rs.getRow<>==1> {setVisible<false>; rs.beforeFirst<>;while<rs.next<>>{this.dispose<>; sql="select*from學(xué)籍信息表"; mainFramemf=newmainFrame<>; mf.setLayout<null>; mf.setVisible<true>; mf.setLocation<300,300>; mf.setResizable<false>; mf.setTitle<"學(xué)生成績(jī)管理系統(tǒng):教師登錄界面">; mf.setDefaultCloseOperation<JFrame.EXIT_ON_CLOSE>; mf.addWindowListener<newWindowAdapter<>{publicvoidwindowClosing<WindowEvente>{ System.exit<0>; } }>; JOptionPane.showMessageDialog<null,rs.getString<"教師姓名">+"老師!您好!歡迎登錄學(xué)生成績(jī)管理系統(tǒng)!">;} }else{ JOptionPane.showMessageDialog<null,"用戶名或密碼錯(cuò)誤","登錄失敗",JOptionPane.INFORMATION_MESSAGE>; } }catch<Exceptioner>{ System.out.println<er.toString<>>; } } }if<b1.isSelected<>>{if<username.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"請(qǐng)輸入用戶名","溫馨提示",JOptionPane.INFORMATION_MESSAGE>; }elseif<password.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"請(qǐng)輸入密碼","溫馨提示",JOptionPane.INFORMATION_MESSAGE>; }else{ myConnectionconn=newmyConnection<>; ResultSetrs; String sql="select*from學(xué)籍信息表where學(xué)號(hào)='"+t2.getText<>.toString<>+"'and登錄密碼='"+t4.getText<>.toString<>+"'";try{ rs=conn.getResult<sql>; rs.last<>;if<rs.getRow<>==1> {setVisible<false>; rs.beforeFirst<>;while<rs.next<>>{this.dispose<>; sql="select*from學(xué)籍信息表"; stuMainFramesmf=newstuMainFrame<>; smf.setSize<500,400>; smf.setVisible<true>; smf.setResizable<false>; smf.setDefaultCloseOperation<JFrame.EXIT_ON_CLOSE>; smf.addWindowListener<newWindowAdapter<>{publicvoidwindowClosing<WindowEvente>{ System.exit<0>; } }>; JOptionPane.showMessageDialog<null,rs.getString<"學(xué)生姓名">+"同學(xué)!您好!歡迎登錄學(xué)生成績(jī)管理系統(tǒng)!">;}}else{ JOptionPane.showMessageDialog<null,"用戶名或密碼錯(cuò)誤","登錄失敗",JOptionPane.INFORMATION_MESSAGE>; }}catch<Exceptioner>{ System.out.println<er.toString<>>; }}}}}publicstaticvoidmain<String[]args>{try{ UIManager.setLookAndFeel<UIManager.getSystemLookAndFeelClassName<>>; }catch<Exceptione>{} CJframe=newCJ<>;newmainFrame<>; stuMainFramestu=newstuMainFrame<>;}}2.添加學(xué)生基本信息importjavax.swing.*;import;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;publicclassaddFormextendsJFrameimplementsActionListener{JLabellabel1=newJLabel<"添加基本信息",JLabel.CENTER>; JLabellabxuehao=newJLabel<"學(xué)號(hào):",JLabel.CENTER>; JLabellabyear=newJLabel<"年齡:",JLabel.CENTER>; JLabellabName=newJLabel<"姓名:",JLabel.CENTER>;JLabellabDate=newJLabel<"出生日期:",JLabel.CENTER>;JLabellabclass=newJLabel<"班級(jí):",JLabel.CENTER>;JLabellabzy=newJLabel<"專業(yè):",JLabel.CENTER>;JLabellabmz=newJLabel<"民族:",JLabel.CENTER>;JLabellabsex=newJLabel<"性別:",JLabel.CENTER>;JTextFieldtxtName=newJTextField<20>;JTextFieldtxtDate=newJTextField<18>;JTextFieldtxtXueHao=newJTextField<20>;JTextFieldtxtYear=newJTextField<20>;JTextFieldtxtClass=newJTextField<20>;JTextFieldtxtZY=newJTextField<20>;JTextFieldtxtMZ=newJTextField<20>;ButtonGroupbgp=newButtonGroup<>; JRadioButtonman=newJRadioButton<"男">; JRadioButtonwomen=newJRadioButton<"女">;JButtonbtnAdd=newJButton<"添加">;JButtonbtnCancel=newJButton<"返回">;JButtonbtnReset=newJButton<"重置">;JPaneljpl=newJPanel<>;//創(chuàng)建面板對(duì)象Connectioncon;Statementsql;ResultSetrs;addForm<>{ super<"添加學(xué)生信息">;this.setResizable<false>;this.setSize<550,450>;this.setVisible<true>;this.setLocation<300,300>;this.setDefaultCloseOperation<JFrame.EXIT_ON_CLOSE>;this.add<jpl>;jpl.setLayout<null>;btnAdd.addActionListener<this>;btnReset.addActionListener<this>;btnCancel.addActionListener<this>;jpl.setBackground<Color.cyan>;man.setBackground<Color.cyan>;women.setBackground<Color.cyan>;label1.setBounds<100,20,300,20>;jpl.add<label1>;labxuehao.setBounds<100,50,70,20>;jpl.add<labxuehao>;txtXueHao.setBounds<190,50,140,20>;jpl.add<txtXueHao>;labName.setBounds<100,90,70,20>;jpl.add<labName>;txtName.setBounds<190,90,140,20>;jpl.add<txtName>;labsex.setBounds<110,130,60,20>;jpl.add<labsex>;man.setBounds<190,130,60,20>;women.setBounds<270,130,60,20>;jpl.add<man>;jpl.add<women>;bgp.add<man>;bgp.add<women>;labyear.setBounds<100,180,70,20>;jpl.add<labyear>;txtYear.setBounds<190,180,140,20>;jpl.add<txtYear>;labDate.setBounds<100,210,70,20>;jpl.add<labDate>;txtDate.setBounds<190,210,140,20>;jpl.add<txtDate>;labmz.setBounds<100,240,70,20>;jpl.add<labmz>;txtMZ.setBounds<190,240,140,20>;jpl.add<txtMZ>; labclass.setBounds<100,270,70,20>;jpl.add<labclass>;txtClass.setBounds<190,270,140,20>;jpl.add<txtClass>;labzy.setBounds<100,300,70,20>;jpl.add<labzy>;txtZY.setBounds<190,300,140,20>;jpl.add<txtZY>;btnReset.setBounds<80,350,90,20>;btnAdd.setBounds<200,350,90,20>;btnCancel.setBounds<320,350,90,20>;jpl.add<btnReset>;jpl.add<btnAdd>;jpl.add<btnCancel>;}publicvoidactionPerformed<ActionEvente> { if<e.getSource<>==btnCancel>{ dispose<>;newmainFrame<>.setVisible<true>;}if<e.getSource<>==btnAdd> {if<txtXueHao.getText<>.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"請(qǐng)輸入學(xué)號(hào)","溫馨提示",JOptionPane.INFORMATION_MESSAGE>; }elseif<txtName.getText<>.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"請(qǐng)輸入姓名","溫馨提示",JOptionPane.INFORMATION_MESSAGE>; }elseif<txtYear.getText<>.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"請(qǐng)輸入年齡","溫馨提示",JOptionPane.INFORMATION_MESSAGE>; }elseif<txtDate.getText<>.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"出生日期","溫馨提示",JOptionPane.INFORMATION_MESSAGE>; }elseif<txtZY.getText<>.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"請(qǐng)輸入專業(yè)","溫馨提示",JOptionPane.INFORMATION_MESSAGE>; }elseif<txtMZ.getText<>.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"請(qǐng)輸入民族","溫馨提示",JOptionPane.INFORMATION_MESSAGE>; }elseif<txtClass.getText<>.toString<>.equals<"">>{ JOptionPane.showMessageDialog<null,"請(qǐng)輸入班級(jí)","溫馨提示",JOptionPane.INFORMATION_MESSAGE>;}else{ Stringsex;if<man.isSelected<>> {sex="男";}else {sex="女";}try {Class.forName<"sun.jdbc.odbc.JdbcOdbcDriver">;}catch<ClassNotFoundExceptionce> {JOptionPane.showMessageDialog<null,ce.getMessage<>>;}try{ Connectioncon=DriverManager.getConnection<"jdbc:odbc:學(xué)生成績(jī)管理系統(tǒng)","ww","123">; Statementstmt=con.createStatement<>;inta=stmt.executeUpdate<"insertinto學(xué)籍信息表<學(xué)號(hào),登錄密碼,姓名,年齡,出生日期,性別,班級(jí),專業(yè),民族>values<'"+txtXueHao.getText<>+"','"+00000+"','"+txtName.getText<>+"','"+txtYear.getText<>+"','"+txtDate.getText<>+"','"+sex+"','"+txtClass.getText<>+"','"+txtZY.getText<>+"','"+txtMZ.getText<>+"'>">;if<a==1> {JOptionPane.showMessageDialog<null,"已成功添加","溫馨提示",JOptionPane.INFORMATION_MESSAGE>;}else {JOptionPane.showMessageDialog<null,"添加失敗","溫馨提示",JOptionPane.INFORMATION_MESSAGE>;} stmt.close<>;}catch<SQLExceptionse> {JOptionPane.showMessageDialog<null,se.getMessage<>>;}}}else{txtClass.setText<"">;txtZY.setText<"">;txtMZ.setText<"">;txtName.setText<"">;txtDate.setText<"">;txtXueHao.setText<"">;txtYear.setText<"">;txtXueHao.requestFocus<>;}}publicstaticvoidmain<String[]args> {addFormamg=newaddForm<>;}}3.添加學(xué)生成績(jī)importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;importjava.sql.*;publicclassaddScoreextendsJFrameimplementsActionListener{staticaddScoress; JLabel[]label={newJLabel<"學(xué)號(hào):">,newJLabel<"計(jì)算機(jī)網(wǎng)絡(luò):">,newJLabel<"Linux操作系統(tǒng):">,newJLabel<"計(jì)算機(jī)專業(yè)英語:">,newJLabel<"計(jì)算機(jī)信息技術(shù)基礎(chǔ):">,newJLabel<"Java程序設(shè)計(jì):">,newJLabel<"數(shù)據(jù)庫應(yīng)用實(shí)訓(xùn)教程:">,newJLabel<"高等數(shù)學(xué):">,newJLabel<"XML:">}; JTextField[]txt={newJTextField<>,newJTextField<>,newJTextField<>,newJTextField<>,newJTextField<>,newJTextField<>,newJTextField<>,newJTextField<>,newJTextField<>}; JButtonadd=newJButton<"添加">; JButtonreset=newJButton<"重置">; JButtonCancel=newJButton<"返回">; JPaneljpl=newJPanel<>; JLabeltitle=newJLabel<"添加學(xué)生成績(jī)",JLabel.CENTER>; Fontf=newFont<"黑體",Font.BOLD,16>;ints=100;publicaddScore<> {super<"添加學(xué)生信息">;this.setResizable<false>;this.setSize<500,600>;this.setDefaultCloseOperation<EXIT_ON_CLOSE>;this.setVisible<true>;this.add<jpl>;Cancel.addActionListener<this>;add.addActionListener<this>;reset.addActionListener<this>;jpl.setLayout<null>;title.setBounds<150,40,200,20>;title.setFont<f>;title.setForeground<Color.red>;jpl.setBackground<Color.LIGHT_GRAY>;jpl.add<title>;for<inti=0;i<label.length;i++> {label[i].setBounds<100,s,140,20>;jpl.add<label[i]>;txt[i].setBounds<260,s,140,20>;jpl.add<txt[i]>;s=s+40; }add.setBounds<100,s,80,20>;reset.setBounds<200,s,80,20>;Cancel.setBounds<300,s,80,20>;jpl.add<add>;jpl.add<reset>;jpl.add<Cancel>; }publicvoidactionPerformed<ActionEvente> {if<e.getSource<>==Cancel>{ dispose<>;newmainFrame<>.setVisible<true>; }elseif<e.getSource<>==add> {try {Class.forName<r">;}catch<ClassNotFoundExceptionce> {JOptionPane.showMessageDialog<ss,ce.getMessage<>>;}try{Connectioncon=DriverManager.getConnection<"jdbc:odbc:學(xué)生成績(jī)管理系統(tǒng)","ww","123">; Statementstmt=con.createStatement<>;inta=stmt.executeUpdate<"insertinto成績(jī)信息表<學(xué)號(hào),計(jì)算機(jī)網(wǎng)絡(luò),Linux操作系統(tǒng),計(jì)算機(jī)專業(yè)英語,計(jì)算機(jī)信息技術(shù)基礎(chǔ),Java程序設(shè)計(jì),數(shù)據(jù)庫應(yīng)用實(shí)訓(xùn)教程,高等數(shù)學(xué),Xml>values<'"+txt[0].getText<>+"','"+txt[1].getText<>+"','"+txt[2].getText<>+"','"+txt[3].getText<>+"','"+txt[4].getText<>+"','"+txt[5].getText<>+"','"+txt[6].getText<>+"','"+txt[7].getText<>+"','"+txt[8].getText<>+"'>">;if<a==1> {JOptionPane.showMessageDialog<ss,"添加成功">;}else {JOptionPane.showMessageDialog<ss,"添加失敗">;}}catch<SQLExceptionse> {JOptionPane.showMessageDialog<ss,se.getMessage<>>; }}else {for<inti=0;i<txt.length;i++> {txt[i].setText<"">;txt[0].requestFocus<>; }}}publicstaticvoidmain<String[]args> {addScoreas=newaddScore<>;}}4.修改學(xué)生信息:importjavax.swing.*;importjava.awt.*;importt.*;importjava.sql.*;publicclassmodifyFormextendsJFrameimplementsActionListener{ JPaneljpl=newJPanel<>; JLabelSCH=newJLabel<"修改學(xué)生信息",JLabel.CENTER>; Fontf=newFont<"楷體",Font.BOLD+Font.ITALIC,30>; JLabellabel1=newJLabel<"請(qǐng)輸入學(xué)號(hào):",JLabel.CENTER>; JButtonbtnQuery=newJButton<"查詢">; JLabellabel2=newJLabel<"姓名:",JLabel.CENTER>; JLabellabyear=newJLabel<"年齡:",JLabel.CENTER>; JLabellabDate=newJLabel<"出生日期:",JLabel.CENTER>; JLabellabel5=newJLabel<"性別:",JLabel.CENTER>; JLabellabel3=newJLabel<"班級(jí):",JLabel.CENTER>; JLabellabel4=newJLabel<"專業(yè):",JLabel.CENTER>;JLabellabmz=newJLabel<"民族:",JLabel.CENTER>; ButtonGroupbgp=newButtonGroup<>; JRadioButtonman=newJRadioButton<"男">; JRadioButtonwomen=newJRadioButton<"女">; JTextFieldtyear=newJTextField<>; JTextFieldtDate=newJTextField<>; JTextFieldtmz=newJTextField<>; JTextFieldnum=newJTextField<>; JTextFieldnam=newJTextField<>; JTextFieldclas=newJTextField<>; JTextFieldscl=newJTextField<>; JButtonbtnModify=newJButton<"修改">; JButtonbtnCancel=newJButton<"取消">; Connectioncon;Statementsql;ResultSetrs;intre;publicmodifyForm<> {this.setSize<560,460>;this.setVisible<true>;this.setResizable<false>;SCH.setForeground<Color.red>;this.setDefaultCloseOperation<JFrame.EXIT_ON_CLOSE>;this.add<jpl>;jpl.setBackground<Color.cyan>;man.setBackground<Color.cyan>;women.setBackground<Color.cyan>;jpl.setLayout<null>;btnQuery.addActionListener<this>;btnModify.addActionListener<this>;btnCancel.addActionListener<this>;SCH.setBounds<100,20,300,20>;jpl.add<SCH>;label1.setBounds<100,60,100,20>;jpl.add<label1>;num.setBounds<220,60,140,20>;jpl.add<num>;btnQuery.setBounds<120,100,90,20>;btnModify.setBounds<230,100,90,20>;btnCancel.setBounds<340,100,90,20>;jpl.add<btnQuery>;jpl.add<btnModify>;jpl.add<btnCancel>;label2.setBounds<100,150,70,20>;jpl.add<label2>;nam.setBounds<190,150,140,20>;jpl.add<nam>;labyear.setBounds<100,180,70,20>;jpl.add<labyear>;tyear.setBounds<190,180,140,20>;jpl.add<tyear>;labDate.setBounds<100,210,70,20>;jpl.add<labDate>;tDate.setBounds<190,210,140,20>;jpl.add<tDate>;label5.setBounds<100,250,70,20>;jpl.add<label5>;man.setBounds<205,250,60,20>;women.setBounds<285,250,60,20>;bgp.add<man>;bgp.add<women>;jpl.add<man>;jpl.add<women>;label3.setBounds<100,290,70,20>;jpl.add<label3>;clas.setBounds<190,290,140,20>;jpl.add<clas>;label4.setBounds<100,320,70,20>;jpl.add<label4>;scl.setBounds<190,320,140,20>;jpl.add<scl>;labmz.setBounds<100,350,70,20>;jpl.add<labmz>;tmz.setBounds<190,350,140,20>;jpl.add<tmz>;}publicvoidactionPerformed<ActionEventae>{if<ae.getSource<>==btnCancel>{dispose<>;newmainFrame<>.setVisible<true>;}elseif<ae.getSource<>==btnQuery>{try{Class.forName<"sun.jdbc.odbc.JdbcOdbcDriver">;}catch<ClassNotFoundExceptione>{}try{con=DriverManager.getConnection<"jdbc:odbc:學(xué)生成績(jī)管理系統(tǒng)","ww","123">;sql=con.createStatement<>;rs=sql.executeQuery<"select*from學(xué)籍信息表where學(xué)號(hào)='"+num.getText<>+"'">;if<rs.next<>>{num.setText<rs.getString<"學(xué)號(hào)">>;nam.setText<rs.getString<"姓名">>;tyear.setText<rs.getString<"年齡">.toString<>>;tDate.setText<rs.getString<"出生日期">>;if<rs.getString<"性別">.equals<"男">> {man.setSelected<true>;}else {women.setSelected<true>;}clas.setText<rs.getString<"班級(jí)">>;scl.setText<rs.getString<"專業(yè)">>;tmz.setText<rs.getString<"民族">>;btnModify.setEnabled<true>;nam.setEditable<true>;tyear.setEditable<true>;tDate.setEditable<true>;clas.setEditable<true>;scl.setEditable<true>;tmz.setEditable<true>;}else{ JOptionPane.showMessageDialog<null,"不存在該記錄!","溫馨提示",JOptionPane.INFORMATION_MESSAGE>;btnModify.setEnabled<false>;tyear.setText<"">;tDate.setText<"">;tmz.setText<"">;num.setText<"">;nam.setText<"">;clas.setText<"">;scl.setText<"">;num.requestFocus<>;nam.setEditable<false>;tyear.setEditable<false>;tDate.setEditable<false>;clas.setEditable<false>;scl.setEditable<false>;tmz.setEditable<false>;}}catch<SQLExceptione>{}}elseif<ae.getSource<>==btnModify>{try{con=DriverManager.getConnection<"jdbc:odbc:學(xué)生成績(jī)管理系統(tǒng)","ww","123">;sql=con.createStatement<>;re=sql.executeUpdate<"Update學(xué)籍信息表set姓名='"+nam.getText<>+"',年齡='"+tyear.getText<>+"',出生日期='"+tDate.getText<>+"',班級(jí)='"+clas.getText<>+"',專業(yè)='"+scl.getText<>+"',民族='"+tmz.getText<>+"'where學(xué)號(hào)='"+num.getText<>+"'">;if<re==1> {JOptionPane.showMessageDialog<null,"記錄修改完畢!","溫馨提示",JOptionPane.INFORMATION_MESSAGE>;}else {JOptionPane.showMessageDialog<null,"記錄修改失??!","溫馨提示",JOptionPane.INFORMATION_MESSAGE>;}sql.close<>;}catch<SQLExceptionse> {JOptionPane.showMessageDialog<null,se.getMessage<>>;}}else{btnModify.setEnabled<false>;tyear.setText<"">;tDate.setText<"">;tmz.setText<"">;num.setText<"">;nam.setText<"">;clas.setText<"">;scl.setText<"">;num.requestFocus<>;nam.setEditable<false>;tyear.setEditable<false>;tDate.setEditable<false>;clas.setEditable<false>;scl.setEditable<false>;tmz.setEditable<false>;}}publicstaticvoidmain<String[]args>{newmodifyForm<>;}}5.刪除學(xué)生信息importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;publicclassdeleteFormextendsJFrameimplementsActionListener{JPaneljpl=newJPanel<>; JLabelSCH=newJLabel<"刪除學(xué)生信息",JLabel.CENTER>; Fontf=newFont<"楷體",Font.BOLD+Font.ITALIC,30>; JLabellabel1=newJLabel<"請(qǐng)輸入學(xué)號(hào):",JLabel.CENTER>; JButtonbtnQuery=newJButton<"查詢">; JLabellabel2=newJLabel<"姓名:",JLabel.CENTER>; JLabellabyear=newJLabel<"年齡:",JLabel.CENTER>; JLabellabDate=newJLabel<"出生日期:",JLabel.CENTER>; JLabellabel5=newJLabel<"性別:",JLabel.CENTER>; JLabellabel3=newJLabel<"班級(jí):",JLabel.CENTER>; JLabellabel4=newJLabel<"專業(yè):",JLabel.CENTER>;JLabellabmz=newJLabel<"民族:",JLabel.CENTER>; ButtonGroupbgp=newButtonGroup<>; JRadioButtonman=newJRadioButton<"男">; JRadioButtonwomen=newJRadioButton<"女">; JTextFieldtyear=newJTextField<>; JTextFieldtDate=newJTextField<>; JTextFieldtmz=newJTextField<>; JTextFieldnum=newJTextField<>; JTextFieldnam=newJTextField<>; JTextFieldclas=newJTextField<>; JTextFieldscl=newJTextField<>; JButtonbtnDelete=newJButton<"刪除">; JButtonbtnCancel=newJButton<"取消">;Connectioncon;Statementsql;ResultSetrs;intre;deleteForm<>{ this.setSize<560,460>;this.setVisible<true>;this.setResizable<false>;SCH.setForeground<Color.red>;this.setDefaultCloseOperation<JFrame.EXIT_ON_CLOSE>;this.add<jpl>;jpl.setBackground<Color.cyan>;man.setBackground<Color.cyan>;women.setBackground<Color.cyan>;jpl.setLayout<null>;btnQuery.addActionListener<this>;btnDelete.addActionListener<this>;btnCancel.addActionListener<this>;SCH.setBounds<100,20,300,20>;jpl.add<SCH>;label1.setBounds<100,60,100,20>;jpl.add<label1>;num.setBounds<220,60,140,20>;jpl.add<num>;btnQuery.setBounds<120,100,90,20>;btnDelete.setBounds<230,100,90,20>;btnCancel.setBounds<340,100,90,20>;jpl.add<btnQuery>;jpl.add<btnDelete>;jpl.add<btnCancel>;label2.setBounds<100,150,70,20>;jpl.add<label2>;nam.setBounds<190,150,140,20>;jpl.add<nam>;labyear.setBounds<100,180,70,20>;jpl.add<labyear>;tyear.setBounds<190,180,140,20>;jpl.add<tyear>;labDate.setBounds<100,210,70,20>;jpl.add<labDate>;tDate.setBounds<190,210,140,20>;jpl.add<tDate>;label5.setBounds<100,250,70,20>;jpl.add<label5>;man.setBounds<205,250,60,20>;women.setBounds<285,250,60,20>;bgp.add<man>;bgp.add<women>;jpl.add<man>;jpl.add<women>;label3.setBounds<100,290,70,20>;jpl.add<label3>;clas.setBounds<190,290,140,20>;jpl.add<clas>;label4.setBounds<100,320,70,20>;jpl.add<label4>;scl.setBounds<190,320,140,20>;jpl.add<scl>;labmz.setBounds<100,350,70,20>;jpl.add<labmz>;tmz.setBounds<190,350,140,20>;jpl.add<tmz>;btnDelete.setEnabled<false>;//取消刪除按鈕的功能nam.setEditable<false>;tyear.setEditable<false>;tDate.setEditable<false>;clas.setEditable<false>;scl.setEditable<false>;tmz.setEditable<false>;setVisible<true>;num.requestFocus<>;}publicvoidactionPerformed<ActionEventae>{ if<ae.getSource<>==btnCancel>{dispose<>;newmainFrame<>.setVisible<true>;}elseif<ae.getSource<>==btnQuery>{try{Class.forName<"sun.jdbc.odbc.JdbcOdbcDriver">;}catch<ClassNotFoundExceptione>{}try{con=DriverManager.getConnection<"jdbc:odbc:學(xué)生成績(jī)管理系統(tǒng)","ww","123">;sql=con.createStatement<>;rs=sql.executeQuery<"select*from學(xué)籍信息表where學(xué)號(hào)='"+num.getText<>+"'">;if<rs.next<>>{num.setText<rs.getString<"學(xué)號(hào)">>;nam.setText<rs.getString<"姓名">>;tyear.setText<rs.getString<"年齡">.toString<>>;tDate.setText<rs.getString<"出生日期">>;if<rs.getString<"性別">.equals<"男">> {man.setSelected<true>;}else {women.setSelected<true>;}clas.setText<rs.getString<"班級(jí)">>;scl.setText<rs.getString<"專業(yè)">>;tmz.setText<rs.getString<"民族">>;btnDelete.setEnabled<true>;nam.setEditable<true>;tyear.setEditable<true>;tDate.setEditable<true>;clas.setEditable<true>;scl.setEditable<true>;tmz.setEditable<true>;}else{JOptionPane.showMessageDialog<null,"不存在該記錄!","溫馨提示",JOptionPane.INFORMATION_MESSAGE>;btnDelete.setEnabled<false>;tyear.setText<"">;tDate.setText<"">;tmz.setText<"">;num.setText<"">;nam.setText<"">;clas.setText<"">;scl.setText<"">;num.requestFocus<>;nam.setEditable<false>;tyear.setEditable<false>;tDate.setEditable<false>;clas.setEditable<false>;scl.setEditable<false>;tmz.setEditable<false>;}}catch<SQLExceptione>{}}elseif<ae.getSource<>==btnDelete> //實(shí)現(xiàn)刪除功能{try{con=DriverManager.getConnection<"jdbc:odbc:學(xué)生成績(jī)管理系統(tǒng)","ww","123">;sql=con.createStatement<>;re=sql.executeUpdate<"DE

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論