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

📄 clothesinmanagementdialog.java

📁 一个优秀的干洗店管理系统
💻 JAVA
字号:
package view.dialog.countmanage;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.util.Iterator;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

import view.common.CenterWindow;
import view.common.DataPicker;
import view.common.GBC;

import common.LogWriter;

import control.clothesinmanagementaction.ClothesInManagementAction;
import dao.common.DbException;
import dao.takeClothesDao.TakeClothesDao;
import dao.takeClothesDao.takeClothesDaoImpl.TakeClothesDaoImpl;

public class ClothesInManagementDialog extends JDialog {
	// 日期、操作员、交易单号输入框标签
	private JLabel dateLabel, toLabel, operatorLabel, itemLabel;

	// 用于输入交易单号的JTextField
	private JTextField itemTxt;

	// 用于选择操作员的JComboBox
	protected JComboBox operatorCombox;

	// 构造日历控件
	protected DataPicker picker = new DataPicker();

	// 用于选择日期的JComboBox
	protected JComboBox fromDateBox, toDateBox;

	// 上面的面板
	private JPanel inquirePanel, infoPanel, btnPanel;

	// 收取衣物汇总面板、收取衣物明细面板、中间的标签面板
	private JPanel clothesInCollectionPanel, clothesInListPanel, labelPanel;

	// 收取衣物汇总表、详细表、收取衣物明细表
	private JTable clothesInCollectionTable, itemTable, clothesInListTable;

	// 用于显示交易单详细信息的标签
	private JLabel label;

	private JTabbedPane tabbedPane;

	private JButton filterBtn;

	private JRadioButtonMenuItem menuItem;

	private JPopupMenu popupMenu;

	private LogWriter log;

	public ClothesInManagementDialog(JFrame frame, LogWriter log) {
		super(frame, "收取衣物管理", true);
		this.log = log;
		log.log("进入类ClothesInManagementDialog的构造方法", LogWriter.INFO);
		initialPanel();
	}

	private void initialPanel() {
		this.setSize(800, 600);
		CenterWindow.centerWindow(this);
		this.setLayout(new BorderLayout());
		this.add(buildInquirePanel(), BorderLayout.NORTH);
		this.add(buildTabbedPane());
	}

	private JPanel buildInquirePanel() {
		if (inquirePanel == null) {
			inquirePanel = new JPanel();
			inquirePanel.setLayout(new GridLayout(1, 2));
			inquirePanel.add(buildInfoPanel());
			inquirePanel.add(buildBtnPanel());
		}
		return inquirePanel;
	}

	public JTabbedPane buildTabbedPane() {
		if (this.tabbedPane == null) {
			tabbedPane = new JTabbedPane();
			tabbedPane.add("收取衣物汇总", buildClothesInCollectionPanel());
			tabbedPane.add("收取衣物明细", buildClothesInListPanel());

		}
		return tabbedPane;
	}

	public JPanel buildClothesInCollectionPanel() {
		if (clothesInCollectionPanel == null) {
			clothesInCollectionPanel = new JPanel();
			clothesInCollectionPanel = new JPanel();
			clothesInCollectionPanel.setLayout(new GridBagLayout());

			clothesInCollectionPanel.add(
					getJTableScrollPane(buildClothesInCollectionTable()),
					new GBC(0, 0, 1, 6).setFill(GBC.BOTH).setWeight(100, 100));
			clothesInCollectionPanel.add(getLabelPanel(), new GBC(0, 6, 1, 1)
					.setFill(GBC.HORIZONTAL).setWeight(10, 10));
			clothesInCollectionPanel.add(getJTableScrollPane(buildItemTable()),
					new GBC(0, 7, 1, 4).setFill(GBC.BOTH).setWeight(100, 100));
		}
		return clothesInCollectionPanel;
	}

	public JPanel buildClothesInListPanel() {
		if (clothesInListPanel == null) {
			clothesInListPanel = new JPanel();
			clothesInListPanel.setLayout(new GridBagLayout());
			clothesInListPanel.add(
					getJTableScrollPane(buildClothesInListTable()), new GBC(0,
							0).setFill(GBC.BOTH).setWeight(100, 100));
		}
		return clothesInListPanel;
	}

	public JScrollPane getJTableScrollPane(JTable table) {
		JScrollPane js = new JScrollPane(table);
		return js;
	}

	public JTable buildClothesInCollectionTable() {
		if (clothesInCollectionTable == null) {
			String[] names = { "洗衣单号", "添加日期", "取衣日期", "应收金额", "实收金额", "优惠金额",
					"欠款金额", "会员编号", "客户名称", "联系手机", "是否取走", "支付情况", 
					"操作员", "现金", "储值卡" };
			Object[][] data = {};
			DefaultTableModel model = new DefaultTableModel(data, names) {
				public boolean isCellEditable(int rowIndex, int columnIndex) {
					return false;
				}
			};
			clothesInCollectionTable = new JTable(model);
			clothesInCollectionTable.getTableHeader().setReorderingAllowed(
					false);

		}
		clothesInCollectionTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

		return clothesInCollectionTable;
	}

