You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
test/branch_zyx/My_branch/InView.java

717 lines
25 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 定义包名表明该类属于com.lingnan.supermarket.view包
package com.lingnan.supermarket.view;
// 导入必要的Java Swing和AWT类库以及自定义的类库
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Vector;
import javax.mail.MessagingException;
import javax.swing.ImageIcon;
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.text.html.HTMLDocument.Iterator;
import com.lingnan.supermarket.componet.BGPanel;
import com.lingnan.supermarket.dao.impl.BufferImpl;
import com.lingnan.supermarket.dao.impl.UserServiceImpl;
import com.lingnan.supermarket.dao.impl.inOrderServiceImpl;
import com.lingnan.supermarket.dao.impl.inRecordServiceImpl;
import com.lingnan.supermarket.dao.impl.prodCatalogImpl;
import com.lingnan.supermarket.dialog.ChangeStatusDialog;
import com.lingnan.supermarket.dialog.ChangeSumDialog;
import com.lingnan.supermarket.dialog.InDialog;
import com.lingnan.supermarket.dialog.UserDialog;
import com.lingnan.supermarket.dto.Buffer;
import com.lingnan.supermarket.dto.InRecord;
import com.lingnan.supermarket.dto.Production;
import com.lingnan.supermarket.dto.User;
import com.lingnan.supermarket.table.*;
import com.lingnan.supermarket.utils.CreateOrder;
import com.lingnan.supermarket.utils.FontUtil;
import com.lingnan.supermarket.utils.SendQQMailUtil;
import com.lingnan.supermarket.utils.TimeAndOrder;
import com.lingnan.supermarket.view.ProdCatalogView.MyItemListener;
// 声明InView类继承JPanel并实现ActionListener接口
public class InView extends JPanel implements ActionListener{
// 定义类的成员变量,用于构建界面元素
// 上面的工具栏面板
private JPanel toolBarPanel;
// 搜索面板
private JPanel searchPanel;
private JLabel nameLabel,locationLabel; // 标签用于显示文本
private JTextField nameSearchTF; // 文本框用于输入搜索内容
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;
// 定义一个静态的Vector集合用于存储Production对象
private static Vector<Production> v = new Vector<Production>();
// 定义一个下拉框组件,用于选择不同的状态
private JComboBox<String> combo;
// 定义一个字符串数组,包含所有可能的状态选项
private String[] status ={"全部","已入库","待入库","已取消"};
// 定义一个变量,用于存储当前选中的目录
private int catalog;
// 定义一个JFrame对象用于表示主窗口
private JFrame jFrame;
// 定义一个User对象用于存储当前用户信息
private User user;
// 定义一个InTableModel对象用于管理表格数据模型
private InTableModel inTableModel ;
// 实例化BufferImpl对象用于操作缓冲区数据
private BufferImpl bufferImpl = new BufferImpl();
// 定义一个标记变量,用于区分是从进货表还是提醒过来的表
private int mark;/*标记从提醒那里来1是进货表0是提醒过来的表*/
// 定义一个inOrderServiceImpl对象用于处理进货订单服务
private inOrderServiceImpl inOrderImpl;
// 定义一个浮点数变量,用于存储总价
private Float allPrice;
// 定义一个整数变量,用于存储选中的行号
private int row;
// 定义一个字符串变量,用于存储用户名
private String uname;
// InView类的构造方法接收主窗口、用户、货物集合和标记作为参数
public InView(JFrame jFrame,User user,Vector<Production> v,int mark) {
// 设置布局管理器为边界布局
this.setLayout(new 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("订单号");
// 创建并初始化文本框用于输入搜索内容宽度为20
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);
// 将搜索面板添加到工具栏面板的西边West
toolBarPanel.add(searchPanel,"West");
// 将操作面板添加到工具栏面板的东边East
toolBarPanel.add(opePanel,"East");
//中间表
// 创建一个表格模型并传入数据向量v
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,"Left");
// 创建底部右侧面板,并设置布局为左对齐流式布局
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");
// 如果标记为1表示是从提醒模块过来的则刷新缓冲区
if(mark==1) /*判断是不是从提醒那里过来的*/{
refreshBuffer(v);
}
// 如果标记为0则执行进货订单记录操作
else if(mark==0) {
InOrderRecord();
}
// 设置窗口为可见状态,这样用户就可以看到并与之交互
setVisible(true);
}
// 提供一个静态方法用于获取存储Production对象的Vector集合
public static Vector<Production> getVector(){
return v;
}
// 定义一个内部类MyItemListener实现ItemListener接口来监听下拉框项目的状态改变
public class MyItemListener implements ItemListener {
// 重写itemStateChanged方法当下拉框中的项目状态改变时被调用
@Override
public void itemStateChanged(ItemEvent e) {
// 将事件源转换为JComboBox类型
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;
// 根据分类代码执行查找操作
resultOfFindStatus(catalog);
}
}
// 设置按钮组件的可见性
public void OrderView() {
// 设置返回按钮为可见
backBtn.setVisible(true);
// 设置详情按钮为可见
detailBtn.setVisible(true);
// 设置更新按钮为可见
updateBtn.setVisible(true);
// 设置删除按钮为可见
deleteBtn.setVisible(true);
// 设置添加按钮为不可见
addBtn.setVisible(false);
// 设置历史按钮为不可见
historyBtn.setVisible(false);
}
// 根据订单编号查询结果,并更新界面
public void resultOfNumber(String iNumber) {
// 重置标记
this.mark=0;
// 创建InOrderTM对象用于处理订单数据
InOrderTM inOrderTM = new InOrderTM();
// 根据订单编号查询结果
inOrderTM.resultOfNumber(iNumber);
// 设置表格模型为查询结果
inTable.setModel(inOrderTM);
// 清除底部左侧面板的内容
bottomPanelLeft.removeAll();
// 创建一个标签,显示记录总数
countInfoLabel = new JLabel("共"+inOrderTM.getRowCount()+"条记录");
// 将标签添加到底部左侧面板
bottomPanelLeft.add(countInfoLabel);
// 更新按钮组件的可见性
OrderView();
}
// 根据状态分类代码查询订单,并更新界面
public void resultOfFindStatus(int catalog) {
// 重置标记
this.mark=0;
// 创建InOrderTM对象用于处理订单数据
InOrderTM inOrderTM = new InOrderTM();
// 根据分类代码查询订单
inOrderTM.resultOfFind(catalog);
// 设置表格模型为查询结果
inTable.setModel(inOrderTM);
// 清除底部左侧面板的内容
bottomPanelLeft.removeAll();
// 创建一个标签,显示记录总数
countInfoLabel = new JLabel("共"+inOrderTM.getRowCount()+"条记录");
// 将标签添加到底部左侧面板
bottomPanelLeft.add(countInfoLabel);
// 更新按钮组件的可见性
OrderView();
}
// 刷新缓冲区数据,并更新界面
public void refreshBuffer(Vector<Production> v) {
// 设置标记为1表示刷新操作
this.mark=1;
// 创建InTableModel对象使用传入的Vector作为数据源
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;
// 创建InOrderTM对象用于处理订单数据
InOrderTM inOrderTM = new InOrderTM();
// 获取所有进货订单记录
inOrderTM.allInOrderRecord();
// 设置表格模型为所有订单记录
inTable.setModel(inOrderTM);
// 清除底部左侧面板的内容
bottomPanelLeft.removeAll();
// 创建一个标签,显示记录总数
countInfoLabel = new JLabel("共"+inOrderTM.getRowCount()+"条记录");
// 将标签添加到底部左侧面板
bottomPanelLeft.add(countInfoLabel);
// 更新按钮组件的可见性
OrderView();
}
// 根据订单编号查询进货记录,并更新界面
public void InRecord(String iNumber) {
// 设置标记为2表示按订单编号查询
this.mark=2;
// 创建InRecordTM对象使用订单编号作为查询条件
InRecordTM inRecordTM = new InRecordTM(iNumber);
// 查询进货记录
inRecordTM.findInRecordByINumber();
// 设置表格模型为查询结果
inTable.setModel(inRecordTM);
// 清除底部左侧面板的内容
bottomPanelLeft.removeAll();
// 创建一个标签,显示订单号和记录总数
countInfoLabel = new JLabel("订单号@"+iNumber+"共有"+inRecordTM.getRowCount()+"条记录");
// 将标签添加到底部左侧面板
bottomPanelLeft.add(countInfoLabel);
// 更新按钮的可见性
backBtn.setVisible(true);
detailBtn.setVisible(false);
updateBtn.setVisible(false);
addBtn.setVisible(false);
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();
// 打印搜索后的订单号
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;
}
// 如果标记值为1表示当前操作是进货表修改
if(mark==1) {
// 从选中的行中获取ID
String id =(String) inTable.getValueAt(rowIndex,0);
// 创建修改数量的对话框实例,并传入相关参数
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("删除进货表");
// 从选中的行中获取记录的ID
String id =(String) inTable.getValueAt(rowIndex,0);
// 弹出确认对话框询问用户是否删除指定ID的记录
int select = JOptionPane.showConfirmDialog(this,"是否删除id为"+id+"的记录","提示",JOptionPane.YES_NO_OPTION);
// 如果用户选择"是",则执行删除操作
if(select==JOptionPane.YES_OPTION) {/*选择是*/
// 遍历向量v寻找匹配的ID进行删除
for(int i =0;i<v.size();i++) {
// 打印日志信息,表示开始删除操作
System.out.println("开始删除");
// 如果找到匹配的ID则从向量中移除该元素
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) {/*历史记录中的返回按钮*/
// 如果标记为0则刷新缓冲区数据
if(mark==0)
refreshBuffer(v);
// 如果标记为2则重新加载订单记录
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) {/*往inRecord表添加数据*/
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("sender@qq.com","自行获取 SMTP 授权码","receiver@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);
}
}
}
}