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

📄 refundpanel.java

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

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Vector;

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

import vo.OperatorVo;
import vo.OrderItemVo;
import vo.OrderVo;
import vo.RefundmentVo;
import vo.VipVo;

public class RefundPanel extends JPanel {
	private JLabel headerLabel, vipCardIdLabel, vipNameLabel,
			vipCardRestMnyLabel, takeClthDateLabel, neededMoneyLb, ifPaidLabel;
	private JScrollPane buyingClothesTableScrollPane;
	private JTable buyingClothesTable;
	private String[] tableHeaders = { "衣服名称", "服务类型", "品牌", "衣服附件", "衣服瑕疵",
			"颜色", "折后价", "数量", "总额", "衣服备注" };
	private JTextField moneyTxFld;
	private JButton okBtn, cancelBtn;
	private JTextArea reasonTextArea;
	private JComboBox operatorComBox;
	private JPasswordField operatorPswFld;
	private OrderVo orderVo;
	private VipVo vipVo;

	public RefundPanel() {
		this.setLayout(new BorderLayout());

		JPanel panel = new JPanel();
		panel.setLayout(new GridLayout(3, 1));
		panel.add(buildVipInfoPanel());
		panel.add(buildBuyingClothesTableScrollPane());
		panel.add(buildRefundInfoPanel());

		this.add(panel);
		this.add(buildBtnPanel(), BorderLayout.SOUTH);
	}

	public JPanel buildVipInfoPanel() {
		JPanel panel = new JPanel();
		panel.setLayout(new BorderLayout());
		panel.add(buildHeaderPanel(), BorderLayout.NORTH);
		panel.add(buildDetailPanel());
		return panel;
	}

	public JPanel buildHeaderPanel() {
		JPanel panel = new JPanel();
		panel.add(buildHeaderLb());
		return panel;
	}

	public JLabel buildHeaderLb() {
		if (headerLabel == null) {
			headerLabel = new JLabel("取衣单号");
			headerLabel.setFont(new Font("", Font.BOLD, 20));
		}
		return headerLabel;
	}

	public JPanel buildDetailPanel() {
		JPanel panel = new JPanel();
		panel.setLayout(new GridLayout(2, 6));
		panel.add(buildLabel("会员卡号:"));
		panel.add(buildVipCardIdLabel());
		panel.add(buildLabel("会员姓名:"));
		panel.add(buildVipNameLabel());
		panel.add(buildLabel("卡内余额:"));
		panel.add(buildVipCardRestMnyLabel());
		panel.add(buildLabel("预取日期:"));
		panel.add(buildTakeClthDateLabel());
		panel.add(buildLabel("应收金额:"));
		panel.add(buildNeededMoneyLb());
		panel.add(buildLabel("是否付费:"));
		panel.add(buildIfPaidLabel());
		return panel;
	}

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

	public JLabel buildVipCardIdLabel() {
		if (vipCardIdLabel == null) {
			vipCardIdLabel = new JLabel();
		}
		return vipCardIdLabel;
	}

	public JLabel buildVipNameLabel() {
		if (vipNameLabel == null) {
			vipNameLabel = new JLabel();
		}
		return vipNameLabel;
	}

	public JLabel buildTakeClthDateLabel() {
		if (takeClthDateLabel == null) {
			takeClthDateLabel = new JLabel();
		}
		return takeClthDateLabel;
	}

	public JLabel buildVipCardRestMnyLabel() {
		if (vipCardRestMnyLabel == null) {
			vipCardRestMnyLabel = new JLabel();
		}
		return vipCardRestMnyLabel;
	}

	public JLabel buildNeededMoneyLb() {
		if (neededMoneyLb == null) {
			neededMoneyLb = new JLabel();
		}
		return neededMoneyLb;
	}

	public JLabel buildIfPaidLabel() {
		if (ifPaidLabel == null) {
			ifPaidLabel = new JLabel();
		}
		return ifPaidLabel;
	}

	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 buildRefundInfoPanel() {
		JPanel panel = new JPanel();
		panel.setLayout(new BorderLayout());
		panel.add(buildMoneyPanel(), BorderLayout.NORTH);
		panel.add(buildReasonPanel(), BorderLayout.CENTER);
		panel.add(buildOperatorInfoPanel(), BorderLayout.SOUTH);
		return panel;
	}

	public JPanel buildMoneyPanel() {
		JPanel panel = new JPanel();
		panel.setLayout(new FlowLayout(FlowLayout.LEFT));

		JPanel pl = new JPanel();
		pl.setLayout(new GridLayout(1, 2));
		pl.add(buildLabel("赔偿金额: "));
		pl.add(buildMoneyTxFld());
		panel.add(pl);
		return panel;
	}

	public JTextField buildMoneyTxFld() {
		if (moneyTxFld == null) {
			moneyTxFld = new JTextField();
		}
		return moneyTxFld;
	}

	public JPanel buildReasonPanel() {
		JPanel panel = new JPanel();
		panel.setLayout(new FlowLayout(FlowLayout.LEFT));
		JLabel label = buildLabel("赔偿理由:");
		label.setVerticalAlignment(JLabel.TOP);
		panel.add(label);
		panel.add(buildReasonTextArea());
		return panel;
	}

