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

📄 stuselect.java~22~

📁 java语言做的教务管理系统
💻 JAVA~22~
📖 第 1 页 / 共 2 页
字号:
                               "08",
                               "09",
                               "10", "11", "12", "13", "14", "15", "16", "17",
                               "18", "19", "20", "21", "22", "23", "24", "25",
                               "26", "27", "28", "29", "30", "31"};
    //状态
    String stuappearance[] = {"", "在读", "休学", "退学", "转班"};
    //学历
    String stubackground[] = {"", "初中", "高中", "大专", "本科", "研究生", "博士"};
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JComboBox cbostubirthdaymonth = new JComboBox(stubirthdaymonth);
    JLabel jLabel4 = new JLabel();
    JComboBox cbostubirthdaydate = new JComboBox(stubirthdaydate);
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JTextField txtstuno = new JTextField();
    JTextField txtstuname = new JTextField();
    JLabel jLabel7 = new JLabel();
    JTextField txtstuphoto = new JTextField();
    JLabel jLabel8 = new JLabel();
    JTextField txtstuidcard = new JTextField();
    JLabel jLabel9 = new JLabel();
    String head[] = {"学号", "姓名", "性别", "班级编号", "身份证", "出生日期", "家庭地址", "联系电话",
                    "毕业学校", "最高学历", "状态", "备注"};
    DefaultTableModel mod = new DefaultTableModel(head, 0);
    JTable tbstu = new JTable(mod);
    JComboBox cbostubirthdayyear = new JComboBox(stubirthdayyear);
    JLabel jLabel10 = new JLabel();
    JLabel jLabel11 = new JLabel();
    JTextArea txasturemarks = new JTextArea();
    JTextField txtstuschool = new JTextField();
    JComboBox cbostubackground = new JComboBox(stubackground);
    JComboBox cbostusex = new JComboBox(stusex);
    JTextField txtstuaddress = new JTextField();
    JLabel jLabel12 = new JLabel();
    JLabel jLabel13 = new JLabel();
    JComboBox cbostuappearance = new JComboBox(stuappearance);
    JLabel jLabel14 = new JLabel();
    JLabel jLabel15 = new JLabel();
    JButton btnstuselect = new JButton();
    JTableHeader jTableHeader1 = tbstu.getTableHeader();
    JButton btnexit = new JButton();
    //状态
    String stuappearancename = this.cbostuappearance.getSelectedItem().
                               toString();

    //性别
    String stusexname = this.cbostusex.getSelectedItem().toString();

    //出生日期
    String stubirthdaytime =
            this.cbostubirthdayyear.getSelectedItem().toString() + "-" +
            this.cbostubirthdaymonth.getSelectedItem().toString() + "-" +
            this.cbostubirthdaydate.getSelectedItem().toString() + " ";

    JLabel jLabel16 = new JLabel();
    JComboBox cboclassno = new JComboBox();
    public void btnstuselect_actionPerformed(ActionEvent e) {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection nod = DriverManager.getConnection("jdbc:odbc:studer");
            String daima =
                    "select stuno,stuname,stusex,stuclassno,stuidcard,stubirthday,stuaddress,stuphoto,stuschool,stubackground,stuappearance,sturemarks from stu where 1=1";
            if (!this.txtstuno.getText().equals("")) {
                daima += " and stuno = '" + this.txtstuno.getText() + "'";
            }
            if (!this.txtstuname.getText().equals("")) {
                daima += " and stuname ='" +
                        this.txtstuname.getText() + "'";
            }
            if (!stusexname.equals("")) {
                daima += " and stusex ='" + stusexname + "'";
            }
            if (!this.txtstuidcard.getText().equals("")) {
                daima += " and stuidcard ='" + this.txtstuidcard.getText() +
                        "'";
            }if(!this.cboclassno.getSelectedItem().toString().equals("")){
                daima+=" and stuclassno = '"+this.cboclassno.getSelectedItem().toString()+"'";
            }if(!this.cbostubirthdayyear.getSelectedItem().toString().equals("")){
                daima+=" and stubirthday like '%"+this.cbostubirthdayyear.getSelectedItem().toString()+"%'";
            }if(!this.cbostubirthdaymonth.getSelectedItem().toString().equals("")){
                daima+= " and stubirthday like '%"+this.cbostubirthdaymonth.getSelectedItem().toString()+"%'";
            }if(!this.cbostubirthdaydate.getSelectedItem().toString().equals("")){
                daima+=" and stubirthday like '%"+this.cbostubirthdaydate.getSelectedItem().toString()+"%'";
            }if(!this.txtstuaddress.getText().equals("")){
                daima+=" and stuaddress like '%"+this.txtstuaddress.getText()+"%'";
            }if(!this.txtstuphoto.getText().equals("")){
                daima+=" and stuphoto like '%"+this.txtstuphoto.getText()+"%'";
            }if(!this.txtstuschool.getText().equals("")){
                daima+=" and stuschool like '%"+this.txtstuschool.getText()+"%'";
            }if(!this.cbostubackground.getSelectedItem().toString()){
                daima+=" and stubackground ='"+this.cbostubackground.getSelectedItem().toString()+"'";
            }
            /*
             if (!this.txtstuaddress.getText().equals("")) {
             daima += " and stuaddress like '%" + this.txtstuaddress.getText() +
                        "%'";
                                 }
                                 if (!this.txtstuphoto.getText().equals("")) {
             daima += " and stuphoto = '" + this.txtstuphoto.getText() + "'";
                                 }
                                 if (!this.txtstuschool.getText().equals("")) {
                daima += " and stuschool = '" + this.txtstuschool.getText() +
                        "'";
                                 }

             if (!this.txtstubackground.getText().equals("")) {
                daima += " and stubackground = '" +
                        this.txtstubackground.getText() + "'";
                                 }
                                 if (!stuappearancename.equals("")) {
                daima += " and stuappearance = '" + stuappearancename + "'";
                                 }
             if (!this.txasturemarks.getText().equals("")) {
             daima += " and sturemarks like '%" + this.txasturemarks.getText() +
                        "%'";
                                 }
            */
            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), i.getString(8), i.getString(9),
                             i.getString(10), i.getString(11), i.getString(12)};
                mod.addRow(j);
            }
            tbstu.updateUI();
            i.close();
            sql.close();
            nod.close();
        } catch (Exception ex) {

        }
    }

    public void tbstu_mouseClicked(MouseEvent e) {
        int row = this.tbstu.getSelectedRow();
        if (row > -1) {
            this.txtstuno.setText(this.tbstu.getValueAt(row, 0).toString());
            this.txtstuname.setText(this.tbstu.getValueAt(row, 1).toString());
            this.cbostusex.setSelectedItem(this.tbstu.getValueAt(row, 2).
                                           toString());
            this.cboclassno.setSelectedItem(this.tbstu.getValueAt(row, 3).
                                            toString());
            this.txtstuidcard.setText(this.tbstu.getValueAt(row, 4).toString());

            String stubirthday = this.tbstu.getValueAt(row, 5).toString();
            this.cbostubirthdayyear.setSelectedItem(stubirthday.substring(0, 4));
            this.cbostubirthdaymonth.setSelectedItem(stubirthday.substring(5, 7));
            this.cbostubirthdaydate.setSelectedItem(stubirthday.substring(8, 10));

            this.txtstuaddress.setText(this.tbstu.getValueAt(row, 6).toString());
            this.txtstuphoto.setText(this.tbstu.getValueAt(row, 7).toString());
            this.txtstuschool.setText(this.tbstu.getValueAt(row, 8).toString());
            this.cbostubackground.setSelectedItem(this.tbstu.getValueAt(row, 9).
                                                  toString());
            this.cbostuappearance.setSelectedItem(this.tbstu.getValueAt(row, 10).
                                                  toString());
            this.txasturemarks.setText(this.tbstu.getValueAt(row, 11).toString());
        }
    }
}


class stuselect_tbstu_mouseAdapter extends MouseAdapter {
    private stuselect adaptee;
    stuselect_tbstu_mouseAdapter(stuselect adaptee) {
        this.adaptee = adaptee;
    }

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


class stuselect_btnstuselect_actionAdapter implements ActionListener {
    private stuselect adaptee;
    stuselect_btnstuselect_actionAdapter(stuselect adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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