|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
|
|
package com.lingnan.supermarket.view;
|
|
|
|
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
@ -28,195 +29,209 @@ import com.lingnan.supermarket.table.*;
|
|
|
|
|
import com.lingnan.supermarket.utils.FontUtil;
|
|
|
|
|
import com.lingnan.supermarket.utils.TimeAndOrder;
|
|
|
|
|
|
|
|
|
|
public class OutView extends JPanel implements ActionListener{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//上面
|
|
|
|
|
public class OutView extends JPanel implements ActionListener {
|
|
|
|
|
|
|
|
|
|
// 声明工具栏相关组件
|
|
|
|
|
private JPanel toolBarPanel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明搜索区域相关组件
|
|
|
|
|
private JPanel searchPanel;
|
|
|
|
|
private JLabel nameLabel,locationLabel;
|
|
|
|
|
private JLabel nameLabel, locationLabel;
|
|
|
|
|
private JTextField nameSearchTF;
|
|
|
|
|
private JButton searchBtn,AccountBtn,exitBtn;
|
|
|
|
|
|
|
|
|
|
private JButton searchBtn, AccountBtn, exitBtn;
|
|
|
|
|
|
|
|
|
|
// 声明操作区域相关组件
|
|
|
|
|
private JPanel opePanel;
|
|
|
|
|
private JButton addBtn,updateBtn,deleteBtn,historyBtn,backBtn,detailBtn;
|
|
|
|
|
|
|
|
|
|
//中间
|
|
|
|
|
private JButton addBtn, updateBtn, deleteBtn, historyBtn, backBtn, detailBtn;
|
|
|
|
|
|
|
|
|
|
// 声明中间区域的表格显示相关组件
|
|
|
|
|
private JScrollPane tableScrollPane;
|
|
|
|
|
private JTable outTable;
|
|
|
|
|
|
|
|
|
|
//下面
|
|
|
|
|
private JPanel bottomPanel,bottomPanelLeft,bottomPanelRight;
|
|
|
|
|
private JLabel countInfoLabel,countInfoLabel2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明底部区域的相关组件
|
|
|
|
|
private JPanel bottomPanel, bottomPanelLeft, bottomPanelRight;
|
|
|
|
|
private JLabel countInfoLabel, countInfoLabel2;
|
|
|
|
|
|
|
|
|
|
// 声明业务数据相关变量
|
|
|
|
|
private Buffer Buffer;
|
|
|
|
|
private BufferImpl BufferImpl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明用于展示的数据集合
|
|
|
|
|
private Vector<Buffer> v;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明当前视图的 JFrame 和用户对象
|
|
|
|
|
private JFrame jFrame;
|
|
|
|
|
private User user;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明表格数据模型
|
|
|
|
|
private OutTableModel outTableModel = new OutTableModel();
|
|
|
|
|
|
|
|
|
|
private int mark;/*标记订单表和订单详情表*/
|
|
|
|
|
|
|
|
|
|
public OutView(JFrame jFrame,User user) {
|
|
|
|
|
|
|
|
|
|
// 标记订单表和订单详情表的区别
|
|
|
|
|
private int mark;
|
|
|
|
|
|
|
|
|
|
// 构造函数,初始化视图并设置 JFrame 和用户
|
|
|
|
|
public OutView(JFrame jFrame, User user) {
|
|
|
|
|
this.setLayout(new BorderLayout());
|
|
|
|
|
initView();
|
|
|
|
|
this.jFrame = jFrame;
|
|
|
|
|
this.user = user;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化视图组件
|
|
|
|
|
private void initView() {
|
|
|
|
|
|
|
|
|
|
toolBarPanel = new JPanel(new BorderLayout());
|
|
|
|
|
|
|
|
|
|
searchPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
|
|
|
|
|
|
|
|
|
// 初始化工具栏面板,使用边界布局
|
|
|
|
|
toolBarPanel = new JPanel(new BorderLayout());
|
|
|
|
|
|
|
|
|
|
// 初始化搜索面板,使用流式布局
|
|
|
|
|
searchPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
|
|
|
|
nameLabel = new JLabel("订单号");
|
|
|
|
|
nameSearchTF = new JTextField(20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化搜索按钮,并为其添加事件监听器
|
|
|
|
|
searchBtn = new JButton(new ImageIcon("static\\icon\\search.png"));
|
|
|
|
|
searchBtn.addActionListener(this);
|
|
|
|
|
locationLabel=new JLabel("当前位置>收银系统");
|
|
|
|
|
|
|
|
|
|
// 初始化当前位置标签
|
|
|
|
|
locationLabel = new JLabel("当前位置>收银系统");
|
|
|
|
|
locationLabel.setFont(new FontUtil().userFont);
|
|
|
|
|
locationLabel.setForeground(new Color(18, 150, 219));
|
|
|
|
|
|
|
|
|
|
opePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
|
|
|
addBtn =new JButton(new ImageIcon("static\\icon\\add.png"));
|
|
|
|
|
updateBtn =new JButton(new ImageIcon("static\\icon\\change.png"));
|
|
|
|
|
deleteBtn =new JButton(new ImageIcon("static\\icon\\delete.png"));
|
|
|
|
|
historyBtn =new JButton(new ImageIcon("static\\icon\\history.png"));
|
|
|
|
|
backBtn =new JButton(new ImageIcon("static\\icon\\back.png"));
|
|
|
|
|
|
|
|
|
|
// 初始化操作面板,使用流式布局
|
|
|
|
|
opePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
|
|
|
addBtn = new JButton(new ImageIcon("static\\icon\\add.png"));
|
|
|
|
|
updateBtn = new JButton(new ImageIcon("static\\icon\\change.png"));
|
|
|
|
|
deleteBtn = new JButton(new ImageIcon("static\\icon\\delete.png"));
|
|
|
|
|
historyBtn = new JButton(new ImageIcon("static\\icon\\history.png"));
|
|
|
|
|
backBtn = new JButton(new ImageIcon("static\\icon\\back.png"));
|
|
|
|
|
detailBtn = new JButton(new ImageIcon("static\\icon\\detail.png"));
|
|
|
|
|
backBtn.setVisible(false);/*在记录页面显示出来*/
|
|
|
|
|
detailBtn.setVisible(false);/*在订单详情页显示出来*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置后退和详情按钮默认不可见
|
|
|
|
|
backBtn.setVisible(false);
|
|
|
|
|
detailBtn.setVisible(false);
|
|
|
|
|
|
|
|
|
|
// 为按钮添加事件监听器
|
|
|
|
|
addBtn.addActionListener(this);
|
|
|
|
|
updateBtn.addActionListener(this);
|
|
|
|
|
deleteBtn.addActionListener(this);
|
|
|
|
|
// 为按钮添加事件监听器
|
|
|
|
|
historyBtn.addActionListener(this);
|
|
|
|
|
backBtn.addActionListener(this);
|
|
|
|
|
detailBtn.addActionListener(this);
|
|
|
|
|
|
|
|
|
|
opePanel.add(addBtn);
|
|
|
|
|
|
|
|
|
|
// 将按钮添加到操作面板中
|
|
|
|
|
opePanel.add(addBtn);
|
|
|
|
|
opePanel.add(backBtn);
|
|
|
|
|
opePanel.add(detailBtn);
|
|
|
|
|
opePanel.add(updateBtn);
|
|
|
|
|
opePanel.add(deleteBtn);
|
|
|
|
|
opePanel.add(historyBtn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将组件添加到搜索面板中
|
|
|
|
|
searchPanel.add(locationLabel);
|
|
|
|
|
searchPanel.add(nameLabel);
|
|
|
|
|
searchPanel.add(nameSearchTF);
|
|
|
|
|
searchPanel.add(searchBtn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolBarPanel.add(searchPanel,"West");
|
|
|
|
|
toolBarPanel.add(opePanel,"East");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//中间表格
|
|
|
|
|
|
|
|
|
|
// 将搜索面板和操作面板添加到工具栏面板中
|
|
|
|
|
toolBarPanel.add(searchPanel, "West");
|
|
|
|
|
toolBarPanel.add(opePanel, "East");
|
|
|
|
|
|
|
|
|
|
// 中间部分的表格
|
|
|
|
|
outTableModel = new OutTableModel();
|
|
|
|
|
outTableModel.allOutBuffer();/*查找所有购物车*/
|
|
|
|
|
outTableModel.allOutBuffer(); // 查找所有购物车
|
|
|
|
|
outTable = new JTable(outTableModel);
|
|
|
|
|
outTable.setFont(FontUtil.tableFont);
|
|
|
|
|
outTable.setRowHeight(50);
|
|
|
|
|
tableScrollPane = new JScrollPane(outTable);
|
|
|
|
|
|
|
|
|
|
//下面
|
|
|
|
|
outTable.setFont(FontUtil.tableFont); // 设置表格字体
|
|
|
|
|
outTable.setRowHeight(50); // 设置表格行高
|
|
|
|
|
tableScrollPane = new JScrollPane(outTable); // 创建带滚动条的表格面板
|
|
|
|
|
|
|
|
|
|
// 下部分区域
|
|
|
|
|
bottomPanelLeft = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
|
|
|
countInfoLabel = new JLabel("商品种类:"+outTableModel.getRowCount()+",总价:"+outTableModel.getAllPrice());
|
|
|
|
|
countInfoLabel = new JLabel("商品种类:" + outTableModel.getRowCount() + ", 总价:" + outTableModel.getAllPrice()); // 显示商品种类和总价
|
|
|
|
|
bottomPanelLeft.add(countInfoLabel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bottomPanelRight = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
|
|
|
|
AccountBtn =new JButton(new ImageIcon("static\\icon\\Account.png"));/*结账按钮*/
|
|
|
|
|
exitBtn =new JButton(new ImageIcon("static\\icon\\exit.png"));/*退出按钮*/
|
|
|
|
|
AccountBtn.addActionListener(this);
|
|
|
|
|
exitBtn.addActionListener(this);
|
|
|
|
|
bottomPanelRight.add(AccountBtn);
|
|
|
|
|
bottomPanelRight.add(exitBtn);
|
|
|
|
|
|
|
|
|
|
AccountBtn = new JButton(new ImageIcon("static\\icon\\Account.png")); // 创建结账按钮
|
|
|
|
|
exitBtn = new JButton(new ImageIcon("static\\icon\\exit.png")); // 创建退出按钮
|
|
|
|
|
AccountBtn.addActionListener(this); // 为结账按钮添加事件监听器
|
|
|
|
|
exitBtn.addActionListener(this); // 为退出按钮添加事件监听器
|
|
|
|
|
bottomPanelRight.add(AccountBtn); // 将结账按钮添加到右侧面板
|
|
|
|
|
bottomPanelRight.add(exitBtn); // 将退出按钮添加到右侧面板
|
|
|
|
|
|
|
|
|
|
// 创建底部面板并添加左右部分
|
|
|
|
|
bottomPanel = new JPanel(new BorderLayout());
|
|
|
|
|
bottomPanel.add(bottomPanelRight,"East");
|
|
|
|
|
bottomPanel.add(bottomPanelLeft,"West");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.add(toolBarPanel,"North");
|
|
|
|
|
this.add(tableScrollPane,"Center");/*将表格放到中间*/
|
|
|
|
|
/* this.add(bottomPanel,"South");*/
|
|
|
|
|
this.add(bottomPanel,"South");
|
|
|
|
|
|
|
|
|
|
bottomPanel.add(bottomPanelRight, "East");
|
|
|
|
|
bottomPanel.add(bottomPanelLeft, "West");
|
|
|
|
|
|
|
|
|
|
// 将工具栏、表格和底部面板添加到主面板
|
|
|
|
|
this.add(toolBarPanel, "North");
|
|
|
|
|
this.add(tableScrollPane, "Center"); // 将表格添加到中间
|
|
|
|
|
this.add(bottomPanel, "South"); // 将底部面板添加到底部
|
|
|
|
|
|
|
|
|
|
// 设置界面可见
|
|
|
|
|
setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//按钮组件隐藏
|
|
|
|
|
|
|
|
|
|
// 按钮组件隐藏,用于切换视图
|
|
|
|
|
public void OrderView() {
|
|
|
|
|
backBtn.setVisible(true);
|
|
|
|
|
detailBtn.setVisible(true);
|
|
|
|
|
updateBtn.setVisible(false);
|
|
|
|
|
deleteBtn.setVisible(true);
|
|
|
|
|
addBtn.setVisible(false);
|
|
|
|
|
historyBtn.setVisible(false);
|
|
|
|
|
backBtn.setVisible(true); // 显示返回按钮
|
|
|
|
|
detailBtn.setVisible(true); // 显示详情按钮
|
|
|
|
|
updateBtn.setVisible(false); // 隐藏更新按钮
|
|
|
|
|
deleteBtn.setVisible(true); // 显示删除按钮
|
|
|
|
|
addBtn.setVisible(false); // 隐藏添加按钮
|
|
|
|
|
historyBtn.setVisible(false); // 隐藏历史按钮
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//通过订单查找
|
|
|
|
|
|
|
|
|
|
// 通过订单号查找对应订单并更新显示
|
|
|
|
|
public void resultOfNumber(String oNumber) {
|
|
|
|
|
this.mark=1;
|
|
|
|
|
this.mark = 1; // 设置标记为订单详情
|
|
|
|
|
OutOrderTM outOrderTM = new OutOrderTM();
|
|
|
|
|
outOrderTM.resultOfNumber(oNumber);
|
|
|
|
|
outTable.setModel(outOrderTM);
|
|
|
|
|
bottomPanelLeft.removeAll();
|
|
|
|
|
countInfoLabel = new JLabel("共"+outOrderTM.getRowCount()+"条记录");
|
|
|
|
|
outOrderTM.resultOfNumber(oNumber); // 根据订单号查找订单
|
|
|
|
|
outTable.setModel(outOrderTM); // 更新表格模型
|
|
|
|
|
bottomPanelLeft.removeAll(); // 清空底部左侧面板
|
|
|
|
|
countInfoLabel = new JLabel("共" + outOrderTM.getRowCount() + "条记录"); // 显示记录条数
|
|
|
|
|
bottomPanelLeft.add(countInfoLabel);
|
|
|
|
|
OrderView();
|
|
|
|
|
OrderView(); // 切换到订单视图
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*刷新*/
|
|
|
|
|
|
|
|
|
|
// 刷新购物车数据
|
|
|
|
|
public void refreshOutBuffer() {
|
|
|
|
|
OutTableModel outTableModel = new OutTableModel();
|
|
|
|
|
outTableModel.allOutBuffer();
|
|
|
|
|
outTable.setModel(outTableModel);
|
|
|
|
|
bottomPanelLeft.removeAll();
|
|
|
|
|
countInfoLabel = new JLabel("商品种类:"+outTableModel.getRowCount()+",总价:"+outTableModel.getAllPrice());
|
|
|
|
|
outTableModel.allOutBuffer(); // 查询所有购物车
|
|
|
|
|
outTable.setModel(outTableModel); // 更新表格模型
|
|
|
|
|
bottomPanelLeft.removeAll(); // 清空底部左侧面板
|
|
|
|
|
countInfoLabel = new JLabel("商品种类:" + outTableModel.getRowCount() + ", 总价:" + outTableModel.getAllPrice()); // 显示商品种类和总价
|
|
|
|
|
bottomPanelLeft.add(countInfoLabel);
|
|
|
|
|
backBtn.setVisible(false);
|
|
|
|
|
detailBtn.setVisible(false);
|
|
|
|
|
historyBtn.setVisible(true);
|
|
|
|
|
updateBtn.setVisible(true);
|
|
|
|
|
addBtn.setVisible(true);
|
|
|
|
|
deleteBtn.setVisible(true);
|
|
|
|
|
backBtn.setVisible(false); // 隐藏返回按钮
|
|
|
|
|
detailBtn.setVisible(false); // 隐藏详情按钮
|
|
|
|
|
historyBtn.setVisible(true); // 显示历史按钮
|
|
|
|
|
updateBtn.setVisible(true); // 显示更新按钮
|
|
|
|
|
addBtn.setVisible(true); // 显示添加按钮
|
|
|
|
|
deleteBtn.setVisible(true); // 显示删除按钮
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*调出收银出货订单表*/
|
|
|
|
|
|
|
|
|
|
// 调出收银出货订单表
|
|
|
|
|
public void OutOrderRecord() {
|
|
|
|
|
this.mark=1;
|
|
|
|
|
this.mark = 1; // 设置标记为订单详情
|
|
|
|
|
OutOrderTM outOrderTM = new OutOrderTM();
|
|
|
|
|
outOrderTM.allOutOrderRecord();
|
|
|
|
|
outTable.setModel(outOrderTM);
|
|
|
|
|
bottomPanelLeft.removeAll();
|
|
|
|
|
countInfoLabel = new JLabel("共"+outOrderTM.getRowCount()+"条记录");
|
|
|
|
|
outOrderTM.allOutOrderRecord(); // 获取所有出货订单记录
|
|
|
|
|
outTable.setModel(outOrderTM); // 更新表格模型
|
|
|
|
|
bottomPanelLeft.removeAll(); // 清空底部左侧面板
|
|
|
|
|
countInfoLabel = new JLabel("共" + outOrderTM.getRowCount() + "条记录"); // 显示记录条数
|
|
|
|
|
bottomPanelLeft.add(countInfoLabel);
|
|
|
|
|
OrderView();
|
|
|
|
|
OrderView(); // 切换到订单视图
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理查看订单记录的逻辑
|
|
|
|
|
public void OutRecord(String oNumber) {
|
|
|
|
|
this.mark=0;
|
|
|
|
|
OutRecordTM outRecordTM = new OutRecordTM(oNumber);
|
|
|
|
|
outRecordTM.findOutRecordByINumber();
|
|
|
|
|
outTable.setModel(outRecordTM);
|
|
|
|
|
bottomPanelLeft.removeAll();
|
|
|
|
|
countInfoLabel = new JLabel("订单号@"+oNumber+"共有"+outRecordTM.getRowCount()+"条记录");
|
|
|
|
|
bottomPanelLeft.add(countInfoLabel);
|
|
|
|
|
this.mark = 0; // 设置标记为0,表示查看历史订单
|
|
|
|
|
OutRecordTM outRecordTM = new OutRecordTM(oNumber); // 创建OutRecordTM实例
|
|
|
|
|
outRecordTM.findOutRecordByINumber(); // 根据订单号查找订单记录
|
|
|
|
|
outTable.setModel(outRecordTM); // 更新表格模型为查询结果
|
|
|
|
|
bottomPanelLeft.removeAll(); // 清空底部左侧信息面板
|
|
|
|
|
countInfoLabel = new JLabel("订单号@" + oNumber + "共有" + outRecordTM.getRowCount() + "条记录"); // 显示订单记录数
|
|
|
|
|
bottomPanelLeft.add(countInfoLabel); // 将记录数标签添加到面板
|
|
|
|
|
// 设置按钮的可见性
|
|
|
|
|
backBtn.setVisible(true);
|
|
|
|
|
detailBtn.setVisible(false);
|
|
|
|
|
updateBtn.setVisible(false);
|
|
|
|
@ -224,115 +239,116 @@ public class OutView extends JPanel implements ActionListener{
|
|
|
|
|
historyBtn.setVisible(false);
|
|
|
|
|
deleteBtn.setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*按钮监听时间*/
|
|
|
|
|
// 按钮点击事件监听
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
BufferImpl = new BufferImpl();/*获得购物车*/
|
|
|
|
|
Object source = e.getSource();
|
|
|
|
|
|
|
|
|
|
if(searchBtn==source) {
|
|
|
|
|
String number = nameSearchTF.getText();
|
|
|
|
|
resultOfNumber(number);
|
|
|
|
|
BufferImpl = new BufferImpl(); // 获取购物车数据
|
|
|
|
|
Object source = e.getSource(); // 获取触发事件的源对象
|
|
|
|
|
|
|
|
|
|
// 搜索按钮点击事件
|
|
|
|
|
if (searchBtn == source) {
|
|
|
|
|
String number = nameSearchTF.getText(); // 获取输入的订单号
|
|
|
|
|
resultOfNumber(number); // 根据订单号查找对应订单
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(addBtn==source) {
|
|
|
|
|
OutDialog outDialog = new OutDialog(jFrame);
|
|
|
|
|
outDialog.setVisible(true);
|
|
|
|
|
refreshOutBuffer();
|
|
|
|
|
|
|
|
|
|
// 添加按钮点击事件
|
|
|
|
|
if (addBtn == source) {
|
|
|
|
|
OutDialog outDialog = new OutDialog(jFrame); // 创建并显示“添加”对话框
|
|
|
|
|
outDialog.setVisible(true);
|
|
|
|
|
refreshOutBuffer(); // 刷新购物车数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(updateBtn==source) {
|
|
|
|
|
int rowIndex = outTable.getSelectedRow();
|
|
|
|
|
if(rowIndex==-1) {
|
|
|
|
|
JOptionPane.showMessageDialog(this,"请选中一条进行更改数量");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String id =(String) outTable.getValueAt(rowIndex,0);
|
|
|
|
|
ChangeSumDialog changesumDialog = new ChangeSumDialog(jFrame,id,"Out");
|
|
|
|
|
changesumDialog.setVisible(true);
|
|
|
|
|
refreshOutBuffer();
|
|
|
|
|
|
|
|
|
|
// 更新按钮点击事件
|
|
|
|
|
else if (updateBtn == source) {
|
|
|
|
|
int rowIndex = outTable.getSelectedRow(); // 获取选中的行索引
|
|
|
|
|
if (rowIndex == -1) {
|
|
|
|
|
JOptionPane.showMessageDialog(this, "请选中一条进行更改数量");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String id = (String) outTable.getValueAt(rowIndex, 0); // 获取选中行的ID
|
|
|
|
|
ChangeSumDialog changesumDialog = new ChangeSumDialog(jFrame, id, "Out"); // 创建并显示“更改数量”对话框
|
|
|
|
|
changesumDialog.setVisible(true);
|
|
|
|
|
refreshOutBuffer(); // 刷新购物车数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(deleteBtn==source) {
|
|
|
|
|
int rowIndex = outTable.getSelectedRow();
|
|
|
|
|
if(rowIndex==-1) {
|
|
|
|
|
JOptionPane.showMessageDialog(this,"请选中一条");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String id =(String) outTable.getValueAt(rowIndex,0);
|
|
|
|
|
int select = JOptionPane.showConfirmDialog(this,"是否删除id为"+id+"的记录","提示",JOptionPane.YES_NO_OPTION);
|
|
|
|
|
if(select==JOptionPane.YES_OPTION) {/*选择是*/
|
|
|
|
|
if(BufferImpl.DelOutBufferById(id)==true) {
|
|
|
|
|
JOptionPane.showMessageDialog(this,"删除成功","提示",JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
}else {
|
|
|
|
|
JOptionPane.showMessageDialog(this,"删除失败","提示",JOptionPane.ERROR_MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
refreshOutBuffer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if(historyBtn==source) {/*查看历史全部记录*/
|
|
|
|
|
OutOrderRecord();
|
|
|
|
|
}else if(backBtn==source) {/*历史记录中的返回按钮*/
|
|
|
|
|
System.out.println("outView中的mark="+mark);
|
|
|
|
|
if(mark==1) {
|
|
|
|
|
refreshOutBuffer();
|
|
|
|
|
}else if(mark==0) {
|
|
|
|
|
OutOrderRecord();
|
|
|
|
|
|
|
|
|
|
// 删除按钮点击事件
|
|
|
|
|
else if (deleteBtn == source) {
|
|
|
|
|
int rowIndex = outTable.getSelectedRow(); // 获取选中的行索引
|
|
|
|
|
if (rowIndex == -1) {
|
|
|
|
|
JOptionPane.showMessageDialog(this, "请选中一条");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String id = (String) outTable.getValueAt(rowIndex, 0); // 获取选中行的ID
|
|
|
|
|
int select = JOptionPane.showConfirmDialog(this, "是否删除id为" + id + "的记录", "提示", JOptionPane.YES_NO_OPTION);
|
|
|
|
|
if (select == JOptionPane.YES_OPTION) { // 如果选择“是”
|
|
|
|
|
if (BufferImpl.DelOutBufferById(id) == true) { // 删除购物车中的记录
|
|
|
|
|
JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
} else {
|
|
|
|
|
JOptionPane.showMessageDialog(this, "删除失败", "提示", JOptionPane.ERROR_MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
refreshOutBuffer(); // 刷新购物车数据
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查看历史记录按钮点击事件
|
|
|
|
|
else if (historyBtn == source) {
|
|
|
|
|
OutOrderRecord(); // 查看出货历史订单记录
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 返回按钮点击事件
|
|
|
|
|
else if (backBtn == source) {
|
|
|
|
|
System.out.println("outView中的mark=" + mark);
|
|
|
|
|
if (mark == 1) {
|
|
|
|
|
refreshOutBuffer(); // 刷新购物车数据
|
|
|
|
|
} else if (mark == 0) {
|
|
|
|
|
OutOrderRecord(); // 刷新出货历史记录
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else if(detailBtn==source) {/*查看订单详细*/
|
|
|
|
|
|
|
|
|
|
int rowIndex = outTable.getSelectedRow();
|
|
|
|
|
if(rowIndex==-1) {
|
|
|
|
|
JOptionPane.showMessageDialog(this,"请选中一条查看订单详细信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查看订单详情按钮点击事件
|
|
|
|
|
else if (detailBtn == source) {
|
|
|
|
|
int rowIndex = outTable.getSelectedRow(); // 获取选中的行索引
|
|
|
|
|
if (rowIndex == -1) {
|
|
|
|
|
JOptionPane.showMessageDialog(this, "请选中一条查看订单详细信息");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String oNumber =(String) outTable.getValueAt(rowIndex,0);
|
|
|
|
|
System.out.println("详情订单号为="+oNumber);
|
|
|
|
|
OutRecord(oNumber);
|
|
|
|
|
String oNumber = (String) outTable.getValueAt(rowIndex, 0); // 获取订单号
|
|
|
|
|
System.out.println("详情订单号为=" + oNumber);
|
|
|
|
|
OutRecord(oNumber); // 查看订单详情
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else if(AccountBtn==source) {/*结账*/
|
|
|
|
|
refreshOutBuffer();
|
|
|
|
|
v = BufferImpl.allOutBuffer();
|
|
|
|
|
if(v.size()==0)/*购物车为空*/{
|
|
|
|
|
JOptionPane.showMessageDialog(null,"您的购物车为空", "提示", JOptionPane.YES_OPTION);
|
|
|
|
|
}
|
|
|
|
|
else {/*购物车不为空*/
|
|
|
|
|
int res = JOptionPane.showConfirmDialog(null,"总金额:"+outTableModel.getAllPrice()+"元\r\n是否已经结账", "结账", JOptionPane.YES_NO_OPTION);
|
|
|
|
|
if(res==JOptionPane.YES_OPTION)/*如果已经结账*/{
|
|
|
|
|
|
|
|
|
|
String[] s =TimeAndOrder.TimeAndOrder(user.getUsername());/*获得时间和订单号*/
|
|
|
|
|
|
|
|
|
|
BufferImpl.InsertOutOrder(s[0],outTableModel.getAllPrice(), s[1], user.getUsername());/*往订单表插入一条记录*/
|
|
|
|
|
for(int i=0;i<v.size();i++) {
|
|
|
|
|
Buffer = v.elementAt(i);
|
|
|
|
|
BufferImpl.Account(s[0],s[1],Buffer.getId(),Buffer.getSum(),Buffer.getPrice());/*调用结账存储过程*/
|
|
|
|
|
}
|
|
|
|
|
refreshOutBuffer();/*刷新所有购物车*/
|
|
|
|
|
HomeView.refreshHome();/*刷新首页*/
|
|
|
|
|
JOptionPane.showConfirmDialog(null,"支付成功\r\n订单号:"+s[0]+"\r\n负责人:"+user.getUsername(), "提示", JOptionPane.YES_OPTION);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 结账按钮点击事件
|
|
|
|
|
else if (AccountBtn == source) {
|
|
|
|
|
refreshOutBuffer(); // 刷新购物车数据
|
|
|
|
|
v = BufferImpl.allOutBuffer(); // 获取购物车中的所有商品
|
|
|
|
|
if (v.size() == 0) { // 如果购物车为空
|
|
|
|
|
JOptionPane.showMessageDialog(null, "您的购物车为空", "提示", JOptionPane.YES_OPTION);
|
|
|
|
|
} else { // 如果购物车不为空
|
|
|
|
|
int res = JOptionPane.showConfirmDialog(null, "总金额:" + outTableModel.getAllPrice() + "元\r\n是否已经结账", "结账", JOptionPane.YES_NO_OPTION);
|
|
|
|
|
if (res == JOptionPane.YES_OPTION) { // 如果选择“已结账”
|
|
|
|
|
String[] s = TimeAndOrder.TimeAndOrder(user.getUsername()); // 获取时间和订单号
|
|
|
|
|
BufferImpl.InsertOutOrder(s[0], outTableModel.getAllPrice(), s[1], user.getUsername()); // 插入订单记录
|
|
|
|
|
for (int i = 0; i < v.size(); i++) {
|
|
|
|
|
Buffer = v.elementAt(i);
|
|
|
|
|
BufferImpl.Account(s[0], s[1], Buffer.getId(), Buffer.getSum(), Buffer.getPrice()); // 调用结账存储过程
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else if(exitBtn==source) {
|
|
|
|
|
refreshOutBuffer();
|
|
|
|
|
int res = JOptionPane.showConfirmDialog(null,"确定退出并清空购物车吗", "结账", JOptionPane.YES_NO_OPTION);
|
|
|
|
|
if(res==JOptionPane.YES_OPTION)/*如果已经结账*/{
|
|
|
|
|
BufferImpl.DelAllOutBuffer();
|
|
|
|
|
refreshOutBuffer();/*刷新所有购物车*/
|
|
|
|
|
JOptionPane.showConfirmDialog(null,"退出成功", "提示", JOptionPane.PLAIN_MESSAGE);
|
|
|
|
|
refreshOutBuffer(); // 刷新购物车数据
|
|
|
|
|
HomeView.refreshHome(); // 刷新首页
|
|
|
|
|
JOptionPane.showConfirmDialog(null, "支付成功\r\n订单号:" + s[0] + "\r\n负责人:" + user.getUsername(), "提示", JOptionPane.YES_OPTION);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 退出按钮点击事件
|
|
|
|
|
else if (exitBtn == source) {
|
|
|
|
|
refreshOutBuffer(); // 刷新购物车数据
|
|
|
|
|
int res = JOptionPane.showConfirmDialog(null, "确定退出并清空购物车吗", "结账", JOptionPane.YES_NO_OPTION);
|
|
|
|
|
if (res == JOptionPane.YES_OPTION) { // 如果选择“是”
|
|
|
|
|
BufferImpl.DelAllOutBuffer(); // 清空购物车
|
|
|
|
|
refreshOutBuffer(); // 刷新购物车数据
|
|
|
|
|
JOptionPane.showConfirmDialog(null, "退出成功", "提示", JOptionPane.PLAIN_MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|