📄 rewashpanel.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.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import view.common.DataPicker;
import view.frame.MainFrame;
import vo.OrderItemVo;
import vo.OrderVo;
import vo.RewashVo;
import vo.VipVo;
public class RewashPanel extends JPanel {
private JLabel headerLabel, vipCardIdLabel, vipNameLabel,
vipCardRestMnyLabel, takeClthDateLabel, neededMoneyLb, ifPaidLabel;
private JScrollPane buyingClothesTableScrollPane;
private JTable buyingClothesTable;
private String[] tableHeaders = { "衣服名称", "服务类型", "品牌", "衣服附件", "衣服瑕疵",
"颜色", "折后价", "数量", "总额", "衣服备注" };
private JButton okBtn, cancelBtn;
private JTextField newDateTxFld;
private DataPicker picker = new DataPicker();
private JComboBox newTakeDateCmbBox;
private OrderVo orderVo;
private VipVo vipVo;
public RewashPanel() {
this.setLayout(new GridLayout(2, 1));
JPanel panelOne = new JPanel();
panelOne.setLayout(new BorderLayout());
panelOne.add(buildVipInfoPanel());
panelOne.add(buildNewDatePanel(), BorderLayout.SOUTH);
JPanel panelTwo = new JPanel();
panelTwo.setLayout(new BorderLayout());
panelTwo.add(buildBuyingClothesTableScrollPane());
panelTwo.add(buildBtnPanel(), BorderLayout.SOUTH);
this.add(panelOne);
this.add(panelTwo);
}
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 buildNewDatePanel() {
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
JPanel panelTwo = new JPanel();
panelTwo.setLayout(new GridLayout(1, 2));
panelTwo.add(buildLabel("新取衣日期:"));
panelTwo.add(buildNewTakeDateCmbBox());
panel.add(panelTwo);
return panel;
}
public JComboBox buildNewTakeDateCmbBox() {
if (newTakeDateCmbBox == null) {
newTakeDateCmbBox = picker.getDataPacker();
}
return newTakeDateCmbBox;
}
public JPanel buildBtnPanel() {
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.add(buildOkBtn());
panel.add(buildCancelBtn());
return panel;
}
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) {
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());
}
if(vipVo == null){
this.buildVipNameLabel().setText("无卡客户");
}
this.buildHeaderLb().setText(
"洗衣单号" + new Long(orderVo.getOrderId()).toString());
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);
}
}
public OrderVo getOrderVo() {
return this.orderVo;
}
public VipVo getVipVo() {
return this.vipVo;
}
public RewashVo getRewashVo() {
long orderId = orderVo.getOrderId();
String originalTakeDate = orderVo.getTakeClothesDate();
String newTakeDate = this.newTakeDateCmbBox.getSelectedItem()
.toString();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd");
String requireRewashDate = sdf.format(new Date());
int newtakedate = Integer.parseInt(newTakeDate.substring(0, 4) +
newTakeDate.substring(5, 7)+newTakeDate.substring(8));
int today = Integer.parseInt(requireRewashDate.substring(0, 4) +
requireRewashDate.substring(5, 7)+requireRewashDate.substring(8));
if(newtakedate < today){
JOptionPane.showMessageDialog(null, "新取衣日期必须大于当前日期,今天是"+requireRewashDate);
return null;
}
String operatorName = MainFrame.getOperatorName();
return new RewashVo(orderId, originalTakeDate,newTakeDate,
requireRewashDate,operatorName);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -