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

📄 addemplodialog.java

📁 java+sql2000企业人力管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }


        jPanel1.add(jLabel34);
        jPanel1.add(jLabel33);
        jPanel1.add(jLabel20, null);
        jPanel1.add(jLabel16, null);
        jPanel1.add(txtPosition, null); //工作岗位
        jPanel1.add(txtOfficephone, null); //办公电话
        jPanel1.add(jLabel18, null);
        jPanel1.add(jLabel17);
        jPanel1.add(cboHireDate);
        jPanel1.add(txtStreet, null);
        jPanel1.add(lblName, null);
        jPanel1.add(txtName, null);
        jPanel1.add(txtPolice, null);
        jPanel1.add(jLabel11, null);
        jPanel1.add(jLabel10, null);
        jPanel1.add(jLabel9, null);
        jPanel1.add(jLabel8, null);
        jPanel1.add(jLabel7, null);
        jPanel1.add(txtWordCard, null);
        jPanel1.add(txtIDCard);
        jPanel1.add(jLabel3, null);
        jPanel1.add(jLabel2, null);
        jPanel1.add(jLabel6, null);
        jPanel1.add(jLabel30);
        jPanel1.add(jLabel1);
        jPanel1.add(cboBirthday);
        jPanel1.add(cboMarriage);
        jPanel1.add(txtFamTelephone);
        jPanel1.add(txtFilesOrg);
        jPanel1.add(txtHuKou);
        jPanel1.add(txtPosition, null);
        jPanel1.add(txtWorkingAge, null);
        jPanel1.add(txtBasePrice, null);
        jPanel1.add(txtSalary);
        jPanel1.add(cboContract);
        jPanel1.add(txtMemo, null);
        jPanel1.add(jLabel12, null);
        jPanel1.add(jLabel13, null);
        jPanel1.add(jLabel14, null);
        jPanel1.add(jLabel22, null);
        jPanel1.add(jLabel19);
        jPanel1.add(txtEmp_id);
        jPanel1.add(jLabel23, null);
        jPanel1.add(jLabel21, null);
        jPanel1.add(txtTelephone);
        jPanel1.add(jLabel25);
        jPanel1.add(txtNationality, null);
        jPanel1.add(jLabel26);
        jPanel1.add(cboCulture);
        jPanel1.add(jLabel27, null);
        jPanel1.add(txtPcId, null);
        jPanel1.add(jLabel28, null);
        jPanel1.add(jLabel24);
        jPanel1.add(txtFillinPerson, null);
        jPanel1.add(jLabel29); //所在编号
        jPanel1.add(jLabel35);
        jPanel1.add(txtFillin_Time);
        jPanel1.add(jLabel31, null);
        jPanel1.add(cbodep_id);
        cbodep_id.addItem("1");
        cbodep_id.addItem("2");
        cbodep_id.addItem("3");
        cbodep_id.addItem("4");
        cbodep_id.addItem("5");
        panel1.add(btnOK);
        panel1.add(btnCancel);
        panel1.add(jPanel1);
        cboCulture.addItem("高中");
        cboCulture.addItem("大学本科");
        cboCulture.addItem("博士");
        cboCulture.addItem("硕士");
        cboCulture.addItem("研究生");
        cboCulture.addItem("其他");

    }
