版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Java程序设计系专业班级学号15号姓名刘振基题目学生成绩管理系统任课老师彭杰一:要求用到书上(书本或试验册)上最少三个实例用到最少两种布局和最少四种组件用到对话框用到对数据库查询、删除、添加和修改最好用到输入输出流含有一定实际意义二:内容 本系统用access作为数据库,用到了书上布局实例和数据库连接实例功效:1、输入十个同学学号,姓名,出生日期,二科成绩(学,大学英语)。2、输入学号查询学生信息。3、删除统计4、查询统计5、添加统计6、修改统计三:代码第一部分:publicclassmain{ publicstaticvoidmain(String[]args){ zhuchuangkouwin=newzhuchuangkou(); }}第二部分主界面:importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjavax.swing.border.*;publicclasszhuchuangkouextendsFrameimplementsActionListener{ Buttonbutton1,button2,button3,button4,tuichu; Panelp1,p2,p3; Labell1,l2,l3; TextFielda1,a2; Boxb1,b2,b3,b4,b5; sss; zhuchuangkou(){ button1=newButton("登陆"); button2=newButton("删除"); button3=newButton("修改"); button4=newButton("添加"); tuichu=newButton("退出"); p1=newPanel(); p2=newPanel(); p3=newPanel(); l1=newLabel("学生成绩管理",Label.CENTER); l1.setFont(newFont("宋体",Font.BOLD,72)); l1.setBackground(Color.green); l2=newLabel("登录名"); l3=newLabel("密码"); a1=newTextField(10); a2=newTextField(10); a2.setEchoChar('*'); b1=Box.createVerticalBox(); b1.add(l2); b1.add(Box.createVerticalStrut(8)); b1.add(l3); b2=Box.createVerticalBox(); b2.add(a1); b2.add(Box.createVerticalStrut(8)); b2.add(a2); b4=Box.createHorizontalBox(); b4.add(button1); b4.add(Box.createHorizontalStrut(10)); b4.add(tuichu); b3=Box.createHorizontalBox(); b3.add(b1); b3.add(Box.createHorizontalStrut(10)); b3.add(b2); b5=Box.createVerticalBox(); b5.add(b3); b5.add(Box.createVerticalStrut(8)); b5.add(b4); button1.addActionListener(this); button2.addActionListener(this); button3.addActionListener(this); button4.addActionListener(this); tuichu.addActionListener(this); p1.add(l1); p2.add(b5); add(p1,BorderLayout.NORTH); add(p2,BorderLayout.CENTER); add(p3,BorderLayout.PAGE_END); addWindowListener(newWindowAdapter(){ publicvoidwindowClosing(WindowEvente){ dispose(); } }); setBackground(Color.RED); setBounds(10,10,1000,500); setVisible(true); validate(); } publicvoidactionPerformed(ActionEvente){ if(e.getSource()==tuichu){ System.exit(0); } if(e.getSource()==button1){ if(a1.getText().equals("liuzhenji")&&a2.getText().equals("123456")){ newchuankou(); System.out.println("wwwww"); dispose(); } else{ System.out.print("nishurucuowu"); } } } }第三部分选择操作:importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjavax.swing.border.*;publicclasszhuchuangkouextendsFrameimplementsActionListener{ Buttonbutton1,button2,button3,button4,tuichu; Panelp1,p2,p3; Labell1,l2,l3; TextFielda1,a2; Boxb1,b2,b3,b4,b5; sss; zhuchuangkou(){ button1=newButton("登陆"); button2=newButton("删除"); button3=newButton("修改"); button4=newButton("添加"); tuichu=newButton("退出"); p1=newPanel(); p2=newPanel(); p3=newPanel(); l1=newLabel("学生成绩管理",Label.CENTER); l1.setFont(newFont("宋体",Font.BOLD,72)); l1.setBackground(Color.green); l2=newLabel("登录名"); l3=newLabel("密码"); a1=newTextField(10); a2=newTextField(10); a2.setEchoChar('*'); b1=Box.createVerticalBox(); b1.add(l2); b1.add(Box.createVerticalStrut(8)); b1.add(l3); b2=Box.createVerticalBox(); b2.add(a1); b2.add(Box.createVerticalStrut(8)); b2.add(a2); b4=Box.createHorizontalBox(); b4.add(button1); b4.add(Box.createHorizontalStrut(10)); b4.add(tuichu); b3=Box.createHorizontalBox(); b3.add(b1); b3.add(Box.createHorizontalStrut(10)); b3.add(b2); b5=Box.createVerticalBox(); b5.add(b3); b5.add(Box.createVerticalStrut(8)); b5.add(b4); button1.addActionListener(this); button2.addActionListener(this); button3.addActionListener(this); button4.addActionListener(this); tuichu.addActionListener(this); p1.add(l1); p2.add(b5); add(p1,BorderLayout.NORTH); add(p2,BorderLayout.CENTER); add(p3,BorderLayout.PAGE_END); addWindowListener(newWindowAdapter(){ publicvoidwindowClosing(WindowEvente){ dispose(); } }); setBackground(Color.RED); setBounds(10,10,1000,500); setVisible(true); validate(); } publicvoidactionPerformed(ActionEvente){ if(e.getSource()==tuichu){ System.exit(0); } if(e.getSource()==button1){ if(a1.getText().equals("liuzhenji")&&a2.getText().equals("123456")){ newchuankou(); System.out.println("wwwww"); dispose(); } else{ System.out.print("nishurucuowu"); } } } }第四部分查询界面实现:importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.JOptionPane;publicclassssextendsFrameimplementsTextListener,ActionListener{ Buttonxunzhao; TextFieldinput; TextAreashow; Strings; intk; Connectioncon;Statementsql;intsum=0;ResultSetrs; ss(){ Panelp=newPanel(); xunzhao=newButton("查找"); input=newTextField(10); show=newTextArea(6,43); p.add(newLabel("输入学号")); p.add(input); p.add(xunzhao); xunzhao.addActionListener(this); show.addTextListener(this); show.setEditable(false); add(p,BorderLayout.NORTH); add(show,BorderLayout.CENTER); setBounds(10,30,500,200); setVisible(true); validate(); addWindowListener(newWindowAdapter(){ publicvoidwindowClosing(WindowEvente){ dispose(); } }); } publicvoidactionPerformed(ActionEventee){ booleanboo=true; s=input.getText(); k=Integer.parseInt(s); try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundExceptioneee){System.out.println(""+eee);}try{con=DriverManager.getConnection("jdbc:odbc:sun","gxy","123");sql=con.createStatement();rs=sql.executeQuery("SELECT*FROMchengjibiao");while(rs.next()){ intnumber=rs.getInt("number");Stringname=rs.getString("name");Stringdate=rs.getString("birthday");intmath=rs.getInt("math");intenglish=rs.getInt("english");if(number==k){boo=false; show.setText(null); show.append("学号:"+number+"姓名:"+name+"出生:"+date+"数学"+math+"英语"+english); show.append("\n");}}con.close();if(boo){ JOptionPane.showMessageDialog(this,"你输入学号不存在");}}catch(SQLExceptioneee){System.out.println(eee);} }}第五部分删除:importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.JOptionPane;publicclassshanchuextendsFrameimplementsTextListener,ActionListener{ Buttonxunzhao; TextFieldinput; TextAreashow; Strings; intk,s1,j; Connectioncon;Statementsql;intsum=0;ResultSetrs; shanchu(){ Panelp=newPanel(); xunzhao=newButton("删除"); input=newTextField(10); show=newTextArea(6,43); p.add(newLabel("输入要删除"+"学号")); p.add(input); p.add(xunzhao); xunzhao.addActionListener(this); show.addTextListener(this); show.setEditable(false); add(p,BorderLayout.NORTH); add(show,BorderLayout.CENTER); setBounds(10,30,500,200); setVisible(true); validate(); addWindowListener(newWindowAdapter(){ publicvoidwindowClosing(WindowEvente){ dispose(); } }); } publicvoidactionPerformed(ActionEventee){ booleanboo=true; s=input.getText(); k=Integer.parseInt(s); Stringm,dir; try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundExceptioneee){System.out.println(""+eee);}try{con=DriverManager.getConnection("jdbc:odbc:sun","gxy","123"); sql=con.createStatement();rs=sql.executeQuery("SELECT*FROMchengjibiao");while(rs.next()){intnumber=rs.getInt(2);Stringname=rs.getString(3);Stringdate=rs.getString("birthday");intmath=rs.getInt("math");intenglish=rs.getInt("english");if(number==k){ show.setText("你删除了:"); show.append("学号:"+number+"姓名:"+name+"出生:"+date+"数学"+math+"英语"+english); show.append("\n"); m="DELETEFROMchengjibiaoWHEREnumber="+k+""; sql.executeUpdate(m);} }con.close();}catch(SQLExceptione){System.out.println(e);}}} 第六部分修改:importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.JOptionPane;publicclassxiugaiextendsFrameimplementsTextListener,ActionListener{ Buttoncharu; TextFieldinput1,input2,input3,input4,input5,input6; TextAreashow; Panelp1,p2; intk,s1,j; Connectioncon;Statementsql;intsum=0;ResultSetrs; xiugai(){ p1=newPanel(); p2=newPanel(); charu=newButton("修改"); input1=newTextField(10); input2=newTextField(10); input3=newTextField(10); input4=newTextField(10); input5=newTextField(10); input6=newTextField(10); show=newTextArea(6,43); p1.add(newLabel("请输入要修改学号")); p1.add(newLabel("number")); p1.add(input1); p2.add(newLabel("请输入修改数据")); p2.add(newLabel("name")); p2.add(input2); p2.add(newLabel("date")); p2.add(input3); p2.add(newLabel("math")); p2.add(input4); p2.add(newLabel("english")); p2.add(input5); p2.add(charu); charu.addActionListener(this); show.addTextListener(this); show.setEditable(false); add(p1,BorderLayout.NORTH); add(p2,BorderLayout.CENTER); setBounds(10,30,1200,200); setVisible(true); validate(); addWindowListener(newWindowAdapter(){ publicvoidwindowClosing(WindowEvente){ dispose(); } }); } publicvoidactionPerformed(ActionEventee){ booleanboo=true; Strings0,s1,s2,s3,s4,s5,insert1,recode,name,date; intm0,m1,m2,m3,number,math,english; s1=input1.getText(); m1=Integer.parseInt(s1); number=m1; s4=input4.getText(); m2=Integer.parseInt(s4); math=m2; s5=input5.getText(); m3=Integer.parseInt(s5); english=m3; try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundExceptioneee){System.out.println(""+eee);}try{con=DriverManager.getConnection("jdbc:odbc:sun","gxy","123"); sql=con.createStatement();recode="("+m0+","+number+","+"'"+name+"'"+","+"'"+date+"'"+","+math+","+english+")";insert1="UPDATEchengjibiaoSETmath="+math+",english="+english+"WHEREnumber="+number+"";sql.executeUpdate(insert1);}catch(SQLExceptione){System.out.println(e);}} }第七部分添加:importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.JOptionPane;publicclasscharuextendsFrameimplementsTextListener,ActionListener{ Buttoncharu; TextFieldinput1,input2,input3,input4,input5,input6; TextAreashow; intk,s1,j; Connectioncon;Statementsql;intsum=0;ResultSetrs; charu(){ Panelp=newPanel(); charu=newButton("插入"); input1=newTextField(10); input2=newTextField(10); input3=newTextField(10); input4=newTextField(10); input5=newTextField(10); input6=newTextField(10); show=newTextArea(6,43); p.add(newLabel("请输入要插入数据")); p.add(newLabel("ID")); p.add(input6); p.add(newLabel("number")); p.add(input1); p.add(newLabel("name")); p.add(input2); p.add(newLabel("date")); p.add(input3); p.add(newLabel("math")); p.add(input4); p.add(newLabel("english")); p.add(input5); p.add(charu); charu.addActionListener(this); show.addTextListener(this); show.setEditable(false); add(p,BorderLayout.NORTH); add(show,BorderLayout.CENTER); setBounds(10,30,1200,200); setVisible(true); validate(); addWindowListener(newWindowAdapter(){ publicvoidwindowClosing(WindowEvente){ dispose(); } }); } publicvoidactionPerformed(ActionEventee){ booleanboo=true; Strings0,s1,s2,s3,s4,s5,insert1,recod
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 26年机构认知障碍心理需求课件
- 《计算机组成原理》 课件 第6-10章 中央处理器-指令集进阶
- 美甲店产品临期积压情况说明
- 美容院装修工程延期情况说明
- 满堂脚手架安全监理实施细则
- 全国卫生健康系统职业技能竞赛(传染病防治监督)复习题(宁夏回族自治区吴忠市2025年)
- 2025年设备监理师考试题库附参考答案(完整版)
- 2025年度公需科目考试物联网技术与应用考试题库含答案
- 大学生暑假实践总结
- 人际沟通 第六章 护理工作中的非语言沟通
- 2025贵州茅台生物科技研发有限责任公司科技人才招聘12人笔试历年参考题库附带答案详解
- 南方中低产田课件
- 陕西省2025年初中学业水平考试地理试卷附真题答案
- 研究生毕业论文答辩流程及注意要点
- 急诊胸痛处理流程
- 安徽大学《工程制图》2024-2025学年期末试卷(A卷)
- 广州医科大学2024年临床医学(呼吸内科)内科学试题及答案
- 矿产开采合作协议(2025年权威版)
- 人工智能赋能家居智能家电市场分析报告
- (2021-2025)五年高考历史真题分类汇编专题22 中国古代史(材料分析题、观点论述题)(全国)(原卷版)
- 第十章 静电场中的能量 总结提升-2023学年高二物理(人教版)
评论
0/150
提交评论