已阅读5页,还剩13页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Java程序设计系 专 业班 级学 号 15号姓 名 刘振基题 目 学生成绩管理系统任课教师 彭杰一:要求1、 用到书上(课本或实验册)上的至少三个实例2、 用到至少两种布局和至少四种组件3、 用到对话框4、 用到对数据库的查询、删除、添加和修改5、 最好用到输入输出流6、 具有一定的实际意义二:内容 本系统用access作为数据库,用到了书上的布局实例和数据库连接实例功能: 1、输入十个同学的学号,姓名,出生日期,二科成绩(学,大学英语) 。2、输入学号查询学生信息。 3、删除记录4、查询记录5、添加记录6、修改记录三:代码第一部分:public class main public static void main(String args) zhuchuangkou win=new zhuchuangkou();第二部分主界面:import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;public class zhuchuangkou extends Frame implements ActionListenerButton button1,button2,button3,button4,tuichu;Panel p1,p2,p3;Label l1,l2,l3;TextField a1,a2;Box b1,b2,b3,b4,b5;ss s;zhuchuangkou()button1=new Button(登陆);button2=new Button(删除);button3=new Button(修改);button4=new Button(添加);tuichu=new Button(退出);p1=new Panel();p2=new Panel();p3=new Panel();l1=new Label(学生成绩管理,Label.CENTER);l1.setFont(new Font(宋体,Font.BOLD,72);l1.setBackground(Color.green);l2=new Label(登录名);l3=new Label(密码);a1=new TextField(10);a2=new TextField(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(new WindowAdapter()public void windowClosing(WindowEvent e)dispose(););setBackground(Color.RED);setBounds(10, 10, 1000, 500);setVisible(true);validate();public void actionPerformed(ActionEvent e)if(e.getSource()=tuichu)System.exit(0);if(e.getSource()=button1)if(a1.getText().equals(liuzhenji)&a2.getText().equals(123456)new chuankou();System.out.println(wwwww);dispose();elseSystem.out.print(nishurucuowu);第三部分选择操作:import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;public class zhuchuangkou extends Frame implements ActionListenerButton button1,button2,button3,button4,tuichu;Panel p1,p2,p3;Label l1,l2,l3;TextField a1,a2;Box b1,b2,b3,b4,b5;ss s;zhuchuangkou()button1=new Button(登陆);button2=new Button(删除);button3=new Button(修改);button4=new Button(添加);tuichu=new Button(退出);p1=new Panel();p2=new Panel();p3=new Panel();l1=new Label(学生成绩管理,Label.CENTER);l1.setFont(new Font(宋体,Font.BOLD,72);l1.setBackground(Color.green);l2=new Label(登录名);l3=new Label(密码);a1=new TextField(10);a2=new TextField(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(new WindowAdapter()public void windowClosing(WindowEvent e)dispose(););setBackground(Color.RED);setBounds(10, 10, 1000, 500);setVisible(true);validate();public void actionPerformed(ActionEvent e)if(e.getSource()=tuichu)System.exit(0);if(e.getSource()=button1)if(a1.getText().equals(liuzhenji)&a2.getText().equals(123456)new chuankou();System.out.println(wwwww);dispose();elseSystem.out.print(nishurucuowu);第四部分查询界面实现:import java.awt.*;import java.awt.event.*;import java.sql.*;import javax.swing.JOptionPane;public class ss extends Frame implements TextListener,ActionListenerButton xunzhao;TextField input;TextArea show;String s;int k;Connection con; Statement sql; int sum=0; ResultSet rs;ss()Panel p=new Panel();xunzhao= new Button(查找);input= new TextField(10);show= new TextArea(6,43);p.add(new Label(输入学号);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(new WindowAdapter()public void windowClosing(WindowEvent e)dispose(););public void actionPerformed(ActionEvent ee) boolean boo=true;s=input.getText();k=Integer.parseInt(s);try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch(ClassNotFoundException eee) System.out.println(+eee); try con=DriverManager.getConnection(jdbc:odbc:sun,gxy,123); sql=con.createStatement(); rs=sql.executeQuery(SELECT * FROM chengjibiao ); while(rs.next() int number=rs.getInt(number); String name=rs.getString(name); String date=rs.getString(birthday); int math=rs.getInt(math); int english=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(SQLException eee) System.out.println(eee); 第五部分删除:import java.awt.*;import java.awt.event.*;import java.sql.*;import javax.swing.JOptionPane;public class shanchu extends Frame implements TextListener,ActionListenerButton xunzhao;TextField input;TextArea show;String s;int k,s1,j;Connection con; Statement sql; int sum=0; ResultSet rs;shanchu()Panel p=new Panel();xunzhao= new Button(删除);input= new TextField(10);show= new TextArea(6,43);p.add(new Label(输入要删除的 +学号);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(new WindowAdapter()public void windowClosing(WindowEvent e)dispose(););public void actionPerformed(ActionEvent ee) boolean boo=true;s=input.getText();k=Integer.parseInt(s);String m,dir;try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch(ClassNotFoundException eee) System.out.println(+eee); try con=DriverManager.getConnection(jdbc:odbc:sun,gxy,123); sql=con.createStatement(); rs=sql.executeQuery(SELECT * FROM chengjibiao); while(rs.next() int number=rs.getInt(2); String name=rs.getString(3); String date=rs.getString(birthday); int math=rs.getInt(math); int english=rs.getInt(english); if(number=k) show.setText(你删除了:); show.append(学号:+number+ 姓名:+name+ 出生:+date+ 数学 +math+ 英语 +english); show.append(n); m=DELETE FROM chengjibiao WHERE number=+k+; sql.executeUpdate(m); con.close(); catch(SQLException e) System.out.println(e); 第六部分修改:import java.awt.*;import java.awt.event.*;import java.sql.*;import javax.swing.JOptionPane;public class xiugai extends Frame implements TextListener,ActionListenerButton charu;TextField input1,input2,input3,input4,input5,input6;TextArea show;Panel p1,p2;int k,s1,j;Connection con; Statement sql; int sum=0; ResultSet rs;xiugai() p1=new Panel(); p2=new Panel();charu= new Button(修改);input1= new TextField(10);input2= new TextField(10);input3= new TextField(10);input4= new TextField(10);input5= new TextField(10);input6= new TextField(10);show= new TextArea(6,43);p1.add(new Label(请输入要修改的学号);p1.add(new Label(number);p1.add(input1);p2.add(new Label(请输入修改的数据);p2.add(new Label(name);p2.add(input2);p2.add(new Label(date);p2.add(input3);p2.add(new Label(math);p2.add(input4);p2.add(new Label(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(new WindowAdapter()public void windowClosing(WindowEvent e)dispose(););public void actionPerformed(ActionEvent ee) boolean boo=true;String s0,s1,s2,s3,s4,s5,insert1,recode,name,date;int m0,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(ClassNotFoundException eee) System.out.println(+eee); try con=DriverManager.getConnection(jdbc:odbc:sun,gxy,123); sql=con.createStatement();recode=(+m0+,+number+,+name+,+date+,+math+,+english+); insert1=UPDATE chengjibiao SET math=+math+,english=+english+ WHERE number=+number+; sql.executeUpdate(insert1); catch(SQLException e) System.out.println(e); 第七部分添加:import java.awt.*;import java.awt.event.*;import java.sql.*;import javax.swing.JOptionPane;public class charu extends Frame implements TextListener,ActionListenerButton charu;TextField input1,input2,input3,input4,input5,input6;TextArea show;int k,s1,j;Connection con; Statement sql; int sum=0; ResultSet rs;charu()Panel p=new Panel();charu= new Button(插入);input1= new TextField(10);input2= new TextField(10);input3= new TextField(10);input4= new TextField(10);input5= new TextField(10);input6= new TextField(10);show= new TextArea(6,43);p.add(new Label(请输入要插入的数据);p.add(new Label(ID);p.add(input6);p.add(new Label(number);p.add(input1);p.add(new Label(name);p.add(input2);p.add(new Label(date);p.add(input3);p.add(new Label(math);p.add(input4);p.add(new Label(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(new WindowAdapter()public void windowClosing(WindowEvent e)dispose(););public void actionPerformed(ActionEvent ee) boolean boo=true;String s0,s
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 《EJT 1171-2004铀矿冶设施选址规定》专题研究报告深度
- 云南省2025云南省少数民族科普工作队招聘人员1人笔试历年参考题库典型考点附带答案详解(3卷合一)
- 云南省2025云南中医药大学公开招聘硕士及以上学历人员(8人)笔试历年参考题库典型考点附带答案详解(3卷合一)
- 乐山市2025上半年四川乐山市五通桥区赴四川师范大学考核招聘事业单位人员6人笔试历年参考题库典型考点附带答案详解(3卷合一)
- 乐山2025上半年四川乐山犍为县招聘卫生专业技术人员47人笔试历年难易错考点试卷带答案解析
- 丽水2025年浙江丽水市中心医院引进高层次人才32人(第三批)笔试历年常考点试题专练附带答案详解
- 2025上海复源教育科技有限公司招聘10人笔试参考题库附带答案详解
- 2025广东清远市广盐食品有限公司招聘20人笔试参考题库附带答案详解
- 2025年国网陕西省电力有限公司招聘480人(第二批)笔试参考题库附带答案详解
- 2025山西国际能源集团有限公司所属企业社会招聘258人笔试参考题库附带答案详解
- DB1310-T 369-2025 化学分析实验室玻璃仪器使用规
- 2025年四川蜀道高速公路集团有限公司招聘工作人员考试笔试备考题库及答案
- 2025年荣昌县辅警招聘考试真题及答案详解(网校专用)
- 上海落户业务培训
- 2025年国家开放大学(电大)《中国法律史》期末考试复习题库及答案解析
- 2025年水利工程质量检测员资格考试模拟试题:(岩土工程)复习题库及答案
- 广东省深圳市罗湖区2024-2025学年六年级上学期语文11月期中试卷(含答案)
- 耳聋护理查房记录
- 中国临床肿瘤学会(CSCO)食管癌诊疗指南2025
- 二保焊培训课件
- 工程变更通知(ECN)流程及管理规范
评论
0/150
提交评论