1、java学生信息管理系统设计数据库:CREATE DATABASE 学生成绩管理系统(1)教师信息表创建:create table 教师信息表(教师ID varchar(8) primary key ,教师姓名 varchar(8) not null unique,登录密码 varchar(8) not null,)(2)学籍信息表创建:create table 学籍信息表(学号 varchar(15) primary key,姓名 varchar(8) not null ,年龄 varchar(10),出生日期 varchar(10),性别 varchar(4) ,班级 varchar(8)
2、 not null ,专业 varchar(5) ,民族 varchar(10),登录密码 varchar(6) not null)(3)成绩信息表创建:create table 成绩信息表(学号 varchar(15),计算机网络 varchar(8),计算机专业英语 smallint,计算机信息技术基础 smallint,Java程序设计 smallint ,数据库应用实训教程 smallint ,高等数学 smallint ,Xml smallint ,)概要结构分析: 1.登录界面和主界面import javax.swing.*;import javax.swing.table.Def
3、aultTableModel;import java.awt.*;import java.awt.event.*;import java.sql.*;class myConnectionResultSet re; public myConnection() public ResultSet getResult(String sql) tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver); Connection conn=DriverManager.getConnection(jdbc:odbc:学生成绩管理系统,ww,123); Statement st
4、mt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet re=stmt.executeQuery(sql); return re; catch(Exception e) System.out.println(getResult-+e.toString(); return null; public boolean executeSql(String sql) tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver); Conne
5、ction conn=DriverManager.getConnection(jdbc:odbc:学生成绩管理系统,ww,123); Statement stmt=conn.createStatement(); stmt.executeUpdate(sql); mit(); return true; catch(Exception e) System.out.println(executeSql-+e.toString(); return false; class stuMainFrame extends JFrame implements ActionListenerJMenuBar jmb
6、 = new JMenuBar(); JMenu Message = new JMenu(信息); JMenu Score = new JMenu(查询); JMenuItem Item1 = new JMenuItem(添加学生信息); JMenuItem mName=new JMenuItem(学生成绩查询); JMenuItem mScore=new JMenuItem(按成绩查询); JMenuItem mNam1=new JMenuItem(查询学生信息); JLabel label = new JLabel(); public stuMainFrame()ImageIcon ico
7、n = new ImageIcon(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.ad
8、d(mScore); Item1.addActionListener(this); mName.addActionListener(this); mScore.addActionListener(this); mNam1.addActionListener(this); public void actionPerformed(ActionEvent e) if(e.getSource()=Item1) new addForm().setVisible(true); else if(e.getSource()=mName) dispose(); new Score1().setVisible(t
9、rue); else if(e.getSource()=mScore) new scoreQueryForm().setVisible(true); else if(e.getSource()=mNam1) dispose(); new Serch1().setVisible(true); class mainFrame extends JFrame implements ActionListener JLabel label = new JLabel(); JMenuBar mBar= new JMenuBar(); JPanel p=new JPanel(); private JMenu
10、mSystem,mOperate,mQuery,mHelp,myMenuUser; private JMenuItem mFile,mNew,mOpen,mExit,mAdd,mDel,mModify,mName,miShow,mScore,mAbout,miUser,mAddSc; public mainFrame() this.setJMenuBar(mBar); ImageIcon icon = new ImageIcon(src/images/1.jpg); label.setIcon(icon); label.setBounds(0, 0, icon.getIconWidth(),
11、icon.getIconHeight(); add(label); setSize(label.getWidth(),label.getHeight(); myMenuUser=new JMenu(用户); miUser=new JMenuItem(编辑用户); myMenuUser.add(miUser); mSystem=new JMenu(系统); mOperate=new JMenu(数据操作); mQuery=new JMenu(查询); mHelp=new JMenu(帮助); mBar.add(mSystem); mBar.add(mOperate); mBar.add(mQue
12、ry); mBar.add(mHelp); mBar.add(myMenuUser); mFile=new JMenuItem(文件); mNew=new JMenuItem(新建); mOpen=new JMenuItem(打开); mExit=new JMenuItem(退出); mSystem.add(mFile); mSystem.add(mNew); mSystem.add(mOpen); mSystem.addSeparator(); mSystem.add(mExit); mAdd=new JMenuItem(添加基本信息); mAddSc=new JMenuItem(添加成绩信
13、息); mDel=new JMenuItem(删除); mModify=new JMenuItem(修改); mOperate.add(mAdd); mOperate.add(mAddSc); mOperate.add(mDel); mOperate.add(mModify); mName=new JMenuItem(查询学生信息); mScore=new JMenuItem(查询学生成绩); miShow=new JMenuItem(全部显示); mQuery.add(mName); mQuery.add(mScore); mQuery.addSeparator(); mQuery.add(
14、miShow); mAbout=new JMenuItem(软件信息); 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(
15、this); miUser.addActionListener(this); mAddSc.addActionListener(this); public void actionPerformed(ActionEvent e) if(e.getSource()=mExit) dispose(); new CJ().setVisible(true); else if(e.getSource()=mAbout) JOptionPane.showMessageDialog(this,学生成绩管理系统nn电信学院nn2012年3月,软件信息,JOptionPane.INFORMATION_MESSAG
16、E); else if(e.getSource()=mAdd) dispose(); new addForm().setVisible(true); else if(e.getSource()=mAddSc) dispose(); new addScore().setVisible(true); else if(e.getSource()=mDel) dispose(); new deleteForm().setVisible(true); else if(e.getSource()=mName) dispose(); new Serch().setVisible(true); else if
17、(e.getSource()=mScore) dispose(); new Score().setVisible(true); else if(e.getSource()=mModify) new modifyForm().setVisible(true); else if(e.getSource()=miUser) new userFrame().setVisible(true); else if(e.getSource()=miShow) new freshTable().setVisible(true); class CJ extends JFrame implements Action
18、Listener JLabel t1=new JLabel(ID号:); JLabel t3=new JLabel(密码:); JLabel label = new JLabel(); public String zh=null; JTextField t2=new JTextField(null,15); JTextField t4=new JPasswordField(null,15); JRadioButton b=new JRadioButton(教师); JRadioButton b1=new JRadioButton(学生); JButton jB1=new JButton(登录)
19、; JButton jB2=new JButton(取消); public CJ ()super(学生生成绩管理系统); 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.setBo
20、unds(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); ButtonGroup bg=new ButtonGroup(); b.setSelected(false); b1.setSelected(true); b1.setSelected(false); add(b);bg.add(b);add(b1); bg.add(b1); b.setContentAreaFilled(false); b1.setC
21、ontentAreaFilled(false); ImageIcon icon = new ImageIcon(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); setDefaultCloseOperati
22、on(JFrame.EXIT_ON_CLOSE); jB1.addActionListener(this); jB2.addActionListener(this); public void actionPerformed(ActionEvent e) if (e.getSource()=jB2) System.exit(0); else if (e.getSource()=jB1) String username , password; username = t2.getText(); password = t4.getText(); if(b.isSelected() if (userna
23、me.toString().equals() JOptionPane.showMessageDialog(null, 请输入用户名, 温馨提示, JOptionPane.INFORMATION_MESSAGE); else if (password.toString().equals() JOptionPane.showMessageDialog(null, 请输入密码, 温馨提示, JOptionPane.INFORMATION_MESSAGE); else myConnection conn=new myConnection(); ResultSet rs; String sql=sele
24、ct * 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 学籍信息表; mainFrame mf=new mainFrame(); mf.setLayout(null); mf.setVisible(tr
25、ue); mf.setLocation(300,300); mf.setResizable(false); mf.setTitle(学生成绩管理系统:教师登录界面); mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mf.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); ); JOptionPane.showMessageDialog( null ,rs.getString(教师姓名)+老师!您好!欢迎
26、登录学生成绩管理系统! ) ; else JOptionPane.showMessageDialog(null, 用户名或密码错误, 登录失败, JOptionPane.INFORMATION_MESSAGE); catch(Exception er) System.out.println(er.toString(); if(b1.isSelected() if (username.toString().equals() JOptionPane.showMessageDialog(null, 请输入用户名, 温馨提示, JOptionPane.INFORMATION_MESSAGE); els
27、e if (password.toString().equals() JOptionPane.showMessageDialog(null, 请输入密码, 温馨提示, JOptionPane.INFORMATION_MESSAGE); else myConnection conn=new myConnection(); ResultSet rs; String sql=select * from 学籍信息表 where 学号=+t2.getText().toString()+ and 登录密码 = +t4.getText().toString()+; try rs=conn.getResult
28、(sql); rs.last(); if(rs.getRow()=1) setVisible(false); rs.beforeFirst(); while(rs.next() this.dispose(); sql=select * from 学籍信息表; stuMainFrame smf =new stuMainFrame(); smf.setSize(500,400); smf.setVisible(true); smf.setResizable(false); smf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); smf.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); ); JOptionPane.showMessageDialog( null ,rs.getString(学生姓名)+同学!您好
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1