java项目(学生成绩管理系统)

上传人:学** 文档编号:82845707 上传时间:2022-04-30 格式:DOCX 页数:35 大小:359.46KB
收藏 版权申诉 举报 下载
java项目(学生成绩管理系统)_第1页
第1页 / 共35页
java项目(学生成绩管理系统)_第2页
第2页 / 共35页
java项目(学生成绩管理系统)_第3页
第3页 / 共35页
资源描述:

《java项目(学生成绩管理系统)》由会员分享,可在线阅读,更多相关《java项目(学生成绩管理系统)(35页珍藏版)》请在装配图网上搜索。

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(

2、8) not null ,专业varchar(5) ,民族varchar(10),登录密码varchar(6) not null)(3 )成绩信息表创建:create table成绩信息表 (Word 专业资料.学号varchar(15),计算机网络varchar(8),计算机专业英语smallint,计算机信息技术基础smallint,Java程序设计smallint ,数据库应用实训教程smallint ,高等数学smallint ,Xml smallint ,)概要结构分析:学生成绩管理系统登录界面教师登录学生登录添添修删查查查查添加加改除看看看看加学学学学学学学学学生生生生生生生生生信

3、成信信信成信成信息绩息息息绩息绩息1.登录界面和主界面importjavax.swing.*;importjavax.swing.table.DefaultTableModel;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;class myConnectionResultSet re;publicmyConnection()publicResultSet getResult(String sql)try Class.forName ( sun.jdbc.odbc.JdbcOdbcDriver);Connection conn=

4、DriverManager.getConnection (jdbc:odbc: 学生成绩管理系统,ww , 123);Word 专业资料.Statementstmt=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 bool

5、eanexecuteSql(String sql)try Class.forName);Connection 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 stuMainFrameext

6、ends JFrame implementsActionListenerJMenuBarjmb = new JMenuBar();Message = new JMenu( 信息 );JMenu Score = new JMenu( 查询 );JMenuItemItem1 = new JMenuItem( 添加学生信息);JMenuItemmName = new JMenuItem( 学生成绩查询);JMenuItemmScore= new JMenuItem( 按成绩查询 );JMenuItemmNam1 = new JMenuItem( 查询学生信息);JLabel label = new

7、JLabel();public stuMainFrame()ImageIcon icon =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( It

8、em1 );Score.add( mNam1 );Score.add( mName );Score.add( mScore );Item1 .addActionListener(this );mName .addActionListener(this );mScore .addActionListener(this );mNam1 .addActionListener(this); Word 专业资料.public void actionPerformed(ActionEvent e)if (e.getSource()=Item1 )new addForm().setVisible(true

9、);else if (e.getSource()=mName ) dispose();new Score1().setVisible( true );else if (e.getSource()=mScore )new scoreQueryForm().setVisible(true );else if (e.getSource()=mNam1 )dispose();new Serch1().setVisible( true );class mainFrameextends JFrame implementsActionListenerJLabel label = new JLabel();J

