付费下载
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
《Java程序设计实训》设计数据库:
学生成果管理系统CREATEDATABASE学生成果管理系统教师信息表创建:createtable教师信息表(教师IDvarchar(8primarykey教师姓名varchar(8notnullunique,登录密码varchar(8notnull,)学籍信息表创建:createtable学籍信息表(学号varchar(15)primarykey,姓名varchar(8)notnull,年龄varchar(10),出生日期varchar(10),性别varchar(4),班级varchar(8)notnull,专业varchar(5),民族varchar(10),登录密码varchar(6notnull)成果信息表创建:createtable成果信息表(学号varchar(15),计算机网络varchar(8),计算机专业英语smallint,计算机信息技术基础smallint,Java程序设计smallint数据库应用实训教程smallint高等数学smallintXmlsmallint学生成果管理系统登录界面学生成果管理系统登录界面1.登录界面和主界面importjavax.swing.*;import;importjava.awt.*;import教师登录学生登录importjava.sql.*;添添修删查查查查添加加改除看看看看加classmyConnection{ResultSetre;publicmyConnection(){}publicResultSetgetResult(Stringsql){try{Class.forName();conn=DriverManager.getConnection("jdbc:odbc:学生成果管理系统","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();conn=DriverManager.getConnection("jdbc:odbc:学生成果管理系统","ww","123");stmt.executeUpdate(sql);mit();returntrue;}catch(Exceptione){System.out.println("executeSql "+e.toString());returnfalse;}}}classstuMainFrameextendsJFrameimplementsActionListener{JMenuBarjmb=newJMenuBar();JMenuMessagenewJMenu("信息");JMenuScorenewJMenu("查询");JMenuItemItem1newJMenuItem("添加学生信息");JMenuItemmName=newJMenuItem("学生成果查询");JMenuItemmScore=newJMenuItem("按成果查询");JMenuItemmNam1=newJMenuItem("查询学生信息");JLabellabelnewJLabel();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());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;privateJMenuItemc;publicmainFrame(){ this.setJMenuBar(mBar);ImageIconicon=newImageIcon("src/images/1.jpg");label.setIcon(icon);label.setBounds(0,0,icon.getIconWidth(),icon.getIconHeight());add(label);myMenuUser=newJMenu("用户");miUser=newJMenuItem("编辑用户");myMenuUser.add(miUser);mSystem=newJMenu("系统");mOperate=newJMenu("数据操作");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.add(mExit);mAdd=newJMenuItem("添加根本信息");mAddSc=newJMenuItem("添加成果信息");mDel=newJMenuItem("删除");mModify=newJMenuItem("修改");mOperate.add(mAdd);mOperate.add(mAddSc);mOperate.add(mDel);mName=newJMenuItem("查询学生信息");mScore=newJMenuItem("查询学生成果");miShow=newJMenuItem("全部显示");mQuery.add(mName);mQuery.add(mScore);mQuery.add(miShow);mAbout=newJMenuItem("软件信息");mHelp.add(mAbout);mExit.addActionListener(this);mAdd.addActionListener(this);mDel.addActionListener(this);mName.addActionListener(this);mScore.addActionListener(this);mAbout.addActionListener(this);miShow.addActionListener(this);miUser.addActionListener(this);publicvoidactionPerformed(ActionEvente){if(e.getSource()==mExit){dispose();newCJ().setVisible(true);}elseif(e.getSource()==mAbout){g(s,"学生成果管理系统n电信学院\n\n2012年3月","软件信息",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号:");JLabelt3=newJLabel("密码:");JLabellabel=newJLabel();publicStringzh=null;JTextFieldt2=newJTextField(null,15);JTextFieldt4=newJPasswordField(null,15);JRadioButtonb=newJRadioButton("教师");JRadioButtonb1=newJRadioButton("学生");JButtonjB1=newJButton("登录");JButtonjB2=newJButton("取消");publicCJsuper("学生生成果管理系统");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);setResizable(false);setVisible(true);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.INFORMATION_MESSAGE);}elseif(password.toString().equals("")){JOptionPane.showMessageDialog(null"请输入密码""温馨提示",JOptionPane.INFORMATION_MESSAGE);}else{myConnectionconn=newmyConnection();ResultSetrs;Stringsql="select*from教师信息表 where教师ID='"+username.toString()+and登录密码+password.toString()+"'";try{rs.last();if(rs.getRow()==1){setVisible(false);rs.beforeFirst();this.dispose();sql="select*from学籍信息表";ewlmf.setVisible(true);mf.setResizable(false);mf.setTitle("学生成果管理系统:教师登录界面");mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);wpublicvoidwindowClosing(WindowEvente){System.exit(0);}});g(l("教师姓名")+"老师!您好!欢迎登录学生成果管理系统!);}}else{JOptionPane.showMessageDialog(null"用户名或密码错误""登录失败"JOptionPane.INFORMATION_MESSAGE);}}catch(Exceptioner){}}}if(b1.isSelected()){if(username.toString().equals("")){"请输入用户名""温馨提示",JOptionPane.INFORMATION_MESSAGE);}elseif(password.toString().equals("")){JOptionPane.showMessageDialog(null"请输入密码""温馨提示",JOptionPane.INFORMATION_MESSAGE);}else{myConnectionconn=newmyConnection();ResultSetrs;Stringsql="select*from学籍信息表 where学号='"+t2.getText().toString()+and登录密码+t4.getText().toString()+"'";try{rs.last();if(rs.getRow()==1){setVisible(false);rs.beforeFirst();this.dispose();sql="select*from学籍信息表";stuMainFramesmf=newstuMainFrame();smf.setSize(500,400);smf.setVisible(true);smf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);smf.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});JOptionPane.showMessageDialog(null,rs.getString("学生姓名")+"同学!您好!欢迎登录学生成果管理系统!");}}else{JOptionPane.showMessageDialog(null"用户名或密码错误""登录失败"JOptionPane.INFORMATION_MESSAGE);}}catch(Exceptioner){}}}}}publicstaticvoidmain(String[]args){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exceptione){}CJframe=newCJ();newmainFrame();stuMainFramestu=newstuMainFrame();}}添加学生根本信息importjavax.swing.*;import;importjava.awt.*;importimportjava.sql.*;publicclassaddFormextendsJFrameimplementsActionListener{ JLabellabel1=newJLabel("添加根本信息",JLabel.CENTER);JLabellabxuehao=newJLabel("学号:",JLabel.CENTER);JLabellabyear=newJLabel("年龄:",JLabel.CENTER);JLabellabName=newJLabel("姓名:",JLabel.CENTER);JLabellabDate=newJLabel("出生日期:",JLabel.CENTER);JLabellabclass=newJLabel("班级:",JLabel.CENTER);JLabellabzy=newJLabel("专业:",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();JRadioButtonmannewJRadioButton("男");JRadioButtonwomennewJRadioButton("女");JButtonbtnAdd=newJButton("添加");JButtonbtnCancel=newJButton("返回");JButtonbtnReset=newJButton("重置");JPaneljpl=newJPanel();//创建面板对象Connectioncon;Statementsql;ResultSetrs;addForm(){super("添加学生信息");this.setResizable(false);this.setSize(550,450);this.setVisible(true);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);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);bgp.add(man);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);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);jpl.add(btnReset);jpl.add(btnAdd);jpl.add(btnCancel);}publicvoidactionPerformed(ActionEvente){ dispose();newmainFrame().setVisible(true);}if(e.getSource()==btnAdd){if(txtXueHao.getText().toString().equals("")){JOptionPane.showMessageDialog(null"请输入学号""温馨提示",JOptionPane.INFORMATION_MESSAGE);}elseif(txtName.getText().toString().equals("")){JOptionPane.showMessageDialog(null"请输入姓名""温馨提示",JOptionPane.INFORMATION_MESSAGE);}elseif(txtYear.getText().toString().equals("")){JOptionPane.showMessageDialog(null"请输入年龄""温馨提示",JOptionPane.INFORMATION_MESSAGE);}elseif(txtDate.getText().toString().equals("")){JOptionPane.showMessageDialog(null"出生日期""温馨提示",JOptionPane.INFORMATION_MESSAGE);}elseif(txtZY.getText().toString().equals("")){JOptionPane.showMessageDialog(null"请输入专业""温馨提示",JOptionPane.INFORMATION_MESSAGE);}elseif(txtMZ.getText().toString().equals("")){JOptionPane.showMessageDialog(null"请输入民族""温馨提示",JOptionPane.INFORMATION_MESSAGE);}elseif(txtClass.getText().toString().equals("")){JOptionPane.showMessageDialog(null"请输入班级""温馨提示",JOptionPane.INFORMATION_MESSAGE);}else{Stringsex;if(man.isSelected())sex="男";}else{"女";}try{Class.forName();}catch(ClassNotFoundExceptionce){JOptionPane.showMessageDialog(null,ce.getMessage());}try{ConnectionconDriverManager.getConnection("jdbc:odbc:学生成果管理系统","ww","123");Statementstmt=con.createStatement();intastmt.executeUpdate("insertinto学籍信息表(学号,登录密码,姓名,年龄出生日期性别班级,专业,民族)values('"+txtXueHao.getText()+"','"+00000+"','"+txtName.getText()+"','"+txtYetZY.getText()+"','"+txtMZ.getText()+"')");if(a==1)已成功添加","温馨提示",JOptionPane.INFORMATION_MESSAGE);}else添加失败","温馨提示",JOptionPane.INFORMATION_MESSAGE);}stmt.close();}catch(SQLExceptionse){JOptionPane.showMessageDialog(null,se.getMessage());}}}else{ txtZY.setText("");txtMZ.setText("");txtName.setText("");txtDate.setText("");txtXueHao.setText("");txtYear.setText("");publicstaticvoidmain(String[]args){addFormamg=newaddForm();}}添加学生成果importjava.awt.*;importjavax.swing.*;importimportjava.sql.*;publicclassaddScoreextendsJFrameimplementsActionListener{staticaddScoress;JLabel[]labelnewJLabel("学号:"newJLabel("计算机网络:"),newJLabel("Linux操作系统:"newJLabel("计算机专业英语:"newJLabel("计算机信息技术基础:"newJLabel("Java程序设计:"newJLabel("数据库应用实训教程:"),newJLabel("高等数学:"newJLabel("XML:")};JTextField[]txt={newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField()};JButtonaddnewJButton("添加");JButtonresetnewJButton("重置");JButtonCancel=newJButton("返回");JPaneljplnewJPanel();JLabeltitlenewJLabel("添加学生成果",JLabel.CENTER);Fontf=newFont("黑体Font.BOLD16ints=100;publicaddScore(){super("添加学生信息");this.setResizable(false);this.setSize(500,600);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.add(title);for(inti=0;i<label.length;i++){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);jpl.add(add);jpl.add(reset);}publicvoidactionPerformed(ActionEvente){dispose();newmainFrame().setVisible(true);}elseif(e.getSource()==add){try{Class.forName();}catch(ClassNotFoundExceptionce){JOptionPane.showMessageDialog(ss,ce.getMessage());}try{ConnectionconDriverManager.getConnection("jdbc:odbc:学生成果管理系统","ww","123");Statementstmt=con.createStatement();inta=stmt.executeUpdate("insertinto成果信息表(学号计算机网络,Linux操作系统,计算机专业英语,计算机信息技术基础Java程序设计,数据库应用实训教程,高等数学,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();}}修改学生信息:importjavax.swing.*;importjava.awt.*;importmodifyFormimportjava.sql.*;modifyFormpublicclass{
extendsJFrameimplementsActionListenerJPaneljpl=newJPanel();JLabelSCH=newJLabel("修改学生信息",JLabel.CENTER);Fontf=newFont("楷体",Font.BOLD+Font.ITALIC,30);JLabellabel1newJLabel("请输入学号:",JLabel.CENTER);JButtonbtnQuery=newJButton("查询");JLabellabel2newJLabel("姓名:",JLabel.CENTER);JLabellabyear=newJLabel("年龄:",JLabel.CENTER);JLabellabDate=newJLabel("出生日期:",JLabel.CENTER);JLabellabel5newJLabel("性别:",JLabel.CENTER);JLabellabel3newJLabel("班级:",JLabel.CENTER);JLabellabel4newJLabel("专业:",JLabel.CENTER);JLabellabmz=newJLabel("民族:",JLabel.CENTER);ButtonGroupbgpnewButtonGroup();JRadioButtonmannewJRadioButton("男");JRadioButtonwomennewJRadioButton("女");JTextFieldtyear=newJTextField();JTextFieldtDatenewJTextField();JTextFieldtmz=newJTextField();JTextFieldnum=newJTextField();JTextFieldnam=newJTextField();JTextFieldclas=newJTextField();JTextFieldscl=newJTextField();JButtonbtnModifynewJButton("修改");JButtonbtnCancelnewJButton("取消");Connectioncon;Statementsql;ResultSetrs;intre;publicmodifyForm(){ this.setSize(560,460);this.setVisible(true);this.setResizable(false);this.add(jpl);jpl.setBackground(Color.cyan);man.setBackground(Color.cyan);women.setBackground(Color.cyan);jpl.setLayout(null);btnQuery.addActionListener(this);SCH.setBounds(100,20,300,20);jpl.add(SCH);jpl.add(label1);num.setBounds(220,60,140,20);jpl.add(num);btnQuery.setBounds(120,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(label3);clas.setBounds(190,290,140,20);jpl.add(clas);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){elseif(ae.getSource()==btnQuery){try{Clasfso.rName();}catch(ClassNotFoundExceptione){ }try{con=DriverManager.getConnection("jdbc:odbc:学生成果管理系统","ww","123");sql=con.createStatement();rs=sql.executeQuery("select*from学籍信息表where学号='"+num.getText()+"'");if(rs.next()){学号"));nam.setText(rs.getString("姓名"));年龄").toString());tDate.setText(rs.getString("出生日期"));if(rs.getString("性别").equals("男")){man.setSelected(true);}else{women.setSelected(true);}clas.setText(rs.getString("班级"));scl.setText(rs.getString("专业"));tmz.setText(rs.getString("民族"));nam.setEditable(true);tyear.setEditable(true);tDate.setEditable(true);clas.setEditable(true);scl.setEditable(true);tmz.setEditable(true);el}se{JOptionPane.showMessageDialog(null"不存在该记录!""温馨提示",JOptionPane.INFORMATION_MESSAGE);tyear.setText("");tDate.setText("");tmz.setText("");num.setText("");nam.setText("");clas.setText("");scl.setText("");nam.setEditable(false);clas.setEditable(false);scl.setEditable(false);tmz.setEditable(false);elseif(ae.getSource()==btnModify){tryn.n(:学生成果管理系统","ww","123");sql=con.createStatement();re=sql.executeUpdate("Update 学籍信息表set姓名='"+nam.getText()+"',年龄='"+tyear.getText()+"',出生日期='"+tDate.getText()+"',班级='"+clas.getText()+"',专业='"+scl.getText()+"',民族='"+tmz.getText()+where学号='"+num.getText()+"'");if(re==1)记录修改完毕!","温馨提示",JOptionPane.INFORMATION_MESSAGE);}else记录修改失败!","温馨提示",JOptionPane.INFORMATION_MESSAGE);}sql.close();}catch(SQLExceptionse){JOptionPane.showMessageDialog(null,se.getMessage());}}tyear.setText("");tDate.setText("");tmz.setText("");num.setText("");nam.setText("");clas.setText("");scl.setText("");nam.setEditable(false);tyear.setEditable(false);tDate.setEditable(false);clas.setEditable(false);scl.setEditable(false);tmz.setEditable(false);}}publicstaticvoidmain(String[]args){newmodifyForm();}}删除学生信息importjavax.swing.*;importjava.awt.*;importimportjava.sql.*;publicclassdeleteFormextendsJFrameimplementsActionListener{ JPaneljpl=newJPanel();JLabelSCHnewJLabel("删除学生信息",JLabel.CENTER);FontfnewFont("楷体",Font.BOLD+Font.ITALIC,30);JLabellabel1newJLabel("请输入学号:",JLabel.CENTER);JButtonbtnQuery=newJButton("查询");JLabellabel2newJLabel("姓名:",JLabel.CENTER);JLabellabyear=newJLabel("年龄:",JLabel.CENTER);JLabellabDate=newJLabel("出生日期:",JLabel.CENTER);JLabellabel5newJLabel("性别:",JLabel.CENTER);JLabellabel3newJLabel("班级:",JLabel.CENTER);JLabellabel4newJLabel("专业:",JLabel.CENTER);JLabellabmz=newJLabel("民族:",JLabel.CENTER);ButtonGroupbgpnewButtonGroup();JRadioButtonmannewJRadioButton("男");JRadioButtonwomennewJRadioButton("女");JTextFieldtyearnewJTextField();JTextFieldtDate=newJTextField();JTextFieldtmz=newJTextField();JTextFieldnum=newJTextField();JTextFieldnam=newJTextField();JTextFieldclas=newJTextField();JTextFieldscl=newJTextField();JButtonbtnDeletenewJButton("删除");JButtonbtnCancelnewJButton("取消");Connectioncon;Statementsql;ResultSetrs;intre;deleteForm(){this.setSize(560,460);this.setVisible(true);this.setResizable(false);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);jpl.add(labyear);tyear.setBounds(190,180,140,20);jpl.add(tyear);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(label3);clas.setBounds(190,290,140,20);jpl.add(clas);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);clas.setEditable(false);scl.setEditable(false);tmz.setEditable(false);e}publicvoidactionPerformed(ActionEventae){if(ae.getSource()==btnCancel){w(eelseif(ae.getSource()==btnQuery){try{Class.forName();}catch(ClassNotFoundExceptione){}try{con=DriverManager.getConnection("jdbc:odbc:学生成果管理系统","ww","123");sql=con.createStatement();rs=sql.executeQuery("select*from学籍信息表where学号='"+num.getText()+"'");if(rs.next()){学号"));nam.setText(rs.getString("姓名"));年龄").toString());tDate.setText(rs.getString("出生日期"));if(rs.getString("性别").equals("男")){man.setSelected(true);}else{women.setSelected(true);}clas.setText(rs.getString("班级"));scl.setText(rs.getString("专业"));tmz.setText(rs.getString("民族"));nam.setEditable(true);tyear.setEditable(true);tDate.setEditable(true);clas.setEditable(true);scl.setEditable(true);tmz.setEditable(true);e.g(l,"不存在该记录!","温馨提示",JOptionPane.INFORMATION_MESSAGE);tyear.setText("");tDate.setText("");tmz.setText("");num.setText("");nam.setText("");clas.setText("");scl.setText("");nam.setEditable(false);clas.setEditable(false);scl.setEditable(false);tmz.setEditable(false);}hnelseif(ae.getSource()==btnDelete)tr{y{
//实现删除功能","ww","123");
con=DriverManager.getConnection("jdbc:odbc:学生成果管理系统sql=con.createStatement();re=sql.executeUpdate("DELETEFROM学籍信息表where学号='"+num.getText()+"'");if(re==1)记录删除完毕!","温馨提示",JOptionPane.INFORMATION_MESSAGE);}else记录删除失败!","温馨提示",JOptionPane.INFORMATION_MESSAGE);}sql.close();}catch(SQLExceptionse){JOptionPane.showMessageDialog(null,se.getMessage());}}else{btnDelete.setEnabled(false);tyear.setText("");tDate.setText("");tmz.setText("");num.setText("");nam.setText("");clas.setText("");scl.setText("");nam.setEditable(false);tyear.setEditable(false);tDate.setEditable(false);clas.setEditable(false);scl.setEditable(false);tmz.setEditable(false);}}publicstaticvoidmain(String[]args){newdeleteForm();}}学生信息查询与成果查询importjava.awt.*;importjavax.swing.*;importimport.*;importjava.sql.*;publicclassScoreextendsJFrameimplementsActionListener{staticScores;JLabeltitlenewJLabel("查询成果",JLabel.CENTER);Fontf=newFont("楷体",Font.BOLD+Font.ITALIC,16);JPaneljpl=newJPanel();JLabellabel1newJLabel("请输入学号:",JLabel.CENTER);JTextFieldnumnewJTextField();JButtonserch=newJButton("查询成果");JButtonreset=newJButton("重置");JLabellabel2=newJLabel("计算机网络:",JLabel.LEFT);JLabellabel3=newJLabel("Linux操作系统:",JLabel.LEFT);JLabellabel4=newJLabel("计算机专业英语:",JLabel.LEFT);JLabellabel5=newJLabel("计算机信息技术基础:",JLabel.LEFT);JLabellabel6=newJLabel("Java程序设计:",JLabel.LEFT);JLabellabel7=newJLabel("数据库:",JLabel.LEFT);JLabellabel8=newJLabel("高等数学:",JLabel.LEFT);JLabellabel9=newJLabel("XML:",JLabel.LEFT);JButtonCancel=newJButton("返回");JTextField[]txt={newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField()};staticintp=140;publicScore(){ super("查询分数");this.setResizable(false);this.setSize(500,550);this.setVisible(true);jpl.setBackground(Color.LIGHT_GRAY);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);title.setFont(f);this.add(jpl);jpl.setLayout(null);title.setBounds(100,20,300,20);jpl.add(title);label1.setBounds(100,60,90,20);jpl.add(label1);num.setBounds(210,60,140,20);jpl.add(num);serch.setBounds(100,100,90,20);reset.setBounds(200,100,90,20);jpl.add(serch);jpl.add(reset);jpl.add(Cancel);serch.addActionListener(this);reset.addActionListener(this);jpl.add(label2);jpl.add(label3);jpl.add(label4);jpl.add(label5);jpl.add(label6);jpl.add(label7);jpl.add(label8);jpl.add(label9);for(inti=0;i<txt.length;i++)jpl.add(txt[i]);p=p+40;}}publicvoidactionPerformed(ActionEvente)dispose();newmainFrame().setVisible(true);}if(e.getSource()==serch){Stringid=num.getText();try{Class.forName();}catch(ClassNotFoundExceptionce){JOptionPane.showMessageDialog(s,ce.getMessage());}try{ConnectionconDriverManager.getConnection("jdbc:odbc:学生成果管理系统","ww","123");Statementstmt=con.createStatement();ResultSetrs=stmt.executeQuery("select*from成果信息表where学号='"+id+"'");while(rs.next()){for(inti=0;i<txt.length;i++){txt[i].setText(rs.getString(i+2));}}}catch(SQLExceptionse){JOptionPane.showMessageDialog(s,se.getMessage());}}else{for(inti=0;i<txt.length;i++){txt[i].setText("");}num.setText("");}}publicstaticvoidmain(String[]args){Scores=newScore();}}importjava.awt.*;importjavax.swing.*;importimportjava.sql.*;publicclassSerchextendsJFrameimplementsActionListener{ staticSerchs;JPaneljpl=newJPanel();JLabelSCHnew
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 三农产业链供应链管理手册
- 催办尚未签署的合作协议的催办函(5篇)范文
- 医疗设备研发团队工作KPI考核表
- 供应商违规行为的处理通知5篇范文
- 旅游业智能化旅游产品设计标准化方案
- 确认2026年新项目启动时间的具体安排函件(5篇)
- 明确研发项目阶段性成果验收标准确认函(7篇)范文
- 软件工程师软件开发过程管理与代码质量绩效考评表
- 远离不良信息培育阳光心态小学主题班会课件
- 多元文化融入世界这么大-小学主题班会课件
- 《三级医院评审标准(2025年版)》深度解读与实施指南
- 2026年吉林省国资委监管企业2026年度第一次集中招聘(613人)考试备考题库及答案详解
- 2026年北京市朝阳区七年级数学下册期末考试试卷及答案
- 《养老机构重大事故隐患判定标准》解读与分析
- TSG 08-2026 特种设备使用管理规则
- 人教版高中数学必修一课后题答案
- 企业负责人带班检查记录
- 城隍庙施工组织设计
- 宜兴文化中心详勘报告
- 公文基础知识试题(带答案)
- 商品期权交易策略
评论
0/150
提交评论