学生信息管理系统完整源代码+mysql文件

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

数据库所用的数据自己导入MYSQL5.5,Navicat8就可以用了。下面是具体的数据资料/*MySQLDataTransferSourceHost:localhostSourceDatabase:simsTargetHost:localhostTargetDatabase:simsDate:2013-6-259:24:26*/SETFOREIGN_KEY_CHECKS=0;--------------------------------Tablestructureformanager------------------------------DROPTABLEIFEXISTS`manager`;CREATETABLE`manager`(`id`varchar(10)NOTNULL,`name`varchar(30)NOTNULL,`Mima`varchar(20)NOTNULL,PRIMARYKEY(`id`))ENGINE=InnoDBDEFAULTCHARSET=utf8;--------------------------------Tablestructureforstudentinfo------------------------------DROPTABLEIFEXISTS`studentinfo`;CREATETABLE`studentinfo`(`Sname`varchar(30)NOTNULL,`Ssex`varchar(10)NOTNULL,`Snumber`varchar(10)NOTNULL,`Sprofession`varchar(30)NOTNULL,`Sclass`varchar(20)NOTNULL,`Sdate`varchar(30)charactersetutf8collateutf8_unicode_ciNOTNULL,PRIMARYKEY(`Snumber`))ENGINE=InnoDBDEFAULTCHARSET=utf8COMMENT='InnoDBfree:4096kB';--------------------------------Tablestructureforuserinfo------------------------------DROPTABLEIFEXISTS`userinfo`;CREATETABLE`userinfo`(`id`varchar(10)NOTNULL,`name`varchar(30)NOTNULL,`Mima`varchar(20)charactersetutf8collateutf8_unicode_ciNOTNULL,PRIMARYKEY(`id`))ENGINE=InnoDBDEFAULTCHARSET=utf8;--------------------------------Records------------------------------INSERTINTO`manager`VALUES('1','1','2');INSERTINTO`manager`VALUES('2','恩恩','123456');INSERTINTO`manager`VALUES('3','大大','123456');INSERTINTO`manager`VALUES('4','啊啊','123456');INSERTINTO`manager`VALUES('5','5','5');INSERTINTO`manager`VALUES('6','孙霞','123456');INSERTINTO`studentinfo`VALUES('张三','男','2010303755','数学','2','2010-02-12');INSERTINTO`studentinfo`VALUES('李四','男','2010303760','物理','1','1995.9.6');INSERTINTO`studentinfo`VALUES('王二','女','2010303761','应数','2','1990.9.11');INSERTINTO`studentinfo`VALUES('麻子','女','2010303762','信计','1','1999.9.10');INSERTINTO`userinfo`VALUES('1','1','1');INSERTINTO`userinfo`VALUES('13','13','1');INSERTINTO`userinfo`VALUES('2','2','2');INSERTINTO`userinfo`VALUES('3','3','3');INSERTINTO`userinfo`VALUES('6','6','6');INSERTINTO`userinfo`VALUES('7','7','6');下面是相应的程序:packageMS;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.Color;importjava.awt.Container;importjava.awt.Dimension;importjava.awt.GridLayout;importjava.awt.Toolkit;importjava.awt.event.FocusEvent;importjava.awt.event.FocusListener;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JTextField;importjavax.swing.SwingConstants;publicclassAddimplementsActionListener{JFramef1;Containerct;JPaneljp,jp1,jp2,jp3;JButtonbtn1,btn2;JLabellabel;JTextFieldtf1,tf2,tf3,tf4,tf5,tf6;Add(){f1=newJFrame();ct=f1.getContentPane();//初始化面板jp=newJPanel();jp1=newJPanel(newGridLayout(6,1));jp2=newJPanel(newGridLayout(6,1));jp3=newJPanel();btn1=newJButton(确定);btn2=newJButton(取消);label=newJLabel(htmlfontcolor=#CC00FFsize='4'添加学生信息/font,SwingConstants.CENTER);label.setForeground(Color.gray);tf1=newJTextField(20);tf2=newJTextField(20);tf3=newJTextField(20);tf4=newJTextField(20);tf5=newJTextField(20);tf6=newJTextField(20);tf6.setText(例:2000-02-02);//文本框加入提示语tf6.addFocusListener(newFocusListener(){publicvoidfocusGained(FocusEvente){tf6.setText();}publicvoidfocusLost(FocusEvente){}});jp.add(label);ct.add(jp,North);jp1.add(newJLabel(姓名,SwingConstants.CENTER));jp2.add(tf1);jp1.add(newJLabel(性别,SwingConstants.CENTER));jp2.add(tf2);jp1.add(newJLabel(学号,SwingConstants.CENTER));jp2.add(tf3);jp1.add(newJLabel(专业,SwingConstants.CENTER));jp2.add(tf4);jp1.add(newJLabel(班级,SwingConstants.CENTER));jp2.add(tf5);jp1.add(newJLabel(入学时间,SwingConstants.CENTER));jp2.add(tf6);jp3.add(btn1);jp3.add(btn2);ct.add(jp1,West);ct.add(jp2,East);ct.add(jp3,South);Toolkitkit=Toolkit.getDefaultToolkit();Dimensionscreen=kit.getScreenSize();intx=screen.width;inty=screen.height;f1.setSize(350,330);intxcenter=(x-350)/2;intycenter=(y-330)/2;f1.setLocation(xcenter,ycenter);f1.setVisible(true);//f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);}publicvoidinsert(){if(tf1.getText().equals()||tf2.getText().equals()||tf3.getText().equals()||tf4.getText().equals()||tf5.getText().equals()||tf6.getText().equals()){JOptionPane.showMessageDialog(f1,请填写完整信息);return;}try{Class.forName(com.mysql.jdbc.Driver);}catch(ClassNotFoundExceptione){System.out.print(加载驱动程序失败);}StringconURL=jdbc:mysql://localhost:3306/sims;try{Connectioncon=DriverManager.getConnection(conURL,root,123456);Statementst=con.createStatement();Strings=insertintostudentinfovalues('+tf1.getText()+','+tf2.getText()+','+tf3.getText()+','+tf4.getText()+','+tf5.getText()+','+tf6.getText()+');;Stringquery=select*fromstudentinfowhereSnumber='+tf3.getText().trim()+';ResultSetres=st.executeQuery(query);if(res.next()){JOptionPane.showMessageDialog(f1,学号信息已经存在!);con.close();tf3.setText();}elseif(tf6.g

1 / 47
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功