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

📄 remarkupdate.java~10~

📁 java语言做的教务管理系统
💻 JAVA~10~
📖 第 1 页 / 共 2 页
字号:
            if (!this.txtresultclassno.getText().equals("")) {
                daima += " and classmastername ='" +
                        this.txtresultclassno.getText() + "'";
            }
            if (!this.txtlessonteacher.getText().equals("")) {
                daima += " and classcategory ='" +
                        this.txtlessonteacher.getText() + "'";
            }
            if (!this.txtexaminationnumber.getText().equals("")) {
                daima += " and beginstime = '" +
                        this.txtexaminationnumber.getText() + "'";
            }
            if (!this.txtresult.getText().equals("")) {
                daima += " and beginstime = '" + this.txtresult.getText() + "'";
            }
            if (!this.cboexaminationdateyear.getSelectedItem().toString().
                equals("")) {
                daima += " and examinationdate like '%" +
                        this.cboexaminationdateyear.getSelectedItem().toString() +
                        "%' ";
            }
            if (!this.cboexaminationdatemonth.getSelectedItem().toString().
                equals("")) {
                daima += " and examinationdate like '%" +
                        this.cboexaminationdatemonth.getSelectedItem().toString() +
                        "%'";
            }
            if (!this.cboexaminationdatedate.getSelectedItem().toString().
                equals("")) {
                daima += " and examinationdate like '%" +
                        this.cboexaminationdatedate.getSelectedItem().toString() +
                        "%'";
            }

            PreparedStatement sql = nod.prepareStatement(daima);
            ResultSet i = sql.executeQuery();
            mod.setNumRows(0);
            while (i.next()) {
                Object j[] = {i.getString(1), i.getString(2), i.getString(3),
                             i.getString(4), i.getString(5), i.getString(6),
                             i.getString(7)};
                mod.addRow(j);
            }
            tbremark.updateUI();
            i.close();
            sql.close();
            nod.close();
        } catch (Exception ex) {
        }
    }

    public void btnupdate_actionPerformed(ActionEvent e) {
        try {
            if (this.txtresultstuno.getText().equals("")) {
                JOptionPane.showMessageDialog(this, "请输入学号");
                return;
            }
            if (this.txtresultclassno.getText().equals("")) {
                JOptionPane.showMessageDialog(this, "请输入课程名称");
                return;
            }
            if (timename.equals("")) {
                JOptionPane.showMessageDialog(this, "请输入考试时间");
                return;
            }
            if (this.txtexaminationnumber.getText().equals("")) {
                JOptionPane.showMessageDialog(this, "请考试次数");
                return;
            }
            if (this.txtresult.getText().equals("")) {
                JOptionPane.showMessageDialog(this, "请输入成绩");
                return;
            }
            //开学时间(年,月,日)
            String examinationdateyear = this.cboexaminationdateyear.
                                         getSelectedItem().
                                         toString();
            String examinationdatemonth = this.cboexaminationdatemonth.
                                          getSelectedItem().
                                          toString();
            String examinationdatedate = this.cboexaminationdatedate.
                                         getSelectedItem().
                                         toString();
            String timename =
                    this.cboexaminationdateyear.getSelectedItem().toString() +
                    "-" +
                    this.cboexaminationdatemonth.getSelectedItem().toString() +
                    "-" +
                    this.cboexaminationdatedate.getSelectedItem().toString() +
                    " ";
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection nod = DriverManager.getConnection("jdbc:odbc:studer");
            PreparedStatement sql = nod.prepareStatement(
                    "update result set resultstuno=?,resultclassno=?,lessonteacher=?,examinationdate=?,examinationnumber=?,result=?,resultremarks=? where resultstuno ='" +
                    this.txtresultstuno.getText() + "'");
            sql.setString(1, this.txtresultstuno.getText());
            sql.setString(2, this.txtresultclassno.getText());
            sql.setString(3, this.txtlessonteacher.getText());
            sql.setString(4, timename);
            sql.setString(5, this.txtexaminationnumber.getText());
            sql.setString(6, this.txtresult.getText());
            sql.setString(7, this.txaresultremarks.getText());
            int i = sql.executeUpdate();
            int row = tbremark.getSelectedRow();
            if (i > 0) {
                tbremark.setValueAt(this.txtresultclassno.getText(), row, 1);
                tbremark.setValueAt(this.txtlessonteacher.getText(), row, 2);
                tbremark.setValueAt(timename, row, 3);
                tbremark.setValueAt(this.txtexaminationnumber.getText(), row, 4);
                tbremark.setValueAt(this.txtresult.getText(), row, 5);
                tbremark.setValueAt(this.txaresultremarks.getText(), row, 6);
                JOptionPane.showMessageDialog(this, "修改成功");
            } else {
                JOptionPane.showMessageDialog(this, "修改失败");
            }
            sql.close();
            nod.close();
        } catch (Exception ex) {
        }
    }

    public void tbremark_mouseClicked(MouseEvent e) {
        int row = this.tbremark.getSelectedRow();
        if (row > -1) {
            this.txtresultstuno.setText(this.tbremark.getValueAt(row, 0).
                                        toString());
            this.txtresultclassno.setText(this.tbremark.getValueAt(row, 1).
                                          toString());
            this.txtlessonteacher.setText(this.tbremark.getValueAt(row, 2).
                                          toString());
            String examinationdate = this.tbremark.getValueAt(row, 3).toString();
            this.cboexaminationdateyear.setSelectedItem(examinationdate.
                    substring(0, 4));
            this.cboexaminationdatemonth.setSelectedItem(examinationdate.
                    substring(5, 7));
            this.cboexaminationdatedate.setSelectedItem(examinationdate.
                    substring(8, 10));
            this.txtexaminationnumber.setText(this.tbremark.getValueAt(row, 4).
                                              toString());
            this.txtresult.setText(this.tbremark.getValueAt(row, 5).toString());
            this.txaresultremarks.setText(this.tbremark.getValueAt(row, 6).
                                          toString());
        }
    }
}


class remarkupdate_tbremark_mouseAdapter extends MouseAdapter {
    private remarkupdate adaptee;
    remarkupdate_tbremark_mouseAdapter(remarkupdate adaptee) {
        this.adaptee = adaptee;
    }

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


class remarkupdate_btnupdate_actionAdapter implements ActionListener {
    private remarkupdate adaptee;
    remarkupdate_btnupdate_actionAdapter(remarkupdate adaptee) {
        this.adaptee = adaptee;
    }

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


class remarkupdate_btnselect_actionAdapter implements ActionListener {
    private remarkupdate adaptee;
    remarkupdate_btnselect_actionAdapter(remarkupdate adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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