//确定提交
    public void btnOK_actionPerformed(ActionEvent e) {
        int WorkingAge = 0;
        double BasePrice = 0;
        double Salary = 0;
        int emp_id = 0;
        String IDCard = " ";
        if (txtEmp_id.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "员工编号不能为空!");
            txtEmp_id.requestFocusInWindow();
            return;
        }
        try {
            emp_id = Integer.parseInt(txtEmp_id.getText()); //员工编号
            if (emp_id < 0) {
                JOptionPane.showMessageDialog(this, "员工编号不能为负数!");
                return;
            }

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "员工编号必须是数字");
            txtEmp_id.requestFocusInWindow();
            return;
        }

        String name = txtName.getText(); //获取姓名
        if (name.equals("")) {
            JOptionPane.showMessageDialog(this, "员工姓名不能为空!", "提示",
                                          JOptionPane.
                                          INFORMATION_MESSAGE);
            txtName.requestFocusInWindow();
            return;
        }
        String Birthday = (String) cboBirthday.getItemAt(cboBirthday.
                getSelectedIndex()); //出生日期
        String Marriage = (String) cboMarriage.getItemAt(cboMarriage.
                getSelectedIndex()); //婚姻状况

        try {
            String idcard = txtIDCard.getText();
            if (idcard.equals("")) {
                IDCard = "";
            } else {
                IDCard = txtIDCard.getText(); //身份证号
                if (IDCard.length() != 18) {
                    JOptionPane.showMessageDialog(this, "身份证应为18位", "提示",
                                                  JOptionPane.
                                                  INFORMATION_MESSAGE);
                    txtIDCard.requestFocusInWindow();
                    return;
                } else if ((IDCard.charAt(17) > 57) &&
                           (IDCard.charAt(17) != 120) &&
                           (IDCard.charAt(17) != 88)) {

                    JOptionPane.showMessageDialog(this,
                                                  "你的身份证含有非法字符!\n如果你身份证最后一位为10请用‘x’代替",
                                                  "提示",
                                                  JOptionPane.
                                                  INFORMATION_MESSAGE);
                    txtIDCard.requestFocusInWindow();
                    return;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        String WordCard = txtWordCard.getText(); //工作证号
        String home = txtFamTelephone.getText(); //家庭电话
        String FilesOrg = txtFilesOrg.getText(); //档案所在地
        String hukou = txtHuKou.getText(); //户口所在地
        String Police = txtPolice.getText(); //户口所在地派出所
        String Street = txtStreet.getText(); //户口所在街道
        String HireDate = (String) cboHireDate.getItemAt(cboHireDate.
                getSelectedIndex()); //本企业工龄起始日
        String Contract = (String) cboContract.getItemAt(cboContract.
                getSelectedIndex()); //签定劳动合同时间

        try {
            String salary = txtSalary.getText();
            if (salary.equals("")) {
                Salary = 0;
            } else {
                Salary = Double.parseDouble(txtSalary.getText()); //基本工资
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(this, "请正确填写基本工资!", "警告",
                                          JOptionPane.WARNING_MESSAGE);
            txtSalary.requestFocusInWindow();
            return;

        }
        String memo = txtMemo.getText(); //备注
        String sex = (String) cboSex.getItemAt(cboSex.getSelectedIndex()); //性别
        String Political = txtPolitical.getText(); //政治面貌
        String Place = txtPlace.getText(); //籍贯
        String Officephone = txtOfficephone.getText(); //办公电话
        String Residence = txtResidence.getText(); //居住地址
        String Position = txtPosition.getText(); //工作岗位
        try {
            String age = txtWorkingAge.getText();
            if (age.equals("")) {
                WorkingAge = 0;
            } else {
                WorkingAge = Integer.parseInt(txtWorkingAge.getText()); //工龄
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(this, "请按格式填写正确工龄!", "警告",
                                          JOptionPane.WARNING_MESSAGE);
            txtWorkingAge.requestFocusInWindow();
            return;
        }
        try {
            String baseprice = txtWorkingAge.getText();
            if (baseprice.equals("")) {
                BasePrice = 0;
            } else {
                BasePrice = Double.parseDouble(txtBasePrice.getText()); //奖金基数
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(this, "请输入正确的奖金基数!", "警告",
                                          JOptionPane.WARNING_MESSAGE);
            txtBasePrice.requestFocusInWindow();
            return;
        }
        int dep_id= Integer.parseInt((String)cbodep_id.getItemAt(cbodep_id.
                getSelectedIndex()));//部门编号
        String State = (String) cboState.getItemAt(cboState.
                getSelectedIndex()); //状态
        String Nationality = txtNationality.getText(); //民族
        String Culture = (String) cboCulture.getItemAt(cboCulture.
                getSelectedIndex()); //文化程度
        String PcId = txtPcId.getText(); //电脑档案号
        String Telephone = txtTelephone.getText(); //移动电话
        String Postcode = txtPostcode.getText(); //邮政编码
        String Title = txtTitle.getText(); //职务
        String FillinPerson = txtFillinPerson.getText(); //填表人
        String Fillin_Time=txtFillin_Time.getText();//填表时间
        // 如果不是更新,创建一个新的员工对象来存放数据,否则使用原来的对象
        if (!isUpdate) {
            objE = new EmployeeBean();
        }

        objE = new EmployeeBean(emp_id, name, sex, Nationality, Birthday,
                                Political, Culture, Marriage, Place,
                                IDCard, PcId, WordCard, Officephone,
                                home, Telephone, FilesOrg, Residence,
                                hukou, Postcode, Police, Street,
                                HireDate, WorkingAge,dep_id, Position, Title,
                                State, Contract, Salary, BasePrice,
                                memo, FillinPerson,Fillin_Time);
        // 调用业务类中的新增员工逻辑
        EmpAction objD = new EmpAction();
        // 如果不是更新,则调用插入方法,否则调用更新方法
        boolean success = false;
        boolean success1 = false;
        if (!isUpdate) {
            success = objD.inserEmployee(objE);
        } else {
            success1 = objD.updateEmployee(objE);
        }
        if (success) {
            JOptionPane.showMessageDialog(this, "添加成功");
            this.dispose();
        } else if (success1) {
            JOptionPane.showMessageDialog(this, "修改成功!");
            this.dispose();
        }

    }

    //取消按纽事件
    public void btnCancel_actionPerformed(ActionEvent e) {
        this.dispose();
    }

//修改员工资料
    public void setUpdate(EmployeeBean objE) {
        isUpdate = true;
        this.objE = objE;
        // 将传入的员工信息显示到对话框中
        txtEmp_id.setText(String.valueOf(objE.getEmp_Id()).trim()); //员工编号
        txtName.setText(objE.getEmp_NAME().trim()); //姓名
        cboBirthday.setSelectedItem(objE.getBirth()); //出生日期
        cboMarriage.setSelectedItem(objE.getMarital_Condition()); //婚姻状况
        txtIDCard.setText(objE.getId_Card().trim()); //身份证
        txtWordCard.setText(objE.getBadgeID().trim()); //工作证号
        txtFamTelephone.setText(objE.getHome_phone().trim()); //家庭电话
        txtFilesOrg.setText(objE.getFiles_Keep_Org().trim());
        txtHuKou.setText(objE.getHukou().trim()); //户口
        txtPolice.setText(objE.getPolice_Post().trim()); //派出所
        txtStreet.setText(objE.getStreet_Office().trim()); //户口所在街道办事处
        cboHireDate.setSelectedItem(objE.getHireDate()); //本企业工龄起始日
        cboContract.setSelectedItem(objE.getContract_Sign_Date()); //签定劳动合同日期
        txtSalary.setText(String.valueOf(objE.getBase_Wage()).trim()); //基本工资
        txtMemo.setText(objE.getMemo().trim()); //备注
        cboSex.setSelectedItem(objE.getSex()); //性别
        txtPolitical.setText(objE.getPolitical_Party().trim()); //政治面貌
        txtPlace.setText(objE.getFamily_Place().trim()); //籍贯
        txtOfficephone.setText(objE.getOffice_phone().trim()); //办公电话
        txtResidence.setText(objE.getResidence().trim()); //居住地址
        txtPosition.setText(objE.getPosition().trim()); //工作岗位
        txtWorkingAge.setText(String.valueOf(objE.getWorking_Years()).trim()); //工龄
        cbodep_id.setSelectedItem(Integer.toString(objE.getDep_Id()));
        txtBasePrice.setText(String.valueOf(objE.getBase_Prize()).trim()); //奖金基数
        cboState.setSelectedItem(String.valueOf(objE.getState())); //状态
        txtNationality.setText(objE.getNationality().trim()); //民族
        cboCulture.setSelectedItem(objE.getCulture_Level().trim()); //文化程度
        txtPcId.setText(objE.getPcID().trim()); //电脑档案号
        txtTelephone.setText(objE.getMobile().trim()); //移动电话
        txtPostcode.setText(objE.getPostcode().trim()); //邮政编码
        txtTitle.setText(objE.getTitle().trim()); //职务
        txtFillinPerson.setText(objE.getFillin_Person().trim()); //添表人
        txtFillin_Time.setText(objE.getFillin_Time().trim());//填表时间
    }


}


class AddEmploDialog_btnCancel_actionAdapter implements ActionListener {
    private AddEmploDialog adaptee;
    AddEmploDialog_btnCancel_actionAdapter(AddEmploDialog adaptee) {
        this.adaptee = adaptee;
    }

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


class AddEmploDialog_btnOK_actionAdapter implements ActionListener {
    private AddEmploDialog adaptee;
    AddEmploDialog_btnOK_actionAdapter(AddEmploDialog adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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