?? recordoperatepanel.java
字號:
.getText());
personalInfo.setSecondSpecialty(secondSpecialtyTextField
.getText());
String myGraduateDate = graduateDateTextField.getText();
if (!myGraduateDate.equals("YYYY-MM-DD")
&& myGraduateDate.length() != 0) {
try {
Date date = Date.valueOf(myGraduateDate);
personalInfo.setGraduateDate(date);
} catch (RuntimeException e) {
JOptionPane.showMessageDialog(null, "畢業日期輸入錯誤,請重新輸入!",
"友情提示", JOptionPane.WARNING_MESSAGE);
return;
}
}
personalInfo.setGraduateSchool(graduateSchoolTextField
.getText());
personalInfo.setComputerGrade(computerTextField.getText());
personalInfo.setLikes(likeTextField.getText());
String myPartyMemberDate = partyMemberDateTextField.getText();
if (!myPartyMemberDate.equals("YYYY-MM-DD")
&& myPartyMemberDate.length() != 0) {
try {
Date date = Date.valueOf(myPartyMemberDate);
personalInfo.setPartyMemberDate(date);
} catch (RuntimeException e) {
JOptionPane.showMessageDialog(null, "入黨日期輸入錯誤,請重新輸入!",
"友情提示", JOptionPane.WARNING_MESSAGE);
return;
}
}
personalInfo.setOnesStrongSuit(onesStrongSuitTextField
.getText());
personalInfo.setPostalcode(homePostalcodeTextField.getText());
personalInfo.setAddress(homeAddressTextField.getText());
// 獲得職務信息
TbDutyInfo dutyInfo = null;
if (UPDATE_RECORD == null)
dutyInfo = new TbDutyInfo();
else
dutyInfo = record.getTbDutyInfo();
TbDept dept = (TbDept) dao.queryDeptByName(deptTextField
.getText());
dutyInfo.setTbDept(dept);// 部門
TbDuty duty = (TbDuty) dao.queryDutyByName(dutyComboBox
.getSelectedItem().toString());
dutyInfo.setTbDuty(duty);// 職務
TbAccessionForm accessionForm = (TbAccessionForm) dao
.queryAccessionFormByName(accessionFormComboBox
.getSelectedItem().toString());
dutyInfo.setTbAccessionForm(accessionForm);// 用工形式
String myDimissionDate = dimissionDateTextField.getText();
if (!myDimissionDate.equals("YYYY-MM-DD")
&& myDimissionDate.length() != 0) {
try {
Date date = Date.valueOf(myDimissionDate);
dutyInfo.setDimissionDate(date);// 離職日期
} catch (RuntimeException e) {
JOptionPane.showMessageDialog(null, "離職日期輸入錯誤,請重新輸入!",
"友情提示", JOptionPane.WARNING_MESSAGE);
return;
}
}
dutyInfo.setDimissionReason(dimissionReasonTextField.getText());// 離職原因
String myPactStartDate = pactStartDateTextField.getText();
if (!myPactStartDate.equals("YYYY-MM-DD")
&& myPactStartDate.length() != 0) {
try {
Date date = Date.valueOf(myPactStartDate);
dutyInfo.setPactStartDate(date);// 合同開始日期
if (firstPactDateTextField.getText().length() == 0)
dutyInfo.setFirstPactDate(date);// 轉正日期
} catch (RuntimeException e) {
JOptionPane.showMessageDialog(null,
"合同開始日期輸入錯誤,請重新輸入!", "友情提示",
JOptionPane.WARNING_MESSAGE);
return;
}
}
String myPactEndDate = pactEndDateTextField.getText();
if (!myPactEndDate.equals("YYYY-MM-DD")
&& myPactEndDate.length() != 0) {
try {
Date date = Date.valueOf(myPactEndDate);
dutyInfo.setPactEndDate(date);// 合同結束日期
} catch (RuntimeException e) {
JOptionPane.showMessageDialog(null,
"合同結束日期輸入錯誤,請重新輸入!", "友情提示",
JOptionPane.WARNING_MESSAGE);
return;
}
}
dutyInfo.setBankName(bankNameTextField.getText());
dutyInfo.setBankNo(bankNOTextField.getText());
dutyInfo.setAnnuitySafetyNo(annuitySafetyNOTextField.getText());
dutyInfo.setMedicareSafetyNo(medicareSafetyNOTextField
.getText());
dutyInfo.setCompoSafetyNo(compoSafetyNOTextField.getText());
dutyInfo.setDoleSafetyNo(doleSafetyNOTextField.getText());
dutyInfo.setSocietySafetyNo(societySafetyNOTextField.getText());
dutyInfo.setAccumulationFundNo(accumulationFundNOTextField
.getText());
// 驗證職務信息
methods = dutyInfo.getClass().getMethods();
String dutyInfoMethodNames[] = { "tbDept", "tbDuty",
"tbAccessionForm" };
for (int i = 0; i < methods.length; i++) {
String methodName = methods[i].getName();
if (methodName.startsWith("get")) {
for (int m = 0; m < dutyInfoMethodNames.length; m++) {
if (methodName.substring(3).toLowerCase().equals(
dutyInfoMethodNames[m].toLowerCase())) {
Object object = null;
try {
object = methods[i].invoke(dutyInfo, null);
System.out.println("method=" + methods[i]);
System.out.println("object=" + object);
} catch (Exception e) {
e.printStackTrace();
}
if (object == null) {
JOptionPane.showMessageDialog(null,
new String[] { "[職務信息]欄中的:",
" 部 門", " 職 務",
" 入職日期", " 用工形式",
"四項不允許為空!" }, "友情提示",
JOptionPane.WARNING_MESSAGE);
return;
}
}
}
}
}
String myAccessionDate = accessionDateTextField.getText();
if (myAccessionDate.equals("YYYY-MM-DD")) {
JOptionPane.showMessageDialog(null, "請填寫入職日期!", "友情提示",
JOptionPane.WARNING_MESSAGE);
return;
} else {
try {
Date date = Date.valueOf(myAccessionDate);
dutyInfo.setAccessionDate(date);
} catch (RuntimeException e) {
JOptionPane.showMessageDialog(null, "入職日期輸入錯誤,請重新輸入!",
"友情提示", JOptionPane.WARNING_MESSAGE);
return;
}
}
// 提交信息
if (UPDATE_RECORD == null) {
personalInfo.setTbRecord(record);
record.setTbPersonalInfo(personalInfo);
dutyInfo.setTbRecord(record);
record.setTbDutyInfo(dutyInfo);
dao.saveObject(record);
UPDATE_RECORD = record;
} else {
dao.updateObject(record);
}
// 關閉Session
HibernateSessionFactory.closeSession();
// 彈出成功提示
JOptionPane.showMessageDialog(null, "已經成功保存該檔案信息!", "友情提示",
JOptionPane.INFORMATION_MESSAGE);
}
});
saveButton.setText("保存");
buttonPanel.add(saveButton);
final JButton exitButton = new JButton();
exitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
rightPanel.removeAll();
rightPanel.add(new RecordSelectedPanel(rightPanel));
SwingUtilities.updateComponentTreeUI(rightPanel);
}
});
exitButton.setText("退出");
buttonPanel.add(exitButton);
final JPanel contentPanel = new JPanel();
contentPanel.setBackground(Color.WHITE);
contentPanel.setBorder(new TitledBorder(null, "",
TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION, null, null));
contentPanel.setLayout(new BorderLayout());
add(contentPanel, BorderLayout.CENTER);
final JPanel recordNumPanel = new JPanel();
recordNumPanel.setBackground(Color.WHITE);
final FlowLayout flowLayout = new FlowLayout();
flowLayout.setAlignment(FlowLayout.LEFT);
recordNumPanel.setLayout(flowLayout);
contentPanel.add(recordNumPanel, BorderLayout.NORTH);
final JLabel recordNoLabel = new JLabel();
recordNoLabel.setText(" 檔案編號:");
recordNumPanel.add(recordNoLabel);
recordNoTextField = new JTextField();
recordNoTextField.setHorizontalAlignment(SwingConstants.CENTER);
recordNoTextField.setPreferredSize(new Dimension(125, 20));
recordNoTextField.setEditable(false);
if (UPDATE_RECORD == null) {
String record = (String) dao.queryRecordOfMaxRecordNum();
if (record == null) {
recordNoTextField.setText("T00001");
} else {
String recordNum = (Integer.valueOf(record.substring(1)) + 1)
+ "";
StringBuffer id = new StringBuffer(6);
id.append(recordNum);
for (int i = 0; i < 5 - recordNum.length(); i++) {
id.insert(0, '0');
}
id.insert(0, 'T');
recordNoTextField.setText(id.toString());
}
} else {
recordNoTextField.setText(UPDATE_RECORD.getRecordNumber());
}
recordNumPanel.add(recordNoTextField);
final JPanel infoPanel = new JPanel();
infoPanel.setLayout(new BorderLayout());
infoPanel.setBackground(Color.WHITE);
contentPanel.add(infoPanel, BorderLayout.CENTER);
final JPanel recordInfoPanel = new JPanel();
recordInfoPanel.setLayout(new GridBagLayout());
recordInfoPanel.setBorder(new TitledBorder(null, "檔按信息",
TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION, null, null));
recordInfoPanel.setBackground(Color.WHITE);
infoPanel.add(recordInfoPanel, BorderLayout.NORTH);
final JLabel nameLabel = new JLabel();
nameLabel.setText("姓 名:");
final GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = new Insets(5, 0, 10, 0);
gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 0;
recordInfoPanel.add(nameLabel, gridBagConstraints);
nameTextField = new JTextField();
nameTextField.setPreferredSize(new Dimension(125, 20));
if (UPDATE_RECORD != null)
nameTextField.setText(UPDATE_RECORD.getName());
final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints();
gridBagConstraints_1.insets = new Insets(5, 0, 10, 20);
gridBagConstraints_1.gridy = 0;
gridBagConstraints_1.gridx = 1;
recordInfoPanel.add(nameTextField, gridBagConstraints_1);
final JLabel sexLabel = new JLabel();
sexLabel.setText("性 別:");
final GridBagConstraints gridBagConstraints_11 = new GridBagConstraints();
gridBagConstraints_11.insets = new Insets(5, 0, 10, 0);
gridBagConstraints_11.gridy = 0;
gridBagConstraints_11.gridx = 2;
recordInfoPanel.add(sexLabel, gridBagConstraints_11);
final JRadioButton manRadioButton = new JRadioButton();
sexButtonGroup.add(manRadioButton);
manRadioButton.setBackground(Color.WHITE);
manRadioButton.setText("男");
final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints();
gridBagConstraints_3.insets = new Insets(0, 16, 10, 0);
gridBagConstraints_3.gridy = 0;
gridBagConstraints_3.gridx = 3;
recordInfoPanel.add(manRadioButton, gridBagConstraints_3);
final JRadioButton womanRadioButton = new JRadioButton();
sexButtonGroup.add(womanRadioButton);
womanRadioButton.setBackground(Color.WHITE);
womanRadioButton.setText("女");
final GridBagConstraints gridBagConstraints_95 = new GridBagConstraints();
gridBagConstraints_95.insets = new Insets(0, 0, 10, 0);
gridBagConstraints_95.gridy = 0;
gridBagConstraints_95.gridx = 4;
recordInfoPanel.add(womanRadioButton, gridBagConstraints_95);
if (UPDATE_RECORD != null) {
if (UPDATE_RECORD.getSex().equals("男"))
manRadioButton.setSelected(true);
else
womanRadioButton.setSelected(true);
}
final JLabel birthdayLabel = new JLabel();
birthdayLabel.setText("出生日期:");
final GridBagConstraints gridBagConstraints_6 = new GridBagConstraints();
gridBagConstraints_6.insets = new Insets(5, 0, 10, 0);
gridBagConstraints_6.gridy = 0;
gridBagConstraints_6.gridx = 5;
recordInfoPanel.add(birthdayLabel, gridBagConstraints_6);
birthdayTextField = new JTextField();
birthdayTextField.setHorizontalAlignment(SwingConstants.CENTER);
birthdayTextField.setPreferredSize(new Dimension(125, 20));
if (UPDATE_RECORD == null) {
birthdayTextField.setText("YYYY-MM-DD");
} else {
String date = UPDATE_RECORD.getBirthday().toString();
date = date.substring(0, 10);
birthdayTextField.setText(date);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -