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

📄 personalinforupdatepanel.java

📁 本员工管理系统使公司员工能通过网络来查询信息、请假
💻 JAVA
字号:
package employeemanagersystem;

import java.awt.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class PersonalInforUpdatePanel
    extends JPanel
{
  //自定义的域变量
  SQLClass mySQL = new SQLClass();
  VectorVariable myVector = new VectorVariable();
  EmployeeDetailInformation detailInfor = new EmployeeDetailInformation();
  LoginInformation li = new LoginInformation();
  String logEmpId = "";
  JLabel nameLabel = new JLabel();
  JLabel depLabel = new JLabel();
  JLabel jobLabel = new JLabel();
  JLabel degreeLabel = new JLabel();
  JLabel isMarryLabel = new JLabel();
  JLabel telLabel = new JLabel();
  JLabel addressLabel = new JLabel();
  JLabel birthLabel = new JLabel();
  JLabel exhibitionLabel = new JLabel();
  JLabel idCardLabel = new JLabel();
  JLabel beginTimeLabel = new JLabel();
  JLabel timeLabel = new JLabel();
  JButton updateButton = new JButton();
  JTextField nameTextField = new JTextField();
  JComboBox depComboBox = new JComboBox();
  JComboBox jobComboBox = new JComboBox();
  JComboBox degreeComboBox = new JComboBox();
  JRadioButton marryRadioButton = new JRadioButton();
  JRadioButton notMarryRadioButton = new JRadioButton();
  JComboBox yearComboBox = new JComboBox();
  JComboBox monthComboBox = new JComboBox();
  JComboBox dayComboBox = new JComboBox();
  JTextField addressTextField = new JTextField();
  JTextField idCardTextField = new JTextField();
  JTextField beginTimeTextField = new JTextField();
  JTextField timeTextField = new JTextField();
  JTextField telTextField = new JTextField();
  JLabel yearLabel = new JLabel();
  JLabel monthLabel = new JLabel();
  JLabel dayLabel = new JLabel();
  ButtonGroup isMarryButtonGroup = new ButtonGroup();
  ButtonGroup exhibitionButtonGroup = new ButtonGroup();
  ButtonGroup exhibitionButtonGroup1 = new ButtonGroup();
  ButtonGroup isContinueButtonGroup = new ButtonGroup();
  JPasswordField PasswordField = new JPasswordField();
  JLabel passwordLabel = new JLabel();
  JTextField depIdValueTextField = new JTextField();
  JTextField jobValueTextField = new JTextField();
  JTextField degreeValueTextField = new JTextField();
  JTextField birthValueTextField = new JTextField();
  JTextField isMarryValueTextField1 = new JTextField();
  JTextField exhibitionValueTextField = new JTextField();
  JButton editButton = new JButton();

  public PersonalInforUpdatePanel()
  {
    try
    {
      jbInit();
    }
    catch (Exception exception)
    {
      exception.printStackTrace();
    }
  }

  private void jbInit()
      throws Exception
  {
    this.setLayout(null);
    logEmpId = li.getLogId();
    mySQL.selectDetailInformation(logEmpId, detailInfor);
    nameLabel.setText("姓名:");
    nameLabel.setBounds(new Rectangle(40, 20, 70, 22));
    depLabel.setText("部门:");
    depLabel.setBounds(new Rectangle(40, 80, 69, 24));
    jobLabel.setText("工种:");
    jobLabel.setBounds(new Rectangle(40, 140, 78, 24));
    degreeLabel.setText("学历:");
    degreeLabel.setBounds(new Rectangle(40, 200, 78, 21));
    isMarryLabel.setText("婚否:");
    isMarryLabel.setBounds(new Rectangle(40, 260, 77, 18));
    birthLabel.setText("出生年月:");
    birthLabel.setBounds(new Rectangle(40, 320, 60, 17));
    addressLabel.setText("地址:");
    addressLabel.setBounds(new Rectangle(40, 440, 59, 18));
    telLabel.setText("联系电话:");
    telLabel.setBounds(new Rectangle(40, 500, 60, 17));

    idCardLabel.setText("身份证号:");
    idCardLabel.setBounds(new Rectangle(500, 20, 70, 19));
    beginTimeLabel.setText("合同开始时间:");
    beginTimeLabel.setBounds(new Rectangle(500, 110, 90, 23));
    timeLabel.setText("合同期限:");
    timeLabel.setBounds(new Rectangle(500, 200, 74, 22));
    exhibitionLabel.setText("工作表现:(新员工默认为一般)");
    exhibitionLabel.setBounds(new Rectangle(500, 290, 182, 23));
    passwordLabel.setText("系统登录密码:");
    passwordLabel.setBounds(new Rectangle(500, 380, 81, 20));

    updateButton.setBounds(new Rectangle(450, 550, 112, 25));
    updateButton.setText("更新个人信息");
    updateButton.addActionListener(new
                                   PersonalInforUpdatePanel_updateButton_actionAdapter(this));

    nameTextField.setBounds(new Rectangle(150, 20, 95, 21));
    nameTextField.setText(detailInfor.name);
    depIdValueTextField.setBounds(new Rectangle(150, 80, 96, 23));
    depIdValueTextField.setText(detailInfor.depName);
    depComboBox.setEnabled(false);
    depComboBox.setBounds(new Rectangle(260, 80, 98, 23));
    this.initDepComboBox();
    depComboBox.setSelectedItem(detailInfor.depName);
    jobValueTextField.setBounds(new Rectangle(150, 140, 92, 22));
    jobValueTextField.setText(detailInfor.jobName);
    jobComboBox.setEnabled(false);
    jobComboBox.setBounds(new Rectangle(260, 140, 99, 25));
    this.initJobComboBox();
    jobComboBox.setSelectedItem(detailInfor.jobName);

    degreeValueTextField.setBounds(new Rectangle(150, 200, 95, 23));
    degreeValueTextField.setText(detailInfor.degree);
    degreeComboBox.setEnabled(false);
    degreeComboBox.setBounds(new Rectangle(260, 200, 100, 27));
    for (int i = 0; i < myVector.degreeValues.length; i++)
    {
      degreeComboBox.addItem(myVector.degreeValues[i]);
    }
    degreeComboBox.setSelectedItem(detailInfor.degree);

    isMarryValueTextField1.setBounds(new Rectangle(150, 260, 94, 27));
    if (detailInfor.isMarry == 0)
    {
      isMarryValueTextField1.setText("未婚");
    }
    else
    {
      isMarryValueTextField1.setText("已婚");
    }
    if(detailInfor.isMarry==1)
    {
      marryRadioButton.setSelected(true);
    }
    else
      notMarryRadioButton.setSelected(true);
    marryRadioButton.setBackground(SystemColor.control);
    marryRadioButton.setEnabled(false);
    marryRadioButton.setText("是");
    marryRadioButton.setBounds(new Rectangle(260, 260, 47, 23));

    notMarryRadioButton.setEnabled(false);
    notMarryRadioButton.setText("否");
    notMarryRadioButton.setBounds(new Rectangle(300, 260, 48, 23));

    birthValueTextField.setBounds(new Rectangle(150, 320, 187, 23));
    birthValueTextField.setText(detailInfor.birth);
    int year=Integer.parseInt(detailInfor.birth.substring(0,detailInfor.birth.indexOf('-')).toString().trim());
    //System.out.println(year);
    //System.out.println(year-1900);
    int month=Integer.parseInt(detailInfor.birth.substring(detailInfor.birth.indexOf('-')+1,detailInfor.birth.lastIndexOf('-')).toString().trim());
    //System.out.println(month);
    //System.out.println(month-1);
    int day=Integer.parseInt(detailInfor.birth.substring(detailInfor.birth.lastIndexOf('-')+1,detailInfor.birth.lastIndexOf('-')+3).toString().trim());
    //System.out.println(day);
    //System.out.println(day-1);
    yearComboBox.setEnabled(false);
    monthComboBox.setEnabled(false);
    dayComboBox.setEnabled(false);
    yearComboBox.setBounds(new Rectangle(150, 380, 49, 19));
    for (int i = 1900; i <= 2100; i++)
    {
      yearComboBox.addItem(i);
    }
    yearComboBox.setSelectedIndex(year-1900);
    yearLabel.setText("年");
    yearLabel.setBounds(new Rectangle(200, 380, 22, 19));
    monthComboBox.setBounds(new Rectangle(220, 380, 47, 19));
    for (int i = 1; i <= 12; i++)
    {
      monthComboBox.addItem(i);
    }
    monthComboBox.setSelectedIndex(month-1);
    monthLabel.setText("月");
    monthLabel.setBounds(new Rectangle(270, 380, 19, 20));
    for (int i = 1; i <= 30; i++)
    {
      dayComboBox.addItem(i);
    }
    dayComboBox.setBounds(new Rectangle(320, 380, 47, 19));
    dayComboBox.setSelectedIndex(day-1);
    dayLabel.setText("日");
    dayLabel.setBounds(new Rectangle(370, 380, 23, 19));
    addressTextField.setBounds(new Rectangle(150, 440, 164, 23));
    addressTextField.setText(detailInfor.address);
    telTextField.setBounds(new Rectangle(150, 500, 131, 21));
    telTextField.setText(detailInfor.tel);


    idCardTextField.setBounds(new Rectangle(600, 20, 120, 29));
    idCardTextField.setText(detailInfor.idCard);
    beginTimeTextField.setEditable(false);
    beginTimeTextField.setBounds(new Rectangle(600, 110, 161, 21));
    beginTimeTextField.setText(detailInfor.beginTime);
    timeTextField.setEditable(false);
    timeTextField.setBounds(new Rectangle(600, 200, 72, 21));
    timeTextField.setText(detailInfor.contractTime + "");
    exhibitionValueTextField.setEditable(false);
    exhibitionValueTextField.setBounds(new Rectangle(600, 330, 77, 19));
    if (detailInfor.exhibition == -1)
    {
      exhibitionValueTextField.setText("差劲");
    }
    else if (detailInfor.exhibition == 0)
    {
      exhibitionValueTextField.setText("一般");
    }
    else
    {
      exhibitionValueTextField.setText("优秀");
    }
    PasswordField.setBounds(new Rectangle(600, 380, 110, 23));
    PasswordField.setText(detailInfor.password);


    editButton.setBounds(new Rectangle(490, 470, 58, 23));
    editButton.setText("编辑");
    editButton.addActionListener(new
                                 PersonalInforUpdatePanel_editButton_actionAdapter(this));
    isMarryButtonGroup.add(notMarryRadioButton);
    isMarryButtonGroup.add(marryRadioButton);
    this.add(jobLabel);
    this.add(birthLabel);
    this.add(isMarryLabel);
    this.add(degreeLabel);
    this.add(depLabel);
    this.add(timeLabel);
    this.add(timeTextField);
    this.add(beginTimeTextField);
    this.add(exhibitionLabel);
    this.add(idCardLabel);
    this.add(beginTimeLabel);
    this.add(nameTextField);
    this.add(PasswordField);
    this.add(passwordLabel);
    this.add(telTextField);
    this.add(addressLabel);
    this.add(addressTextField);
    this.add(telLabel);
    this.add(monthComboBox);
    this.add(dayComboBox);
    this.add(yearComboBox);
    this.add(monthLabel);
    this.add(yearLabel);
    this.add(dayLabel);
    this.add(birthValueTextField);
    this.add(nameLabel);
    this.add(depIdValueTextField);
    this.add(depComboBox);
    this.add(jobValueTextField);
    this.add(jobComboBox);
    this.add(degreeValueTextField);
    this.add(degreeComboBox);
    this.add(marryRadioButton);
    this.add(notMarryRadioButton);
    this.add(isMarryValueTextField1);
    this.add(updateButton);
    this.add(editButton);
    this.add(exhibitionValueTextField);
    this.add(idCardTextField);
  }

  public void initDepComboBox()
  {
    for (int i = 0; i < myVector.depIds.size(); i++)
    {
      depComboBox.addItem(myVector.depNames.elementAt(i).toString().trim());
    }
    depComboBox.addItem("");
    //System.out.println(detailInfor.depId+"    1");
  }

  public void initJobComboBox()
  {
    for (int i = 0; i < myVector.jobIds.size(); i++)
    {
      jobComboBox.addItem(myVector.jobNames.elementAt(i).toString().trim());
    }
    jobComboBox.addItem("");
  }

  public void updateButton_actionPerformed(ActionEvent e)
  {
    String empAtFirst=detailInfor.empId;
    if (depComboBox.isEnabled())
    {
      detailInfor.depId = myVector.depIds.elementAt(depComboBox.
          getSelectedIndex()).
          toString().trim();
      detailInfor.empId=(detailInfor.depId+empAtFirst.substring(5)).trim();
      depIdValueTextField.setText(depComboBox.getSelectedItem().toString().trim());
    }
    System.out.println(detailInfor.empId);
    System.out.println(empAtFirst);
    if (jobComboBox.isEnabled())
    {
      detailInfor.jobId = myVector.jobIds.elementAt(jobComboBox.
          getSelectedIndex()).
          toString().trim();
      jobValueTextField.setText(jobComboBox.getSelectedItem().toString().trim());
    }
    detailInfor.name = nameTextField.getText().toString().trim();
    if (degreeComboBox.isEnabled())
    {
      detailInfor.degree = degreeComboBox.getSelectedItem().toString().trim();
      degreeValueTextField.setText(degreeComboBox.getSelectedItem().toString().trim());
    }
    if (marryRadioButton.isSelected() && marryRadioButton.isEnabled())
    {
      detailInfor.isMarry = 1;
      isMarryValueTextField1.setText("已婚");
    }
    else if (notMarryRadioButton.isSelected() && notMarryRadioButton.isEnabled())
    {
      detailInfor.isMarry = 0;
      isMarryValueTextField1.setText("未婚");
    }
    detailInfor.tel = telTextField.getText().toString().trim();
    detailInfor.address = addressTextField.getText().toString().trim();
    if (yearComboBox.isEnabled())
    {
      detailInfor.birth = yearComboBox.getSelectedItem().toString().trim() +
          "-" +
          monthComboBox.getSelectedItem().toString().trim() + "-" +
          dayComboBox.getSelectedItem().toString().trim();
      this.birthValueTextField.setText(detailInfor.birth);
    }
    detailInfor.idCard = idCardTextField.getText().toString().trim();
    detailInfor.password = String.valueOf(PasswordField.getPassword()).toString().
        trim();
    boolean flag = mySQL.updateDetailInformation(detailInfor,empAtFirst);
    if (flag)
    {
      JOptionPane.showMessageDialog(this, "更新成功!", "Information",
                                    JOptionPane.INFORMATION_MESSAGE);
    }
    else
    {
      JOptionPane.showMessageDialog(this, "更新失败!", "Error",
                                    JOptionPane.ERROR_MESSAGE);
    }

  }

  public void editButton_actionPerformed(ActionEvent e)
  {
    jobComboBox.setEnabled(true);
    depComboBox.setEnabled(true);
    degreeComboBox.setEnabled(true);
    marryRadioButton.setEnabled(true);
    notMarryRadioButton.setEnabled(true);
    yearComboBox.setEnabled(true);
    monthComboBox.setEnabled(true);
    dayComboBox.setEnabled(true);
  }

}

class PersonalInforUpdatePanel_editButton_actionAdapter
    implements ActionListener
{
  private PersonalInforUpdatePanel adaptee;
  PersonalInforUpdatePanel_editButton_actionAdapter(PersonalInforUpdatePanel
      adaptee)
  {
    this.adaptee = adaptee;
  }

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

class PersonalInforUpdatePanel_updateButton_actionAdapter
    implements ActionListener
{
  private PersonalInforUpdatePanel adaptee;
  PersonalInforUpdatePanel_updateButton_actionAdapter(PersonalInforUpdatePanel
      adaptee)
  {
    this.adaptee = adaptee;
  }

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

⌨️ 快捷键说明

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