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

📄 reportformspanel.java

📁 根据企业对人事管理的要求
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.mwq.frame.treatement;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Vector;

import javax.swing.AbstractButton;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

import com.mwq.hibernate.Dao;
import com.mwq.hibernate.mapping.TbAccountItem;
import com.mwq.hibernate.mapping.TbDutyInfo;
import com.mwq.hibernate.mapping.TbReckoning;
import com.mwq.hibernate.mapping.TbReckoningInfo;
import com.mwq.hibernate.mapping.TbReckoningList;
import com.mwq.hibernate.mapping.TbRecord;
import com.mwq.hibernate.mapping.TbRewardsAndPunishment;
import com.mwq.hibernate.mapping.TbTimecard;
import com.mwq.mwing.MTable;
import com.mwq.tool.Today;

public class ReportFormsPanel extends JPanel {

	private JComboBox monthComboBox;

	private JComboBox quarterComboBox;

	private JComboBox halfYearComboBox;

	private JComboBox yearComboBox;

	private ButtonGroup buttonGroup = new ButtonGroup();

	private MTable table;

	private final Vector<String> tableColumnV = new Vector<String>();

	private final Vector<Vector> tableValueV = new Vector<Vector>();

	private final DefaultTableModel tableModel = new DefaultTableModel(
			tableValueV, tableColumnV);

	private final Dao dao = Dao.getInstance();

