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

📄 studenttextpanel.java~1~

📁 使用JBuilder基于Oracle数据库的课程作业
💻 JAVA~1~
📖 第 1 页 / 共 2 页
字号:
        jTextField_stu_no.setText("");
        jTextField_stu_no.setText("");
        jFormattedTextField_birthday.setText("");
        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 save() {
        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();
            }





            //dorm_no=((String)jComboBox_Build_no.getSelectedItem()).trim()+((String)jComboBox_apartment_no.getSelectedItem()).trim();



            /*String sex=((String)jComboBox_sex.getSelectedItem()).trim();

            String polity=((String)jComboBox_polity.getSelectedItem()).trim();
            String source=((String)jComboBox_source.getSelectedItem()).trim();*/


            String updatesql="update student set 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="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();
            }





            //dorm_no=((String)jComboBox_Build_no.getSelectedItem()).trim()+((String)jComboBox_apartment_no.getSelectedItem()).trim();



            /*String sex=((String)jComboBox_sex.getSelectedItem()).trim();

            String polity=((String)jComboBox_polity.getSelectedItem()).trim();
            String source=((String)jComboBox_source.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) {
       }
    }

}


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 + -