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

📄 getclothespanel.java

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

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

import view.common.DataPicker;
import view.common.GBC;
import view.frame.MainFrame;
import view.panel.basePanel.CustomerInfoPanel;
import vo.OrderItemVo;
import vo.OrderVo;
import vo.VipVo;
import control.getClothes.GetClothesListener;

public class GetClothesPanel extends JPanel {
	private JPanel headerPanel;
	private JPanel searchCustomerPanel;

	private CustomerInfoPanel customerInfoPanel;
	private JTextField customerCardIdTxField;
	private JButton searchCustomerBtn, addCustomerBtn;

	private JPanel clothesOperBtnPanel;
	private JButton addClothesBtn, deleteClothesBtn, clearClothesBtn;
	private JScrollPane buyingClothesTableScrollPane;
	private String[] tableHeaders = { "衣服名称", "服务类型", "品牌", "衣服附件", "衣服瑕疵",
			"颜色", "折后价", "数量", "总额", "衣服备注" };
	private JTable buyingClothesTable;

	private JPanel payInfoPanel;
	private JLabel orderIdLabel, moneyLabel;
	private JCheckBox payCkboxBtn;
	private JButton vipConsumingHistoryBtn;
	private String ckBoxContent = "取衣时再付现金";

	private DataPicker picker = new DataPicker();
	private JComboBox dateCmbBox;

	private JPanel payBtnPanel;
	private JButton okBtn, cancelBtn;

	private VipVo vipVo;
	public OrderVo orderVo;
	public Vector<OrderItemVo> itemVector;

	public GetClothesPanel() {
		this.setLayout(new GridBagLayout());
		this.add(buildHeaderPanel("收取衣服"), new GBC(0, 0, 1, 1)
				.setFill(GBC.BOTH).setWeight(100, 100));
		this.add(buildSearchCustomerPanel(), new GBC(0, 1, 1, 1).setFill(
				GBC.BOTH).setWeight(100, 100));
		this.add(buildCustomerInfoPanel(), new GBC(0, 2, 1, 2)
				.setFill(GBC.BOTH).setWeight(100, 100));
		this.add(buildClothesOperBtnPanel(), new GBC(0, 4, 1, 1).setFill(
				GBC.BOTH).setWeight(100, 100));
		this.add(buildBuyingClothesTableScrollPane(), new GBC(0, 5, 1, 6)
				.setFill(GBC.BOTH).setWeight(100, 100));
		this.add(buildPayInfoPanel(), new GBC(0, 11, 1, 1).setFill(GBC.BOTH)
				.setWeight(100, 100));
		this.add(buildPayBtnPanel(), new GBC(0, 12, 1, 1).setFill(GBC.BOTH)
				.setWeight(100, 100));
	}

	public JPanel buildSearchCustomerPanel() {
		if (searchCustomerPanel == null) {
			searchCustomerPanel = new JPanel();
			searchCustomerPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

			JPanel panelOne = new JPanel();
			panelOne.setLayout(new GridLayout(1, 2, 10, 1));
			panelOne.add(buildLabel("请输入会员卡号:"));
			panelOne.add(buildCustomerCardIdTxField());

			JPanel panelTwo = new JPanel();
			panelTwo.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 1));
			panelTwo.add(buildSearchCustomerBtn());
			JLabel lb = buildLabel("提示:对于无卡客户,请用会员卡号0进行搜素");
			lb.setForeground(Color.RED);
			panelTwo.add(lb);

			searchCustomerPanel.add(panelOne);
			searchCustomerPanel.add(panelTwo);
		}
		return searchCustomerPanel;
	}

	public JTextField buildCustomerCardIdTxField() {
		if (customerCardIdTxField == null) {
			customerCardIdTxField = new JTextField();
		}
		return customerCardIdTxField;
	}

	public JButton buildSearchCustomerBtn() {
		if (searchCustomerBtn == null) {
			searchCustomerBtn = new JButton("搜素");
			searchCustomerBtn.setToolTipText("搜索会员,对于无卡客户请用用数字0搜素");
			searchCustomerBtn.addActionListener(new GetClothesListener(this));
		}
		return searchCustomerBtn;
	}

	public JPanel buildHeaderPanel(String header) {
		if (headerPanel == null) {
			headerPanel = new JPanel();
			headerPanel.setLayout(new FlowLayout());
			JLabel headLabel = new JLabel(header);
			headLabel.setFont(new Font("", Font.BOLD, 20));
			headerPanel.add(headLabel);
		}
		return headerPanel;
	}

	public CustomerInfoPanel buildCustomerInfoPanel() {
		if (customerInfoPanel == null) {
			customerInfoPanel = new CustomerInfoPanel();
			customerInfoPanel.setBorder(BorderFactory
					.createTitledBorder("会员信息"));
		}
		return customerInfoPanel;
	}

	public JPanel buildClothesOperBtnPanel() {
		if (clothesOperBtnPanel == null) {
			clothesOperBtnPanel = new JPanel();
			clothesOperBtnPanel.setLayout(new FlowLayout());
			clothesOperBtnPanel.add(buildAddClothesBtn());
			clothesOperBtnPanel.add(buildDeleteClothesBtn());
			clothesOperBtnPanel.add(buildClearClothesBtn());
		}
		return clothesOperBtnPanel;
	}

	public JButton buildAddClothesBtn() {
		if (addClothesBtn == null) {
			addClothesBtn = new JButton("添加衣服");
			addClothesBtn.addActionListener(new GetClothesListener(this));
		}
		return addClothesBtn;
	}

	public JButton buildDeleteClothesBtn() {
		if (deleteClothesBtn == null) {
			deleteClothesBtn = new JButton("删除衣服");
			deleteClothesBtn.addActionListener(new GetClothesListener(this));
		}
		return deleteClothesBtn;
	}

	public JButton buildClearClothesBtn() {
		if (clearClothesBtn == null) {
			clearClothesBtn = new JButton("清空衣服");
			clearClothesBtn.addActionListener(new GetClothesListener(this));
		}
		return clearClothesBtn;
	}

	public JScrollPane buildBuyingClothesTableScrollPane() {
		if (buyingClothesTableScrollPane == null) {
			buyingClothesTableScrollPane = new JScrollPane(
					buildBuyingClothesTable());
		}
		return buyingClothesTableScrollPane;
	}

	public JTable buildBuyingClothesTable() {
		if (buyingClothesTable == null) {
			Object[][] data = {};
			DefaultTableModel tableModel = new DefaultTableModel(data,
					tableHeaders) {
				public boolean isCellEditable(int rowIndex, int columnIndex) {
					return false;
				}
			};
			buyingClothesTable = new JTable(tableModel);
		}
		return buyingClothesTable;
	}

	public JPanel buildPayInfoPanel() {
		if (payInfoPanel == null) {
			payInfoPanel = new JPanel();
			payInfoPanel.setLayout(new GridLayout(2, 1));

			JPanel firPanel = new JPanel();
			firPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 25, 1));
			firPanel.add(buildLabel("订单号"));
			firPanel.add(buildOrderIdLabel());
			firPanel.add(buildLabel("应收金额"));
			firPanel.add(buildMoneyLabel());
			firPanel.add(buildPayCkBox());
			firPanel.add(buildLabel("取衣日期"));
			firPanel.add(buildTakeDateCmbBox());
			payInfoPanel.add(firPanel);

			JPanel sndPanel = new JPanel();
			sndPanel.setLayout(new FlowLayout());
			JLabel reminderLabel = buildLabel("提示: 消费10元积1分");
			reminderLabel.setForeground(Color.RED);
			sndPanel.add(reminderLabel);
			payInfoPanel.add(sndPanel);
		}
		return payInfoPanel;
	}

	public JLabel buildLabel(String content) {
		return new JLabel(content);
	}

	public JLabel buildOrderIdLabel() {
		if (orderIdLabel == null) {
			orderIdLabel = new JLabel();
		}
		return orderIdLabel;
	}

	public JLabel buildMoneyLabel() {
		if (moneyLabel == null) {
			moneyLabel = new JLabel("¥0");
		}
		return moneyLabel;
	}

	public JCheckBox buildPayCkBox() {
		if (payCkboxBtn == null) {
			payCkboxBtn = new JCheckBox(ckBoxContent);
		}
		return payCkboxBtn;
	}

	public JComboBox buildTakeDateCmbBox() {
		if (dateCmbBox == null) {
			dateCmbBox = picker.getDataPacker();
		}
		return dateCmbBox;
	}

	public JButton buildVipConsumingHistoryBtn() {
		if (vipConsumingHistoryBtn == null) {
			vipConsumingHistoryBtn = new JButton("此会员消费记录");
		}
		return vipConsumingHistoryBtn;
	}

	public JPanel buildPayBtnPanel() {
		if (payBtnPanel == null) {
			payBtnPanel = new JPanel();
			payBtnPanel.setLayout(new FlowLayout());
			payBtnPanel.add(buildOkBtn());
		}
		return payBtnPanel;
	}

	public JButton buildOkBtn() {
		if (okBtn == null) {
			okBtn = new JButton("确定");
			okBtn.addActionListener(new GetClothesListener(this));
		}
		return okBtn;
	}

	public int getToSearchVipId() throws NumberFormatException{
		return Integer.parseInt(this.buildCustomerCardIdTxField().getText());
	}

	public void iniVipInfo(VipVo vipVo) {
		this.vipVo = vipVo;
		if (vipVo == null) {
			this.customerInfoPanel.buildVipCardIdLabel().setText("0");
			this.customerInfoPanel.buildVipNameLabel().setText("无卡客户");
		} else {
			this.customerInfoPanel.buildVipCardIdLabel().setText(
					new Integer(vipVo.getVipCard().getVipId()).toString());
			this.customerInfoPanel.buildVipNameLabel().setText(
					vipVo.getVipName());
			this.customerInfoPanel.buildVipGradeLabel().setText(
					vipVo.getVipCard().getVipLevel());
			this.customerInfoPanel.buildVipCardRestMnyLabel().setText(
					new Double(vipVo.getVipCard().getRestMoney()).toString());
			this.customerInfoPanel.buildVipScoresLabel().setText(
					new Integer(vipVo.getVipCard().getPoints()).toString());
			this.customerInfoPanel.buildVipPhoneLabel().setText(
					vipVo.getVipPhone());
		}
	}

	public VipVo getVipVo() {
		return vipVo;
	}

	public OrderVo getOrderVo() {
		return orderVo;
	}

	public OrderVo formOrderVo() {
		orderVo.setOrderItemVector(itemVector);
		if(vipVo != null){
			orderVo.setCustomerId(vipVo.getVipCard().getVipId());
		}else{
			orderVo.setCustomerId(0);
		}		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd");
		String takeDate = this.buildTakeDateCmbBox().getSelectedItem().toString();
		int takedate = Integer.parseInt(takeDate.substring(0, 4) +  
				takeDate.substring(5, 7)+takeDate.substring(8));
		int today = Integer.parseInt(sdf.format(new Date()).substring(0, 4) +  
				sdf.format(new Date()).substring(5, 7)+sdf.format(new Date()).substring(8));
		if(takedate < today){
			JOptionPane.showMessageDialog(null, "新取衣日期必须大于当前日期,今天是"+sdf.format(new Date()));
			return null;
		}
		orderVo.setGetClothesDate(sdf.format(new Date()));
		orderVo.setOrderValue(Double.parseDouble(this.buildMoneyLabel()
				.getText()));
		if(orderVo.getOrderValue() >= 10000){
			JOptionPane.showMessageDialog(
					null,"单个洗衣单总额不能大于等于10000");
			return null;
		}
		orderVo.setTakeClothesDate(this.buildTakeDateCmbBox().getSelectedItem()
				.toString());
		orderVo.setPaidOrNot(false);
		orderVo.setTakeOrNot(false);
		orderVo.setOperatorName(MainFrame.getOperatorName());
		return orderVo;
	}

	public void clearAllContent() {
		this.customerCardIdTxField.setText(null);

		this.customerInfoPanel.buildVipCardIdLabel().setText(null);
		this.customerInfoPanel.buildVipCardRestMnyLabel().setText(null);
		this.customerInfoPanel.buildVipGradeLabel().setText(null);
		this.customerInfoPanel.buildVipNameLabel().setText(null);
		this.customerInfoPanel.buildVipPhoneLabel().setText(null);
		this.customerInfoPanel.buildVipScoresLabel().setText(null);

		DefaultTableModel tableModel = (DefaultTableModel) buyingClothesTable
				.getModel();
		int rowCount = buyingClothesTable.getRowCount();
		while (rowCount > 0) {
			tableModel.removeRow(0);
			rowCount--;
		}
		this.orderIdLabel.setText(null);
		this.moneyLabel.setText(null);
	}
}

⌨️ 快捷键说明

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