10、MenuBarmBar = new JMenuBar();JPanel p= new JPanel();private JMenu mSystem ,mOperate ,mQuery ,mHelp ,myMenuUser ; private JMenuItemmFile ,mNew ,mOpen ,mExit , mAdd ,mDel ,mModify ,mName ,miShow ,mScore, mAbout ,miUser ,m AddSc;public mainFrame()this .setJMenuBar( mBar );ImageIcon icon =new ImageIcon(

11、 src/images/1.jpg );label .setIcon(icon);label .setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight();add( label );setSize(label .getWidth(),label .getHeight();myMenuUser= new JMenu( 用户 );miUser = new JMenuItem(编辑用户 );myMenuUser .add( miUser );mSystem = new JMenu( 系统 );mOperate = new JMenu( 数据操作

12、 );mQuery = new JMenu( 查询 );mHelp = new JMenu( 帮助 );mBar .add( mSystem );mBar .add( mOperate );mBar .add( mQuery );mBar .add( mHelp );mBar .add( myMenuUser);mFile = new JMenuItem( 文件 );mNew = new JMenuItem( 新建 );mOpen = new JMenuItem(打开 );mExit = new JMenuItem(退出 );mSystem .add( mFile );Word 专业资料.mS

13、ystem .add( mNew );mSystem .add( mOpen );mSystem .addSeparator();mSystem .add( mExit );mAdd = new JMenuItem( 添加基本信息);mAddSc = new JMenuItem(添加成绩信息);mDel = new JMenuItem( 删除 );mModify= new JMenuItem( 修改 );mOperate .add( mAdd );mOperate .add( mAddSc );mOperate .add( mDel );mOperate .add( mModify);mNam

14、e = new JMenuItem(查询学生信息 );mScore = newJMenuItem(查询学生成绩 );miShow = newJMenuItem(全部显示 );mQuery .add( mName );mQuery.add( mScore );mQuery.addSeparator();mQuery.add( miShow );mAbout= newJMenuItem(软件信息 );mHelp .add( mAbout );mExit .addActionListener(this );mAdd .addActionListener(this );mDel .addActionL

15、istener(this );mModify.addActionListener( this );mName .addActionListener(this );mScore .addActionListener(this);mAbout.addActionListener(this );miShow .addActionListener(this );miUser .addActionListener(this);mAddSc .addActionListener(this );public void actionPerformed(ActionEvent e)if (e.getSource

16、()=mExit )dispose();new CJ().setVisible( true );else if (e.getSource()=mAbout)JOptionPane.showMessageDialog (this ,学生成绩管理系统nn 电信学院nn2012 年 3月 ,软件信息 ,JOptionPane. INFORMATION_MESSAGE );else if (e.getSource()=mAdd )dispose();new addForm().setVisible(true );else if (e.getSource()=mAddSc )dispose();new

17、addScore().setVisible(true );Word 专业资料.else if (e.getSource()=mDel )dispose();new deleteForm().setVisible(true );else if (e.getSource()=mName )dispose();new Serch().setVisible( true );else if (e.getSource()=mScore)dispose();new Score().setVisible( true );else if (e.getSource()=mModify)new modifyForm

18、().setVisible(true );else if (e.getSource()=miUser )new userFrame().setVisible(true );else if (e.getSource()=miShow )new freshTable().setVisible(true );class CJ extends JFrame implementsActionListenerJLabel t1= new JLabel( ID 号 :);JLabel t3 = new JLabel( 密码 :);JLabel label = new JLabel();public Stri

19、ng zh= null ;JTextField t2 = new JTextField( null ,15);JTextField t4 = new JPasswordField( null ,15);JRadioButtonb = new JRadioButton(教师 );JRadioButtonb1= newJRadioButton(学生 );JButtonjB1= newJButton( 登录 );JButtonjB2= newJButton( 取消 );public CJ () super (学生生成绩管理系统 );setLayout( null );jB1.setBounds(11

20、0,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);

21、b1.setBounds(120,20,70,30);Word 专业资料.ButtonGroup bg=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);ImageIcon icon =newImageIcon(src/images/a.jpg );label .setI

22、con(icon);label .setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight();add( label );setSize(label .getWidth(),label .getHeight();setResizable( false );setVisible( true );setLocation(300,300);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);jB1.addActionListener(this );jB2 .addActionListener(this )

23、;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 (username.toString().equals()JOptionPane.showMessageDialog ( null , 请输入用户名, 温馨提示, JOptionPane

24、.INFORMATION_MESSAGE );else if (password.toString().equals()JOptionPane.showMessageDialog ( null , 请输入密码 , 温馨提示 ,JOptionPane.INFORMATION_MESSAGE );elsemyConnection conn=new myConnection();ResultSet rs;Stringsql= select * from教师信息表where教师ID= +username.toString()+ and登录密码= +password.toString()+;try rs

25、=conn.getResult(sql);rs.last();if (rs.getRow()=1) setVisible( false);Word 专业资料.rs.beforeFirst();while (rs.next()this.dispose();sql= select * from学籍信息表 ;mainFrame mf=new mainFrame();mf.setLayout( null );mf.setVisible( true );mf.setLocation(300,300);mf.setResizable( false);mf.setTitle( 学生成绩管理系统:教师登录界面

26、);mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);mf.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System. exit (0););JOptionPane.showMessageDialog ( null ,rs.getString( 教师姓名)+ 老师!您好!欢迎登录学生成绩管理系统! ) ;elseJOptionPane.showMessageDialog ( null , 用户名或密码错误, 登录失败 , JOption

27、Pane.INFORMATION_MESSAGE );catch (Exception er)System. out .println(er.toString();if (b1.isSelected() if (username.toString().equals()JOptionPane.showMessageDialog ( null , 请输入用户名, 温馨提示, JOptionPane.INFORMATION_MESSAGE );else if (password.toString().equals()JOptionPane.showMessageDialog ( null , 请输入

28、密码 , 温馨提示 ,JOptionPane.INFORMATION_MESSAGE );elsemyConnection conn=new myConnection();ResultSet rs;Stringsql= select * from学籍信息表where学号= + t2.getText().toString()+ and登录密码= + t4 .getText().toString()+;Word 专业资料.try rs=conn.getResult(sql);rs.last();if (rs.getRow()=1)setVisible( false);rs.beforeFirst(

29、);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)Syst

30、em. exit (0););JOptionPane. showMessageDialog ( null ,rs.getString( 学生姓名 )+ 同学!您好!欢迎登录学生成绩管理系统!);elseJOptionPane.showMessageDialog ( null , 用户名或密码错误, 登录失败 , JOptionPane.INFORMATION_MESSAGE );catch (Exception er)System. out .println(er.toString(); public static void main(String args) try UIManager. s

31、etLookAndFeel (UIManager.getSystemLookAndFeelClassName();catch (Exception e)CJ frame= new CJ();new mainFrame();stuMainFrame stu =new stuMainFrame();Word 专业资料.2.添加学生基本信息importimportWord 专业资料.public class addFormextends JFrame implementsActionListener JLabel label1 = new JLabel( 添加基本信息 ,JLabel. CENTER

32、);JLabel labxuehao = new JLabel( 学号: ,JLabel. CENTER);JLabel labyear = newJLabel( 年龄: ,JLabel. CENTER);JLabel labName = newJLabel( 姓名: ,JLabel.);CENTERJLabel labDate = newJLabel( 出生日期: ,JLabel. CENTER);JLabel labclass= newJLabel( 班级: ,JLabel.);CENTERJLabel labzy = newJLabel( 专业: ,JLabel. CENTER);JLa

33、bel labmz = newJLabel( 民族: ,JLabel. CENTER);JLabel labsex = newJLabel( 性别: ,JLabel.);CENTERJTextFieldtxtName= new JTextField(20);JTextFieldtxtDate = newJTextField(18);JTextFieldtxtXueHao= new JTextField(20);JTextFieldtxtYear = newJTextField(20);JTextFieldtxtClass = newJTextField(20);JTextFieldtxtZY

34、= newJTextField(20);JTextFieldtxtMZ = newJTextField(20);ButtonGroupbgp =newButtonGroup();JRadioButtonman =new JRadioButton( 男 );JRadioButtonwomen=new JRadioButton( 女 );JButtonbtnAdd = newJButton( 添加 );JButtonbtnCancel= newJButton( 返回 );JButton btnReset = new JButton( 重置 );JPanel jpl = new JPanel();/

35、 创建面板对象Connectioncon ;Statement sql;ResultSet rs;addForm()super (添加学生信息 ); this .setResizable( false); this .setSize(550,450); this .setVisible( true );this .setLocation(300,300);this .setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE); this .add( jpl );jpl .setLayout( null );btnAdd .addActionListener(

36、 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);Word 专业资料.jpl .add( label1);labxuehao .setBounds(100,50,70,20);jpl .add( labxuehao

37、);txtXueHao.setBounds(190,50,140,20);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 );jpl .a

38、dd( women );bgp .add( man );bgp .add( women );labyear .setBounds(100,70,20);jpl .add( labyear );txtYear .setBounds(190,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( la

39、bmz );txtMZ .setBounds(190,240,140,20);jpl .add( txtMZ );labclass.setBounds(100,270,70,20);jpl .add( labclass);txtClass.setBounds(190,270,140,20);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

40、);btnAdd .setBounds(200,350,90,20);btnCancel .setBounds(320,350,90,20);jpl .add( btnReset );jpl .add( btnAdd );jpl .add( btnCancel );publicvoid actionPerformed(ActionEvent e)Word 专业资料.if(e.getSource()= btnCancel ) dispose();new mainFrame().setVisible( true );if(e.getSource()=btnAdd )if (txtXueHao.ge

41、tText().toString().equals()JOptionPane. showMessageDialog (null , 请输入学号 , 温馨提示 ,JOptionPane.INFORMATION_MESSAGE );else if (txtName .getText().toString().equals()JOptionPane. showMessageDialog (null , 请输入姓名 , 温馨提示 ,JOptionPane.INFORMATION_MESSAGE );else if (txtYear .getText().toString().equals()JOpti

42、onPane. showMessageDialog (null , 请输入年龄 , 温馨提示 ,JOptionPane.INFORMATION_MESSAGE );else if (txtDate .getText().toString().equals()JOptionPane. showMessageDialog (null , 出生日期 , 温馨提示 ,JOptionPane.INFORMATION_MESSAGE );else if (txtZY .getText().toString().equals()JOptionPane. showMessageDialog (null , 请

43、输入专业 , 温馨提示 ,JOptionPane.INFORMATION_MESSAGE );else if (txtMZ .getText().toString().equals()JOptionPane. showMessageDialog (null , 请输入民族 , 温馨提示 ,JOptionPane.INFORMATION_MESSAGE );else if (txtClass .getText().toString().equals()JOptionPane. showMessageDialog (null , 请输入班级 , 温馨提示 ,JOptionPane.INFORMAT

44、ION_MESSAGE );elseString sex;if (man .isSelected() sex= 男 ; else sex= 女 ; tryClass.forName);catch (ClassNotFoundException ce)JOptionPane.showMessageDialog (null ,ce.getMessage();try Connection con = DriverManager.getConnection (jdbc:odbc:学生成绩管理系统 ,ww ,123);Statement stmt = con.createStatement();int

45、a = stmt.executeUpdate( insert into 学籍信息表 (学号 ,登录密码 ,姓名 , 年龄 , 出生日期 , 性别 , 班级,专业,民族)values( + txtXueHao .getText()+ ,+00000+ ,+ txtName .getText()+ , + txtYear .getText() + ,+ txtDate .getText()+ , +sex+ , + txtClass .getText()+ ,+ txtZY .getText()+ , + txtMZ .getText()+ ) );Word 专业资料.if(a=1)JOption

46、Pane. showMessageDialog (null ,已成功添加 ,温馨提示,JOptionPane.INFORMATION_MESSAGE );elseJOptionPane. showMessageDialog (null ,添加失败 , 温馨提示,JOptionPane.INFORMATION_MESSAGE );stmt.close();catch (SQLException se)JOptionPane.showMessageDialog (null ,se.getMessage();elsetxtClass .setText( );txtZY .setText( );txt

47、MZ .setText( );txtName .setText( );txtDate .setText( );txtXueHao.setText( );txtYear .setText( );txtXueHao.requestFocus();public static void main(String args)addForm amg =new addForm();3.添加学生成绩importWord 专业资料.importpublic class addScore extends JFrame implementsActionListenerstatic addScore ss;JLabel

48、 label = new JLabel(学号: ) , new JLabel(计算机网络:) , new JLabel(Linux 操作系统: ) , new JLabel( 计算机专业英语:) , new JLabel(计算机信息技术基础:) , newJLabel( Java 程序设计: ) , new JLabel( 数据库应用实训教程:) , new JLabel( 高等数学: ) , newJLabel( XML : );JTextFieldtxt = new JTextField() ,new JTextField() ,new JTextField() ,newJTextFiel

49、d() ,new JTextField() , new JTextField() ,new JTextField() , new JTextField() , newJTextField() ;JButton add = new JButton( 添加 );JButton reset = new JButton( 重置 );JButton Cancel = new JButton( 返回 );JPanel jpl = new JPanel();JLabel title = new JLabel( 添加学生成绩 , JLabel. CENTER);Font f = new Font( 黑体 ,

50、Font. BOLD , 16 );int s=100;public addScore()super (添加学生信息);this .setResizable( false);this .setSize(500,600);this .setDefaultCloseOperation(EXIT_ON_CLOSE);this .setVisible( true );this .add( jpl );Cancel .addActionListener(this );add .addActionListener(this );reset.addActionListener(this );jpl .set

51、Layout( null );title .setBounds(150,40,200,20);title .setFont( f);title .setForeground(Color.red);jpl .setBackground(Color.LIGHT_GRAY);jpl .add( title );for (int i = 0 ; i label .length ; i+)label i.setBounds(100,s,140,20);jpl .add( label i);txt i.setBounds(260,s,140,20);jpl .add( txt i);s= s+40;Word 专业资料.add .setBounds(100, s,80,20);reset.setBounds(200,s,80,20);Cancel .setBounds(300,s,80,20);jpl .add( add );jpl .add( reset );jpl .add( Cancel );public void actionPerformed(ActionEvent e)if(e.getSource()= Ca

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!