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

📄 studentinfo.java~44~

📁 S1项目本需求规格说明描述了北大青鸟ACCP教学管理系统项目的要求
💻 JAVA~44~
📖 第 1 页 / 共 2 页
字号:
               this.cmbSex.setSelectedItem(this.jTable1.getValueAt(row, 3).
                                           toString());
               this.txtshenfenzheng.setText(this.jTable1.getValueAt(row, 4).toString());
               this.txtBirthday.setText(this.jTable1.getValueAt(row, 5).toString());
               this.txtAddress.setText(this.jTable1.getValueAt(row, 6).toString());
               this.txtDianhua.setText(this.jTable1.getValueAt(row, 7).toString());
               this.txtSchool.setText(this.jTable1.getValueAt(row, 8).toString());
               this.cmbXueli.setSelectedItem(this.jTable1.getValueAt(row, 9).
                                             toString());
               this.cmbInTerm.setSelectedItem(this.jTable1.getValueAt(row, 10).
                                              toString());
               this.txtInDate.setText(this.jTable1.getValueAt(row, 11).toString());
               this.cmbZhengshu.setSelectedItem(this.jTable1.getValueAt(row, 12).
                                                toString());
               this.cmbStatus.setSelectedItem(this.jTable1.getValueAt(row, 13).
                                              toString());
               this.txaRemark.setText(this.jTable1.getValueAt(row, 14).toString());
           }
    }

    public void btnDel_actionPerformed(ActionEvent e) {
        try {
                   int row = this.jTable1.getSelectedRow();
                   if (JOptionPane.showConfirmDialog(this, "你确定删除吗?", "删除提示",
                                                     JOptionPane.OK_CANCEL_OPTION) ==
                       JOptionPane.OK_OPTION) {
                       if (row < 0) {
                           JOptionPane.showMessageDialog(this, "请选择数据");
                           return;
                       }
                       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                       Connection nod = DriverManager.getConnection(
                               "jdbc:odbc:xiangmu");
                       PreparedStatement sql = nod.prepareStatement(
                               "delete from StudentInfo where StudentNo = ?");
                       sql.setString(1, this.jTable1.getValueAt(row, 1).toString());
                       int i = sql.executeUpdate();
                       if (i > 0) {
                           bg.removeRow(row);
                           JOptionPane.showMessageDialog(this, "删除成功");
                       } else {
                           JOptionPane.showMessageDialog(this, "删除失败");
                       }
                       sql.close();
                       nod.close();
                   }
               } catch (Exception ex) {
                   ex.printStackTrace();

               }
    }
    public void btnshuaxin_actionPerformed(ActionEvent e) {
       this.txtClassNo.setText("");
       this.txtStudentNo.setText("");
       this.txtName.setText("");
       this.cmbSex.setSelectedItem("");
       this.txtBirthday.setText("");
       this.txtAddress.setText("");
       this.txtDianhua.setText("");
       this.txtInDate.setText("");
       this.txaRemark.setText("");
       this.txtSchool.setText("");
       this.txtshenfenzheng.setText("");
       this.cmbXueli.setSelectedItem("");
       this.cmbZhengshu.setSelectedItem("");
       this.cmbInTerm.setSelectedItem("");
       this.cmbStatus.setSelectedItem("");
    }

    public void btnAdd_actionPerformed(ActionEvent e) {
      try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection conn = DriverManager.getConnection("jdbc:odbc:xiangmu");
            PreparedStatement sql = conn.prepareStatement(
                    "insert into StudentInfo (ClassNO,StudentNo,Name,Sex,Shenfenzheng,Birthday,Address,Dianhua,School,xueli,InTerm,Indate,Certificate,Status,Remark) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            //班级
            sql.setString(1,this.txtClassNo.getText());
            //学号
            sql.setString(2, this.txtStudentNo.getText());
            //姓名
            sql.setString(3, this.txtName.getText());
            //性别
            sql.setString(4,this.cmbSex.getSelectedItem().toString());
            //身份证
            sql.setString(5, this.txtshenfenzheng.getText());
            //出生年月
            sql.setString(6,this.txtBirthday.getText());
            //家庭地址
            sql.setString(7, this.txtAddress.getText());
            //联系电话
            sql.setString(8, this.txtDianhua.getText());
            //毕业学校
            sql.setString(9, this.txtSchool.getText());
            //学历
            sql.setString(10, this.cmbXueli.getSelectedItem().toString());
            //年级
            sql.setString(11,this.cmbInTerm.getSelectedItem().toString());
            //入学日期
            sql.setString(12,this.txtInDate.getText());
            //获得证书
            sql.setString(13,this.cmbZhengshu.getSelectedItem().toString());
            //状态
            sql.setString(14,this.cmbStatus.getSelectedItem().toString());
            //备注
            sql.setString(15, this.txaRemark.getText());
            int row = sql.executeUpdate();
            if (row > 0) {
                JOptionPane.showMessageDialog(this, "添加成功!");
            } else {
                JOptionPane.showMessageDialog(this, "添加失败!");
            }
            sql.close();
            conn.close();
      } catch (Exception ex) {
          JOptionPane.showMessageDialog(this, "添加失败!");
      }
    }

    public void btnEdit_actionPerformed(ActionEvent e) {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //加载驱动程序
            Connection conn = DriverManager.getConnection("jdbc:odbc:xiangmu"); //注册驱动并连接数据库
            PreparedStatement ps = conn.prepareStatement(
                    "update StudentInfo set ClassNO=?,StudentNo=?,Name=?,Sex=?,Shenfenzheng=?,Birthday=?,Address=?,Dianhua=?,School=?,xueli=?,InTerm=?,Indate=?,Certificate=?,Status=?,Remark=? where StudentNo=?"); //创建执行语句的对象
            int selRow = jTable1.getSelectedRow();
            ps.setString(1, this.txtClassNo.getText());
            ps.setString(2, this.txtStudentNo.getText());
            ps.setString(3, this.txtName.getText());
            ps.setString(4, this.cmbSex.getSelectedItem().toString());
            ps.setString(5, this.txtshenfenzheng.getText());
            ps.setString(6, this.txtBirthday.getText());
            ps.setString(7, this.txtAddress.getText());
            ps.setString(8, this.txtDianhua.getText());
            ps.setString(9, this.txtSchool.getText());
            ps.setString(10, this.cmbXueli.getSelectedItem().toString());
            ps.setString(11, this.cmbInTerm.getSelectedItem().toString());
            ps.setString(12, this.txtInDate.getText());
            ps.setString(13, this.cmbZhengshu.getSelectedItem().toString());
            ps.setString(14, this.cmbStatus.getSelectedItem().toString());
            ps.setString(15, this.txaRemark.getText());
            ps.setString(16, jTable1.getValueAt(selRow, 1).toString());
            int rows = ps.executeUpdate(); //执行语句,返回受影响行数
            if (rows > 0) {
                jTable1.setValueAt(this.txtClassNo.getText(), selRow, 0);
                jTable1.setValueAt(this.txtStudentNo.getText(),selRow, 1);
                jTable1.setValueAt(this.txtName.getText(),selRow, 2);
                jTable1.setValueAt(this.cmbSex.getSelectedItem().toString(), selRow, 3);
                jTable1.setValueAt(this.txtshenfenzheng.getText(), selRow, 4);
                jTable1.setValueAt(this.txtBirthday.getText(), selRow, 5);
                jTable1.setValueAt(this.txtAddress.getText(), selRow, 6);
                jTable1.setValueAt(this.txtDianhua.getText(), selRow, 7);
                jTable1.setValueAt(this.txtSchool.getText(), selRow, 8);
                jTable1.setValueAt(this.cmbXueli.getSelectedItem().toString(), selRow, 9);
                jTable1.setValueAt(this.cmbInTerm.getSelectedItem().toString(), selRow, 10);
                jTable1.setValueAt(this.txtInDate.getText(), selRow, 11);
                jTable1.setValueAt(this.cmbZhengshu.getSelectedItem().toString(), selRow, 12);
                jTable1.setValueAt(this.cmbStatus.getSelectedItem().toString(), selRow, 13);
                jTable1.setValueAt(this.txaRemark.getText(), selRow, 14);
                JOptionPane.showMessageDialog(this, "修改成功!");
            } else {
                JOptionPane.showMessageDialog(this, "修改失败!");
            }
            ps.close();
            conn.close();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "修改失败!");
                ex.printStackTrace();
        }

    }

    public void txtshenfenzheng_actionPerformed(ActionEvent e) {

    }
}