	public JTable buildItemTable() {
		if (itemTable == null) {
			String[] head = { "衣服名称", "数量", "服务类型", "折后价", "总金额", "扣折",
					"衣服品牌", "衣服附件", "衣服瑕疵", "颜色", "备注" };
			Object[][] data = {};
			DefaultTableModel model = new DefaultTableModel(data, head) {
				public boolean isCellEditable(int rowIndex, int columnIndex) {
					return false;
				}
			};
			itemTable = new JTable(model);
			itemTable.getTableHeader().setReorderingAllowed(false);
		}
		itemTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		return itemTable;
	}

	public JTable buildClothesInListTable() {
		if (clothesInListTable == null) {
			String[] names = { "洗衣单号", "添加日期", "取衣日期", "会员编号", "客户名称", "衣服名称",
					"数量", "服务类型", "折后价", "总金额", "扣折", "是否取走", "衣服品牌", "衣服附件",
					"衣服瑕疵", "颜色", "备注", "操作员" };
			Object[][] data = {};
			DefaultTableModel model = new DefaultTableModel(data, names) {
				public boolean isCellEditable(int rowIndex, int columnIndex) {
					return false;
				}
			};
			clothesInListTable = new JTable(model);
			clothesInListTable.getTableHeader().setReorderingAllowed(false);

		}
		clothesInListTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		return clothesInListTable;
	}

	private JPanel getLabelPanel() {
		if (labelPanel == null) {
			labelPanel = new JPanel();
			labelPanel.add(buildLabel());
		}
		return labelPanel;
	}

	public JLabel buildLabel() {
		if (label == null) {
			label = new JLabel("交易单:,应收金额:元,实收金额:,折扣:");
		}
		return label;
	}

	private JPanel buildBtnPanel() {
		if (btnPanel == null) {
			btnPanel = new JPanel();
			btnPanel.setLayout(new FlowLayout());

			btnPanel.add(buildButton("查询"));
			btnPanel.add(buildButton("打印"));
			btnPanel.add(buildButton("退出"));

		}
		return btnPanel;
	}

	private JPanel buildInfoPanel() {
		if (infoPanel == null) {
			infoPanel = new JPanel();
			infoPanel.setLayout(new GridBagLayout());
			initLabel();
			infoPanel.add(dateLabel, new GBC(0, 0, 1, 1).setInset(3));
			infoPanel.add(buildFromDateBox(), new GBC(1, 0, 1, 1).setInset(3));
			infoPanel.add(toLabel, new GBC(2, 0, 1, 1).setInset(3));
			infoPanel.add(buildToDateBox(), new GBC(3, 0, 1, 1).setInset(3));
			infoPanel.add(operatorLabel, new GBC(0, 1, 1, 1).setInset(3)
					.setWeight(5, 5));
			infoPanel.add(buildOperatorCombox(), new GBC(1, 1, 1, 1)
					.setInset(3).setWeight(5, 5));
			infoPanel.add(itemLabel, new GBC(2, 1, 1, 1).setInset(3).setWeight(
					5, 5));
			infoPanel.add(buildItemTxt(), new GBC(3, 1, 1, 1).setInset(3)
					.setWeight(5, 5));
		}
		return infoPanel;
	}

	public JComboBox buildFromDateBox() {
		if (fromDateBox == null) {
			fromDateBox = picker.getDataPacker();
		}
		return fromDateBox;
	}

	public JComboBox buildToDateBox() {
		if (toDateBox == null) {
			toDateBox = picker.getDataPacker();
		}
		return toDateBox;
	}

	public JTextField buildItemTxt() {
		if (itemTxt == null) {
			itemTxt = new JTextField(12);
		}
		return itemTxt;
	}

	private void initLabel() {
		dateLabel = new JLabel("日期:");
		toLabel = new JLabel("到");
		operatorLabel = new JLabel("操作员");
		itemLabel = new JLabel("单号查询");
	}

	public JButton buildButton(String name) {
		JButton btn = new JButton(name);
		btn.addActionListener(new ClothesInManagementAction(this, log));
		return btn;
	}

	public JComboBox buildOperatorCombox() {
		if (operatorCombox == null) {
			TakeClothesDao takeClothesDao = new TakeClothesDaoImpl();
			Vector v = null;
			try {
				v = takeClothesDao.getAllOperatorName();
			} catch (DbException e) {
				JOptionPane.showMessageDialog(null, e.getMessage(), "提示",
						JOptionPane.YES_OPTION);
			}
			operatorCombox = new JComboBox();
			operatorCombox.addItem("不限制");
			if (v != null) {
				Iterator it = v.iterator();
				while (it.hasNext()) {
					String item = it.next().toString();
					operatorCombox.addItem(item);
				}
			}
			operatorCombox.setSize(12, 2);
		}
		return operatorCombox;
	}
}

⌨️ 快捷键说明

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