base文件夹部分修改

pull/43/head
郑亦歆 9 months ago
parent a19fdbe104
commit 43656d2b42

@ -43,193 +43,298 @@ 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;
// 定义一个静态的向量用于存储Production对象
private static Vector<Production> v = new Vector<Production>();
// 定义一个下拉框,用于选择状态
private JComboBox<String> combo;
// 定义状态数组,包含不同的货物状态
private String[] status ={"全部","已入库","待入库","已取消"};
// 定义商品目录ID
private int catalog;
// 定义一个JFrame对象用于引用主窗口
private JFrame jFrame;
// 定义一个User对象用于存储当前用户信息
private User user;
// 定义一个表格模型,用于进货表格
private InTableModel inTableModel ;
// 实例化缓冲区实现类
private BufferImpl bufferImpl = new BufferImpl();
// 定义一个标记,用于区分是从进货表还是提醒过来的表
private int mark;/*标记从提醒那里来1是进货表0是提醒过来的表*/
// 定义一个进货订单服务实现类
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.setLayout(new BorderLayout());
// 保存传入的JFrame引用
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));
// 创建工具栏面板,并设置布局管理器为边界布局
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));
// 创建操作面板,并设置布局管理器为流布局,对齐方式为左对齐
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);/*在订单详情页显示出来*/
// 设置返回按钮为不可见,它在记录页面会显示出来
backBtn.setVisible(false);
// 设置详情按钮为不可见,它在订单详情页会显示出来
detailBtn.setVisible(false);
// 将添加按钮添加到操作面板
opePanel.add(addBtn);
// 将返回按钮添加到操作面板
opePanel.add(backBtn);
// 将详情按钮添加到操作面板
opePanel.add(detailBtn);
opePanel.add(updateBtn);
// 将更新按钮添加到操作面板
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");
//中间表
// 初始化中间表格模型使用货物向量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);
// 创建并初始化显示商品种类和总价的标签
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对象的向量
public static Vector<Production> getVector(){
return v;
}
// 定义一个内部类实现ItemListener接口用于监听下拉框的项目状态改变事件
public class MyItemListener implements ItemListener {
// 重写itemStateChanged方法当下拉框中的项目状态改变时被调用
@Override
public void itemStateChanged(ItemEvent e) {
// 将事件源强制转换为JComboBox
JComboBox cb = (JComboBox) e.getSource();
// 获取下拉框中选中的项目,并转换为字符串
String catalog1 = (String) cb.getSelectedItem();
// 根据选中的项目设置商品目录ID
if(catalog1.equals("全部"))
catalog=0;
else if(catalog1.equals("已入库"))
@ -238,276 +343,424 @@ public class InView extends JPanel implements ActionListener{
catalog=2;
else if(catalog1.equals("已取消"))
catalog=3;
// 根据商品目录ID执行查找状态的结果处理
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 = new InOrderTM();
// 根据订单编号查询结果
inOrderTM.resultOfNumber(iNumber);
// 更新表格模型
inTable.setModel(inOrderTM);
// 清空底部左侧面板
bottomPanelLeft.removeAll();
// 创建并初始化显示记录数的标签
countInfoLabel = new JLabel("共"+inOrderTM.getRowCount()+"条记录");
// 将标签添加到底部左侧面板
bottomPanelLeft.add(countInfoLabel);
// 调用OrderView设置按钮可见性
OrderView();
}
}
// 根据状态处理查询结果
public void resultOfFindStatus(int catalog) {
// 重置标记
this.mark=0;
// 创建订单表格模型
InOrderTM inOrderTM = new InOrderTM();
// 根据状态查询结果
inOrderTM.resultOfFind(catalog);
// 更新表格模型
inTable.setModel(inOrderTM);
// 清空底部左侧面板
bottomPanelLeft.removeAll();
// 创建并初始化显示记录数的标签
countInfoLabel = new JLabel("共"+inOrderTM.getRowCount()+"条记录");
// 将标签添加到底部左侧面板
bottomPanelLeft.add(countInfoLabel);
// 调用OrderView设置按钮可见性
OrderView();
}
/*刷新*/
public void refreshBuffer(Vector<Production> v) {
this.mark=1;
// 刷新缓冲区,更新表格数据
public void refreshBuffer(Vector<Production> v) {
// 设置标记
this.mark=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();
// 更新总价和行数
allPrice = inTableModel.getAllPrice();
row = inTableModel.getRowCount();
}
/*调出进货订单表*/
/* 调出进货订单表 */
public void InOrderRecord() {
// 设置标记为0
this.mark=0;
// 创建进货订单表格模型
InOrderTM inOrderTM = new InOrderTM();
// 获取所有进货订单记录
inOrderTM.allInOrderRecord();
// 更新表格模型
inTable.setModel(inOrderTM);
// 清空底部左侧面板
bottomPanelLeft.removeAll();
// 创建并初始化显示记录数的标签
countInfoLabel = new JLabel("共"+inOrderTM.getRowCount()+"条记录");
// 将标签添加到底部左侧面板
bottomPanelLeft.add(countInfoLabel);
// 调用OrderView设置按钮可见性
OrderView();
}
/*调出进货订单表*/
/* 根据订单号调出进货订单记录 */
public void InRecord(String iNumber) {
// 设置标记为2
this.mark=2;
// 创建进货记录表格模型,并传入订单号
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();/*获得购物车*/
}
/* 按钮监听事件 */
@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);
// 获取搜索框中的文本
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(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;
}
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);
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();
}
// 如果标记为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);
}
// 如果标记为0表示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);
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();
}
}
// 获取选中行的索引
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);
// 显示确认删除对话框
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();
// 重新加载进货订单记录
InOrderRecord();
// 如果事件源是返回按钮
}else if(backBtn==source) {/*历史记录中的返回按钮*/
if(mark==0)
refreshBuffer(v);
else if(mark==2)
InOrderRecord();
// 如果标记为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);
// 获取选中行的索引
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("cwfeng5@qq.com","wlcinslohrgpdiac","1912638153@qq.com","@新民超市进货需求申请",OrderText);
} catch (MessagingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
v=new Vector<Production>();
refreshBuffer(v);
MainView.refreshRemind();
JOptionPane.showConfirmDialog(null,"发送邮件成功\r\n订单号:"+s[0]+"\r\n负责人:"+uname, "提示", JOptionPane.YES_OPTION);
}
}
// 刷新购物车
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("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);
}
}
// 显示确认对话框,询问是否退出并清空购物车
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);
}
}
}
}