class StudentInfo_txtshenfenzheng_actionAdapter implements ActionListener {
    private StudentInfo adaptee;
    StudentInfo_txtshenfenzheng_actionAdapter(StudentInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.txtshenfenzheng_actionPerformed(e);
    }
}


class StudentInfo_btnEdit_actionAdapter implements ActionListener {
    private StudentInfo adaptee;
    StudentInfo_btnEdit_actionAdapter(StudentInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnEdit_actionPerformed(e);
    }
}


class StudentInfo_btnAdd_actionAdapter implements ActionListener {
    private StudentInfo adaptee;
    StudentInfo_btnAdd_actionAdapter(StudentInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnAdd_actionPerformed(e);
    }
}


class StudentInfo_btnshuaxin_actionAdapter implements ActionListener {
    private StudentInfo adaptee;
    StudentInfo_btnshuaxin_actionAdapter(StudentInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnshuaxin_actionPerformed(e);
    }
}


class StudentInfo_btnDel_actionAdapter implements ActionListener {
    private StudentInfo adaptee;
    StudentInfo_btnDel_actionAdapter(StudentInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnDel_actionPerformed(e);
    }
}


class StudentInfo_jTable1_mouseAdapter extends MouseAdapter {
    private StudentInfo adaptee;
    StudentInfo_jTable1_mouseAdapter(StudentInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void mouseClicked(MouseEvent e) {
        adaptee.jTable1_mouseClicked(e);
    }
}


class StudentInfo_btnjiansuo_mouseAdapter extends MouseAdapter {
    private StudentInfo adaptee;
    StudentInfo_btnjiansuo_mouseAdapter(StudentInfo adaptee) {
        this.adaptee = adaptee;
    }
}


class StudentInfo_btnjiansuo_actionAdapter implements ActionListener {
    private StudentInfo adaptee;
    StudentInfo_btnjiansuo_actionAdapter(StudentInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnjiansuo_actionPerformed(e);
    }
}


class StudentInfo_btnExit_actionAdapter implements ActionListener {
    private StudentInfo adaptee;
    StudentInfo_btnExit_actionAdapter(StudentInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnExit_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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