package com.mwq.frame.personnel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.sql.Date;
import java.util.Enumeration;
import java.util.Iterator;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.border.TitledBorder;
import javax.swing.filechooser.FileFilter;
import com.mwq.frame.common.DeptTreeDialog;
import com.mwq.hibernate.Dao;
import com.mwq.hibernate.HibernateSessionFactory;
import com.mwq.hibernate.mapping.TbAccessionForm;
import com.mwq.hibernate.mapping.TbDept;
import com.mwq.hibernate.mapping.TbDuty;
import com.mwq.hibernate.mapping.TbDutyInfo;
import com.mwq.hibernate.mapping.TbNation;
import com.mwq.hibernate.mapping.TbNativePlace;
import com.mwq.hibernate.mapping.TbPersonalInfo;
import com.mwq.hibernate.mapping.TbRecord;
import com.mwq.tool.Today;
public class RecordOperatePanel extends JPanel {
private JTextField deptTextField;
private JComboBox accessionFormComboBox;
private JComboBox dutyComboBox;
private ButtonGroup partyMemberButtonGroup = new ButtonGroup();
private ButtonGroup marriagedButtonGroup = new ButtonGroup();
private ButtonGroup sexButtonGroup = new ButtonGroup();
private JComboBox schoolageComboBox;
private JComboBox nativePlaceComboBox;
private JComboBox nationComboBox;
private JTextField accumulationFundNOTextField;
private JTextField annuitySafetyNOTextField;
private JTextField pactEndDateTextField;
private JTextField dimissionReasonTextField;
private JTextField compoSafetyNOTextField;
private JTextField doleSafetyNOTextField;
private JTextField medicareSafetyNOTextField;
private JTextField societySafetyNOTextField;
private JTextField pactAgeTextField;
private JTextField bankNOTextField;
private JTextField pactStartDateTextField;
private JTextField dimissionDateTextField;
private JTextField bankNameTextField;
private JTextField firstPactDateTextField;
private JTextField accessionDateTextField;
private JTextField homeAddressTextField;
private JTextField onesStrongSuitTextField;
private JTextField likeTextField;
private JTextField homePostalcodeTextField;
private JTextField partyMemberDateTextField;
private JTextField graduateSchoolTextField;
private JTextField graduateDateTextField;
private JTextField secondSpecialtyTextField;
private JTextField secondSchoolageTextField;
private JTextField computerTextField;
private JTextField emailTextField;
private JTextField qqTextField;
private JTextField telephoneTextField;
private JTextField handsetTextField;
private JTextField addressTextField;
private JTextField postalcodeTextField;
private JTextField gradeTextField;
private JTextField specialtyTextField;
private JTextField foreignLanguageTextField;
private JTextField idCardTextField;
private JTextField partyMemberTextField;
private JTextField birthdayTextField;
private JTextField nameTextField;
private JTextField recordNoTextField;
private JLabel photoLabel;
private Dao dao = Dao.getInstance();
public static TbRecord UPDATE_RECORD = null;
/**
* Create the panel
*/
public RecordOperatePanel(final JPanel rightPanel) {
super();
setLayout(new BorderLayout());
final JPanel buttonPanel = new JPanel();
buttonPanel.setBackground(Color.WHITE);
add(buttonPanel, BorderLayout.NORTH);
final JButton saveButton = new JButton();
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
// 获取档案信息
TbRecord record = null;
if (UPDATE_RECORD == null) {
record = new TbRecord();
} else {
record = (TbRecord) dao.queryRecordByNum(recordNoTextField
.getText());
}
record.setRecordNumber(recordNoTextField.getText());
record.setName(nameTextField.getText());
Enumeration<AbstractButton> sexElements = sexButtonGroup
.getElements();
while (sexElements.hasMoreElements()) {
AbstractButton button = sexElements.nextElement();
if (button.isSelected()) {
record.setSex(button.getText());
break;
}
}
TbNation nation = (TbNation) dao
.queryNationByName(nationComboBox.getSelectedItem()
.toString());
record.setTbNation(nation);
TbNativePlace nativePlace = (TbNativePlace) dao
.queryNativePlaceByName(nativePlaceComboBox
.getSelectedItem().toString());
record.setTbNativePlace(nativePlace);
record.setIdCard(idCardTextField.getText());
record.setSchoolAge(schoolageComboBox.getSelectedItem()
.toString());
record.setSpecialty(specialtyTextField.getText());
Enumeration<AbstractButton> partyMembers = partyMemberButtonGroup
.getElements();
while (partyMembers.hasMoreElements()) {
AbstractButton button = partyMembers.nextElement();
if (button.isSelected()) {
record.setPartyMember(button.getText().trim());
break;
}
}
record.setForeignLanguage(foreignLanguageTextField.getText());
record.setGrade(gradeTextField.getText());
Enumeration<AbstractButton> marriagedElements = marriagedButtonGroup
.getElements();
while (marriagedElements.hasMoreElements()) {
AbstractButton button = marriagedElements.nextElement();
if (button.isSelected()) {
record.setMarriaged(button.getText());
break;
}
}
record.setPostalcode(postalcodeTextField.getText());
record.setAddress(addressTextField.getText());
// 验证档案信息
Method[] methods = record.getClass().getMethods();
String recordMethodNames[] = { "name", "sex", "tbNation",
"tbNativePlace;", "idCard", " schoolAge", " specialty",
" partyMember", " foreignLanguage", " grade",
"marriaged", " postalcode", "address" };
for (int i = 0; i < methods.length; i++) {
String methodName = methods[i].getName();
if (methodName.startsWith("get")) {
for (int m = 0; m < recordMethodNames.length; m++) {
if (methodName.substring(3).toLowerCase().equals(
recordMethodNames[m].toLowerCase())) {
Object object = null;
try {
object = methods[i].invoke(record, null);
} catch (Exception e) {
e.printStackTrace();
}
if (object == null) {
System.out.println(methods[i].getName()
+ "=" + object);
JOptionPane.showMessageDialog(null,
"除照片外,[档案信息]栏的其他项均不允许为空!", "友情提示",
JOptionPane.WARNING_MESSAGE);
return;
}
}
}
}
}
String myBirthday = birthdayTextField.getText();
if (myBirthday.equals("YYYY-MM-DD")) {
JOptionPane.showMessageDialog(null, "请输入出生日期!", "友情提示",
JOptionPane.WARNING_MESSAGE);
return;
} else {
try {
Date birthday = Date.valueOf(myBirthday);
record.setBirthday(birthday);
} catch (RuntimeException e) {
JOptionPane.show
评论6
最新资源