赞
踩
效果演示:点击此处跳转
之前做了一个外卖点餐系统之后点此查看详情,这段时间在这个系统的基础上改了改帮几位同学实现了其他的几个系统,本文所述的学生课程成绩管理系统就是其中之一。
一、数据库表及字段
1、学生表
2、课程表
3、成绩表
4、管理员表
二、系统运行界面图(部分)
1、登陆界面
2、管理员首界面
3、成绩统计界面
并将统计结果写入外部文件:
4、学生管理界面
管理中心里面的功能基本都差不多,所以就列举上面几个,下面展示主要代码。
三、部分核心代码
1、登录功能
String url = "jdbc:sqlserver://localhost:1433;DatabaseName=student_course_grade"; String username = "sa"; String password = "123"; Connection connection = null; PreparedStatement ps=null; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel2; private javax.swing.JPasswordField jPasswordField1; private javax.swing.JScrollPane jScrollPane1; private JTextField jTextField1; private javax.swing.JToggleButton jToggleButton1; public guanlidenglu() { initComponents(); } private void connectdb() { try { Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" ); connection = DriverManager.getConnection(url, username, password ); } catch ( ClassNotFoundException cnfex ) { System.err.println( "装载 JDBC/ODBC 驱动程序失败。" ); cnfex.printStackTrace(); System.exit( 1 ); } catch ( SQLException sqlex ) { System.err.println( "无法连接数据库" ); sqlex.printStackTrace(); System.exit( 1 ); } } private void initComponents() { jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextField1 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jToggleButton1 = new javax.swing.JToggleButton(); jButton3 = new javax.swing.JButton(); jPasswordField1 = new javax.swing.JPasswordField(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel2.setBackground(new java.awt.Color(120, 150, 190)); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "学生成绩管理系统", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("微软雅黑", 1, 24), new java.awt.Color(255, 255, 255))); // NOI18N jPanel2.setAutoscrolls(true); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel1.setText("账号:"); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel2.setText("密码:"); jTextField1.setColumns(20); jScrollPane1.setViewportView(jTextField1); jButton1.setText("登录"); jButton2.setText("注册"); jToggleButton1.setText("退出"); jToggleButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton1ActionPerformed(evt); } }); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { try { jButton1ActionPerformed(evt); } catch (SQLException e) { e.printStackTrace(); } } }); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText("帮助"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jButton3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton1)) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(162, 162, 162) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(19, 19, 19) .addComponent(jButton1) .addGap(85, 85, 85) .addComponent(jButton2)) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jPasswordField1, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING))) .addContainerGap(171, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(69, 69, 69) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(51, 51, 51) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(36, 36, 36) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(41, 41, 41) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 118, Short.MAX_VALUE) .addComponent(jToggleButton1)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton3) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(113, 113, 113) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(290, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(44, 44, 44) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(441, Short.MAX_VALUE)) ); pack(); } private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) throws SQLException { String Ausername=jTextField1.getText(); String Apassword=jPasswordField1.getText(); connectdb(); String sql="select adminName,adminPassword from admin where adminName='"+Ausername+"' and adminPassword='"+Apassword+"'"; ps=connection.prepareStatement(sql); ResultSet rs=ps.executeQuery(); if(rs.next()) { guanlidenglu.this.setVisible(false); guanli Guanli=new guanli(); Guanli.setVisible(true); } else { JOptionPane.showMessageDialog(null,"密码或用户名错误!!!!"); } connection.close(); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { JOptionPane.showMessageDialog(null,"请联系BOSS申请管理员!!!"); } public static void main(String args[]) {
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。