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

📄 recordoperatepanel.java

📁 java swing 开发的一些实例
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
						.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 + -