p4vsywzlp 9 months ago
commit 7a7c3179bd

@ -19,73 +19,73 @@ public class productionImpl implements productionService {
public Vector<Production> findAllproduction() {
Vector<Production> productions = new Vector<Production>();
Connection conn = JDBCUtil.getConn();
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
String SQL = "select * from production where delmark = 1";
String SQL = "select * from production where delmark = 1"; // SQL查询语句只查询未被删除的商品
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
preparedStatement = conn.prepareStatement(SQL);
preparedStatement = conn.prepareStatement(SQL); // 创建PreparedStatement对象
resultSet = preparedStatement.executeQuery();
resultSet = preparedStatement.executeQuery(); // 执行查询,获取结果集
while (resultSet.next()) {
while (resultSet.next()) { // 遍历结果集
Production production = new Production();
production.setId(resultSet.getString("id"));
production.setName(resultSet.getString("name"));
production.setInPrice(resultSet.getFloat("inPrice"));
production.setOutPrice(resultSet.getFloat("OutPrice"));
production.setLife(resultSet.getInt("life"));
production.setSum(resultSet.getInt("sum"));
production.setSupplyId(resultSet.getInt("supplyId"));
production.setId2(resultSet.getString("id2"));
production.setName2(resultSet.getString("name2"));
production.setDelmark(resultSet.getInt("delmark"));
productions.add(production);
production.setId(resultSet.getString("id")); // 设置商品ID
production.setName(resultSet.getString("name")); // 设置商品名称
production.setInPrice(resultSet.getFloat("inPrice")); // 设置进价
production.setOutPrice(resultSet.getFloat("OutPrice")); // 设置售价
production.setLife(resultSet.getInt("life")); // 设置保质期
production.setSum(resultSet.getInt("sum")); // 设置库存数量
production.setSupplyId(resultSet.getInt("supplyId")); // 设置供应商ID
production.setId2(resultSet.getString("id2")); // 设置商品类别ID
production.setName2(resultSet.getString("name2")); // 设置商品类别名称
production.setDelmark(resultSet.getInt("delmark")); // 设置删除标记
productions.add(production); // 将商品信息添加到Vector中
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(resultSet, preparedStatement, conn);
JDBCUtil.close(resultSet, preparedStatement, conn); // 关闭数据库资源
}
return productions;
return productions; // 返回所有商品信息
}
/* 用于收银系统通过商品id返回所有信息 */
public Production findByIdProduction(String id) {
Production production = new Production();
Connection conn = JDBCUtil.getConn();
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
preparedStatement = conn
.prepareStatement("select * from production where id=? and delmark = 1");
preparedStatement.setString(1, id);
resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
production.setId(resultSet.getString("id"));
production.setName(resultSet.getString("name"));
production.setInPrice(resultSet.getFloat("inPrice"));
production.setOutPrice(resultSet.getFloat("OutPrice"));
production.setLife(resultSet.getInt("life"));
production.setSum(resultSet.getInt("sum"));
production.setSupplyId(resultSet.getInt("supplyId"));
production.setId2(resultSet.getString("id2"));
production.setName2(resultSet.getString("name2"));
production.setDelmark(resultSet.getInt("delmark"));
.prepareStatement("select * from production where id=? and delmark = 1"); // 查询指定ID且未被删除的商品
preparedStatement.setString(1, id); // 设置查询参数
resultSet = preparedStatement.executeQuery(); // 执行查询
if (resultSet.next()) { // 如果找到商品
production.setId(resultSet.getString("id")); // 设置商品ID
production.setName(resultSet.getString("name")); // 设置商品名称
production.setInPrice(resultSet.getFloat("inPrice")); // 设置进价
production.setOutPrice(resultSet.getFloat("OutPrice")); // 设置售价
production.setLife(resultSet.getInt("life")); // 设置保质期
production.setSum(resultSet.getInt("sum")); // 设置库存数量
production.setSupplyId(resultSet.getInt("supplyId")); // 设置供应商ID
production.setId2(resultSet.getString("id2")); // 设置商品类别ID
production.setName2(resultSet.getString("name2")); // 设置商品类别名称
production.setDelmark(resultSet.getInt("delmark")); // 设置删除标记
} else {
System.out.println("未找到");
return null;
return null; // 如果未找到商品返回null
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(resultSet, preparedStatement, conn);
JDBCUtil.close(resultSet, preparedStatement, conn); // 关闭数据库资源
}
return production;
return production; // 返回商品信息
}
@Override
@ -94,35 +94,35 @@ public class productionImpl implements productionService {
*
*/
Vector<Production> productions = new Vector<Production>();
Connection conn = JDBCUtil.getConn();
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
preparedStatement = conn.prepareStatement("select * from production where name like ? and delmark = 1");
String s='%'+name+'%';
preparedStatement.setString(1, s);
resultSet = preparedStatement.executeQuery();
preparedStatement = conn.prepareStatement("select * from production where name like ? and delmark = 1"); // 模糊查询商品名称
String s = '%' + name + '%'; // 构造模糊查询字符串
preparedStatement.setString(1, s); // 设置查询参数
resultSet = preparedStatement.executeQuery(); // 执行查询
while (resultSet.next()) {
while (resultSet.next()) { // 遍历结果集
Production production = new Production();
production.setId(resultSet.getString("id"));
production.setName(resultSet.getString("name"));
production.setInPrice(resultSet.getFloat("inPrice"));
production.setOutPrice(resultSet.getFloat("OutPrice"));
production.setLife(resultSet.getInt("life"));
production.setSum(resultSet.getInt("sum"));
production.setSupplyId(resultSet.getInt("supplyId"));
production.setId2(resultSet.getString("id2"));
production.setName2(resultSet.getString("name2"));
production.setDelmark(resultSet.getInt("delmark"));
productions.add(production);
production.setId(resultSet.getString("id")); // 设置商品ID
production.setName(resultSet.getString("name")); // 设置商品名称
production.setInPrice(resultSet.getFloat("inPrice")); // 设置进价
production.setOutPrice(resultSet.getFloat("OutPrice")); // 设置售价
production.setLife(resultSet.getInt("life")); // 设置保质期
production.setSum(resultSet.getInt("sum")); // 设置库存数量
production.setSupplyId(resultSet.getInt("supplyId")); // 设置供应商ID
production.setId2(resultSet.getString("id2")); // 设置商品类别ID
production.setName2(resultSet.getString("name2")); // 设置商品类别名称
production.setDelmark(resultSet.getInt("delmark")); // 设置删除标记
productions.add(production); // 将商品信息添加到Vector中
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(resultSet, preparedStatement, conn);
JDBCUtil.close(resultSet, preparedStatement, conn); // 关闭数据库资源
}
return productions;
return productions; // 返回所有匹配的商品信息
}
@Override
@ -131,34 +131,34 @@ public class productionImpl implements productionService {
*/
public Production findByNameProduction(String name) {
Production production = new Production();
Connection conn = JDBCUtil.getConn();
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
preparedStatement = conn
.prepareStatement("select * from production where name=?");
preparedStatement.setString(1, name);
resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
production.setId(resultSet.getString("id"));
production.setName(resultSet.getString("name"));
production.setInPrice(resultSet.getFloat("inPrice"));
production.setOutPrice(resultSet.getFloat("OutPrice"));
production.setLife(resultSet.getInt("life"));
production.setSum(resultSet.getInt("sum"));
production.setSupplyId(resultSet.getInt("supplyId"));
production.setDelmark(resultSet.getInt("delmark"));
.prepareStatement("select * from production where name=?"); // 精确查询商品名称
preparedStatement.setString(1, name); // 设置查询参数
resultSet = preparedStatement.executeQuery(); // 执行查询
if (resultSet.next()) { // 如果找到商品
production.setId(resultSet.getString("id")); // 设置商品ID
production.setName(resultSet.getString("name")); // 设置商品名称
production.setInPrice(resultSet.getFloat("inPrice")); // 设置进价
production.setOutPrice(resultSet.getFloat("OutPrice")); // 设置售价
production.setLife(resultSet.getInt("life")); // 设置保质期
production.setSum(resultSet.getInt("sum")); // 设置库存数量
production.setSupplyId(resultSet.getInt("supplyId")); // 设置供应商ID
production.setDelmark(resultSet.getInt("delmark")); // 设置删除标记
} else {
return null;
return null; // 如果未找到商品返回null
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(resultSet, preparedStatement, conn);
JDBCUtil.close(resultSet, preparedStatement, conn); // 关闭数据库资源
}
return production;
return production; // 返回商品信息
}
@Override
@ -167,39 +167,39 @@ public class productionImpl implements productionService {
*/
public int addProduction(Production p) {
int flag = 0;
Connection conn = JDBCUtil.getConn();
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
PreparedStatement preparedStatement = null;
PreparedStatement preparedStatement1 = null;
ResultSet resultSet1=null;
ResultSet resultSet1 = null;
// 假设商品不存在
try {
preparedStatement1 = conn.prepareStatement("select * from production where id=?");
preparedStatement1.setString(1, p.getId());
resultSet1=preparedStatement1.executeQuery();
if(resultSet1.next()){
return flag=2;
preparedStatement1 = conn.prepareStatement("select * from production where id=?"); // 检查商品是否已存在
preparedStatement1.setString(1, p.getId()); // 设置查询参数
resultSet1 = preparedStatement1.executeQuery(); // 执行查询
if (resultSet1.next()) {
return flag = 2; // 如果商品已存在返回2
}
preparedStatement = conn.prepareStatement("insert into production values(?,?,?,?,?,?,?,?,?,?,?)");
preparedStatement.setString(1, p.getId());
preparedStatement.setString(2, p.getName());
preparedStatement.setFloat(3, p.getInPrice());
preparedStatement.setFloat(4, p.getOutPrice());
preparedStatement.setInt(5, p.getLife());
preparedStatement.setInt(6, p.getSum());
preparedStatement.setInt(7, p.getSupplyId());
preparedStatement.setString(8, p.getId2());
preparedStatement.setString(9, p.getName2());
preparedStatement.setFloat(10, 0);
preparedStatement.setInt(11, 1);
preparedStatement.executeUpdate();
flag=1;
preparedStatement = conn.prepareStatement("insert into production values(?,?,?,?,?,?,?,?,?,?,?)"); // 插入新商品
preparedStatement.setString(1, p.getId()); // 设置商品ID
preparedStatement.setString(2, p.getName()); // 设置商品名称
preparedStatement.setFloat(3, p.getInPrice()); // 设置进价
preparedStatement.setFloat(4, p.getOutPrice()); // 设置售价
preparedStatement.setInt(5, p.getLife()); // 设置保质期
preparedStatement.setInt(6, p.getSum()); // 设置库存数量
preparedStatement.setInt(7, p.getSupplyId()); // 设置供应商ID
preparedStatement.setString(8, p.getId2()); // 设置商品类别ID
preparedStatement.setString(9, p.getName2()); // 设置商品类别名称
preparedStatement.setFloat(10, 0); // 设置未知字段
preparedStatement.setInt(11, 1); // 设置删除标记为1未删除
preparedStatement.executeUpdate(); // 执行插入
flag = 1; // 插入成功返回1
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(null, preparedStatement, conn);
JDBCUtil.close(null, preparedStatement, conn); // 关闭数据库资源
}
return flag;
return flag; // 返回操作结果
}
@Override
@ -208,22 +208,21 @@ public class productionImpl implements productionService {
*/
public int deleteProduction(String id) {
int flag = 0;
Connection conn = JDBCUtil.getConn();
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
PreparedStatement preparedStatement = null;
try {
preparedStatement = conn
.prepareStatement("delete from production where id = ?");
preparedStatement.setString(1, id);
preparedStatement.executeUpdate();
flag = 1;
.prepareStatement("delete from production where id = ?"); // 删除指定ID的商品
preparedStatement.setString(1, id); // 设置查询参数
preparedStatement.executeUpdate(); // 执行删除
flag = 1; // 删除成功返回1
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(null, preparedStatement, conn);
JDBCUtil.close(null, preparedStatement, conn); // 关闭数据库资源
}
return flag;
return flag; // 返回操作结果
}
@Override
@ -232,98 +231,99 @@ public class productionImpl implements productionService {
*/
public int updateProduction(Production p) {
int flag = 0;
Connection conn = JDBCUtil.getConn();
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
PreparedStatement preparedStatement = null;
try {
preparedStatement = conn
.prepareStatement("update production set name=?,inPrice=?,OutPrice=?,life=?,sum=?,delmark=? where id = ? and supplyId=?");
.prepareStatement("update production set name=?,inPrice=?,OutPrice=?,life=?,sum=?,delmark=? where id = ? and supplyId=?"); // 更新商品信息
preparedStatement.setString(1, p.getName());
preparedStatement.setFloat(2, p.getInPrice());
preparedStatement.setFloat(3, p.getOutPrice());
preparedStatement.setInt(4, p.getLife());
preparedStatement.setInt(5, p.getSum());
preparedStatement.setInt(6, p.getDelmark());
preparedStatement.setString(7, p.getId());
preparedStatement.setInt(8, p.getSupplyId());
preparedStatement.setString(1, p.getName()); // 设置商品名称
preparedStatement.setFloat(2, p.getInPrice()); // 设置进价
preparedStatement.setFloat(3, p.getOutPrice()); // 设置售价
preparedStatement.setInt(4, p.getLife()); // 设置保质期
preparedStatement.setInt(5, p.getSum()); // 设置库存数量
preparedStatement.setInt(6, p.getDelmark()); // 设置删除标记
preparedStatement.setString(7, p.getId()); // 设置商品ID
preparedStatement.setInt(8, p.getSupplyId()); // 设置供应商ID
preparedStatement.executeUpdate();
flag = 1;
preparedStatement.executeUpdate(); // 执行更新
flag = 1; // 更新成功返回1
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(null, preparedStatement, conn);
JDBCUtil.close(null, preparedStatement, conn); // 关闭数据库资源
}
return flag;
return flag; // 返回操作结果
}
@Override
public Vector<Production> findProductionById2(String id) {
/**
* id2
* id2
*/
Vector<Production> productions = new Vector<Production>();
Connection conn = JDBCUtil.getConn();
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
if(id.equals("0"))
preparedStatement = conn.prepareStatement("select * from production where delmark = 1");
else
{preparedStatement = conn.prepareStatement("select * from production where id2= ? and delmark = 1");
preparedStatement.setString(1, id);}
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
if (id.equals("0"))
preparedStatement = conn.prepareStatement("select * from production where delmark = 1"); // 查询所有未删除的商品
else {
preparedStatement = conn.prepareStatement("select * from production where id2= ? and delmark = 1"); // 查询指定类别ID且未删除的商品
preparedStatement.setString(1, id); // 设置查询参数
}
resultSet = preparedStatement.executeQuery(); // 执行查询
while (resultSet.next()) { // 遍历结果集
Production production = new Production();
production.setId(resultSet.getString("id"));
production.setName(resultSet.getString("name"));
production.setInPrice(resultSet.getFloat("inPrice"));
production.setOutPrice(resultSet.getFloat("OutPrice"));
production.setLife(resultSet.getInt("life"));
production.setSum(resultSet.getInt("sum"));
production.setSupplyId(resultSet.getInt("supplyId"));
production.setId2(resultSet.getString("id2"));
production.setName2(resultSet.getString("name2"));
production.setDelmark(resultSet.getInt("delmark"));
productions.add(production);
production.setId(resultSet.getString("id")); // 设置商品ID
production.setName(resultSet.getString("name")); // 设置商品名称
production.setInPrice(resultSet.getFloat("inPrice")); // 设置进价
production.setOutPrice(resultSet.getFloat("OutPrice")); // 设置售价
production.setLife(resultSet.getInt("life")); // 设置保质期
production.setSum(resultSet.getInt("sum")); // 设置库存数量
production.setSupplyId(resultSet.getInt("supplyId")); // 设置供应商ID
production.setId2(resultSet.getString("id2")); // 设置商品类别ID
production.setName2(resultSet.getString("name2")); // 设置商品类别名称
production.setDelmark(resultSet.getInt("delmark")); // 设置删除标记
productions.add(production); // 将商品信息添加到Vector中
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(resultSet, preparedStatement, conn);
JDBCUtil.close(resultSet, preparedStatement, conn); // 关闭数据库资源
}
return productions;
return productions; // 返回所有匹配的商品信息
}
@Override
/**
*
*/
public boolean updateProductionSum(String prodId,int sum) {
public boolean updateProductionSum(String prodId, int sum) {
boolean flag = false;
Connection conn = JDBCUtil.getConn();
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
PreparedStatement preparedStatement = null;
try {
preparedStatement = conn
.prepareStatement("update production set sum=?+(select sum from(select sum from production where id = ? and delmark=1 ) p) where id = ? and delmark=1;");
.prepareStatement("update production set sum=?+(select sum from(select sum from production where id = ? and delmark=1 ) p) where id = ? and delmark=1;"); // 更新商品库存数量
preparedStatement.setInt(1, sum);
preparedStatement.setString(2, prodId);
preparedStatement.setString(3, prodId);
preparedStatement.setInt(1, sum); // 设置新增库存数量
preparedStatement.setString(2, prodId); // 设置商品ID
preparedStatement.setString(3, prodId); // 设置商品ID
if(preparedStatement.executeUpdate()==1);
flag = true;
if (preparedStatement.executeUpdate() == 1)
flag = true; // 更新成功返回true
} catch (SQLException e) {
e.printStackTrace();
} finally {
JDBCUtil.close(null, preparedStatement, conn);
JDBCUtil.close(null, preparedStatement, conn); // 关闭数据库资源
}
return flag;
return flag; // 返回操作结果
}
}
}

@ -30,195 +30,157 @@ import com.lingnan.supermarket.table.OutTableModel;
import com.lingnan.supermarket.view.InView;
import com.lingnan.supermarket.view.OutView;
// 定义一个继承自JDialog的类InDialog用于显示添加商品的对话框
public class InDialog extends JDialog implements ActionListener {
public class InDialog extends JDialog implements ActionListener{
private JPanel prodIdPanel,sumPanel,phonePanel,opePanel;
private JLabel prodIdLabel,sumLabel;
private JTextField prodIdTF,sumTF;
private JButton addBtn,cancelBtn;
// 定义面板、标签、文本框、按钮等组件
private JPanel prodIdPanel, sumPanel, phonePanel, opePanel;
private JLabel prodIdLabel, sumLabel;
private JTextField prodIdTF, sumTF;
private JButton addBtn, cancelBtn;
// 定义OutTableModel对象用于表格数据模型
private OutTableModel outTableModel = new OutTableModel();
// 定义Production对象和productionImpl对象用于处理商品数据
private Production production;
private productionImpl productionImpl;
// 定义Vector集合用于存储商品数据
private Vector<Production> v;
// 定义User对象用于存储用户信息
private User user;
// 定义JFrame对象用于存储父窗口
private JFrame JFramparent;
// 定义JComboBox对象和字符串数组用于商品编号选择
private JComboBox<String> combo;
private String allProdId[] = null;
private Vector<Production> vAll;
private static String catalog;
public InDialog(JFrame parent,Vector<Production> v,User user) {
super(parent,"添加商品");
setSize(250,200);
setLocationRelativeTo(null);
setModal(true);
setResizable(false);
this.setLayout(new FlowLayout());
JFramparent=parent;
this.v=v;
this.user = user;
initView();
// 构造方法,初始化对话框并设置相关属性
public InDialog(JFrame parent, Vector<Production> v, User user) {
super(parent, "添加商品"); // 调用父类构造方法,设置对话框标题
setSize(250, 200); // 设置对话框大小
setLocationRelativeTo(null); // 设置对话框居中显示
setModal(true); // 设置对话框为模态对话框
setResizable(false); // 禁止调整对话框大小
this.setLayout(new FlowLayout()); // 设置布局为流式布局
JFramparent = parent; // 保存父窗口
this.v = v; // 保存商品数据集合
this.user = user; // 保存用户信息
initView(); // 初始化界面
}
// 初始化界面方法
private void initView() {
prodIdPanel = new JPanel();
prodIdLabel = new JLabel("编号");
productionImpl= new productionImpl();
vAll=productionImpl.findAllproduction();
allProdId = new String[vAll.size()];
for(int i=0;i<vAll.size();i++) {
allProdId[i]=vAll.elementAt(i).getId();
prodIdPanel = new JPanel(); // 创建商品编号面板
prodIdLabel = new JLabel("编号"); // 创建商品编号标签
productionImpl = new productionImpl(); // 创建productionImpl对象
vAll = productionImpl.findAllproduction(); // 获取所有商品数据
allProdId = new String[vAll.size()]; // 初始化商品编号数组
for (int i = 0; i < vAll.size(); i++) {
allProdId[i] = vAll.elementAt(i).getId(); // 将商品编号存入数组
}
catalog = allProdId[0];
System.out.println(allProdId[0]);
combo = new JComboBox<String>(allProdId);
combo.addItemListener(new MyItemListener());
prodIdPanel.add(prodIdLabel);
prodIdPanel.add(combo);
sumPanel = new JPanel();
sumLabel = new JLabel("数量");
sumTF = new JTextField(10);
sumPanel.add(sumLabel);
sumPanel.add(sumTF);
opePanel = new JPanel();
addBtn = new JButton("添加");
cancelBtn = new JButton("取消");
addBtn.addActionListener(this);
cancelBtn.addActionListener(this);
opePanel.add(addBtn);
opePanel.add(cancelBtn);
Container container = getContentPane();
container.add(prodIdPanel);
container.add(sumPanel);
container.add(opePanel);
catalog = allProdId[0]; // 默认选择第一个商品编号
System.out.println(allProdId[0]); // 打印默认商品编号
combo = new JComboBox<String>(allProdId); // 创建商品编号下拉框
combo.addItemListener(new MyItemListener()); // 添加下拉框监听器
prodIdPanel.add(prodIdLabel); // 将商品编号标签添加到面板
prodIdPanel.add(combo); // 将商品编号下拉框添加到面板
sumPanel = new JPanel(); // 创建数量面板
sumLabel = new JLabel("数量"); // 创建数量标签
sumTF = new JTextField(10); // 创建数量文本框
sumPanel.add(sumLabel); // 将数量标签添加到面板
sumPanel.add(sumTF); // 将数量文本框添加到面板
opePanel = new JPanel(); // 创建操作面板
addBtn = new JButton("添加"); // 创建添加按钮
cancelBtn = new JButton("取消"); // 创建取消按钮
addBtn.addActionListener(this); // 为添加按钮添加事件监听器
cancelBtn.addActionListener(this); // 为取消按钮添加事件监听器
opePanel.add(addBtn); // 将添加按钮添加到面板
opePanel.add(cancelBtn); // 将取消按钮添加到面板
Container container = getContentPane(); // 获取内容面板
container.add(prodIdPanel); // 将商品编号面板添加到内容面板
container.add(sumPanel); // 将数量面板添加到内容面板
container.add(opePanel); // 将操作面板添加到内容面板
}
/*将数组传到inview的刷新方法里面再刷新*/
public Vector<Production> getVector(){
return v;
// 获取商品数据集合的方法
public Vector<Production> getVector() {
return v; // 返回商品数据集合
}
//下拉框监听
static class MyItemListener implements ItemListener{
// 下拉框监听器类
static class MyItemListener implements ItemListener {
@Override
public void itemStateChanged(ItemEvent e) {
JComboBox cb=(JComboBox)e.getSource();
String select=(String) cb.getSelectedItem();
catalog=select;
JComboBox cb = (JComboBox) e.getSource(); // 获取事件源
String select = (String) cb.getSelectedItem(); // 获取选中的商品编号
catalog = select; // 更新当前选中的商品编号
}
}
// 事件处理方法
@Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if(source==addBtn){
//1.判断是否存在这个商品
//2.如果存在就获取这条商品记录为一个对象
//3.判断购物缓冲区是否有这个记录
//3.1如果有update数量和price
//3.2如果没有就insert这条记录把sum更新
//保存到数据库
//关闭对话框
//刷新table
String prodId =catalog;
System.out.println("proId="+prodId);
System.out.println("vatalog="+catalog);
if(sumTF.getText().equals("")) {
JOptionPane.showMessageDialog(this,"请输入完整","提示",JOptionPane.ERROR_MESSAGE);
Object source = e.getSource(); // 获取事件源
if (source == addBtn) { // 如果事件源是添加按钮
String prodId = catalog; // 获取选中的商品编号
System.out.println("proId=" + prodId); // 打印商品编号
System.out.println("vatalog=" + catalog); // 打印当前选中的商品编号
if (sumTF.getText().equals("")) { // 如果数量文本框为空
JOptionPane.showMessageDialog(this, "请输入完整", "提示", JOptionPane.ERROR_MESSAGE); // 提示输入完整信息
return;
}
int sum = Integer.parseInt(sumTF.getText()) ;
int sum = Integer.parseInt(sumTF.getText()); // 获取输入的数量
if(sum<0) {/*判断输入大于0*/
JOptionPane.showMessageDialog(this,"请输入大于0的数量","提示",JOptionPane.ERROR_MESSAGE);
if (sum < 0) { // 如果数量小于0
JOptionPane.showMessageDialog(this, "请输入大于0的数量", "提示", JOptionPane.ERROR_MESSAGE); // 提示输入大于0的数量
return;
}
//TODO 参数校验
/*/判断是已添加,未添加还是不存在*/
productionImpl productionImpl = new productionImpl();
production = new Production();
production = productionImpl.findByIdProduction(prodId);
// 参数校验
productionImpl productionImpl = new productionImpl(); // 创建productionImpl对象
production = new Production(); // 创建Production对象
production = productionImpl.findByIdProduction(prodId); // 根据商品编号查找商品
if(production!=null) {/*商品库有这个商品存在*/
if (production != null) { // 如果商品存在
int mark = 0;
for(Production p:v) {
if(p.getId().equals(prodId)){/*如果数组中存在相同商品就更新数量和价格*/
sum=p.getSum()+sum;/*数量*/
p.setSum(sum);
p.setPrice(sum*p.getInPrice());/*进货价格*/
mark = 1;
for (Production p : v) { // 遍历商品数据集合
if (p.getId().equals(prodId)) { // 如果集合中存在相同商品
sum = p.getSum() + sum; // 更新数量
p.setSum(sum); // 设置数量
p.setPrice(sum * p.getInPrice()); // 更新价格
mark = 1; // 标记为已存在
break;
}
}
if(mark==0) {/*插入新的*/
if (mark == 0) { // 如果集合中不存在相同商品
System.out.println("缓存区不存在,插入新的数据");
production.setSum(sum);/*更新价格和数量后插入心的*/
production.setPrice(sum*production.getInPrice());
v.add(production);
production.setSum(sum); // 设置数量
production.setPrice(sum * production.getInPrice()); // 设置价格
v.add(production); // 将商品添加到集合
}
System.out.println("插入后v的大小"+v.size());
this.dispose();
JOptionPane.showMessageDialog(this,"添加成功","提示",JOptionPane.ERROR_MESSAGE);
System.out.println("插入后v的大小" + v.size()); // 打印集合大小
this.dispose(); // 关闭对话框
JOptionPane.showMessageDialog(this, "添加成功", "提示", JOptionPane.ERROR_MESSAGE); // 提示添加成功
} else { // 如果商品不存在
JOptionPane.showMessageDialog(this, "商品不存在", "提示", JOptionPane.ERROR_MESSAGE); // 提示商品不存在
}
else {/*商品库没有这个商品*/
JOptionPane.showMessageDialog(this,"商品不存在","提示",JOptionPane.ERROR_MESSAGE);
}
}
else if(source == cancelBtn) {
this.dispose();
} else if (source == cancelBtn) { // 如果事件源是取消按钮
this.dispose(); // 关闭对话框
}
}
}
}

@ -17,7 +17,6 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import com.lingnan.supermarket.*;
import com.lingnan.supermarket.dao.SupplierInfService;
import com.lingnan.supermarket.dao.productionService;
import com.lingnan.supermarket.dao.impl.SupplierInfImpl;
@ -28,172 +27,179 @@ import com.lingnan.supermarket.dto.Production;
import com.lingnan.supermarket.dto.SupplierInf;
import com.lingnan.supermarket.table.ProdCatalogTM;
import com.lingnan.supermarket.view.StorageView;
import com.lingnan.supermarket.view.SupplierView;
import com.lingnan.supermarket.view.ProdCatalogView.MyItemListener;
/**
*
* JDialog
*/
public class ProductionDialog extends JDialog implements ActionListener {
// 定义各个面板,用于组织界面布局
private JPanel namePanel, addressPanel, contactPanel,
opePanel,idPanel,inpricePanel,outpricePanel,lifePanel,
sumPanel,supplyidPanel,id2Panel,name2Panel;
opePanel, idPanel, inpricePanel, outpricePanel, lifePanel,
sumPanel, supplyidPanel, id2Panel, name2Panel;
// 定义各个标签,用于显示提示信息
private JLabel nameLabel, addressLabel, contactLabel,
idLabel,inpriceLabel,outpriceLabel,lifeLabel,sumLabel,
supplyidLabel,id2Label,name2Label;
idLabel, inpriceLabel, outpriceLabel, lifeLabel, sumLabel,
supplyidLabel, id2Label, name2Label;
// 定义各个文本框,用于用户输入数据
private JTextField nameTF, addressTF, contactTF,
idTF,inpriceTF,outpriceTF,lifeTF,sumTF,
supplyidTF,id2TF,name2TF;
idTF, inpriceTF, outpriceTF, lifeTF, sumTF,
supplyidTF, id2TF, name2TF;
// 定义保存和取消按钮
private JButton saveBtn, cancelBtn;
// 商品服务接口的实现类,用于操作商品数据
private productionService productionService = new productionImpl();
//下拉类别
private String log[]=null;
private ArrayList<String>alog=null;
private ProdCatalogTM prodCatalogTM;
private ProdCatalog pc;
private prodCatalogImpl pci;
private JComboBox<String> combo;
private String id2;
private String name2;
//下拉供应商类别
private String superlier[]=null;
private ArrayList<String>asuperlier=null;
private SupplierInf si;
private SupplierInfImpl sii;
private JComboBox<String> combo1;
private int supplyid;
private StorageView storageView;
private Production production;
// 下拉类别相关变量
private String log[] = null; // 商品类别名称数组
private ArrayList<String> alog = null; // 商品类别名称列表
private ProdCatalogTM prodCatalogTM; // 商品类别表格模型
private ProdCatalog pc; // 商品类别对象
private prodCatalogImpl pci; // 商品类别服务实现类
private JComboBox<String> combo; // 商品类别下拉框
private String id2; // 商品类别ID
private String name2; // 商品类别名称
// 下拉供应商类别相关变量
private String superlier[] = null; // 供应商名称数组
private ArrayList<String> asuperlier = null; // 供应商名称列表
private SupplierInf si; // 供应商对象
private SupplierInfImpl sii; // 供应商服务实现类
private JComboBox<String> combo1; // 供应商下拉框
private int supplyid; // 供应商ID
private StorageView storageView; // 库存视图
private Production production; // 商品对象
/**
*
* @param parent
*/
public ProductionDialog(JFrame parent) {
super(parent, "添加");
super(parent, "添加"); // 调用父类构造函数,设置标题为“添加”
// 设置对话框大小
setSize(350, 500);
// 设置对话框居中显示
setLocationRelativeTo(null);
// 设置为模态对话框,即打开对话框时,父窗口不可操作
setModal(true);
setResizable(false);
setResizable(false); // 禁止调整对话框大小
// 设置布局为流式布局
this.setLayout(new FlowLayout());
// 初始化视图
initView();
}
/**
*
*/
private void initView() {
// 商品编号面板
idPanel = new JPanel();
idLabel = new JLabel("商品编号");
idTF = new JTextField(15);
idPanel.add(idLabel);
idPanel.add(idTF);
// 商品名称面板
namePanel = new JPanel();
nameLabel = new JLabel("名称");
nameTF = new JTextField(15);
namePanel.add(nameLabel);
namePanel.add(nameTF);
// 进货单价面板
inpricePanel = new JPanel();
inpriceLabel = new JLabel("进货单价");
inpriceTF = new JTextField(15);
inpricePanel.add(inpriceLabel);
inpricePanel.add(inpriceTF);
// 购买单价面板
outpricePanel = new JPanel();
outpriceLabel = new JLabel("购买单价");
outpriceTF = new JTextField(15);
outpricePanel.add(outpriceLabel);
outpricePanel.add(outpriceTF);
// 保质期面板
lifePanel = new JPanel();
lifeLabel = new JLabel("保质期(月份数)");
lifeTF = new JTextField(15);
lifePanel.add(lifeLabel);
lifePanel.add(lifeTF);
// 库存面板
sumPanel = new JPanel();
sumLabel = new JLabel("库存");
sumTF = new JTextField(15);
sumPanel.add(sumLabel);
sumPanel.add(sumTF);
//供应商名下拉框 传递supplyid
// 供应商名下拉框面板
supplyidPanel = new JPanel();
supplyidLabel = new JLabel("供应商");
// supplyidTF = new JTextField(15);
sii = new SupplierInfImpl(); // 创建供应商服务实现类对象
this.asuperlier = sii.findNameSupplier(); // 获取所有供应商名称
this.superlier = new String[asuperlier.size()]; // 初始化供应商名称数组
for (int i = 0; i < asuperlier.size(); i++)
superlier[i] = asuperlier.get(i); // 将供应商名称存入数组
sii=new SupplierInfImpl();
this.asuperlier=sii.findNameSupplier();
this.superlier=new String[asuperlier.size()];
for(int i=0;i<asuperlier.size();i++)
superlier[i]=asuperlier.get(i);
for(int i=0;i<superlier.length;i++)
{
System.out.println(superlier[i]);
}
combo1 = new JComboBox<String>(superlier);
combo1.addItemListener(new MyItemListener1());
combo1 = new JComboBox<String>(superlier); // 创建供应商下拉框
combo1.addItemListener(new MyItemListener1()); // 添加下拉框监听器
supplyidPanel.add(supplyidLabel);
supplyidPanel.add(combo1);
/* id2Panel = new JPanel();
id2Label = new JLabel("分类id");
id2TF = new JTextField(id2,15);
id2Panel.add(id2Label);
id2Panel.add(id2TF);*/
//类名下拉框
// 类名下拉框面板
name2Panel = new JPanel();
name2Label = new JLabel("类名");
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);
combo = new JComboBox<String>(log);
combo.addItemListener(new MyItemListener());
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); // 将商品类别名称存入数组
combo = new JComboBox<String>(log); // 创建商品类别下拉框
combo.addItemListener(new MyItemListener()); // 添加下拉框监听器
name2Panel.add(name2Label);
name2Panel.add(combo);
// 地址面板
addressPanel = new JPanel();
addressLabel = new JLabel("地址");
addressTF = new JTextField(15);
addressPanel.add(addressLabel);
addressPanel.add(addressTF);
// 电话面板
contactPanel = new JPanel();
contactLabel = new JLabel("电话");
contactTF = new JTextField(15);
contactPanel.add(contactLabel);
contactPanel.add(contactTF);
// 操作按钮面板
opePanel = new JPanel();
saveBtn = new JButton("保存");
cancelBtn = new JButton("取消");
saveBtn.addActionListener(this);
cancelBtn.addActionListener(this);
saveBtn.addActionListener(this); // 添加保存按钮监听器
cancelBtn.addActionListener(this); // 添加取消按钮监听器
opePanel.add(saveBtn);
opePanel.add(cancelBtn);
// 将所有面板添加到容器中
Container container = getContentPane();
container.add(idPanel);
container.add(namePanel);
@ -202,20 +208,19 @@ public class ProductionDialog extends JDialog implements ActionListener {
container.add(lifePanel);
container.add(sumPanel);
container.add(supplyidPanel);
// container.add(id2Panel);
container.add(name2Panel);
container.add(opePanel);
}
/**
*
* @param e
*/
@Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == saveBtn) {
// 思路获取数据
// 保存到数据库
// 关闭对话框
// 刷新table
// 获取输入的数据
String name = nameTF.getText();
String id = idTF.getText();
float inprice = Float.parseFloat((inpriceTF.getText()));
@ -223,26 +228,25 @@ public class ProductionDialog extends JDialog implements ActionListener {
int life = Integer.parseInt(lifeTF.getText());
int sum = Integer.parseInt(sumTF.getText());
// TODO 参数校验
// 参数校验
if (this.production == null) {
if(supplyid==-1){
if (supplyid == -1) {
JOptionPane.showMessageDialog(this, "商品检索出错", "提示",
JOptionPane.ERROR_MESSAGE);
return;
}
if(supplyid==0){
if (supplyid == 0) {
JOptionPane.showMessageDialog(this, "请选择商品名", "提示",
JOptionPane.ERROR_MESSAGE);
return;
}
if(id2.equals("0")){
if (id2.equals("0")) {
JOptionPane.showMessageDialog(this, "请选择商品类", "提示",
JOptionPane.ERROR_MESSAGE);
return;
}
// 创建商品对象并设置属性
Production production = new Production();
production.setId(id);
production.setName(name);
@ -253,69 +257,58 @@ public class ProductionDialog extends JDialog implements ActionListener {
production.setSupplyId(supplyid);
production.setId2(id2);
production.setName2(name2);
// 调用服务接口添加商品
int result = productionService.addProduction(production);
// int result = 1;
if (result == 1) {
JOptionPane.showMessageDialog(this, "添加成功", "提示",
JOptionPane.INFORMATION_MESSAGE);
this.dispose();
} else if(result == 2){
this.dispose(); // 关闭对话框
} else if (result == 2) {
JOptionPane.showMessageDialog(this, "已存在该商品", "提示",
JOptionPane.ERROR_MESSAGE);
}
else {
} else {
JOptionPane.showMessageDialog(this, "出错!添加失败", "提示",
JOptionPane.ERROR_MESSAGE);
}
}/*else{
//更新
SupplierInf supplierInf= new SupplierInf();
supplierInf.setName(name);
supplierInf.setAddress(address);
supplierInf.setContact(contact);
supplierInf.setId(this.supplierInf.getId());
int result = supplierInfService.updateSupplierInf(supplierInf);
if(result==1){
JOptionPane.showMessageDialog(this, "更新成功", "提示",
JOptionPane.INFORMATION_MESSAGE);
}
}*/
}
} else if (source == cancelBtn) {
// 关闭对话框
this.dispose();
}
}
/**
*
*/
public class MyItemListener implements ItemListener {
@Override
public void itemStateChanged(ItemEvent e) {
JComboBox cb = (JComboBox) e.getSource();
name2 = (String) cb.getSelectedItem();
pci =new prodCatalogImpl();
for(int i=0;i<log.length;i++){
if(name2.equals(log[i]))
id2=pci.findProdCatalogByname(name2);
name2 = (String) cb.getSelectedItem(); // 获取选中的商品类别名称
pci = new prodCatalogImpl();
for (int i = 0; i < log.length; i++) {
if (name2.equals(log[i]))
id2 = pci.findProdCatalogByname(name2); // 根据名称获取商品类别ID
}
}
}
/**
*
*/
public class MyItemListener1 implements ItemListener {
@Override
public void itemStateChanged(ItemEvent e) {
JComboBox cb = (JComboBox) e.getSource();
String suppliername = (String) cb.getSelectedItem();
sii =new SupplierInfImpl();
for(int i=0;i<superlier.length;i++){
if(suppliername.equals(superlier[i]))
supplyid=sii.findIdSupplierByName(suppliername);
String suppliername = (String) cb.getSelectedItem(); // 获取选中的供应商名称
sii = new SupplierInfImpl();
for (int i = 0; i < superlier.length; i++) {
if (suppliername.equals(superlier[i]))
supplyid = sii.findIdSupplierByName(suppliername); // 根据名称获取供应商ID
}
}
}
}
}

@ -13,7 +13,6 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import com.lingnan.supermarket.*;
import com.lingnan.supermarket.dao.SupplierInfService;
import com.lingnan.supermarket.dao.impl.SupplierInfImpl;
import com.lingnan.supermarket.dto.SupplierInf;
@ -21,68 +20,78 @@ import com.lingnan.supermarket.view.SupplierView;
public class SupplierInfDialog extends JDialog implements ActionListener {
private JPanel namePanel, addressPanel, contactPanel,emailPanel, opePanel;
private JPanel namePanel, addressPanel, contactPanel, emailPanel, opePanel;
private JLabel nameLabel, addressLabel, contactLabel,emailLabel;
private JTextField nameTF, addressTF, contactTF,emailTF;
private JLabel nameLabel, addressLabel, contactLabel, emailLabel;
private JTextField nameTF, addressTF, contactTF, emailTF;
private JButton saveBtn, cancelBtn;
private SupplierInfService supplierInfService = new SupplierInfImpl();
private SupplierInfService supplierInfService = new SupplierInfImpl(); // 供应商信息服务接口的实现类
private SupplierView supplierView;
private SupplierView supplierView; // 供应商视图对象
private SupplierInf supplierInf;
private SupplierInf supplierInf; // 供应商信息对象
//构造函数,初始化对话框
public SupplierInfDialog(JFrame parent, SupplierView supplierView) {
super(parent, "添加");
this.supplierView = supplierView;
super(parent, "添加"); // 调用父类构造函数,设置对话框标题为“添加”
this.supplierView = supplierView; // 保存供应商视图对象
setSize(350, 300);
setSize(350, 300); // 设置对话框大小
setLocationRelativeTo(null);
setLocationRelativeTo(null); // 设置对话框居中显示
setModal(true);
setResizable(false);
setModal(true); // 设置对话框为模态对话框
setResizable(false); // 禁止调整对话框大小
this.setLayout(new FlowLayout());
this.setLayout(new FlowLayout()); // 设置对话框的布局为流式布局
initView();
initView(); // 初始化对话框界面
}
/**
*
*/
private void initView() {
// 名称面板
namePanel = new JPanel();
nameLabel = new JLabel("名称");
nameTF = new JTextField(15);
namePanel.add(nameLabel);
namePanel.add(nameTF);
// 地址面板
addressPanel = new JPanel();
addressLabel = new JLabel("地址");
addressTF = new JTextField(15);
addressPanel.add(addressLabel);
addressPanel.add(addressTF);
// 联系电话面板
contactPanel = new JPanel();
contactLabel = new JLabel("电话");
contactTF = new JTextField(15);
contactPanel.add(contactLabel);
contactPanel.add(contactTF);
// 邮箱面板
emailPanel = new JPanel();
emailLabel = new JLabel("邮箱");
emailTF = new JTextField(15);
emailPanel.add(emailLabel);
emailPanel.add(emailTF);
// 操作面板
opePanel = new JPanel();
saveBtn = new JButton("保存");
cancelBtn = new JButton("取消");
saveBtn.addActionListener(this);
cancelBtn.addActionListener(this);
saveBtn.addActionListener(this); // 为保存按钮添加事件监听器
cancelBtn.addActionListener(this); // 为取消按钮添加事件监听器
opePanel.add(saveBtn);
opePanel.add(cancelBtn);
// 将各个面板添加到对话框的内容面板中
Container container = getContentPane();
container.add(namePanel);
container.add(addressPanel);
@ -91,56 +100,51 @@ public class SupplierInfDialog extends JDialog implements ActionListener {
container.add(opePanel);
}
/**
*
*
* @param e
*/
@Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == saveBtn) {
// 思路获取数据
// 保存到数据库
// 关闭对话框
// 刷新table
Object source = e.getSource(); // 获取事件源
if (source == saveBtn) { // 如果事件源是保存按钮
// 获取用户输入的数据
String name = nameTF.getText();
String address = addressTF.getText();
String contact = contactTF.getText();
String email = emailTF.getText();
// TODO 参数校验
if (this.supplierInf == null) {
if (this.supplierInf == null) { // 如果当前没有供应商信息对象(即新增操作)
SupplierInf supplierInf = new SupplierInf();
supplierInf.setName(name);
supplierInf.setAddress(address);
supplierInf.setContact(contact);
supplierInf.setEmail(email);
int result = supplierInfService.addSupplierInf(supplierInf);
// int result = 1;
if (result == 1) {
JOptionPane.showMessageDialog(this, "添加成功", "提示",
JOptionPane.INFORMATION_MESSAGE);
this.dispose();
} else {
JOptionPane.showMessageDialog(this, "添加失败", "提示",
JOptionPane.ERROR_MESSAGE);
}
}/*else{
//更新
SupplierInf supplierInf= new SupplierInf();
supplierInf.setName(name);
supplierInf.setAddress(address);
supplierInf.setContact(contact);
supplierInf.setId(this.supplierInf.getId());
int result = supplierInfService.updateSupplierInf(supplierInf);
if(result==1){
JOptionPane.showMessageDialog(this, "更新成功", "提示",
JOptionPane.INFORMATION_MESSAGE);
int result = supplierInfService.addSupplierInf(supplierInf); // 调用服务接口添加供应商信息
if (result == 1) { // 如果添加成功
JOptionPane.showMessageDialog(this, "添加成功", "提示", JOptionPane.INFORMATION_MESSAGE);
this.dispose(); // 关闭对话框
} else { // 如果添加失败
JOptionPane.showMessageDialog(this, "添加失败", "提示", JOptionPane.ERROR_MESSAGE);
}
}*/
} else if (source == cancelBtn) {
this.dispose();
} /*else {
// 更新操作(当前代码被注释掉)
SupplierInf supplierInf = new SupplierInf();
supplierInf.setName(name);
supplierInf.setAddress(address);
supplierInf.setContact(contact);
supplierInf.setId(this.supplierInf.getId());
int result = supplierInfService.updateSupplierInf(supplierInf);
if (result == 1) {
JOptionPane.showMessageDialog(this, "更新成功", "提示", JOptionPane.INFORMATION_MESSAGE);
}
}*/
} else if (source == cancelBtn) { // 如果事件源是取消按钮
this.dispose(); // 关闭对话框
}
}
}
}

@ -2,6 +2,7 @@ package com.lingnan.supermarket.dto;
import com.lingnan.supermarket.dto.base.BaseProduction;
public class Buffer extends BaseProduction{
// 定义一个 Buffer 类,继承自 BaseProduction
public class Buffer extends BaseProduction {
}
}

@ -2,40 +2,71 @@ package com.lingnan.supermarket.dto;
import java.util.Date;
//表示出库订单的相关信息
public class OutOrder {
private String oNumber;
private Float allOutPrice;
private Date oDate;
private String principal;
private int delmark;
//出库订单编号
private String oNumber;
// 出库订单的总出库价格
private Float allOutPrice;
//出库日期
private Date oDate;
//负责人
private String principal;
//删除标记用于标识该订单是否被删除0已删除1未删除
private int delmark;
// 获取出库订单编号
public String getoNumber() {
return oNumber;
}
// 设置出库订单编号
public void setoNumber(String oNumber) {
this.oNumber = oNumber;
}
// 获取出库订单的总出库价格
public Float getAllOutPrice() {
return allOutPrice;
}
// 设置出库订单的总出库价格
public void setAllOutPrice(Float allOutPrice) {
this.allOutPrice = allOutPrice;
}
// 获取出库日期
public Date getoDate() {
return oDate;
}
// 设置出库日期
public void setoDate(Date oDate) {
this.oDate = oDate;
}
//获取负责人
public String getPrincipal() {
return principal;
}
//设置负责人
public void setPrincipal(String principal) {
this.principal = principal;
}
//获取删除标记
public int getDelmark() {
return delmark;
}
//设置删除标记
public void setDelmark(int delmark) {
this.delmark = delmark;
}
}
}

@ -2,26 +2,46 @@ package com.lingnan.supermarket.dto;
import com.lingnan.supermarket.dto.base.BsDomain;
public class OutRecord extends BsDomain{
private String oNumber;
private int sum;
private Float outPrice;
// 出库记录类
public class OutRecord extends BsDomain {
// 出库编号
private String oNumber;
// 出库数量
private int sum;
// 出库单价
private Float outPrice;
// 获取出库编号
public String getoNumber() {
return oNumber;
}
// 设置出库编号
public void setoNumber(String oNumber) {
this.oNumber = oNumber;
}
//获取出库数量
public int getSum() {
return sum;
}
//设置出库数量
public void setSum(int sum) {
this.sum = sum;
}
//获取出库单价
public Float getOutPrice() {
return outPrice;
}
//设置出库单价
public void setOutPrice(Float outPrice) {
this.outPrice = outPrice;
}
}
}

@ -1,15 +1,18 @@
package com.lingnan.supermarket.dto.base;
// 封装对象的通用属性
public class BaseDomain {
private Integer id;
// 获取 id 属性的 getter 方法
public Integer getId() {
return id;
}
// 设置 id 属性的 setter 方法
public void setId(Integer id) {
this.id = id;
}
}
}

@ -1,86 +1,148 @@
package com.lingnan.supermarket.dto.base;
// 封装商品相关的通用属性
public class BaseProduction {
// 商品标识符
private String id;
// 商品的名称
private String name;
private float inPrice;
private float OutPrice;
private int life;
private int sum;
private int supplyId;
private String id2;
private String name2;
private Float price;
private int delmark;
public String getId() {
// 商品的进货价格
private float inPrice;
// 商品的出货价格
private float OutPrice;
// 商品的保质期
private int life;
// 商品的库存数量
private int sum;
// 供应商的唯一标识符
private int supplyId;
// 商品的辅助标识符
private String id2;
// 商品的辅助名称
private String name2;
// 商品的总价格,浮点数类型
private Float price;
// 商品的删除标记用于标识商品是否被删除0未删除1已删除
private int delmark;
// 获取商品唯一标识符的方法
public String getId() {
return id;
}
// 设置商品唯一标识符
public void setId(String id) {
this.id = id;
}
// 获取商品删除标记
public int getDelmark() {
return delmark;
}
// 设置商品删除标记
public void setDelmark(int delmark) {
this.delmark = delmark;
}
// 获取商品库存数量
public int getSum() {
return sum;
}
// 设置商品库存数量
public void setSum(int sum) {
this.sum = sum;
}
// 获取商品名称
public String getName() {
return name;
}
// 设置商品名称
public void setName(String name) {
this.name = name;
}
// 获取商品进货价格
public float getInPrice() {
return inPrice;
}
// 设置商品进货价格
public void setInPrice(float inPrice) {
this.inPrice = inPrice;
}
// 获取商品出货价格
public float getOutPrice() {
return OutPrice;
}
// 设置商品出货价格
public void setOutPrice(float outPrice) {
OutPrice = outPrice;
}
// 获取商品保质期
public int getLife() {
return life;
}
// 设置商品保质期
public void setLife(int life) {
this.life = life;
}
// 获取商品辅助标识符
public String getId2() {
return id2;
}
// 设置商品辅助标识符
public void setId2(String id2) {
this.id2 = id2;
}
// 获取商品辅助名称
public String getName2() {
return name2;
}
// 设置商品辅助名称
public void setName2(String name2) {
this.name2 = name2;
}
// 获取供应商唯一标识符
public int getSupplyId() {
return supplyId;
}
// 设置供应商唯一标识符
public void setSupplyId(int supplyId) {
this.supplyId = supplyId;
}
// 获取商品总价格
public Float getPrice() {
return price;
}
// 设置商品总价格
public void setPrice(Float price) {
this.price = price;
}
}
}

@ -1,13 +1,13 @@
package com.lingnan.supermarket.dto.base;
public class BsDomain {
private String id;
private String id;
// 获取 id 属性的 getter 方法
public String getId() {
return id;
}
// 设置 id 属性的 setter 方法
public void setId(String id) {
this.id = id;
}
}
}

@ -15,93 +15,102 @@ import com.lingnan.supermarket.dao.UserService;
import com.lingnan.supermarket.dao.impl.*;
import com.lingnan.supermarket.dialog.InDialog;
//用于管理入库订单的表格数据
public class InOrderTM extends AbstractTableModel{
public class InOrderTM extends AbstractTableModel {
private String [] columnName = {"订单号","总价","时间","负责人","状态"};
// 表格列名
private String[] columnName = {"订单号", "总价", "时间", "负责人", "状态"};
// 商品服务实现类
private productionImpl prodDao = new productionImpl();
private Vector<InOrder> InOrders;
private inOrderServiceImpl inOrderImpl= new inOrderServiceImpl();
private InOrder inOrder ;
// 入库订单数据集合
private Vector<InOrder> InOrders;
String iNumber ;/*订单号*/
// 入库订单服务实现类
private inOrderServiceImpl inOrderImpl = new inOrderServiceImpl();
// 当前操作的入库订单对象
private InOrder inOrder;
// 订单号
String iNumber;
//加载所有入库订单记录
public void allInOrderRecord() {
//将添加的商品加入到静态变量Vector数组中
/*prod = InDialog.getProduction();*/
// 从数据库中获取所有入库订单记录
InOrders = inOrderImpl.findAllInOrder();
}
//查找分类结果
//根据分类查找入库订单记录0全部1已入库2待入库3已取消
public void resultOfFind(int catalog) {
if(catalog==0)
if (catalog == 0) {
// 加载所有入库订单记录
InOrders = inOrderImpl.findAllInOrder();
else
} else {
// 根据状态查找入库订单记录
InOrders = inOrderImpl.FindStatus(catalog);
}
}
//根据订单查找
// 根据订单查找入库订单记录
public void resultOfNumber(String Number) {
InOrders=new Vector<InOrder>();
InOrders = new Vector<InOrder>();
inOrder = inOrderImpl.findByIdinOrder(Number);
InOrders.add(inOrder);
}
//获取表格行数
@Override
public int getRowCount() {
return InOrders.size();
}
/* public Float getAllPrice() {
return BufferImpl.InBufferAllPrice();
}
*/
// 获取表格列数
@Override
public int getColumnCount() {
return columnName.length;
}
//获取指定单元格的值
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
inOrder = InOrders.get(rowIndex);
/* System.out.println( "id="+users.get(rowIndex).getId());
System.out.println("rowIndex"+rowIndex);
System.out.println("columnIndex"+columnIndex);*/
iNumber=inOrder.getiNumber();
if(columnIndex==0) {
return inOrder.getiNumber();
}else if(columnIndex==1) {
return inOrder.getAllInPrice();
}else if(columnIndex==2) {
return inOrder.getInDate();
}else if(columnIndex==3) {
return inOrder.getPrincipal();
}else if(columnIndex==4) {
iNumber = inOrder.getiNumber();
// 根据列索引返回对应的数据
if (columnIndex == 0) {
return inOrder.getiNumber(); // 订单号
} else if (columnIndex == 1) {
return inOrder.getAllInPrice(); // 总价
} else if (columnIndex == 2) {
return inOrder.getInDate(); // 时间
} else if (columnIndex == 3) {
return inOrder.getPrincipal(); // 负责人
} else if (columnIndex == 4) {
// 根据状态返回对应的字符串
String status = null;
if(inOrder.getStatus()==1)
status= "已入库";
else if(inOrder.getStatus()==2)
status= "待入库";
else if(inOrder.getStatus()==3)
status= "已取消";
if (inOrder.getStatus() == 1)
status = "已入库";
else if (inOrder.getStatus() == 2)
status = "待入库";
else if (inOrder.getStatus() == 3)
status = "已取消";
return status;
}else {
} else {
return null;
}
}
public String getINumber() { /*返回要修改或删除的记录*/
//获取当前操作的订单号
public String getINumber() {
return iNumber;
}
//获取指定列的列名
@Override
public String getColumnName(int column) {
return columnName[column];
}
}
}

@ -9,83 +9,83 @@ import javax.swing.table.AbstractTableModel;
import com.lingnan.supermarket.dto.Buffer;
import com.lingnan.supermarket.dto.InOrder;
import com.lingnan.supermarket.dto.InRecord;
import com.lingnan.supermarket.dto.Buffer;
import com.lingnan.supermarket.dto.Production;
import com.lingnan.supermarket.dto.User;
import com.lingnan.supermarket.dao.UserService;
import com.lingnan.supermarket.dao.impl.*;
import com.lingnan.supermarket.dialog.InDialog;
//用于管理入库记录的表格数据
public class InRecordTM extends AbstractTableModel {
public class InRecordTM extends AbstractTableModel{
private String [] columnName = {"订单号","id","数量","金额"};
// 表格列名数组
private String[] columnName = { "订单号", "id", "数量", "金额" };
// 商品数据访问对象
private productionImpl prodDao = new productionImpl();
private Vector<InRecord> InRecords;
// 入库记录数据集合
private Vector<InRecord> InRecords;
// 入库记录服务实现类
private inRecordServiceImpl inRecordImpl = new inRecordServiceImpl();
private InRecord inRecord= new InRecord();
// 当前操作的入库记录对象
private InRecord inRecord = new InRecord();
private String iNumber ;/*订单号*/
// 订单号
private String iNumber;
//构造函数,初始化订单号
public InRecordTM(String iNumber) {
this.iNumber=iNumber;
this.iNumber = iNumber;
}
//根据订单号查找入库记录
public void findInRecordByINumber() {
//将添加的商品加入到静态变量Vector数组中
/*prod = InDialog.getProduction();*/
// 将添加的商品加入到静态变量 Vector 数组中
// prod = InDialog.getProduction();
InRecords = inRecordImpl.findByIdinRecord(iNumber);
}
//获取表格的行数
@Override
public int getRowCount() {
return InRecords.size();
}
/* public Float getAllPrice() {
return BufferImpl.InBufferAllPrice();
}
*/
//获取表格的列数
@Override
public int getColumnCount() {
return columnName.length;
}
//获取指定单元格的值
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
inRecord = InRecords.get(rowIndex);
/* System.out.println( "id="+users.get(rowIndex).getId());
System.out.println("rowIndex"+rowIndex);
System.out.println("columnIndex"+columnIndex);*/
iNumber=inRecord.getiNumber();
if(columnIndex==0) {
return inRecord.getiNumber();
}else if(columnIndex==1) {
return inRecord.getId();
}else if(columnIndex==2) {
return inRecord.getSum();
}else if(columnIndex==3) {
return inRecord.getInPrice();
}else {
iNumber = inRecord.getiNumber();
if (columnIndex == 0) {
return inRecord.getiNumber(); // 返回订单号
} else if (columnIndex == 1) {
return inRecord.getId(); // 返回商品ID
} else if (columnIndex == 2) {
return inRecord.getSum(); // 返回数量
} else if (columnIndex == 3) {
return inRecord.getInPrice(); // 返回金额
} else {
return null;
}
}
public String getINumber() { /*返回要修改或删除的记录*/
//获取订单
public String getINumber() {
return iNumber;
}
// 获取指定列的列名
@Override
public String getColumnName(int column) {
return columnName[column];
}
}
}

@ -3,91 +3,90 @@ package com.lingnan.supermarket.table;
import java.util.List;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;
import com.lingnan.supermarket.dto.SupplierInf;
import com.lingnan.supermarket.dao.SupplierInfService;
import com.lingnan.supermarket.dao.impl.*;
import com.lingnan.supermarket.dao.impl.SupplierInfImpl;
public class SupplierTableModel extends AbstractTableModel{
// 管理供应商信息的表格数据
public class SupplierTableModel extends AbstractTableModel {
private String [] columnName = {"id","名称","地址","电话","邮箱"};
// 定义表格的列名数组
private String[] columnName = { "id", "名称", "地址", "电话", "邮箱" };
//private SupplierInfImpl supplierDao = new SupplierInfImpl();
// 创建 SupplierInfService 对象,用于与数据库交互
private SupplierInfService supplierInfService = new SupplierInfImpl();
// 创建 SupplierInf 对象,用于存储单个供应商信息
private SupplierInf supplierInf = new SupplierInf();
// 创建 Vector 集合,用于存储所有供应商信息
private Vector<SupplierInf> suppliers;
private int id=0;
// 定义一个整型变量 id用于存储供应商的唯一标识符
private int id = 0;
// 加载所有供应商信息的方法
public void all() {
//查找全部数据
// 从数据库中查找全部供应商信息
suppliers = supplierInfService.findAllSupplierInf();
}
// 根据供应商名称加载供应商信息的方法
public void Byname(SupplierInf supplierInf) {
// 根据供应商名称查找供应商信息
suppliers = supplierInfService.findByNameSupplierInf(supplierInf);
}
// 获取表格行数的方法
@Override
public int getRowCount() {
return suppliers.size();
return suppliers.size(); // 返回供应商集合的大小
}
// 获取表格列数的方法
@Override
public int getColumnCount() {
return columnName.length;
return columnName.length; // 返回列名数组的长度
}
// 获取指定单元格值的方法
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
SupplierInf prod = suppliers.get(rowIndex);
//id = supplierInf.getId();
/* System.out.println( "id="+users.get(rowIndex).getId());
System.out.println("rowIndex"+rowIndex);
System.out.println("columnIndex"+columnIndex);*/
if(columnIndex==0) {
return prod.getId();
}else if(columnIndex==1) {
return prod.getName();
}else if(columnIndex==2) {
return prod.getAddress();
}else if(columnIndex==3) {
return prod.getContact();
}else if(columnIndex==4){
return prod.getEmail();
}
else {
return null;
SupplierInf prod = suppliers.get(rowIndex); // 获取指定行的供应商对象
// 根据列索引返回对应的供应商信息
if (columnIndex == 0) {
return prod.getId(); // 返回供应商的唯一标识符
} else if (columnIndex == 1) {
return prod.getName(); // 返回供应商的名称
} else if (columnIndex == 2) {
return prod.getAddress(); // 返回供应商的地址
} else if (columnIndex == 3) {
return prod.getContact(); // 返回供应商的联系电话
} else if (columnIndex == 4) {
return prod.getEmail(); // 返回供应商的邮箱
} else {
return null; // 如果列索引无效,返回 null
}
}
// 获取指定列名的方法
@Override
public String getColumnName(int column) {
return columnName[column];
return columnName[column]; // 返回列名数组中指定索引的列名
}
/*
public int getId() {
return id;
}
public int getValueAt(int rowIndex){
SupplierInf supplierInf = suppliers.get(rowIndex);
id=suppliers.get(rowIndex).getId();
//System.out.println("rowIndex"+rowIndex);
//System.out.println("columnIndex"+columnIndex);
return supplierInf.getId();
}
*/
}
/*
*
* public int getId() {
* return id;
* }
*
* public int getValueAt(int rowIndex){
* SupplierInf supplierInf = suppliers.get(rowIndex);
* id = suppliers.get(rowIndex).getId();
* return supplierInf.getId();
* }
*/
}

@ -3,17 +3,8 @@ package com.lingnan.supermarket.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
// DateUtil类从名称可以推测是用于处理日期相关操作的工具类
// 用于处理日期相关操作的工具类
public class DateUtil {
/**
* dateToStringDate
*
* @param date Date
* @param pattern "yyyy-MM-dd HH:mm:ss"-- ::
* patternnull使"yyyy-MM-dd HH:mm:ss"
* @return 便使
*/
public static String dateToString(Date date, String pattern) {
// 创建SimpleDateFormat对象它是Java中用于格式化日期的类通过指定的模式将日期转换为相应格式的字符串。
SimpleDateFormat simpleDateFormat = new SimpleDateFormat();

@ -3,7 +3,6 @@ package com.lingnan.supermarket.utils;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
// EmailTest类
public class EmailTest {
//Java程序的入口点

@ -9,7 +9,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
// JDBCUtil工具类用于管理数据库连接相关的操作,如加载数据库配置、获取数据库连接以及释放相关资源等
// 用于管理数据库连接相关的操作,如加载数据库配置、获取数据库连接以及释放相关资源等
public class JDBCUtil {
// 用于存储数据库连接相关的配置信息,通过读取配置文件将配置项加载到该对象中

@ -1,6 +1,6 @@
package com.lingnan.supermarket.utils;
//测试类,用于演示静态代码块的使用
//用于演示静态代码块的使用
public class Test {
static {
System.out.println("tasdasd."); // 打印一条测试信息

@ -4,17 +4,8 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Random;
//具类,用于生成订单号和时间戳
//生成订单号和时间戳
public class TimeAndOrder {
/**
*
*
* "yyyy-MM-dd HH:mm:ss"
*
* @param username
* @return
*/
public static String[] TimeAndOrder(String username) {
// 创建一个长度为2的字符串数组用于存储订单号和时间戳
String[] s = new String[2];

@ -29,166 +29,136 @@ import com.lingnan.supermarket.table.StorageTableModel;
import com.lingnan.supermarket.table.UserTableModel;
import com.lingnan.supermarket.utils.FontUtil;
public class ProdCatalogView extends JPanel {
/**
*
* JPanel
*/
public class ProdCatalogView extends JPanel {
// 上面
// 顶部工具栏面板
private JPanel toolBarPanel;
// 搜索面板
private JPanel searchPanel;
private JLabel logLabel, locationLabel;
private JTextField nameSearchTF;
private JButton searchBtn;
// 操作面板
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"; // 当前选中的商品类别ID
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 JPanel bottomPanel;
private JLabel countInfoLabel;
private JFrame jFrame;
private JFrame jFrame; // 父窗口
// 构造函数,初始化商品目录视图
public ProdCatalogView(JFrame jFrame) {
this.setLayout(new BorderLayout());
initView();
this.jFrame = jFrame;
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));
locationLabel.setFont(new FontUtil().userFont); // 设置字体
locationLabel.setForeground(new Color(18, 150, 219)); // 设置颜色
logLabel = 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);
// 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);
for(int i=0;i<log.length;i++)
{
System.out.println(log[i]);
}
// 初始化商品类别下拉框
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); // 将商品类别名称存入数组
combo = new JComboBox<String>(log); // 创建商品类别下拉框
combo.addItemListener(new MyItemListener()); // 添加下拉框监听器
combo = new JComboBox<String>(log);
combo.addItemListener(new MyItemListener());
// 将组件添加到搜索面板
searchPanel.add(locationLabel);
searchPanel.add(logLabel);
searchPanel.add(combo);
/*
* searchPanel.add(nameSearchTF); searchPanel.add(searchBtn);
*/
// 将搜索面板添加到工具栏面板的左侧
toolBarPanel.add(searchPanel, "West");
// toolBarPanel.add(opePanel, "East");
// 中间表格
// 初始化中间表格
prodCatalogTM = new ProdCatalogTM();
prodCatalogTM.all();
prodCatalogTM.all(); // 加载所有商品类别数据
prodCatalogTable = new JTable(prodCatalogTM);
prodCatalogTable.setFont(FontUtil.tableFont);
prodCatalogTable.setRowHeight(50);
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");
// 将各个面板添加到主面板
this.add(toolBarPanel, "North"); // 顶部工具栏
this.add(tableScrollPane, "Center"); // 中间表格
this.add(bottomPanel, "South"); // 底部信息
setVisible(true);
setVisible(true); // 设置可见
}
// @Override
// public void actionPerformed(ActionEvent e) {
// Object source = e.getSource();
// if (addBtn == source) {
// 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);
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); // 根据名称获取商品类别ID
System.out.println(catalog);
}
refreshFindId2();
refreshFindId2(); // 刷新界面
}
}
// 刷新当前界面
//刷新当前界面根据商品类别ID加载数据
public void refreshFindId2() {
Production p = new Production();
p.setId2(catalog);
p.setId2(catalog); // 设置商品类别ID
prodCatalogTM = new ProdCatalogTM();
prodCatalogTM.ById2(p);
prodCatalogTable.setModel(prodCatalogTM);
// 同时更新下面的记录数
refreshCount();
prodCatalogTM.ById2(p); // 根据商品类别ID加载数据
prodCatalogTable.setModel(prodCatalogTM); // 更新表格模型
refreshCount(); // 同时更新下面的记录数
}
//刷新底部记录数信息
public void refreshCount() {
bottomPanel.removeAll();
countInfoLabel = new JLabel("总共" + prodCatalogTM.getRowCount() + "条");
bottomPanel.add(countInfoLabel);
bottomPanel.removeAll(); // 清空底部面板
countInfoLabel = new JLabel("总共" + prodCatalogTM.getRowCount() + "条"); // 更新记录数
bottomPanel.add(countInfoLabel); // 添加到底部面板
}
}

@ -16,4 +16,5 @@ d7
顶顶顶
444444
11111
Z4
Z4
Z5
Loading…
Cancel
Save