@ -1,146 +1,185 @@
package com.lingnan.supermarket.view;
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.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import com.lingnan.supermarket.dao.impl.prodCatalogImpl;
import com.lingnan.supermarket.dialog.UserDialog;
import com.lingnan.supermarket.dto.ProdCatalog;
import com.lingnan.supermarket.dto.Production;
import com.lingnan.supermarket.dto.User;
import com.lingnan.supermarket.table.ProdCatalogTM;
import com.lingnan.supermarket.table.StorageTableModel;
import com.lingnan.supermarket.table.UserTableModel;
import com.lingnan.supermarket.utils.FontUtil;
public class ProdCatalogView extends JPanel {
package com.lingnan.supermarket.view; // 定义包名,包含视图相关的类
import java.awt.BorderLayout; // 导入用于窗口布局的BorderLayout类
import java.awt.Color; // 导入用于颜色处理的Color类
import java.awt.FlowLayout; // 导入用于面板布局的FlowLayout类
import java.awt.event.ActionEvent; // 导入用于处理动作事件的ActionEvent类
import java.awt.event.ActionListener; // 导入用于监听动作事件的ActionListener接口
import java.awt.event.ItemEvent; // 导入用于处理项目事件的ItemEvent类
import java.awt.event.ItemListener; // 导入用于监听项目事件的ItemListener接口
import java.util.ArrayList; // 导入用于数组列表的ArrayList类
import javax.swing.ImageIcon; // 导入用于处理图像图标的ImageIcon类
import javax.swing.JButton; // 导入用于创建按钮的JButton类
import javax.swing.JComboBox; // 导入用于创建组合框的JComboBox类
import javax.swing.JFrame; // 导入用于创建窗口的JFrame类
import javax.swing.JLabel; // 导入用于创建标签的JLabel类
import javax.swing.JPanel; // 导入用于创建面板的JPanel类
import javax.swing.JScrollPane; // 导入用于创建滚动窗格的JScrollPane类
import javax.swing.JTable; // 导入用于创建表格的JTable类
import javax.swing.JTextField; // 导入用于创建文本字段的JTextField类
import com.lingnan.supermarket.dao.impl.prodCatalogImpl; // 导入产品目录数据访问层的实现类
import com.lingnan.supermarket.dialog.UserDialog; // 导入用户对话框类
import com.lingnan.supermarket.dto.ProdCatalog; // 导入产品目录数据传输对象
import com.lingnan.supermarket.dto.Production; // 导入产品数据传输对象
import com.lingnan.supermarket.dto.User; // 导入用户数据传输对象
import com.lingnan.supermarket.table.ProdCatalogTM; // 导入产品目录表格模型
import com.lingnan.supermarket.table.StorageTableModel; // 导入存储表格模型
import com.lingnan.supermarket.table.UserTableModel; // 导入用户表格模型
import com.lingnan.supermarket.utils.FontUtil; // 导入字体工具类
public class ProdCatalogView extends JPanel { // 创建一个公共类ProdCatalogView继承自JPanel
// 上面
private JPanel toolBarPanel;
private JPanel toolBarPanel; // 工具栏面板
private JPanel searchPanel;
private JLabel logLabel, locationLabel;
private JTextField nameSearchTF;
private JButton searchBtn;
private JPanel searchPanel; // 搜索面板
private JLabel logLabel, locationLabel; // 日志标签和位置标签
private JTextField nameSearchTF; // 名称搜索文本字段
private JButton searchBtn; // 搜索按钮
private JPanel opePanel;
private JButton addBtn, updateBtn, deleteBtn;
private JPanel opePanel; // 操作面板
private JButton addBtn, updateBtn, deleteBtn; // 添加、更新、删除按钮
private String catalog = "0";
private JComboBox<String> combo;
private String log[]=null;
private ArrayList<String>alog=null;
private ProdCatalogTM prodCatalogTM;
private ProdCatalog pc;
private prodCatalogImpl pci;
private String catalog = "0"; // 目录字符串,默认为"0"
private JComboBox<String> combo; // 字符串组合框
private String log[]=null; // 日志数组
private ArrayList<String>alog=null; // 日志数组列表
private ProdCatalogTM prodCatalogTM; // 产品目录表格模型
private ProdCatalog pc; // 产品目录对象
private prodCatalogImpl pci; // 产品目录数据访问层实现对象
// 中间
private JScrollPane tableScrollPane;
private JTable prodCatalogTable;
private JScrollPane tableScrollPane; // 表格滚动窗格
private JTable prodCatalogTable; // 产品目录表格
// 下面
private JPanel bottomPanel;
private JLabel countInfoLabel;
private JPanel bottomPanel; // 底部面板
private JLabel countInfoLabel; // 记录数信息标签
private JFrame jFrame;
private JFrame jFrame; // 窗口对象
public ProdCatalogView(JFrame jFrame) {
this.setLayout(new BorderLayout());
initView();
this.jFrame = jFrame;
public ProdCatalogView(JFrame jFrame) { // ProdCatalogView构造方法接收一个JFrame参数
this.setLayout(new BorderLayout()); // 设置面板布局为BorderLayout
initView(); // 初始化视图
this.jFrame = jFrame; // 将传入的JFrame对象赋值给成员变量jFrame
}
private void initView() {
// 创建一个面板,使用边界布局管理器
toolBarPanel = new JPanel(new BorderLayout());
// 创建搜索面板,使用流布局管理器,对齐方式为左对齐
searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
// 创建并初始化商品目录标签
locationLabel = new JLabel("商品目录");
// 设置标签字体
locationLabel.setFont(new FontUtil().userFont);
// 设置标签前景色
locationLabel.setForeground(new Color(18, 150, 219));
// 创建分类标签
logLabel = new JLabel("分类");
// 创建文本框用于输入搜索内容指定宽度为10
nameSearchTF = new JTextField(10);
// 创建搜索按钮,并指定图标
searchBtn = new JButton("搜索", new ImageIcon("static\\icon\\search.png"));
// 创建操作面板,使用流布局管理器,对齐方式为右对齐
// opePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
// // 创建并初始化按钮,指定图标
// addBtn = new JButton(new ImageIcon("static\\icon\\add.png"));
// updateBtn = new JButton(new ImageIcon("static\\icon\\update.png"));
// deleteBtn = new JButton(new ImageIcon("static\\icon\\delete.png"));
//
// // 为按钮添加事件监听器
// addBtn.addActionListener(this);
// updateBtn.addActionListener(this);
// deleteBtn.addActionListener(this);
//
// // 将按钮添加到操作面板
// opePanel.add(addBtn);
// opePanel.add(updateBtn);
// opePanel.add(deleteBtn);
// 实例化商品目录实现类
pci=new prodCatalogImpl();
// 查找所有商品目录名称
this.alog=pci.findNameProdCatalog();
// 创建字符串数组,用于存储商品目录名称
this.log=new String[alog.size()];
// 将商品目录名称填充到数组
for(int i=0;i<alog.size();i++)
log[i]=alog.get(i);
log[i]=alog.get(i);
// 打印商品目录名称,用于调试
for(int i=0;i<log.length;i++)
{
System.out.println(log[i]);
System.out.println(log[i]);
}
// 创建下拉列表,并使用商品目录名称作为选项
combo = new JComboBox<String>(log);
// 为下拉列表添加项目监听器
combo.addItemListener(new MyItemListener());
// 将标签、下拉列表添加到搜索面板
searchPanel.add(locationLabel);
searchPanel.add(logLabel);
searchPanel.add(combo);
/*
* searchPanel.add(nameSearchTF); searchPanel.add(searchBtn);
*
* searchPanel.add(nameSearchTF);
* searchPanel.add(searchBtn);
*/
// 将搜索面板添加到工具栏面板的西边
toolBarPanel.add(searchPanel, "West");
// 将操作面板添加到工具栏面板的东边,当前被注释
// toolBarPanel.add(opePanel, "East");
// 中间表格
// 创建表格模型,并获取所有数据
prodCatalogTM = new ProdCatalogTM();
prodCatalogTM.all();
// 创建表格,使用表格模型
prodCatalogTable = new JTable(prodCatalogTM);
// 设置表格字体
prodCatalogTable.setFont(FontUtil.tableFont);
// 设置表格行高
prodCatalogTable.setRowHeight(50);
// 创建滚动面板,并将表格添加到其中
tableScrollPane = new JScrollPane(prodCatalogTable);
}
// 下面
bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
countInfoLabel = new JLabel("总共" + prodCatalogTable.getRowCount() + "条");
bottomPanel.add(countInfoLabel);
this.add(toolBarPanel, "North");
this.add(tableScrollPane, "Center");/* 将表格放到中间 */
this.add(bottomPanel, "South");
setVisible(true);
}
// 下面
// 创建底部面板,使用流布局管理器,对齐方式为左对齐
bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
// 创建并初始化显示总记录数的标签
countInfoLabel = new JLabel("总共" + prodCatalogTable.getRowCount() + "条");
// 将记录数标签添加到底部面板
bottomPanel.add(countInfoLabel);
// 将工具栏面板添加到当前窗口的北部
this.add(toolBarPanel, "North");
// 将表格滚动面板添加到当前窗口的中间
this.add(tableScrollPane, "Center");/* 将表格放到中间 */
// 将底部面板添加到当前窗口的南部
this.add(bottomPanel, "South");
// 设置当前窗口为可见
setVisible(true);
}
// 以下是注释掉的代码,实现按钮的事件监听
// @Override
// public void actionPerformed(ActionEvent e) {
// Object source = e.getSource();
@ -148,47 +187,73 @@ public class ProdCatalogView extends JPanel {
// UserDialog userDialog = new UserDialog(jFrame);
// userDialog.setVisible(true);
// } else if (updateBtn == source) {
//
// // 更新按钮的逻辑
// } else if (deleteBtn == source) {
//
// // 删除按钮的逻辑
// }
// }
public class MyItemListener implements ItemListener {
@Override
public void itemStateChanged(ItemEvent e) {
JComboBox cb = (JComboBox) e.getSource();
String catalog1 = (String) cb.getSelectedItem();
pci =new prodCatalogImpl();
for(int i=0;i<log.length;i++){
if(catalog1.equals(log[i]))
catalog=pci.findProdCatalogByname(catalog1);
System.out.println(catalog);
}
refreshFindId2();
// 内部类,实现下拉列表的项目监听器
public class MyItemListener implements ItemListener {
@Override
// 当下拉列表中的项目状态改变时触发此方法
public void itemStateChanged(ItemEvent e) {
// 获取事件源,即下拉列表
JComboBox cb = (JComboBox) e.getSource();
// 获取当前选中的商品目录名称
String catalog1 = (String) cb.getSelectedItem();
// 实例化商品目录实现类
pci =new prodCatalogImpl();
// 遍历商品目录名称数组,找到匹配的名称
for(int i=0;i<log.length;i++){
if(catalog1.equals(log[i]))
// 根据名称获取商品目录对象
catalog=pci.findProdCatalogByname(catalog1);
// 打印商品目录对象,用于调试
System.out.println(catalog);
}
// 刷新界面,显示与所选商品目录相关的数据
refreshFindId2();
}
// 刷新当前界面
}
// 刷新当前界面,显示与特定商品目录相关的数据
public void refreshFindId2() {
// 创建商品对象
Production p = new Production();
// 设置商品目录ID
p.setId2(catalog);
// 创建新的表格模型根据商品目录ID查询数据
prodCatalogTM = new ProdCatalogTM();
prodCatalogTM.ById2(p);
// 更新表格模型
prodCatalogTable.setModel(prodCatalogTM);
// 同时更新下面的记录数
refreshCount();
}
public void refreshCount() {
}
// 更新底部面板上的记录数显示
public void refreshCount() {
// 清除底部面板上的所有组件
bottomPanel.removeAll();
// 创建新的标签,显示当前表格模型中的记录总数
countInfoLabel = new JLabel("总共" + prodCatalogTM.getRowCount() + "条");
// 将新的记录数标签添加到底部面板
bottomPanel.add(countInfoLabel);
}
}
}

@ -1,224 +1,234 @@
package com.lingnan.supermarket.view;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
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 com.lingnan.supermarket.dao.productionService;
import com.lingnan.supermarket.dao.impl.productionImpl;
import com.lingnan.supermarket.dialog.ProductionDialog;
import com.lingnan.supermarket.dialog.UserDialog;
import com.lingnan.supermarket.dto.Production;
import com.lingnan.supermarket.table.StorageRecordTM;
import com.lingnan.supermarket.table.StorageTableModel;
import com.lingnan.supermarket.utils.FontUtil;
public class StorageView extends JPanel implements ActionListener{
package com.lingnan.supermarket.view; // 定义包名
import java.awt.BorderLayout; // 导入BorderLayout布局管理器
import java.awt.Color; // 导入Color类用于颜色管理
import java.awt.FlowLayout; // 导入FlowLayout布局管理器
import java.awt.event.ActionEvent; // 导入ActionEvent类用于事件处理
import java.awt.event.ActionListener; // 导入ActionListener接口用于监听事件
import javax.swing.ImageIcon; // 导入ImageIcon类用于显示图片
import javax.swing.JButton; // 导入JButton类用于创建按钮
import javax.swing.JFrame; // 导入JFrame类用于创建窗口
import javax.swing.JLabel; // 导入JLabel类用于创建标签
import javax.swing.JOptionPane; // 导入JOptionPane类用于显示对话框
import javax.swing.JPanel; // 导入JPanel类用于创建面板
import javax.swing.JScrollPane; // 导入JScrollPane类用于创建滚动面板
import javax.swing.JTable; // 导入JTable类用于创建表格
import javax.swing.JTextField; // 导入JTextField类用于创建文本框
import com.lingnan.supermarket.dao.productionService; // 导入productionService接口
import com.lingnan.supermarket.dao.impl.productionImpl; // 导入productionImpl类
import com.lingnan.supermarket.dialog.ProductionDialog; // 导入ProductionDialog类
import com.lingnan.supermarket.dialog.UserDialog; // 导入UserDialog类
import com.lingnan.supermarket.dto.Production; // 导入Production类
import com.lingnan.supermarket.table.StorageRecordTM; // 导入StorageRecordTM类
import com.lingnan.supermarket.table.StorageTableModel; // 导入StorageTableModel类
import com.lingnan.supermarket.utils.FontUtil; // 导入FontUtil类
public class StorageView extends JPanel implements ActionListener{ // 定义StorageView类并实现ActionListener接口
//上面
private JPanel toolBarPanel;
private JPanel searchPanel;
private JLabel nameLabel,locationLabel;
private JTextField nameSearchTF;
private JButton searchBtn;
private JPanel opePanel;
private JButton addBtn,updateBtn,deleteBtn,historyBtn,backBtn;
private JPanel toolBarPanel; // 工具栏面板变量声明
private JPanel searchPanel; // 搜索面板变量声明
private JLabel nameLabel,locationLabel; // 标签变量声明
private JTextField nameSearchTF; // 文本框变量声明
private JButton searchBtn; // 搜索按钮变量声明
private JPanel opePanel; // 操作面板变量声明
private JButton addBtn,updateBtn,deleteBtn,historyBtn,backBtn; // 按钮变量声明
//中间
private JScrollPane tableScrollPane;
private JTable storageTable;
private JScrollPane tableScrollPane; // 表格滚动面板变量声明
private JTable storageTable; // 表格变量声明
//下面
private JPanel bottomPanel;
private JLabel countInfoLabel;
private StorageTableModel storageTableModel ;
private JFrame jFrame;
private productionService productionService=new productionImpl();
public StorageView(JFrame jFrame) {
this.setLayout(new BorderLayout());
initView();
this.jFrame = jFrame;
private JPanel bottomPanel; // 底部面板变量声明
private JLabel countInfoLabel; // 记录数标签变量声明
private StorageTableModel storageTableModel ; // 存储表格模型变量声明
private JFrame jFrame; // 窗口变量声明
private productionService productionService=new productionImpl(); // 创建productionService实例
public StorageView(JFrame jFrame) { // StorageView构造方法
this.setLayout(new BorderLayout()); // 设置布局管理器为BorderLayout
initView(); // 初始化视图
this.jFrame = jFrame; // 设置窗口引用
}
private void initView() {
toolBarPanel = new JPanel(new BorderLayout());
searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
locationLabel=new JLabel("当前位置>商品库存");
locationLabel.setFont(new FontUtil().userFont);
locationLabel.setForeground(new Color(18, 150, 219));
nameLabel = new JLabel("商品名");
nameSearchTF = new JTextField(10);
searchBtn = new JButton(new ImageIcon("static\\icon\\search.png"));
opePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
addBtn =new JButton(new ImageIcon("static\\icon\\add.png"));
updateBtn =new JButton(new ImageIcon("static\\icon\\update.png"));
deleteBtn =new JButton(new ImageIcon("static\\icon\\delete.png"));
backBtn =new JButton(new ImageIcon("static\\icon\\back.png"));
historyBtn =new JButton(new ImageIcon("static\\icon\\history.png"));
backBtn.setVisible(false);
addBtn.addActionListener(this);
updateBtn.addActionListener(this);
deleteBtn.addActionListener(this);
searchBtn.addActionListener(this);
backBtn.addActionListener(this);
historyBtn.addActionListener(this);
opePanel.add(addBtn);
opePanel.add(updateBtn);
opePanel.add(deleteBtn);
opePanel.add(backBtn);
opePanel.add(historyBtn);
searchPanel.add(locationLabel);
searchPanel.add(nameLabel);
searchPanel.add(nameSearchTF);
searchPanel.add(searchBtn);
toolBarPanel.add(searchPanel,"West");
toolBarPanel.add(opePanel,"East");
private void initView() { // 初始化视图方法
toolBarPanel = new JPanel(new BorderLayout()); // 创建工具栏面板并设置布局为BorderLayout
searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建搜索面板并设置布局为左对齐的FlowLayout
locationLabel=new JLabel("当前位置>商品库存"); // 创建当前位置标签并设置文本
locationLabel.setFont(new FontUtil().userFont); // 设置标签字体
locationLabel.setForeground(new Color(18, 150, 219)); // 设置标签前景色
nameLabel = new JLabel("商品名"); // 创建商品名标签
nameSearchTF = new JTextField(10); // 创建文本框用于输入商品名大小为10
searchBtn = new JButton(new ImageIcon("static\\icon\\search.png")); // 创建搜索按钮并设置图标
opePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建操作面板并设置布局为右对齐的FlowLayout
addBtn =new JButton(new ImageIcon("static\\icon\\add.png")); // 创建添加按钮并设置图标
updateBtn =new JButton(new ImageIcon("static\\icon\\update.png")); // 创建更新按钮并设置图标
deleteBtn =new JButton(new ImageIcon("static\\icon\\delete.png")); // 创建删除按钮并设置图标
backBtn =new JButton(new ImageIcon("static\\icon\\back.png")); // 创建返回按钮并设置图标
historyBtn =new JButton(new ImageIcon("static\\icon\\history.png")); // 创建历史按钮并设置图标
backBtn.setVisible(false); // 设置返回按钮不可见
addBtn.addActionListener(this); // 为添加按钮添加事件监听器
updateBtn.addActionListener(this); // 为更新按钮添加事件监听器
deleteBtn.addActionListener(this); // 为删除按钮添加事件监听器
searchBtn.addActionListener(this); // 为搜索按钮添加事件监听器
backBtn.addActionListener(this); // 为返回按钮添加事件监听器
historyBtn.addActionListener(this); // 为历史按钮添加事件监听器
opePanel.add(addBtn); // 将添加按钮添加到操作面板
opePanel.add(updateBtn); // 将更新按钮添加到操作面板
opePanel.add(deleteBtn); // 将删除按钮添加到操作面板
opePanel.add(backBtn); // 将返回按钮添加到操作面板
opePanel.add(historyBtn); // 将历史按钮添加到操作面板
searchPanel.add(locationLabel); // 将位置标签添加到搜索面板
searchPanel.add(nameLabel); // 将商品名标签添加到搜索面板
searchPanel.add(nameSearchTF); // 将商品名文本框添加到搜索面板
searchPanel.add(searchBtn); // 将搜索按钮添加到搜索面板
toolBarPanel.add(searchPanel,"West"); // 将搜索面板添加到工具栏面板的西边
toolBarPanel.add(opePanel,"East"); // 将操作面板添加到工具栏面板的东边
//中间表格
storageTableModel = new StorageTableModel();
storageTableModel.all();
storageTable = new JTable(storageTableModel);
storageTable.setFont(FontUtil.tableFont);
storageTable.setRowHeight(50);
tableScrollPane = new JScrollPane(storageTable);
storageTableModel = new StorageTableModel(); // 创建存储表格模型
storageTableModel.all(); // 初始化表格模型数据
storageTable = new JTable(storageTableModel); // 创建表格并设置模型
storageTable.setFont(FontUtil.tableFont); // 设置表格字体
storageTable.setRowHeight(50); // 设置表格行高
tableScrollPane = new JScrollPane(storageTable); // 创建滚动面板并包含表格
//下面
bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
countInfoLabel = new JLabel("总共"+storageTableModel.getRowCount()+"条");
bottomPanel.add(countInfoLabel);
this.add(toolBarPanel,"North");
this.add(tableScrollPane,"Center");/*将表格放到中间*/
this.add(bottomPanel,"South");
setVisible(true);
bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建底部面板并设置布局为左对齐的FlowLayout
countInfoLabel = new JLabel("总共"+storageTableModel.getRowCount()+"条"); // 创建记录数标签并设置文本
bottomPanel.add(countInfoLabel); // 将记录数标签添加到底部面板
this.add(toolBarPanel,"North"); // 将工具栏面板添加到当前面板的北边
this.add(tableScrollPane,"Center"); /*将表格放到中间*/
this.add(bottomPanel,"South"); // 将底部面板添加到当前面板的南边
setVisible(true); // 设置当前面板可见
}
@Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if(addBtn==source) {
public void actionPerformed(ActionEvent e) { // 重写actionPerformed方法以处理按钮点击事件
Object source = e.getSource(); // 获取事件源
if(addBtn==source) { // 如果事件源是添加按钮
//添加数据的对话框
ProductionDialog productionDialog = new ProductionDialog(jFrame);
productionDialog.setVisible(true);
refreshProduction();
}else if(updateBtn==source) {
refreshProduction();
}else if(historyBtn==source) {
storageRecord();
}else if(backBtn==source) {
refreshProduction();
ProductionDialog productionDialog = new ProductionDialog(jFrame); // 创建添加数据的对话框
productionDialog.setVisible(true); // 显示对话框
refreshProduction(); // 刷新数据
}else if(updateBtn==source) { // 如果事件源是更新按钮
refreshProduction(); // 刷新数据
}else if(historyBtn==source) { // 如果事件源是历史按钮
storageRecord(); // 处理存储记录
}else if(backBtn==source) { // 如果事件源是返回按钮
refreshProduction(); // 刷新数据
}
else if(deleteBtn==source) {
else if(deleteBtn==source) { // 如果事件源是删除按钮
//获取选中记录,删除
int[] rowIndexs = storageTable.getSelectedRows();
if(rowIndexs.length==0) {
JOptionPane.showMessageDialog(this,"请至少选中一条");
return;
int[] rowIndexs = storageTable.getSelectedRows(); // 获取表格中选中的行索引
if(rowIndexs.length==0) { // 如果没有选中任何行
JOptionPane.showMessageDialog(this,"请至少选中一条"); // 显示提示信息
return; // 结束方法执行
}
int select=JOptionPane.showConfirmDialog(this,"是否删除选中的"+rowIndexs.length+"条记录","提示",JOptionPane.YES_NO_OPTION);
if(select==JOptionPane.YES_OPTION){
for(int i=0;i<rowIndexs.length;i++){
String id = (String)storageTable.getValueAt(rowIndexs[i],0);
if(productionService.deleteProduction(id)==1) {
}else {
JOptionPane.showMessageDialog(this,"删除失败,id="+id,"提示",JOptionPane.ERROR_MESSAGE);
int select=JOptionPane.showConfirmDialog(this,"是否删除选中的"+rowIndexs.length+"条记录","提示",JOptionPane.YES_NO_OPTION); // 显示确认对话框
if(select==JOptionPane.YES_OPTION){ // 如果用户选择是
for(int i=0;i<rowIndexs.length;i++){ // 遍历所有选中的行
String id = (String)storageTable.getValueAt(rowIndexs[i],0); // 获取选中行的ID
if(productionService.deleteProduction(id)==1) { // 尝试删除记录
}else {
JOptionPane.showMessageDialog(this,"删除失败,id="+id,"提示",JOptionPane.ERROR_MESSAGE); // 显示删除失败信息
}
}
}
JOptionPane.showMessageDialog(this,"删除操作结束","提示",JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(this,"删除操作结束","提示",JOptionPane.INFORMATION_MESSAGE); // 显示删除操作结束信息
}
refreshProduction();
refreshProduction(); // 刷新数据
}else if(source==searchBtn){
refreshFindRname();
}else if(source==searchBtn){ // 如果事件源是搜索按钮
refreshFindRname(); // 刷新搜索结果
}
}
public void refreshFindRname() {
String name = nameSearchTF.getText();
Production p=new Production();
p.setName(name);
storageTableModel = new StorageTableModel();
storageTableModel.Byname(p);
storageTable.setModel(storageTableModel);
public void refreshFindRname() { // 刷新搜索结果的方法
String name = nameSearchTF.getText(); // 获取搜索框中的文本
Production p=new Production(); // 创建Production对象
p.setName(name); // 设置Production对象的名称
storageTableModel = new StorageTableModel(); // 创建新的存储表格模型
storageTableModel.Byname(p); // 根据名称过滤数据
storageTable.setModel(storageTableModel); // 更新表格模型
//同时更新下面的记录数
refreshCount();
hiddinBtn();
refreshCount(); // 刷新记录数
hiddinBtn(); // 隐藏按钮
}
public void refreshProduction() {
storageTableModel = new StorageTableModel();
storageTableModel.all();
storageTable.setModel(storageTableModel);
public void refreshProduction() { // 刷新生产数据的方法
storageTableModel = new StorageTableModel(); // 创建新的存储表格模型
storageTableModel.all(); // 加载所有数据
storageTable.setModel(storageTableModel); // 更新表格模型
//同时更新下面的记录数
refreshCount();
hiddinBtn();
refreshCount(); // 刷新记录数
hiddinBtn(); // 隐藏按钮
}
public void refreshCount(){
bottomPanel.removeAll();
countInfoLabel = new JLabel("总共"+storageTableModel.getRowCount()+"条");
bottomPanel.add(countInfoLabel);
hiddinBtn();
public void refreshCount(){ // 刷新记录数的方法
bottomPanel.removeAll(); // 清除底部面板上的所有组件
countInfoLabel = new JLabel("总共"+storageTableModel.getRowCount()+"条"); // 创建新的记录数标签
bottomPanel.add(countInfoLabel); // 将记录数标签添加到底部面板
hiddinBtn(); // 隐藏按钮
}
public void storageRecord() {
StorageRecordTM storageRecordTM= new StorageRecordTM();
storageRecordTM.allStoragrRecord();
storageTable.setModel(storageRecordTM);
StorageRecordTM storageRecordTM= new StorageRecordTM(); // 创建存储记录表格模型
storageRecordTM.allStoragrRecord(); // 加载所有存储记录
storageTable.setModel(storageRecordTM); // 设置表格模型为存储记录
//同时更新下面的记录数
bottomPanel.removeAll();
countInfoLabel = new JLabel("总共"+storageRecordTM.getRowCount()+"条");
bottomPanel.add(countInfoLabel);
backBtn.setVisible(true);
updateBtn.setVisible(false);
addBtn.setVisible(false);
historyBtn.setVisible(false);
deleteBtn.setVisible(false);
bottomPanel.removeAll(); // 清除底部面板上的所有组件
countInfoLabel = new JLabel("总共"+storageRecordTM.getRowCount()+"条"); // 创建新的记录数标签
bottomPanel.add(countInfoLabel); // 将记录数标签添加到底部面板
backBtn.setVisible(true); // 设置返回按钮可见
updateBtn.setVisible(false); // 设置更新按钮不可见
addBtn.setVisible(false); // 设置添加按钮不可见
historyBtn.setVisible(false); // 设置历史按钮不可见
deleteBtn.setVisible(false); // 设置删除按钮不可见
}
public void hiddinBtn() {
backBtn.setVisible(false);
updateBtn.setVisible(true);
addBtn.setVisible(true);
historyBtn.setVisible(true);
deleteBtn.setVisible(true);
backBtn.setVisible(false); // 设置返回按钮不可见
updateBtn.setVisible(true); // 设置更新按钮可见
addBtn.setVisible(true); // 设置添加按钮可见
historyBtn.setVisible(true); // 设置历史按钮可见
deleteBtn.setVisible(true); // 设置删除按钮可见
}

@ -1,177 +1,183 @@
package com.lingnan.supermarket.view;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
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 com.lingnan.supermarket.dao.SupplierInfService;
import com.lingnan.supermarket.dao.impl.SupplierInfImpl;
import com.lingnan.supermarket.dialog.SupplierInfDialog;
import com.lingnan.supermarket.dto.SupplierInf;
import com.lingnan.supermarket.table.SupplierTableModel;
import com.lingnan.supermarket.utils.FontUtil;
public class SupplierView extends JPanel implements ActionListener{
package com.lingnan.supermarket.view; // 定义包名
import java.awt.BorderLayout; // 导入BorderLayout布局管理器
import java.awt.Color; // 导入Color类用于颜色管理
import java.awt.FlowLayout; // 导入FlowLayout布局管理器
import java.awt.event.ActionEvent; // 导入ActionEvent类用于监听按钮点击事件
import java.awt.event.ActionListener; // 导入ActionListener接口用于实现事件监听
import javax.swing.ImageIcon; // 导入ImageIcon类用于显示图片
import javax.swing.JButton; // 导入JButton类用于创建按钮
import javax.swing.JFrame; // 导入JFrame类用于创建窗口
import javax.swing.JLabel; // 导入JLabel类用于创建标签
import javax.swing.JOptionPane; // 导入JOptionPane类用于显示对话框
import javax.swing.JPanel; // 导入JPanel类用于创建面板
import javax.swing.JScrollPane; // 导入JScrollPane类用于创建滚动面板
import javax.swing.JTable; // 导入JTable类用于创建表格
import javax.swing.JTextField; // 导入JTextField类用于创建文本框
import com.lingnan.supermarket.dao.SupplierInfService; // 导入供应商信息服务接口
import com.lingnan.supermarket.dao.impl.SupplierInfImpl; // 导入供应商信息实现类
import com.lingnan.supermarket.dialog.SupplierInfDialog; // 导入供应商信息对话框类
import com.lingnan.supermarket.dto.SupplierInf; // 导入供应商信息数据传输对象
import com.lingnan.supermarket.table.SupplierTableModel; // 导入供应商表格模型类
import com.lingnan.supermarket.utils.FontUtil; // 导入字体工具类
public class SupplierView extends JPanel implements ActionListener{ // 创建一个公共类SupplierView继承JPanel并实现ActionListener接口
//上面
private JPanel toolBarPanel;
private JPanel searchPanel;
private JLabel nameLabel,locationLabel;
private JTextField nameSearchTF;
private JButton searchBtn;
private JPanel opePanel;
private JButton addBtn,updateBtn,deleteBtn;
private JPanel toolBarPanel; // 声明工具栏面板变量
private JPanel searchPanel; // 声明搜索面板变量
private JLabel nameLabel,locationLabel; // 声明标签变量
private JTextField nameSearchTF; // 声明文本框变量
private JButton searchBtn; // 声明搜索按钮变量
private JPanel opePanel; // 声明操作面板变量
private JButton addBtn,updateBtn,deleteBtn; // 声明添加、更新、删除按钮变量
//中间
private JScrollPane tableScrollPane;
private JTable supplierTable;
private JScrollPane tableScrollPane; // 声明表格滚动面板变量
private JTable supplierTable; // 声明表格变量
//下面
private JPanel bottomPanel;
private JLabel countInfoLabel;
private SupplierTableModel supplierTableModel;
private JFrame jFrame;
private SupplierInfService supplierInfService = new SupplierInfImpl();
public SupplierView(JFrame jFrame) {
this.setLayout(new BorderLayout());
initView();
this.jFrame = jFrame;
private JPanel bottomPanel; // 声明底部面板变量
private JLabel countInfoLabel; // 声明信息标签变量
private SupplierTableModel supplierTableModel; // 声明供应商表格模型变量
private JFrame jFrame; // 声明窗口变量
private SupplierInfService supplierInfService = new SupplierInfImpl(); // 创建供应商信息服务实例
public SupplierView(JFrame jFrame) { // SupplierView构造方法接收一个JFrame参数
this.setLayout(new BorderLayout()); // 设置面板布局为BorderLayout
initView(); // 调用初始化视图方法
this.jFrame = jFrame; // 将传入的JFrame赋值给成员变量
}
private void initView() {
toolBarPanel = new JPanel(new BorderLayout());
searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
locationLabel=new JLabel("当前位置>供应商");
locationLabel.setFont(new FontUtil().userFont);
locationLabel.setForeground(new Color(18, 150, 219));
nameLabel = new JLabel("公司名称");
nameSearchTF = new JTextField(10);
searchBtn = new JButton(new ImageIcon("static\\icon\\search.png"));
opePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
addBtn =new JButton(new ImageIcon("static\\icon\\add.png"));
updateBtn =new JButton(new ImageIcon("static\\icon\\update.png"));
deleteBtn =new JButton(new ImageIcon("static\\icon\\delete.png"));
addBtn.addActionListener(this);
updateBtn.addActionListener(this);
deleteBtn.addActionListener(this);
searchBtn.addActionListener(this);
opePanel.add(addBtn);
opePanel.add(updateBtn);
opePanel.add(deleteBtn);
searchPanel.add(locationLabel);
searchPanel.add(nameLabel);
searchPanel.add(nameSearchTF);
searchPanel.add(searchBtn);
toolBarPanel.add(searchPanel,"West");
toolBarPanel.add(opePanel,"East");
private void initView() { // 初始化视图方法
toolBarPanel = new JPanel(new BorderLayout()); // 创建工具栏面板并设置布局为BorderLayout
searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建搜索面板并设置布局为左对齐的FlowLayout
locationLabel=new JLabel("当前位置>供应商"); // 创建当前位置标签
locationLabel.setFont(new FontUtil().userFont); // 设置标签字体
locationLabel.setForeground(new Color(18, 150, 219)); // 设置标签前景色
nameLabel = new JLabel("公司名称"); // 创建公司名称标签
nameSearchTF = new JTextField(10); // 创建文本框用于输入公司名称大小为10
searchBtn = new JButton(new ImageIcon("static\\icon\\search.png")); // 创建搜索按钮并设置图标
opePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建操作面板并设置布局为右对齐的FlowLayout
addBtn =new JButton(new ImageIcon("static\\icon\\add.png")); // 创建添加按钮并设置图标
updateBtn =new JButton(new ImageIcon("static\\icon\\update.png")); // 创建更新按钮并设置图标
deleteBtn =new JButton(new ImageIcon("static\\icon\\delete.png")); // 创建删除按钮并设置图标
addBtn.addActionListener(this); // 为添加按钮添加事件监听器
updateBtn.addActionListener(this); // 为更新按钮添加事件监听器
deleteBtn.addActionListener(this); // 为删除按钮添加事件监听器
searchBtn.addActionListener(this); // 为搜索按钮添加事件监听器
opePanel.add(addBtn); // 将添加按钮添加到操作面板
opePanel.add(updateBtn); // 将更新按钮添加到操作面板
opePanel.add(deleteBtn); // 将删除按钮添加到操作面板
searchPanel.add(locationLabel); // 将当前位置标签添加到搜索面板
searchPanel.add(nameLabel); // 将公司名称标签添加到搜索面板
searchPanel.add(nameSearchTF); // 将公司名称文本框添加到搜索面板
searchPanel.add(searchBtn); // 将搜索按钮添加到搜索面板
toolBarPanel.add(searchPanel,"West"); // 将搜索面板添加到工具栏面板的西边
toolBarPanel.add(opePanel,"East"); // 将操作面板添加到工具栏面板的东边
//中间表格
SupplierTableModel supplierTableModel = new SupplierTableModel();
supplierTableModel.all();
supplierTable = new JTable(supplierTableModel);
supplierTable.setFont(FontUtil.tableFont);
supplierTable.setRowHeight(50);
tableScrollPane = new JScrollPane(supplierTable);/*滑动条*/
supplierTableModel = new SupplierTableModel(); // 创建供应商表格模型实例
supplierTableModel.all(); // 调用表格模型的方法以加载所有数据
supplierTable = new JTable(supplierTableModel); // 创建表格并使用供应商表格模型
supplierTable.setFont(FontUtil.tableFont); // 设置表格字体
supplierTable.setRowHeight(50); // 设置表格行高为50像素
tableScrollPane = new JScrollPane(supplierTable); // 创建滚动面板并添加表格/*滑动条*/
//下面
bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
countInfoLabel = new JLabel("总共"+supplierTableModel.getRowCount()+"条");
bottomPanel.add(countInfoLabel);
this.add(toolBarPanel,"North");
this.add(tableScrollPane,"Center");/*将表格放到中间*/
this.add(bottomPanel,"South");
setVisible(true);
bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建底部面板并设置布局为左对齐的FlowLayout
countInfoLabel = new JLabel("总共"+supplierTableModel.getRowCount()+"条"); // 创建信息标签并设置显示总条数
bottomPanel.add(countInfoLabel); // 将信息标签添加到底部面板
this.add(toolBarPanel,"North"); // 将工具栏面板添加到当前面板的北边
this.add(tableScrollPane,"Center"); // 将表格滚动面板添加到当前面板的中间/*将表格放到中间*/
this.add(bottomPanel,"South"); // 将底部面板添加到当前面板的南边
setVisible(true); // 设置当前面板可见
}
@Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if(addBtn==source) {
SupplierInfDialog supplierInfDialog = new SupplierInfDialog(jFrame, null);
supplierInfDialog.setVisible(true);
refreshSupplier();
}else if(updateBtn==source) {
refreshSupplier();
}else if(deleteBtn==source) {
public void actionPerformed(ActionEvent e) { // 重写actionPerformed方法以处理按钮点击事件
Object source = e.getSource(); // 获取事件源
if(addBtn==source) { // 如果事件源是添加按钮
SupplierInfDialog supplierInfDialog = new SupplierInfDialog(jFrame, null); // 创建供应商信息对话框
supplierInfDialog.setVisible(true); // 显示供应商信息对话框
refreshSupplier(); // 刷新供应商列表
}else if(updateBtn==source) { // 如果事件源是更新按钮
refreshSupplier(); // 刷新供应商列表
}else if(deleteBtn==source) { // 如果事件源是删除按钮
//获取选中记录
int rowIndex = supplierTable.getSelectedRow();
if(rowIndex==-1) {
JOptionPane.showMessageDialog(this,"请选中一条");
return;
}
int id = (Integer)supplierTable.getValueAt(rowIndex,0);
int select=JOptionPane.showConfirmDialog(this,"是否删除id="+id,"提示",JOptionPane.YES_NO_OPTION);
if(select==JOptionPane.YES_OPTION){
if(supplierInfService.deleteSupplierInf(id)==1) {
JOptionPane.showMessageDialog(this,"删除成功","提示",JOptionPane.INFORMATION_MESSAGE);
refreshSupplier();
}else {
JOptionPane.showMessageDialog(this,"删除失败","提示",JOptionPane.ERROR_MESSAGE);
int rowIndex = supplierTable.getSelectedRow(); // 获取表格中选中的行索引
if(rowIndex==-1) { // 如果没有选中任何行
JOptionPane.showMessageDialog(this,"请选中一条"); // 显示提示信息
return; // 结束方法执行
}
int id = (Integer)supplierTable.getValueAt(rowIndex,0); // 获取选中行的ID
int select=JOptionPane.showConfirmDialog(this,"是否删除id="+id,"提示",JOptionPane.YES_NO_OPTION); // 显示确认删除对话框
if(select==JOptionPane.YES_OPTION){ // 如果用户选择是
if(supplierInfService.deleteSupplierInf(id)==1) { // 尝试删除供应商信息
JOptionPane.showMessageDialog(this,"删除成功","提示",JOptionPane.INFORMATION_MESSAGE); // 显示删除成功信息
refreshSupplier(); // 刷新供应商列表
}else {
JOptionPane.showMessageDialog(this,"删除失败","提示",JOptionPane.ERROR_MESSAGE); // 显示删除失败信息
}
}
}else{
System.out.println("搜索");
refreshFindRname();
}else{ // 如果事件源不是以上按钮
System.out.println("搜索"); // 输出搜索信息
refreshFindRname(); // 刷新搜索结果
}
}
public void refreshFindRname() {
String name = nameSearchTF.getText();
SupplierInf supplierInf =new SupplierInf();
supplierInf.setName(name);
supplierTableModel = new SupplierTableModel();
supplierTableModel.Byname(supplierInf);
supplierTable.setModel(supplierTableModel);
refreshCount();
public void refreshFindRname() { // 刷新搜索结果的方法
String name = nameSearchTF.getText(); // 获取文本框中的搜索名称
SupplierInf supplierInf =new SupplierInf(); // 创建供应商信息对象
supplierInf.setName(name); // 设置供应商名称
supplierTableModel = new SupplierTableModel(); // 创建供应商表格模型
supplierTableModel.Byname(supplierInf); // 根据名称过滤供应商信息
supplierTable.setModel(supplierTableModel); // 更新表格模型
refreshCount(); // 刷新记录数显示
}
public void refreshSupplier() {
supplierTableModel = new SupplierTableModel();
supplierTableModel.all();
supplierTable.setModel(supplierTableModel);
refreshCount();
public void refreshSupplier() { // 刷新供应商列表的方法
supplierTableModel = new SupplierTableModel(); // 创建供应商表格模型
supplierTableModel.all(); // 加载所有供应商信息
supplierTable.setModel(supplierTableModel); // 更新表格模型
refreshCount(); // 刷新记录数显示
}
public void refreshCount(){
bottomPanel.removeAll();
countInfoLabel = new JLabel("总共"+supplierTableModel.getRowCount()+"条");
bottomPanel.add(countInfoLabel);
public void refreshCount(){ // 刷新记录数显示的方法
bottomPanel.removeAll(); // 清除底部面板上的所有组件
countInfoLabel = new JLabel("总共"+supplierTableModel.getRowCount()+"条"); // 创建新的记录数标签
bottomPanel.add(countInfoLabel); // 将记录数标签添加到底部面板
}
}
}

Loading…
Cancel
Save