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

📄 studenttextpanel.java~41~

📁 使用JBuilder基于Oracle数据库的课程作业
💻 JAVA~41~
📖 第 1 页 / 共 2 页
字号:
        jTextField_score.setText("");
        jTextField_address.setText("");
        jComboBox_class.setSelectedItem(null);
        jComboBox_department.setSelectedItem(null);
        jComboBox_Build_no.setSelectedItem(null);
        jComboBox_apartment_no.setSelectedItem(null);
        jComboBox_college.setSelectedItem(null);

    }

    public boolean update() {
        try{
            String class_no;
            if(jComboBox_class.getSelectedItem()==null){
                class_no="0000";
            }else{
                String clname=(String)(jComboBox_class.getSelectedItem());
                ResultSet rs=SQLRunner.getResult("select * from class where clname='"+clname+"'");
                if(!rs.next())System.out.println("can't find clname");
                class_no=rs.getString("class_no").trim();
            }
            String sname=jTextField_name.getText().trim();
            String stu_no=jTextField_stu_no.getText().trim();
            String home_phone=jTextField_home_phone.getText().trim();
            String address=jTextField_address.getText().trim();
            String nation;
            if(jComboBox_nation.getSelectedItem()==null){
                nation="";
            }else{
                nation=((String)jComboBox_nation.getSelectedItem()).trim();
            }String Build_no;
            if(jComboBox_Build_no.getSelectedItem()==null){
                Build_no="";
            }else{
                Build_no=((String)jComboBox_Build_no.getSelectedItem()).trim();
            }String sex;
            if(jComboBox_sex.getSelectedItem()==null){
                sex="";
            }else{
                sex=((String)jComboBox_sex.getSelectedItem()).trim();
            }String polity;
            if(jComboBox_polity.getSelectedItem()==null){
                polity="";
            }else{
                polity=((String)jComboBox_polity.getSelectedItem()).trim();
            }String source;
            if(jComboBox_source.getSelectedItem()==null){
                source="";
            }else{
                source=((String)jComboBox_source.getSelectedItem()).trim();
            }String dorm_no;
            if(jComboBox_Build_no.getSelectedItem()==null||jComboBox_apartment_no.getSelectedItem()==null){
                dorm_no="";
            }else{
                dorm_no=((String)jComboBox_Build_no.getSelectedItem()).trim()+((String)jComboBox_apartment_no.getSelectedItem()).trim();
            }String updatesql="update student set class_no='"+class_no+"',sname='"+sname+"' where stu_no='"+stu_no+"'";
            return SQLRunner.executSql(updatesql);
        }catch(Exception e){
            JOptionPane.showMessageDialog(null,e.toString(),"系统提示",JOptionPane.ERROR_MESSAGE);
            return false;
        }

    }

    public boolean insert() {
        try{
            String class_no;
            if(jComboBox_class.getSelectedItem()==null){
                class_no="";
            }else{
                String clname=(String)(jComboBox_class.getSelectedItem());
                ResultSet rs=SQLRunner.getResult("select * from class where clname='"+clname+"'");
                if(!rs.next())System.out.println("can't find clname");
                class_no=rs.getString("class_no").trim();
            }
            String sname=jTextField_name.getText().trim();
            String stu_no=jTextField_stu_no.getText().trim();
            String home_phone=jTextField_home_phone.getText().trim();
            String address=jTextField_address.getText().trim();
            String nation;
            if(jComboBox_nation.getSelectedItem()==null){
                nation="";
            }else{
                nation=((String)jComboBox_nation.getSelectedItem()).trim();
            }String Build_no;
            if(jComboBox_Build_no.getSelectedItem()==null){
                Build_no="";
            }else{
                Build_no=((String)jComboBox_Build_no.getSelectedItem()).trim();
            }String sex;
            if(jComboBox_sex.getSelectedItem()==null){
                sex="";
            }else{
                sex=((String)jComboBox_sex.getSelectedItem()).trim();
            }String polity;
            if(jComboBox_polity.getSelectedItem()==null){
                polity="";
            }else{
                polity=((String)jComboBox_polity.getSelectedItem()).trim();
            }String source;
            if(jComboBox_source.getSelectedItem()==null){
                source="";
            }else{
                source=((String)jComboBox_source.getSelectedItem()).trim();
            }String dorm_no;
            if(jComboBox_Build_no.getSelectedItem()==null||jComboBox_apartment_no.getSelectedItem()==null){
                dorm_no="";
            }else{
                dorm_no=((String)jComboBox_Build_no.getSelectedItem()).trim()+((String)jComboBox_apartment_no.getSelectedItem()).trim();
            }String insertsql="insert into student(stu_no,sname,nation,sex,polity,dorm_no,class_no) values('"+stu_no+"','"+sname+"','"+nation+"','"+sex+"','"+polity+"','"+dorm_no+"','"+class_no+"')";
            return SQLRunner.executSql(insertsql);
        }catch(Exception e){
            JOptionPane.showMessageDialog(null,e.toString(),"系统提示",JOptionPane.ERROR_MESSAGE);
            return false;
        }

    }

    public void jComboBox_college_actionPerformed(ActionEvent e) {
        try {
            addItemFromDpt(jComboBox_department, jComboBox_college);
            addItemFromCls(jComboBox_class,jComboBox_department);
        } catch (SQLException ex) {
        }
    }

    public void jComboBox_department_actionPerformed(ActionEvent e) {
        try {
           addItemFromCls(jComboBox_class,jComboBox_department);
       } catch (SQLException ex) {
       }
    }

    public void jComboBox_Build_no_actionPerformed(ActionEvent e) {
        try {
           addItemFromRom(jComboBox_apartment_no,jComboBox_Build_no);
       } catch (SQLException ex) {
       }
    }

    public boolean delete() {
        String stu_no=jTextField_stu_no.getText().trim();
        return SQLRunner.executSql("delete from student where stu_no='"+stu_no+"'");
    }

    public void setAllNew(String limit){
        try {
            //if(sql==null)return;

            //if(!resultSet.next())return;
            addItemFromDic(jComboBox_sex,"sex");
            addItemFromDic(jComboBox_source,"source");
            addItemFromDic(jComboBox_polity,"polity");
            addItemFromDic(jComboBox_nation,"nation");
            jComboBox_sex.setSelectedItem(null);
            jComboBox_source.setSelectedItem(null);
            jComboBox_polity.setSelectedItem(null);
            jComboBox_nation.setSelectedItem(null);
            jTextField_home_phone.setText("");
            jTextField_name.setText("");
            jTextField_name.setText("");
            jTextField_stu_no.setText("");
            jTextField_stu_no.setText("");
            jFormattedTextField_birthday.setText("");
            jTextField_score.setText("");
            jTextField_address.setText("");
            resultSet=SQLRunner.getResult("select * from studentinfo where class_no='"+limit+"'");
            if(!resultSet.next())return;
            //resultSet=SQLRunner.getResult("select * from studentinfo where class_no='"+limit+"'");
            //addItem(jComboBox_college,"select * from college","coname");
            //jComboBox_college.
            jComboBox_college.addItem(resultSet.getString("coname"));
            jComboBox_college.setSelectedItem(resultSet.getString("coname"));
            jComboBox_college.setEnabled(false);
            //addItemFromDpt(jComboBox_department,jComboBox_college);
            jComboBox_department.addItem(resultSet.getString("dpname"));
            jComboBox_department.setSelectedItem(resultSet.getString("dpname"));
            jComboBox_department.setEnabled(false);
            //addItemFromCls(jComboBox_class,jComboBox_department);
            jComboBox_class.addItem(resultSet.getString("clname"));
            jComboBox_class.setSelectedItem(resultSet.getString("clname"));
            jComboBox_class.setEnabled(false);
            addItemFromBld(jComboBox_Build_no);
            jComboBox_Build_no.setSelectedItem(null);
            //jComboBox_Build_no.addItem(resultSet.getString("Build_no"));
            //addItemFromBld(jComboBox_Build_no);
            //jComboBox_Build_no.setSelectedItem(resultSet.getString("Build_no"));
            addItemFromRom(jComboBox_apartment_no,jComboBox_Build_no);
            //jComboBox_apartment_no.addItem(resultSet.getString("apartment_no"));
            jComboBox_apartment_no.setSelectedItem(null);
            //jTextField_home_phone.setText(resultSet.getString("home_phone"));
            //jTextField_stu_no.setText(resultSet.getString("stu_no"));
            //jTextField_name.setText(resultSet.getString("sname"));
            //jFormattedTextField_birthday.setText(resultSet.getString("birthday"));
            //jTextField_score.setText(resultSet.getString("score"));
            //jTextField_address.setText(resultSet.getString("address"));
        } catch (SQLException ex) {
            System.out.print(ex.toString());
        }

    }

    /*public String createSQL(String keyvlue) {
        return "select * from student where stu_no='"+keyvlue+"'";
    }*/

}


class StudentTextPanel_jComboBox_Build_no_actionAdapter implements
        ActionListener {
    private StudentTextPanel adaptee;
    StudentTextPanel_jComboBox_Build_no_actionAdapter(StudentTextPanel adaptee) {
        this.adaptee = adaptee;
    }

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


class StudentTextPanel_jComboBox_department_actionAdapter implements
        ActionListener {
    private StudentTextPanel adaptee;
    StudentTextPanel_jComboBox_department_actionAdapter(StudentTextPanel
            adaptee) {
        this.adaptee = adaptee;
    }

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


class StudentTextPanel_jComboBox_college_actionAdapter implements
        ActionListener {
    private StudentTextPanel adaptee;
    StudentTextPanel_jComboBox_college_actionAdapter(StudentTextPanel adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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