|
|
|
@ -43,15 +43,29 @@ import com.lingnan.supermarket.utils.SendQQMailUtil;
|
|
|
|
|
import com.lingnan.supermarket.utils.TimeAndOrder;
|
|
|
|
|
import com.lingnan.supermarket.view.ProdCatalogView.MyItemListener;
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
public class InView extends JPanel implements ActionListener{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//上面
|
|
|
|
|
private JPanel toolBarPanel;
|
|
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
/**
|
|
|
|
|
* 用于显示进货系统的界面。
|
|
|
|
|
* 包含进货系统的各种操作按钮、搜索框、表格等组件。
|
|
|
|
|
*/
|
|
|
|
|
public class InView extends JPanel implements ActionListener {
|
|
|
|
|
|
|
|
|
|
// 顶部工具栏面板
|
|
|
|
|
private JPanel toolBarPanel;
|
|
|
|
|
|
|
|
|
|
// 搜索面板
|
|
|
|
|
>>>>>>> developer
|
|
|
|
|
private JPanel searchPanel;
|
|
|
|
|
private JLabel nameLabel,locationLabel;
|
|
|
|
|
private JTextField nameSearchTF;
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
private JButton searchBtn,StockBtn,exitBtn;
|
|
|
|
|
|
|
|
|
|
private JPanel opePanel;
|
|
|
|
@ -70,10 +84,35 @@ public class InView extends JPanel implements ActionListener{
|
|
|
|
|
|
|
|
|
|
private static Vector<Production> v = new Vector<Production>();
|
|
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
private JButton searchBtn, StockBtn, exitBtn;
|
|
|
|
|
|
|
|
|
|
// 操作面板
|
|
|
|
|
private JPanel opePanel;
|
|
|
|
|
private JButton addBtn, updateBtn, deleteBtn, historyBtn, backBtn, detailBtn;
|
|
|
|
|
|
|
|
|
|
// 中间表格区域
|
|
|
|
|
private JScrollPane tableScrollPane;
|
|
|
|
|
private JTable inTable;
|
|
|
|
|
|
|
|
|
|
// 底部面板
|
|
|
|
|
private JPanel bottomPanel, bottomPanelLeft, bottomPanelRight;
|
|
|
|
|
private JLabel countInfoLabel, countInfoLabel2;
|
|
|
|
|
|
|
|
|
|
// 缓冲区对象
|
|
|
|
|
private Buffer Buffer;
|
|
|
|
|
private BufferImpl BufferImpl;
|
|
|
|
|
|
|
|
|
|
// 商品向量
|
|
|
|
|
private static Vector<Production> v = new Vector<Production>();
|
|
|
|
|
|
|
|
|
|
// 状态下拉框
|
|
|
|
|
>>>>>>> developer
|
|
|
|
|
private JComboBox<String> combo;
|
|
|
|
|
private String[] status ={"全部","已入库","待入库","已取消"};
|
|
|
|
|
private int catalog;
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
private JFrame jFrame;
|
|
|
|
|
private User user;
|
|
|
|
|
|
|
|
|
@ -85,10 +124,30 @@ public class InView extends JPanel implements ActionListener{
|
|
|
|
|
|
|
|
|
|
private inOrderServiceImpl inOrderImpl;
|
|
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
// 主窗口和用户信息
|
|
|
|
|
private JFrame jFrame;
|
|
|
|
|
private User user;
|
|
|
|
|
|
|
|
|
|
// 表格模型
|
|
|
|
|
private InTableModel inTableModel;
|
|
|
|
|
|
|
|
|
|
// 缓冲区实现类
|
|
|
|
|
private BufferImpl bufferImpl = new BufferImpl();
|
|
|
|
|
|
|
|
|
|
// 标记从提醒那里来1是进货表,0是提醒过来的表
|
|
|
|
|
private int mark;
|
|
|
|
|
|
|
|
|
|
// 进货订单服务实现类
|
|
|
|
|
private inOrderServiceImpl inOrderImpl;
|
|
|
|
|
|
|
|
|
|
// 总价和行数
|
|
|
|
|
>>>>>>> developer
|
|
|
|
|
private Float allPrice;
|
|
|
|
|
private int row;
|
|
|
|
|
private String uname;
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
public InView(JFrame jFrame,User user,Vector<Production> v,int mark) {
|
|
|
|
|
this.setLayout(new BorderLayout());
|
|
|
|
|
this.jFrame = jFrame;
|
|
|
|
@ -224,10 +283,126 @@ public class InView extends JPanel implements ActionListener{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
//构造函数
|
|
|
|
|
|
|
|
|
|
public InView(JFrame jFrame, User user, Vector<Production> v, int mark) {
|
|
|
|
|
this.setLayout(new BorderLayout()); // 设置布局为BorderLayout
|
|
|
|
|
this.jFrame = jFrame; // 设置主窗口
|
|
|
|
|
this.user = user; // 设置用户信息
|
|
|
|
|
// 获得进货缓冲区的保存的货物并删除缓冲区
|
|
|
|
|
this.v = bufferImpl.allInBuffer(); // 从缓冲区获取商品数据
|
|
|
|
|
bufferImpl.DelAllInBuffer(); // 清空缓冲区
|
|
|
|
|
|
|
|
|
|
this.mark = mark; // 设置标记
|
|
|
|
|
System.out.println("mark=" + mark); // 打印标记值
|
|
|
|
|
uname = user.getUsername(); // 获取用户名
|
|
|
|
|
initView(); // 初始化界面
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化界面组件。
|
|
|
|
|
private void initView() {
|
|
|
|
|
toolBarPanel = new JPanel(new BorderLayout()); // 创建顶部工具栏面板
|
|
|
|
|
|
|
|
|
|
searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建搜索面板
|
|
|
|
|
nameLabel = new JLabel("订单号"); // 创建订单号标签
|
|
|
|
|
nameSearchTF = new JTextField(20); // 创建订单号搜索文本框
|
|
|
|
|
searchBtn = new JButton(new ImageIcon("static\\icon\\search.png")); // 创建搜索按钮
|
|
|
|
|
searchBtn.addActionListener(this); // 为搜索按钮添加事件监听器
|
|
|
|
|
locationLabel = new JLabel("当前位置>进货系统"); // 创建位置标签
|
|
|
|
|
locationLabel.setFont(new FontUtil().userFont); // 设置字体
|
|
|
|
|
locationLabel.setForeground(new Color(18, 150, 219)); // 设置颜色
|
|
|
|
|
|
|
|
|
|
combo = new JComboBox<String>(status); // 创建状态下拉框
|
|
|
|
|
combo.addItemListener(new MyItemListener()); // 为下拉框添加事件监听器
|
|
|
|
|
|
|
|
|
|
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")); // 创建详情按钮
|
|
|
|
|
|
|
|
|
|
addBtn.addActionListener(this); // 为添加按钮添加事件监听器
|
|
|
|
|
updateBtn.addActionListener(this); // 为更新按钮添加事件监听器
|
|
|
|
|
deleteBtn.addActionListener(this); // 为删除按钮添加事件监听器
|
|
|
|
|
historyBtn.addActionListener(this); // 为历史记录按钮添加事件监听器
|
|
|
|
|
backBtn.addActionListener(this); // 为返回按钮添加事件监听器
|
|
|
|
|
detailBtn.addActionListener(this); // 为详情按钮添加事件监听器
|
|
|
|
|
|
|
|
|
|
backBtn.setVisible(false); // 隐藏返回按钮
|
|
|
|
|
detailBtn.setVisible(false); // 隐藏详情按钮
|
|
|
|
|
|
|
|
|
|
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); // 添加搜索按钮到搜索面板
|
|
|
|
|
searchPanel.add(combo); // 添加状态下拉框到搜索面板
|
|
|
|
|
|
|
|
|
|
toolBarPanel.add(searchPanel, "West"); // 将搜索面板添加到工具栏面板的西侧
|
|
|
|
|
toolBarPanel.add(opePanel, "East"); // 将操作面板添加到工具栏面板的东侧
|
|
|
|
|
|
|
|
|
|
// 中间表
|
|
|
|
|
inTableModel = new InTableModel(v); // 创建表格模型
|
|
|
|
|
|
|
|
|
|
inTable = new JTable(inTableModel); // 创建表格
|
|
|
|
|
inTable.setFont(FontUtil.tableFont); // 设置表格字体
|
|
|
|
|
inTable.setRowHeight(50); // 设置表格行高
|
|
|
|
|
tableScrollPane = new JScrollPane(inTable); // 创建表格滚动面板
|
|
|
|
|
|
|
|
|
|
allPrice = inTableModel.getAllPrice(); // 获取总价
|
|
|
|
|
row = inTableModel.getRowCount(); // 获取行数
|
|
|
|
|
|
|
|
|
|
// 下面
|
|
|
|
|
bottomPanelLeft = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建底部左侧面板
|
|
|
|
|
countInfoLabel = new JLabel("商品种类:" + row + ",总价:" + allPrice); // 创建商品种类和总价标签
|
|
|
|
|
bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板
|
|
|
|
|
|
|
|
|
|
bottomPanelRight = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建底部右侧面板
|
|
|
|
|
StockBtn = new JButton(new ImageIcon("static\\icon\\stock.png")); // 创建结账按钮
|
|
|
|
|
exitBtn = new JButton(new ImageIcon("static\\icon\\exit.png")); // 创建退出按钮
|
|
|
|
|
StockBtn.addActionListener(this); // 为结账按钮添加事件监听器
|
|
|
|
|
exitBtn.addActionListener(this); // 为退出按钮添加事件监听器
|
|
|
|
|
bottomPanelRight.add(StockBtn); // 将结账按钮添加到底部右侧面板
|
|
|
|
|
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"); // 将底部面板添加到底部
|
|
|
|
|
|
|
|
|
|
if (mark == 1) { // 判断是否从提醒那里过来的
|
|
|
|
|
refreshBuffer(v); // 刷新缓冲区
|
|
|
|
|
} else if (mark == 0) {
|
|
|
|
|
InOrderRecord(); // 调出进货订单表
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setVisible(true); // 设置可见
|
|
|
|
|
}
|
|
|
|
|
//获取商品数量
|
|
|
|
|
public static Vector<Production> getVector() {
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理状态下拉框的选项变化
|
|
|
|
|
|
|
|
|
|
>>>>>>> developer
|
|
|
|
|
public class MyItemListener implements ItemListener {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void itemStateChanged(ItemEvent e) {
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
JComboBox cb = (JComboBox) e.getSource();
|
|
|
|
|
String catalog1 = (String) cb.getSelectedItem();
|
|
|
|
|
if(catalog1.equals("全部"))
|
|
|
|
@ -240,15 +415,31 @@ public class InView extends JPanel implements ActionListener{
|
|
|
|
|
catalog=3;
|
|
|
|
|
|
|
|
|
|
resultOfFindStatus(catalog);
|
|
|
|
|
=======
|
|
|
|
|
JComboBox cb = (JComboBox) e.getSource(); // 获取事件源
|
|
|
|
|
String catalog1 = (String) cb.getSelectedItem(); // 获取选中的状态
|
|
|
|
|
if (catalog1.equals("全部"))
|
|
|
|
|
catalog = 0;
|
|
|
|
|
else if (catalog1.equals("已入库"))
|
|
|
|
|
catalog = 1;
|
|
|
|
|
else if (catalog1.equals("待入库"))
|
|
|
|
|
catalog = 2;
|
|
|
|
|
else if (catalog1.equals("已取消"))
|
|
|
|
|
catalog = 3;
|
|
|
|
|
>>>>>>> developer
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//按钮组件隐藏
|
|
|
|
|
=======
|
|
|
|
|
//按钮组件隐藏。
|
|
|
|
|
>>>>>>> developer
|
|
|
|
|
public void OrderView() {
|
|
|
|
|
backBtn.setVisible(true);
|
|
|
|
|
detailBtn.setVisible(true);
|
|
|
|
@ -258,6 +449,7 @@ public class InView extends JPanel implements ActionListener{
|
|
|
|
|
historyBtn.setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
|
|
|
|
|
public void resultOfNumber(String iNumber) {
|
|
|
|
|
this.mark=0;
|
|
|
|
@ -270,6 +462,21 @@ public class InView extends JPanel implements ActionListener{
|
|
|
|
|
OrderView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
//根据订单号查询结果
|
|
|
|
|
public void resultOfNumber(String iNumber) {
|
|
|
|
|
this.mark = 0; // 设置标记为0
|
|
|
|
|
InOrderTM inOrderTM = new InOrderTM(); // 创建进货订单表格模型
|
|
|
|
|
inOrderTM.resultOfNumber(iNumber); // 根据订单号查询结果
|
|
|
|
|
inTable.setModel(inOrderTM); // 设置表格模型
|
|
|
|
|
bottomPanelLeft.removeAll(); // 清空底部左侧面板
|
|
|
|
|
countInfoLabel = new JLabel("共" + inOrderTM.getRowCount() + "条记录"); // 创建记录数标签
|
|
|
|
|
bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板
|
|
|
|
|
OrderView(); // 调用OrderView方法
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据状态查询结果
|
|
|
|
|
>>>>>>> developer
|
|
|
|
|
public void resultOfFindStatus(int catalog) {
|
|
|
|
|
this.mark=0;
|
|
|
|
|
InOrderTM inOrderTM = new InOrderTM();
|
|
|
|
@ -281,6 +488,7 @@ public class InView extends JPanel implements ActionListener{
|
|
|
|
|
OrderView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
|
|
|
|
|
/*刷新*/
|
|
|
|
|
public void refreshBuffer(Vector<Production> v) {
|
|
|
|
@ -336,10 +544,45 @@ public class InView extends JPanel implements ActionListener{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
//刷新缓冲区
|
|
|
|
|
public void refreshBuffer(Vector<Production> v) {
|
|
|
|
|
this.mark = 1; // 设置标记为1
|
|
|
|
|
|
|
|
|
|
InTableModel inTableModel = new InTableModel(v); // 创建表格模型
|
|
|
|
|
inTable.setModel(inTableModel); // 设置表格模型
|
|
|
|
|
bottomPanelLeft.removeAll(); // 清空底部左侧面板
|
|
|
|
|
countInfoLabel = new JLabel("商品种类:" + inTableModel.getRowCount() + ",总价:" + inTableModel.getAllPrice()); // 创建商品种类和总价标签
|
|
|
|
|
bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板
|
|
|
|
|
backBtn.setVisible(false); // 隐藏返回按钮
|
|
|
|
|
detailBtn.setVisible(false); // 隐藏详情按钮
|
|
|
|
|
historyBtn.setVisible(true); // 显示历史记录按钮
|
|
|
|
|
updateBtn.setVisible(true); // 显示更新按钮
|
|
|
|
|
addBtn.setVisible(true); // 显示添加按钮
|
|
|
|
|
deleteBtn.setVisible(true); // 显示删除按钮
|
|
|
|
|
|
|
|
|
|
allPrice = inTableModel.getAllPrice(); // 获取总价
|
|
|
|
|
row = inTableModel.getRowCount(); // 获取行数
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//调出进货订单表。
|
|
|
|
|
public void InOrderRecord() {
|
|
|
|
|
this.mark = 0; // 设置标记为0
|
|
|
|
|
InOrderTM inOrderTM = new InOrderTM(); // 创建进货订单表格模型
|
|
|
|
|
inOrderTM.allInOrderRecord(); // 查询所有进货订单记录
|
|
|
|
|
inTable.setModel(inOrderTM); // 设置表格模型
|
|
|
|
|
bottomPanelLeft.removeAll(); // 清空底部左侧面板
|
|
|
|
|
countInfoLabel = new JLabel("共" + inOrderTM.getRowCount() + "条记录"); // 创建记录数标签
|
|
|
|
|
bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板
|
|
|
|
|
OrderView(); // 调用OrderView方法
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
>>>>>>> developer
|
|
|
|
|
|
|
|
|
|
/*按钮监听时间*/
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
BufferImpl = new BufferImpl();/*获得购物车*/
|
|
|
|
|
Object source = e.getSource();
|
|
|
|
|
|
|
|
|
@ -511,3 +754,147 @@ public class InView extends JPanel implements ActionListener{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
=======
|
|
|
|
|
BufferImpl = new BufferImpl(); // 获取购物车
|
|
|
|
|
Object source = e.getSource(); // 获取事件源
|
|
|
|
|
|
|
|
|
|
if (searchBtn == source) { // 如果是搜索按钮
|
|
|
|
|
String number = nameSearchTF.getText(); // 获取搜索的订单号
|
|
|
|
|
System.out.println("搜索后的订单:" + number); // 打印订单号
|
|
|
|
|
resultOfNumber(number); // 根据订单号查询结果
|
|
|
|
|
} else if (addBtn == source) { // 如果是添加按钮
|
|
|
|
|
InDialog outDialog = new InDialog(jFrame, v, user); // 创建添加对话框
|
|
|
|
|
outDialog.setVisible(true); // 显示对话框
|
|
|
|
|
v = outDialog.getVector(); // 获取更新后的商品向量
|
|
|
|
|
refreshBuffer(v); // 刷新缓冲区
|
|
|
|
|
} else if (updateBtn == source) { // 如果是更新按钮
|
|
|
|
|
System.out.println("mark=" + mark); // 打印标记值
|
|
|
|
|
int rowIndex = inTable.getSelectedRow(); // 获取选中的行
|
|
|
|
|
if (rowIndex == -1) { // 如果没有选中行
|
|
|
|
|
JOptionPane.showMessageDialog(this, "请选中一条进行更改数量"); // 提示用户选中行
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 进货表修改
|
|
|
|
|
if (mark == 1) {
|
|
|
|
|
String id = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的ID
|
|
|
|
|
ChangeSumDialog changesumDialog = new ChangeSumDialog(jFrame, id, "In", v); // 创建更改数量对话框
|
|
|
|
|
changesumDialog.setVisible(true); // 显示对话框
|
|
|
|
|
v = changesumDialog.getVector(); // 获取更新后的商品向量
|
|
|
|
|
System.out.println("更改状态后v.size=" + v.size()); // 打印商品向量大小
|
|
|
|
|
refreshBuffer(v); // 刷新缓冲区
|
|
|
|
|
}
|
|
|
|
|
// inOrder修改,修改状态
|
|
|
|
|
else if (mark == 0) {
|
|
|
|
|
String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号
|
|
|
|
|
String status = (String) inTable.getValueAt(rowIndex, 4); // 获取选中行的状态
|
|
|
|
|
if (status.equals("已入库")) { // 如果状态是已入库
|
|
|
|
|
JOptionPane.showMessageDialog(this, "订单上的货物已入库无法修改状态", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户无法修改状态
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChangeStatusDialog changeStatusDialog = new ChangeStatusDialog(jFrame, iNumber, status); // 创建更改状态对话框
|
|
|
|
|
changeStatusDialog.setVisible(true); // 显示对话框
|
|
|
|
|
MainView.refreshRemind(); // 刷新提醒
|
|
|
|
|
HomeView.refreshHome(); // 刷新主页
|
|
|
|
|
InOrderRecord(); // 调出进货订单表
|
|
|
|
|
}
|
|
|
|
|
} else if (deleteBtn == source) { // 如果是删除按钮
|
|
|
|
|
int rowIndex = inTable.getSelectedRow(); // 获取选中的行
|
|
|
|
|
if (rowIndex == -1) { // 如果没有选中行
|
|
|
|
|
JOptionPane.showMessageDialog(this, "请选中一条"); // 提示用户选中行
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 删除进货表的 */
|
|
|
|
|
if (mark == 1) {
|
|
|
|
|
System.out.println("删除进货表"); // 打印日志
|
|
|
|
|
String id = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的ID
|
|
|
|
|
int select = JOptionPane.showConfirmDialog(this, "是否删除id为" + id + "的记录", "提示", JOptionPane.YES_NO_OPTION); // 提示用户确认删除
|
|
|
|
|
if (select == JOptionPane.YES_OPTION) { // 如果用户选择是
|
|
|
|
|
for (int i = 0; i < v.size(); i++) { // 遍历商品向量
|
|
|
|
|
System.out.println("开始删除"); // 打印日志
|
|
|
|
|
if (v.elementAt(i).getId().equals(id)) { // 如果找到对应的商品
|
|
|
|
|
v.remove(i); // 删除商品
|
|
|
|
|
JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户删除成功
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
refreshBuffer(v); // 刷新缓冲区
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 删除进货订单
|
|
|
|
|
else if (mark == 0) {
|
|
|
|
|
System.out.println("删除订单表"); // 打印日志
|
|
|
|
|
String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号
|
|
|
|
|
int select = JOptionPane.showConfirmDialog(this, "是否删除订单为" + iNumber + "的记录", "提示", JOptionPane.YES_NO_OPTION); // 提示用户确认删除
|
|
|
|
|
if (select == JOptionPane.YES_OPTION) { // 如果用户选择是
|
|
|
|
|
System.out.println("iNumber=" + iNumber); // 打印订单号
|
|
|
|
|
inOrderImpl = new inOrderServiceImpl(); // 创建进货订单服务实现类
|
|
|
|
|
inOrderImpl.deleteInOrder(iNumber); // 删除订单
|
|
|
|
|
JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户删除成功
|
|
|
|
|
InOrderRecord(); // 调出进货订单表
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (historyBtn == source) { // 如果是历史记录按钮
|
|
|
|
|
InOrderRecord(); // 调出进货订单表
|
|
|
|
|
} else if (backBtn == source) { // 如果是返回按钮
|
|
|
|
|
if (mark == 0)
|
|
|
|
|
refreshBuffer(v); // 刷新缓冲区
|
|
|
|
|
else if (mark == 2)
|
|
|
|
|
InOrderRecord(); // 调出进货订单表
|
|
|
|
|
} else if (detailBtn == source) { // 如果是详情按钮
|
|
|
|
|
int rowIndex = inTable.getSelectedRow(); // 获取选中的行
|
|
|
|
|
if (rowIndex == -1) { // 如果没有选中行
|
|
|
|
|
JOptionPane.showMessageDialog(this, "请选中一条查看订单详细信息"); // 提示用户选中行
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号
|
|
|
|
|
System.out.println("详情订单号为=" + iNumber); // 打印订单号
|
|
|
|
|
InRecord(iNumber); // 调出进货记录表
|
|
|
|
|
} else if (StockBtn == source) { // 如果是结账按钮
|
|
|
|
|
refreshBuffer(v); // 刷新缓冲区
|
|
|
|
|
|
|
|
|
|
if (v.size() == 0) { // 如果购物车为空
|
|
|
|
|
JOptionPane.showMessageDialog(null, "您的进货页面为空", "提示", JOptionPane.YES_OPTION); // 提示用户购物车为空
|
|
|
|
|
} else { // 如果购物车不为空
|
|
|
|
|
int res = JOptionPane.showConfirmDialog(null, "进价总金额:" + allPrice + "元\r\n负责人:" + uname + "\r\n发送邮件至 re@qq.com", "提交订单", JOptionPane.YES_NO_OPTION); // 提示用户确认提交订单
|
|
|
|
|
if (res == JOptionPane.YES_OPTION) { // 如果用户选择是
|
|
|
|
|
/* 获得时间和订单号,s[0]为订单号,s[1]为时间 */
|
|
|
|
|
String[] s = TimeAndOrder.TimeAndOrder(uname); // 获取时间和订单号
|
|
|
|
|
|
|
|
|
|
/* 往订单表插入一条记录 */
|
|
|
|
|
inOrderServiceImpl inOrderImpl = new inOrderServiceImpl(); // 创建进货订单服务实现类
|
|
|
|
|
inOrderImpl.InsertInOrder(s[0], allPrice, s[1], uname, 2); // 插入订单记录
|
|
|
|
|
|
|
|
|
|
/* 往inRecord表添加数据 */
|
|
|
|
|
inRecordServiceImpl inRecordImpl = new inRecordServiceImpl(); // 创建进货记录服务实现类
|
|
|
|
|
for (Production p : v) { // 遍历商品向量
|
|
|
|
|
inRecordImpl.insertInRecord(s[0], p); // 插入进货记录
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 生成订单文本 */
|
|
|
|
|
CreateOrder createOrder = new CreateOrder(); // 创建订单生成工具类
|
|
|
|
|
String OrderText = createOrder.CreateOrder(v, s[0], s[1], allPrice, uname); // 生成订单文本
|
|
|
|
|
try { // 发送邮件
|
|
|
|
|
SendQQMailUtil QQEmail = new SendQQMailUtil("cwfeng5@qq.com", "wlcinslohrgpdiac", "1912638153@qq.com", "@新民超市进货需求申请", OrderText); // 创建邮件发送工具类
|
|
|
|
|
} catch (MessagingException e1) { // 捕获异常
|
|
|
|
|
e1.printStackTrace(); // 打印异常信息
|
|
|
|
|
}
|
|
|
|
|
v = new Vector<Production>(); // 清空商品向量
|
|
|
|
|
refreshBuffer(v); // 刷新缓冲区
|
|
|
|
|
MainView.refreshRemind(); // 刷新提醒
|
|
|
|
|
JOptionPane.showConfirmDialog(null, "发送邮件成功\r\n订单号:" + s[0] + "\r\n负责人:" + uname, "提示", JOptionPane.YES_OPTION); // 提示用户发送邮件成功
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else if (exitBtn == source) { // 如果是退出按钮
|
|
|
|
|
int res = JOptionPane.showConfirmDialog(null, "确定退出并清空购物车吗", "结账", JOptionPane.YES_NO_OPTION); // 提示用户确认退出
|
|
|
|
|
if (res == JOptionPane.YES_OPTION) { // 如果用户选择是
|
|
|
|
|
v = new Vector<Production>(); // 清空商品向量
|
|
|
|
|
refreshBuffer(v); // 刷新缓冲区
|
|
|
|
|
JOptionPane.showConfirmDialog(null, "退出成功", "提示", JOptionPane.PLAIN_MESSAGE); // 提示用户退出成功
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
>>>>>>> developer
|
|
|
|
|