	/**
	 * Create the panel
	 */
	public ReportFormsPanel() {
		super();
		setLayout(new BorderLayout());

		final JPanel buttonPanel = new JPanel();
		buttonPanel.setBackground(Color.WHITE);
		add(buttonPanel, BorderLayout.NORTH);

		final JLabel createLabel = new JLabel();
		createLabel.setText("生成");
		buttonPanel.add(createLabel);

		final JPanel panel = new JPanel();
		panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
		panel.setPreferredSize(new Dimension(175, 31));
		panel.setBorder(new TitledBorder(null, "",
				TitledBorder.DEFAULT_JUSTIFICATION,
				TitledBorder.DEFAULT_POSITION, null, null));
		panel.setBackground(Color.WHITE);
		buttonPanel.add(panel);

		final JRadioButton monthRadioButton = new JRadioButton();
		monthRadioButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				halfYearComboBox.setEnabled(false);
				quarterComboBox.setEnabled(false);
				monthComboBox.setEnabled(true);
			}
		});
		panel.add(monthRadioButton);
		buttonGroup.add(monthRadioButton);
		monthRadioButton.setSelected(true);
		monthRadioButton.setBackground(Color.WHITE);
		monthRadioButton.setText("月");

		final JRadioButton quarterRadioButton = new JRadioButton();
		quarterRadioButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				halfYearComboBox.setEnabled(false);
				quarterComboBox.setEnabled(true);
				monthComboBox.setEnabled(false);
			}
		});
		panel.add(quarterRadioButton);
		buttonGroup.add(quarterRadioButton);
		quarterRadioButton.setBackground(Color.WHITE);
		quarterRadioButton.setText("季");

		final JRadioButton halfYearRadioButton = new JRadioButton();
		halfYearRadioButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				halfYearComboBox.setEnabled(true);
				quarterComboBox.setEnabled(false);
				monthComboBox.setEnabled(false);
			}
		});
		panel.add(halfYearRadioButton);
		buttonGroup.add(halfYearRadioButton);
		halfYearRadioButton.setBackground(Color.WHITE);
		halfYearRadioButton.setText("半年");

		final JRadioButton yearRadioButton = new JRadioButton();
		yearRadioButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				halfYearComboBox.setEnabled(false);
				quarterComboBox.setEnabled(false);
				monthComboBox.setEnabled(false);
			}
		});
		panel.add(yearRadioButton);
		buttonGroup.add(yearRadioButton);
		yearRadioButton.setBackground(Color.WHITE);
		yearRadioButton.setText("年");

		final JLabel reportFormsLabel = new JLabel();
		reportFormsLabel.setText("报表          ");
		buttonPanel.add(reportFormsLabel);

		yearComboBox = new JComboBox();
		Object minAccessionDateObj = dao.queryRecordOfMinAccessionDate();
		String minAccessionDate = Today.YEAR + "";
		if (minAccessionDateObj != null)
			minAccessionDate = minAccessionDateObj.toString();
		int minYear = Integer.valueOf(minAccessionDate.substring(0, 4));
		for (int i = Today.YEAR; i >= minYear; i--) {
			yearComboBox.addItem(i);
		}
		buttonPanel.add(yearComboBox);

		final JLabel yearLabel = new JLabel();
		yearLabel.setText("年");
		buttonPanel.add(yearLabel);

		halfYearComboBox = new JComboBox();
		halfYearComboBox.addItem("上");
		halfYearComboBox.addItem("下");
		buttonPanel.add(halfYearComboBox);

		final JLabel halfYearLabel = new JLabel();
		halfYearLabel.setText("半年");
		buttonPanel.add(halfYearLabel);

		quarterComboBox = new JComboBox();
		quarterComboBox.addItem("第一");
		quarterComboBox.addItem("第二");
		quarterComboBox.addItem("第三");
		quarterComboBox.addItem("第四");
		buttonPanel.add(quarterComboBox);

		final JLabel quarterLabel = new JLabel();
		quarterLabel.setText("季度");
		buttonPanel.add(quarterLabel);

		monthComboBox = new JComboBox();
		monthComboBox.setMaximumRowCount(12);
		monthComboBox.addItem("1");
		monthComboBox.addItem("2");
		monthComboBox.addItem("3");
		monthComboBox.addItem("4");
		monthComboBox.addItem("5");
		monthComboBox.addItem("6");
		monthComboBox.addItem("7");
		monthComboBox.addItem("8");
		monthComboBox.addItem("9");
		monthComboBox.addItem("10");
		monthComboBox.addItem("11");
		monthComboBox.addItem("12");
		buttonPanel.add(monthComboBox);

		final JLabel monthLabel = new JLabel();
		monthLabel.setText("月份    ");
		buttonPanel.add(monthLabel);

		final JButton submitButton = new JButton();
		submitButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				tableValueV.removeAllElements();// 移除表格中的所有行
				Enumeration<AbstractButton> buttonEnu = buttonGroup
						.getElements();
				while (buttonEnu.hasMoreElements()) {// 遍历报表类型单选按钮
					JRadioButton button = (JRadioButton) buttonEnu
							.nextElement();// 获得单选按钮对象
					if (button.isSelected()) {// 单选按钮被选中
						String year = yearComboBox.getSelectedItem().toString();// 获得报表年度
						String reportFormsType = button.getText();// 获得报表类型名称
						if (reportFormsType.equals("月")) {// 生成月报表
							String month = monthComboBox.getSelectedItem()
									.toString();// 获得报表月份
							String monthDay[] = new String[] { "00", "31",
									"28", "31", "30", "31", "30", "31", "31",
									"30", "31", "30", "31" };
							if (month.equals("2")) {// 如果是生成2月份的报表,需要判断是否为闰年
								int y = Integer.valueOf(year);
								if (y / 100 == 0) {
									if (y / 400 == 0)
										monthDay[2] = "29";
								} else {
									if (y / 4 == 0)
										monthDay[2] = "29";
								}
								reportForms(year + "-2-1", year + "-2-"
										+ monthDay[2]);// 生成报表
							} else {
								reportForms(year + "-" + month + "-1", year
										+ "-" + month + "-"
										+ monthDay[Integer.valueOf(month)]);// 生成报表
							}
						} else if (reportFormsType.equals("季")) {// 生成季报表
							String quarter = quarterComboBox.getSelectedItem()
									.toString();// 获得报表季度
							if (quarter.equals("第一")) {
								reportForms(year + "-1-1", year + "-3-31");// 生成报表
							} else if (quarter.equals("第二")) {

⌨️ 快捷键说明

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