⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myjframe.java

📁 是java与sql2000编写的学生学籍管理系统,利用java工具NetBeans5.5.1设计界面
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch (ClassNotFoundException ce) {
            System.out.println(ce);
        } try {
            String url = "jdbc:odbc:XSXJGLXT";
            Connection con = DriverManager.getConnection(url);
            Statement s = con.createStatement();
                   int m=s.executeUpdate("insert into KC3"+
                        " values('"+jTextField3.getText()+"','"+String.valueOf(jPasswordField1.getPassword())+"')");
                if(m==1)
                    JOptionPane.showMessageDialog(null, "注册成功", "提示", JOptionPane.INFORMATION_MESSAGE);
                jTextField3.setText("");
                jPasswordField1.setText("");
                jPasswordField2.setText("");
                 s.close();
            con.close();
                }catch (SQLException ce) {            
            JOptionPane.showMessageDialog(null,"注册失败!\n"+ce, "提示", JOptionPane.INFORMATION_MESSAGE);
                }
                }
     
     }
    }//GEN-LAST:event_B4ActionPerformed

    private void B8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B8ActionPerformed
// 删除
      try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch (ClassNotFoundException ce) {
        System.out.println(ce);
    } try {
      String url = "jdbc:odbc:XSXJGLXT";
      Connection con = DriverManager.getConnection(url);
      Statement s = con.createStatement();
        String xuehao=jTextField1.getText();
        int m= s.executeUpdate("delete from  KC2 where 学号='"+xuehao+"'");
       if(m==1)
        JOptionPane.showMessageDialog(null, "删除成功!", "提示", JOptionPane.INFORMATION_MESSAGE);
      else
          JOptionPane.showMessageDialog(null, "删除失败!数据库中不存在该数据!\n", "提示", JOptionPane.INFORMATION_MESSAGE);
       s.close();
    } catch (SQLException ce) {
        System.out.println(ce);
    } 
    }//GEN-LAST:event_B8ActionPerformed

    private void B7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B7ActionPerformed
// 学生成绩修改
        
       if(jTextField2.getText().equals("")||jTextField6.getText().equals("")||jTextField5.getText().equals("")||jTextField7.getText().equals("")||jTextField8.getText().equals(""))
        JOptionPane.showMessageDialog(null,"输入完整后,再点修改!","错误信息",1);
            else{
               if(jTextField2.getText().length()!=8||jTextField2.getText().charAt(0)!='0'
               ||jTextField2.getText().charAt(1)<'4'||jTextField2.getText().charAt(1)>'7'||jTextField2.getText().charAt(2)!='1'
               ||jTextField2.getText().charAt(3)<'3'||jTextField2.getText().charAt(3)>'5'
               ||jTextField2.getText().charAt(4)!='8')
              JOptionPane.showMessageDialog(null,"学号输入有误,请重新输入!","错误信息",1);        
         else{
          int op=JOptionPane.showConfirmDialog(null,"确定要修改吗","提示",0);
        if(op==0)
        {
              try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch (ClassNotFoundException ce) {
        System.out.println(ce);
    } try {
      String url = "jdbc:odbc:XSXJGLXT";
      Connection con = DriverManager.getConnection(url);
      Statement s = con.createStatement();
      String sno=jTextField2.getText();
      String sname=jTextField5.getText();
      String sdept=jTextField6.getText();
      String kemu= jTextField7.getText(); 
     
      String kaoshichengji=jTextField8.getText();
       int m=s.executeUpdate("update KC2 set 姓名='"+sname+
               "',科目编号='"+sdept+"',科目='"+kemu+"',考试成绩='"+kaoshichengji+ "' where 学号='"+sno+"'");
      if(m==1)  JOptionPane.showMessageDialog(null, "修改成功", "提示", JOptionPane.INFORMATION_MESSAGE);
       else  JOptionPane.showMessageDialog(null, "修改失败", "提示", JOptionPane.INFORMATION_MESSAGE); 
        jTextField2.setText("");
        jTextField5.setText("");
        jTextField6.setText("");
        jTextField7.setText("");
        jTextField8.setText("");
         s.close();
      con.close();
    } catch (SQLException ce) {
        JOptionPane.showMessageDialog(null, "修改失败!/n "+ce, "提示", JOptionPane.INFORMATION_MESSAGE); 
    }
        }
        else
            JB3.setVisible(true);
      }                  
    }
    }//GEN-LAST:event_B7ActionPerformed

    private void B10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B10ActionPerformed