	public JTextArea buildReasonTextArea() {
		if (reasonTextArea == null) {
			reasonTextArea = new JTextArea(3, 40);
			reasonTextArea.setLineWrap(true);
		}
		return reasonTextArea;
	}

	public JPanel buildOperatorInfoPanel() {
		JPanel panel = new JPanel();
		panel.setLayout(new FlowLayout(FlowLayout.LEFT));

		JPanel panelOne = new JPanel();
		panelOne.setLayout(new GridLayout(1, 2));
		panelOne.add(buildLabel("操作员:     "));
		panelOne.add(buildOperatorComBox());

		JPanel panelTwo = new JPanel();
		panelTwo.setLayout(new GridLayout(1, 2));
		panelTwo.add(buildLabel("                         密码:"));
		panelTwo.add(buildOperatorPswFld());

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

	public JComboBox buildOperatorComBox() {
		if (operatorComBox == null) {
			operatorComBox = new JComboBox();
		}
		return operatorComBox;
	}

	public JPanel buildBtnPanel() {
		JPanel panel = new JPanel();
		panel.setLayout(new FlowLayout());
		panel.add(buildOkBtn());
		panel.add(buildCancelBtn());
		return panel;
	}

	public JPasswordField buildOperatorPswFld() {
		if (operatorPswFld == null) {
			operatorPswFld = new JPasswordField();
		}
		return operatorPswFld;
	}

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

	public JButton buildCancelBtn() {
		if (cancelBtn == null) {
			cancelBtn = new JButton("取消");
		}
		return cancelBtn;
	}

	public void initiallize(OrderVo iniOrderVo, VipVo iniVipVo,
			Vector operNameVector) {
		this.orderVo = iniOrderVo;
		this.vipVo = iniVipVo;
		if (orderVo == null) {
			return;
		}
		if (vipVo != null) {
			this.buildVipNameLabel().setText(vipVo.getVipName());
			this.buildVipCardRestMnyLabel().setText(
					new Double(vipVo.getVipCard().getRestMoney()).toString());
		}
		this.buildHeaderLb().setText(
				"洗衣单号" + new Long(orderVo.getOrderId()).toString());
		if (vipVo == null) {
			this.buildVipNameLabel().setText("无卡客户");
		}
		this.buildVipCardIdLabel().setText(
				new Integer(orderVo.getCustomerId()).toString());
		this.buildTakeClthDateLabel().setText(orderVo.getTakeClothesDate());
		this.buildNeededMoneyLb().setText(
				new Double(orderVo.getOrderValue()).toString());
		this.buildIfPaidLabel().setText(orderVo.isPaidOrNot() ? "是" : "否");

		Vector itemVector = null;
		itemVector = orderVo.getOrderItemVector();
		if (itemVector == null) {
			return;
		}
		DefaultTableModel itemModel = (DefaultTableModel) this
				.buildBuyingClothesTable().getModel();
		Iterator itItem = itemVector.iterator();
		while (itItem.hasNext()) {
			OrderItemVo item = (OrderItemVo) itItem.next();
			DecimalFormat format = new DecimalFormat("#0.0");
			Object[] rowContent = {
					item.getClothesType().getClothesName(),
					item.getClothesType().getServiceType(),
					item.getClothesBrand(),
					item.getAccessory(),
					item.getFlaw(),
					item.getColor(),
					new Double(format.format(item.getItemValue() / item.getClothesQuatity()))
							.toString(),
					new Integer(item.getClothesQuatity()).toString(),
					new Double(item.getItemValue()).toString(),
					item.getClothesAdditionInfo() };
			itemModel.addRow(rowContent);
		}
		this.setOperatorNameCmbBob(operNameVector);
	}

	public OrderVo getOrderVo() {
		return this.orderVo;
	}

	public VipVo getVipVo() {
		return this.vipVo;
	}

	public OperatorVo getOperatorVo() {
		String operatorName = this.buildOperatorComBox().getSelectedItem()
				.toString();
		String operatorPsw = String.valueOf(this.buildOperatorPswFld().getPassword());
		return new OperatorVo(0, operatorName, operatorPsw, null, null, null);
	}

	public RefundmentVo getRefundmentVo() throws NumberFormatException {
		long orderId = orderVo.getOrderId();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd");
		String refundDate = sdf.format(new Date());
		double refundAmount = Double.parseDouble(this.buildMoneyTxFld()
				.getText());
		String operatorName = this.buildOperatorComBox().getSelectedItem()
				.toString();
		String refundReason = this.buildReasonTextArea().getText();
		if (refundReason.equals("")) {
			JOptionPane.showMessageDialog(null, "您未填写赔偿理由");
			return null;
		}
		return new RefundmentVo(orderId, refundDate, refundAmount,
				refundReason, operatorName);
	}

	public void setOperatorNameCmbBob(Vector v) {
		if (v == null) {
			return;
		}
		Iterator it = v.iterator();
		while (it.hasNext()) {
			this.operatorComBox.addItem(it.next());
		}
	}
}

⌨️ 快捷键说明

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