|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
// 定义包名,表明该类属于com.lingnan.supermarket.dialog包
|
|
|
|
|
package com.lingnan.supermarket.dialog;
|
|
|
|
|
|
|
|
|
|
// 导入必要的Java和Swing类库
|
|
|
|
|
import java.awt.Container;
|
|
|
|
|
import java.awt.FlowLayout;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
@ -18,6 +20,7 @@ import javax.swing.JPanel;
|
|
|
|
|
import javax.swing.JTable;
|
|
|
|
|
import javax.swing.JTextField;
|
|
|
|
|
|
|
|
|
|
// 导入项目相关的类和接口
|
|
|
|
|
import com.lingnan.supermarket.*;
|
|
|
|
|
import com.lingnan.supermarket.dao.UserService;
|
|
|
|
|
import com.lingnan.supermarket.dao.impl.BufferImpl;
|
|
|
|
@ -37,91 +40,128 @@ import com.lingnan.supermarket.view.HomeView;
|
|
|
|
|
import com.lingnan.supermarket.view.OutView;
|
|
|
|
|
import com.lingnan.supermarket.view.ProdCatalogView.MyItemListener;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 定义ChangeStatusDialog类,继承JDialog并实现ActionListener接口
|
|
|
|
|
public class ChangeStatusDialog extends JDialog implements ActionListener{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明面板、标签、按钮等组件
|
|
|
|
|
private JPanel statusPanel,opePanel,titlePanel,comboPanel;
|
|
|
|
|
private JLabel titleLabel,statusLabel;
|
|
|
|
|
private JButton UpdateBtn,cancelBtn;
|
|
|
|
|
|
|
|
|
|
// 声明字符串变量,用于存储订单编号和状态
|
|
|
|
|
private String iNumber;
|
|
|
|
|
private String status;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明一个Vector集合,用于存储InRecord对象
|
|
|
|
|
private Vector<InRecord> InRecords;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明一个JComboBox组件,用于显示订单状态选项
|
|
|
|
|
private JComboBox<String> combo;
|
|
|
|
|
|
|
|
|
|
// 声明一个字符串数组,用于存储订单状态选项
|
|
|
|
|
private String[] log = { "待入库", "已入库", "取消订单" };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明inRecordServiceImpl对象,用于操作入库记录
|
|
|
|
|
private inRecordServiceImpl inRecordImpl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明一个整数变量,用于存储分类信息
|
|
|
|
|
private int catalog;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 声明productionImpl对象,用于操作商品信息
|
|
|
|
|
private productionImpl productionImpl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构造方法,接收父窗口、订单编号和状态作为参数
|
|
|
|
|
public ChangeStatusDialog(JFrame parent,String iNumber,String status) {
|
|
|
|
|
// 调用父类构造方法,设置对话框标题
|
|
|
|
|
super(parent,"修改进货订单状态");
|
|
|
|
|
|
|
|
|
|
setSize(400,200);
|
|
|
|
|
setLocationRelativeTo(null);
|
|
|
|
|
|
|
|
|
|
// 设置对话框大小
|
|
|
|
|
setSize(400,200);
|
|
|
|
|
// 设置对话框在屏幕中央显示
|
|
|
|
|
setLocationRelativeTo(null);
|
|
|
|
|
// 设置对话框为模态
|
|
|
|
|
setModal(true);
|
|
|
|
|
setResizable(false);
|
|
|
|
|
// 设置对话框不可调整大小
|
|
|
|
|
setResizable(false);
|
|
|
|
|
// 设置对话框布局为FlowLayout
|
|
|
|
|
this.setLayout(new FlowLayout());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化成员变量
|
|
|
|
|
this.iNumber=iNumber;
|
|
|
|
|
this.status=status;
|
|
|
|
|
// 初始化视图
|
|
|
|
|
initView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化视图的私有方法
|
|
|
|
|
private void initView() {
|
|
|
|
|
|
|
|
|
|
// 创建标题面板
|
|
|
|
|
titlePanel = new JPanel();
|
|
|
|
|
// 创建标题标签,显示订单编号
|
|
|
|
|
titleLabel = new JLabel("修改订单为"+iNumber+"的状态");
|
|
|
|
|
// 将标题标签添加到标题面板
|
|
|
|
|
titlePanel.add(titleLabel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建状态面板
|
|
|
|
|
statusPanel = new JPanel();
|
|
|
|
|
// 创建状态标签,显示当前状态
|
|
|
|
|
statusLabel = new JLabel("当前状态:"+status);
|
|
|
|
|
// 将状态标签添加到状态面板
|
|
|
|
|
statusPanel.add(statusLabel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建组合框面板
|
|
|
|
|
comboPanel = new JPanel();
|
|
|
|
|
// 创建组合框,用于选择订单状态
|
|
|
|
|
combo = new JComboBox<String>(log);/*下拉表*/
|
|
|
|
|
// 为组合框添加项目监听器
|
|
|
|
|
combo.addItemListener(new MyItemListener());
|
|
|
|
|
// 将组合框添加到组合框面板
|
|
|
|
|
comboPanel.add(combo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建操作面板
|
|
|
|
|
opePanel = new JPanel();
|
|
|
|
|
// 创建更新按钮
|
|
|
|
|
UpdateBtn = new JButton("更改");
|
|
|
|
|
// 创建取消按钮
|
|
|
|
|
cancelBtn = new JButton("取消");
|
|
|
|
|
// 为更新按钮添加动作监听器
|
|
|
|
|
UpdateBtn.addActionListener(this);
|
|
|
|
|
// 为取消按钮添加动作监听器
|
|
|
|
|
cancelBtn.addActionListener(this);
|
|
|
|
|
// 将按钮添加到操作面板
|
|
|
|
|
opePanel.add(UpdateBtn);
|
|
|
|
|
opePanel.add(cancelBtn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取内容面板
|
|
|
|
|
Container container = getContentPane();
|
|
|
|
|
// 将标题面板添加到内容面板的北部
|
|
|
|
|
container.add(titlePanel,"North");
|
|
|
|
|
// 将状态面板添加到内容面板的中央
|
|
|
|
|
container.add(statusPanel,"Center");
|
|
|
|
|
// 将组合框面板添加到内容面板的南部
|
|
|
|
|
container.add(comboPanel,"South");
|
|
|
|
|
// 将操作面板添加到内容面板
|
|
|
|
|
container.add(opePanel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 内部类,实现ItemListener接口,用于监听组合框项目变化
|
|
|
|
|
public class MyItemListener implements ItemListener {
|
|
|
|
|
|
|
|
|
|
// 重写itemStateChanged方法,当组合框项目变化时调用
|
|
|
|
|
@Override
|
|
|
|
|
public void itemStateChanged(ItemEvent e) {
|
|
|
|
|
// 获取触发事件的组合框
|
|
|
|
|
JComboBox cb = (JComboBox) e.getSource();
|
|
|
|
|
// 获取选中的项目
|
|
|
|
|
String catalog1 = (String) cb.getSelectedItem();
|
|
|
|
|
// 根据选中的项目设置分类变量
|
|
|
|
|
if (catalog1.equals("已入库")) {
|
|
|
|
|
catalog = 1;
|
|
|
|
|
}
|
|
|
|
@ -129,56 +169,143 @@ public class ChangeStatusDialog extends JDialog implements ActionListener{
|
|
|
|
|
catalog = 2;
|
|
|
|
|
} else if (catalog1.equals("取消订单")) {
|
|
|
|
|
catalog = 3;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 公共方法,返回InRecords向量
|
|
|
|
|
public Vector<InRecord> getVector(){
|
|
|
|
|
// 返回InRecords向量
|
|
|
|
|
return InRecords;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 重写ActionListener接口的actionPerformed方法,用于处理按钮点击事件
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
// 获取事件源对象
|
|
|
|
|
Object source = e.getSource();
|
|
|
|
|
// 如果事件源是更新按钮
|
|
|
|
|
if(source==UpdateBtn){
|
|
|
|
|
// 打印当前分类变量的值
|
|
|
|
|
System.out.println("此时此刻的catalog为"+catalog);
|
|
|
|
|
//这里修改进货订单表的状态*/
|
|
|
|
|
// 这里修改进货订单表的状态
|
|
|
|
|
inOrderServiceImpl inOrderImpl = new inOrderServiceImpl();
|
|
|
|
|
inRecordServiceImpl inRecordImpl = new inRecordServiceImpl();
|
|
|
|
|
storageRecordImpl storageRecordImpl = new storageRecordImpl();
|
|
|
|
|
productionImpl = new productionImpl();
|
|
|
|
|
Production p ;
|
|
|
|
|
//获得订单信息
|
|
|
|
|
|
|
|
|
|
//修改状态
|
|
|
|
|
// 获得订单信息
|
|
|
|
|
|
|
|
|
|
// 修改订单状态
|
|
|
|
|
inOrderImpl.updateInOrderStatus(iNumber,catalog);
|
|
|
|
|
//确认进货,修改状态并对库存和库存日志修改
|
|
|
|
|
// 确认进货,修改状态并对库存和库存日志进行修改
|
|
|
|
|
if(catalog==1) {
|
|
|
|
|
//获得订单详细信息
|
|
|
|
|
// 获得订单详细信息
|
|
|
|
|
this.InRecords = inRecordImpl.findByIdinRecord(iNumber);
|
|
|
|
|
//遍历添加库存
|
|
|
|
|
// 遍历订单详细信息,添加库存
|
|
|
|
|
String s[]=TimeAndOrder.TimeAndOrder("");/*生成时间*/
|
|
|
|
|
for(InRecord i:InRecords) {
|
|
|
|
|
//查找到原来的价格
|
|
|
|
|
//更新库存表
|
|
|
|
|
productionImpl.updateProductionSum(i.getId(),i.getSum());
|
|
|
|
|
//增加库存日志表
|
|
|
|
|
// 查找到原来的价格
|
|
|
|
|
// 更新库存表
|
|
|
|
|
productionImpl.updateProductionSum(i.getId(),i.getSum());
|
|
|
|
|
// 增加库存日志表记录
|
|
|
|
|
storageRecordImpl.insertStorageRecord(iNumber,s[1], i.getId(),"+", i.getSum());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 弹出订单确认和库存更新成功的提示对话框
|
|
|
|
|
JOptionPane.showMessageDialog(this,"订单已确认,库存更新成功","提示",JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
/*刷新首页*/
|
|
|
|
|
}
|
|
|
|
|
// 刷新首页
|
|
|
|
|
this.dispose();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 如果事件源是取消按钮
|
|
|
|
|
else if(source == cancelBtn) {
|
|
|
|
|
|
|
|
|
|
// 关闭对话框
|
|
|
|
|
this.dispose();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|