//学生学籍查询
        try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch (ClassNotFoundException ce) {
        System.out.println(ce);
    } try {
      String url = "jdbc:odbc:XSXJGLXT";
      Connection con = DriverManager.getConnection(url);
      Statement s = con.createStatement();
        String xuehao=jTextField1.getText();
      ResultSet rs = s.executeQuery("select * from KC1 where 学号='"+xuehao+"'");
      if(rs.next())
      { 
        jTextArea3.setText("学号:"+rs.getString(1)+"\n");
        jTextField10.setText(rs.getString(2)); 
        jTextField12.setText(rs.getString(3));
        jTextField13.setText(rs.getString(4));
        jTextField11.setText(rs.getString(5));
        jTextField14.setText(rs.getString(6));
        jTextField15.setText(rs.getString(7));
       }   
    } catch (SQLException ce) {
        System.out.println(ce);
    }
                                     
    }//GEN-LAST:event_B10ActionPerformed

    private void B6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B6ActionPerformed
   try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch (ClassNotFoundException ce) {
        System.out.println(ce);
    } try {
      String url = "jdbc:odbc:XSXJGLXT";
      Connection con = DriverManager.getConnection(url);
      Statement s = con.createStatement();
       String xuehao=jTextField1.getText();
      ResultSet rs = s.executeQuery("select * from KC2  where 学号='"+xuehao+"'");
      if(rs.next())
      { 
        jTextArea2.setText("学号:"+rs.getString(1)+"\n");
     
        jTextField5.setText(rs.getString(2));
        jTextField6.setText(rs.getString(3));
        jTextField7.setText(rs.getString(4));
        jTextField8.setText(rs.getString(5));
         }  
      else  JOptionPane.showMessageDialog(null, "不存在该记录", "提示", JOptionPane.INFORMATION_MESSAGE);
      s.close();
      con.close(); 
    } catch (SQLException ce) {
        System.out.println(ce);
    }
    
    }//GEN-LAST:event_B6ActionPerformed

    private void B5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B5ActionPerformed
if(evt.getActionCommand()=="退出")
{ dispose();
  System.exit(0);
}
    }//GEN-LAST:event_B5ActionPerformed

    private void B3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B3ActionPerformed
this.setVisible(false);
        JB2.setVisible(true);
        JB2.setSize(400,300);
    }//GEN-LAST:event_B3ActionPerformed

    private void B2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B2ActionPerformed
if(evt.getActionCommand()=="返回")
{ dispose();
  System.exit(0);
}
    }//GEN-LAST:event_B2ActionPerformed

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MyJFrame().setVisible(true);
            }
        });
    }
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JButton B1;
    private javax.swing.JButton B10;
    private javax.swing.JButton B11;
    private javax.swing.JButton B12;
    private javax.swing.JButton B13;
    private javax.swing.JButton B14;
    private javax.swing.JButton B2;
    private javax.swing.JButton B3;
    private javax.swing.JButton B4;
    private javax.swing.JButton B5;
    private javax.swing.JButton B6;
    private javax.swing.JButton B7;
    private javax.swing.JButton B8;
    private javax.swing.JButton B9;
    private javax.swing.JFrame JB2;
    private javax.swing.JFrame JB3;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JPasswordField jPasswordField2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JTextArea jTextArea3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField12;
    private javax.swing.JTextField jTextField13;
    private javax.swing.JTextField jTextField14;
    private javax.swing.JTextField jTextField15;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;
    private javax.swing.JPasswordField mima;
    private javax.swing.JLabel xuehao;
    private javax.swing.JTextField yonghu;
    // 变量声明结束//GEN-END:variables
    
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -