diff --git a/Supermarket/bin/.idea/dataSources/5b23e521-053a-47c0-ae28-a98b513bc6ec.xml b/Supermarket/bin/.idea/dataSources/5b23e521-053a-47c0-ae28-a98b513bc6ec.xml
deleted file mode 100644
index 7c2a72a..0000000
--- a/Supermarket/bin/.idea/dataSources/5b23e521-053a-47c0-ae28-a98b513bc6ec.xml
+++ /dev/null
@@ -1,1334 +0,0 @@
-
-
-
-
- lower/lower
- InnoDB
- InnoDB
- |root||root|localhost|ALTER|G
-|root||root|localhost|ALTER ROUTINE|G
-|root||root|localhost|CREATE|G
-|root||root|localhost|CREATE ROUTINE|G
-|root||root|localhost|CREATE TABLESPACE|G
-|root||root|localhost|CREATE TEMPORARY TABLES|G
-|root||root|localhost|CREATE USER|G
-|root||root|localhost|CREATE VIEW|G
-|root||root|localhost|DELETE|G
-|root||root|localhost|DROP|G
-|root||root|localhost|EVENT|G
-|root||root|localhost|EXECUTE|G
-|root||root|localhost|FILE|G
-|root||root|localhost|INDEX|G
-|root||root|localhost|INSERT|G
-|root||root|localhost|LOCK TABLES|G
-|root||root|localhost|PROCESS|G
-|root||root|localhost|REFERENCES|G
-|root||root|localhost|RELOAD|G
-|root||root|localhost|REPLICATION CLIENT|G
-|root||root|localhost|REPLICATION SLAVE|G
-|root||root|localhost|SELECT|G
-|root||root|localhost|SHOW DATABASES|G
-|root||root|localhost|SHOW VIEW|G
-|root||root|localhost|SHUTDOWN|G
-|root||mysql.session|localhost|SUPER|G
-|root||root|localhost|SUPER|G
-|root||root|localhost|TRIGGER|G
-|root||root|localhost|UPDATE|G
-|root||root|localhost|grant option|G
-performance_schema|schema||mysql.session|localhost|SELECT|G
-sys|schema||mysql.sys|localhost|TRIGGER|G
- 5.7.44
-
-
- big5
- 1
-
-
- big5
-
-
- dec8
- 1
-
-
- dec8
-
-
- cp850
- 1
-
-
- cp850
-
-
- hp8
- 1
-
-
- hp8
-
-
- koi8r
- 1
-
-
- koi8r
-
-
- latin1
-
-
- latin1
- 1
-
-
- latin1
-
-
- latin1
-
-
- latin1
-
-
- latin1
-
-
- latin1
-
-
- latin1
-
-
- latin2
-
-
- latin2
- 1
-
-
- latin2
-
-
- latin2
-
-
- latin2
-
-
- swe7
- 1
-
-
- swe7
-
-
- ascii
- 1
-
-
- ascii
-
-
- ujis
- 1
-
-
- ujis
-
-
- sjis
- 1
-
-
- sjis
-
-
- hebrew
- 1
-
-
- hebrew
-
-
- tis620
- 1
-
-
- tis620
-
-
- euckr
- 1
-
-
- euckr
-
-
- koi8u
- 1
-
-
- koi8u
-
-
- gb2312
- 1
-
-
- gb2312
-
-
- greek
- 1
-
-
- greek
-
-
- cp1250
- 1
-
-
- cp1250
-
-
- cp1250
-
-
- cp1250
-
-
- cp1250
-
-
- gbk
- 1
-
-
- gbk
-
-
- latin5
- 1
-
-
- latin5
-
-
- armscii8
- 1
-
-
- armscii8
-
-
- utf8
- 1
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- utf8
-
-
- ucs2
- 1
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- ucs2
-
-
- cp866
- 1
-
-
- cp866
-
-
- keybcs2
- 1
-
-
- keybcs2
-
-
- macce
- 1
-
-
- macce
-
-
- macroman
- 1
-
-
- macroman
-
-
- cp852
- 1
-
-
- cp852
-
-
- latin7
-
-
- latin7
- 1
-
-
- latin7
-
-
- latin7
-
-
- utf8mb4
- 1
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- utf8mb4
-
-
- cp1251
-
-
- cp1251
-
-
- cp1251
-
-
- cp1251
- 1
-
-
- cp1251
-
-
- utf16
- 1
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16
-
-
- utf16le
- 1
-
-
- utf16le
-
-
- cp1256
- 1
-
-
- cp1256
-
-
- cp1257
-
-
- cp1257
-
-
- cp1257
- 1
-
-
- utf32
- 1
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- utf32
-
-
- binary
- 1
-
-
- geostd8
- 1
-
-
- geostd8
-
-
- cp932
- 1
-
-
- cp932
-
-
- eucjpms
- 1
-
-
- eucjpms
-
-
- gb18030
- 1
-
-
- gb18030
-
-
- gb18030
-
-
- utf8_general_ci
-
-
- latin1_swedish_ci
-
-
- latin1_swedish_ci
-
-
- latin1_swedish_ci
-
-
- utf8_general_ci
-
-
- latin1_swedish_ci
-
-
- utf8mb4_unicode_ci
-
-
- utf8_general_ci
-
-
- utf8mb4_general_ci
-
-
- localhost
-
-
- localhost
-
-
- localhost
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- InnoDB
- utf8mb4_unicode_ci
-
-
- varchar(20)|0s
- 1
- 1
-
-
- varchar(20)|0s
- 2
-
-
- float|0s
- 3
-
-
- float|0s
- 4
-
-
- int(11)|0s
- 5
-
-
- int(11)|0s
- 6
-
-
- int(11)|0s
- 7
-
-
- varchar(20)|0s
- 8
-
-
- varchar(20)|0s
- 9
-
-
- float|0s
- 10
-
-
- int(11)|0s
- 0
- 11
-
-
- supplyId
- id
- supplierinf
-
-
- id2
- id
- prodcatalog
-
-
- id
- btree
- 1
-
-
- name
- btree
- 1
-
-
- supplyId
- btree
-
-
- id2
- btree
-
-
- 1
- 1
- PRIMARY
-
-
- name
-
-
- varchar(30)|0s
- 1
- 1
-
-
- float|0s
- 2
-
-
- timestamp|0s
- CURRENT_TIMESTAMP
- 1
- CURRENT_TIMESTAMP
- 3
-
-
- varchar(15)|0s
- 4
-
-
- int(11)|0s
- 2
- 5
-
-
- int(11)|0s
- 1
- 6
-
-
- iNumber
- btree
- 1
-
-
- 1
- 1
- PRIMARY
-
-
- varchar(30)|0s
- 1
-
-
- varchar(20)|0s
- 2
-
-
- int(11)|0s
- 3
-
-
- float|0s
- 4
-
-
- iNumber
- iNumber
- inorder
-
-
- iNumber
- btree
-
-
- varchar(20)|0s
- 1
- 1
-
-
- varchar(20)|0s
- 2
-
-
- float|0s
- 3
-
-
- float|0s
- 4
-
-
- int(11)|0s
- 5
-
-
- int(11)|0s
- 6
-
-
- int(11)|0s
- 7
-
-
- varchar(20)|0s
- 8
-
-
- varchar(20)|0s
- 9
-
-
- float|0s
- 10
-
-
- int(11)|0s
- 0
- 11
-
-
- supplyId
- id
- supplierinf
-
-
- id2
- id
- prodcatalog
-
-
- id
- btree
- 1
-
-
- name
- btree
- 1
-
-
- supplyId
- btree
-
-
- id2
- btree
-
-
- 1
- 1
- PRIMARY
-
-
- name
-
-
- varchar(30)|0s
- 1
- 1
-
-
- float|0s
- 2
-
-
- timestamp|0s
- CURRENT_TIMESTAMP
- 1
- CURRENT_TIMESTAMP
- 3
-
-
- varchar(15)|0s
- 4
-
-
- int(11)|0s
- 1
- 5
-
-
- oNumber
- btree
- 1
-
-
- 1
- 1
- PRIMARY
-
-
- varchar(30)|0s
- 1
-
-
- varchar(20)|0s
- 2
-
-
- int(11)|0s
- 3
-
-
- float|0s
- 4
-
-
- oNumber
- oNumber
- outorder
-
-
- oNumber
- btree
-
-
- varchar(20)|0s
- 1
- 1
-
-
- varchar(20)|0s
- 2
-
-
- id
- btree
- 1
-
-
- 1
- 1
- PRIMARY
-
-
- varchar(20)|0s
- 1
- 1
-
-
- varchar(20)|0s
- 2
-
-
- float|0s
- 3
-
-
- float|0s
- 4
-
-
- int(11)|0s
- 5
-
-
- int(11)|0s
- 6
-
-
- int(11)|0s
- 7
-
-
- varchar(20)|0s
- 8
-
-
- varchar(20)|0s
- 9
-
-
- float|0s
- 10
-
-
- int(11)|0s
- 1
- 11
-
-
- id2
- id
- prodcatalog
-
-
- id
- btree
- 1
-
-
- name
- btree
- 1
-
-
- id2
- btree
-
-
- 1
- 1
- PRIMARY
-
-
- name
-
-
- varchar(30)|0s
- 1
-
-
- timestamp|0s
- CURRENT_TIMESTAMP
- 1
- CURRENT_TIMESTAMP
- 2
-
-
- varchar(20)|0s
- 3
-
-
- enum('+', '-')|0e
- 4
-
-
- int(11)|0s
- 5
-
-
- 9
- int(11)|0s
- 1
- 1
-
-
- varchar(30)|0s
- 2
-
-
- varchar(50)|0s
- 3
-
-
- varchar(11)|0s
- 4
-
-
- varchar(50)|0s
- 5
-
-
- int(11)|0s
- 1
- 6
-
-
- id
- btree
- 1
-
-
- name
- btree
- 1
-
-
- 1
- 1
- PRIMARY
-
-
- name
-
-
- 7
- int(11)|0s
- 1
- 1
-
-
- varchar(15)|0s
- 2
-
-
- varchar(255)|0s
- 3
-
-
- varchar(20)|0s
- 1
- 4
-
-
- varchar(11)|0s
- 5
-
-
- int(11)|0s
- 1
- 6
-
-
- varchar(50)|0s
- 7
-
-
- int(11)|0s
- 1
- 8
-
-
- id
- btree
- 1
-
-
- name
- btree
- 1
-
-
- 1
- 1
- PRIMARY
-
-
- name
-
-
-
\ No newline at end of file
diff --git a/Supermarket/bin/com/lingnan/supermarket/dao/impl/productionImpl.class b/Supermarket/bin/com/lingnan/supermarket/dao/impl/productionImpl.class
index 90154e9..f0d9b62 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dao/impl/productionImpl.class and b/Supermarket/bin/com/lingnan/supermarket/dao/impl/productionImpl.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dialog/InDialog$MyItemListener.class b/Supermarket/bin/com/lingnan/supermarket/dialog/InDialog$MyItemListener.class
index 9c4f5cd..ece0731 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dialog/InDialog$MyItemListener.class and b/Supermarket/bin/com/lingnan/supermarket/dialog/InDialog$MyItemListener.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dialog/InDialog.class b/Supermarket/bin/com/lingnan/supermarket/dialog/InDialog.class
index a5e905b..9b3cfaa 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dialog/InDialog.class and b/Supermarket/bin/com/lingnan/supermarket/dialog/InDialog.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog$MyItemListener.class b/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog$MyItemListener.class
index c5db66f..810fd5e 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog$MyItemListener.class and b/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog$MyItemListener.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog$MyItemListener1.class b/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog$MyItemListener1.class
index dec8820..5218b80 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog$MyItemListener1.class and b/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog$MyItemListener1.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog.class b/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog.class
index eb9ddd9..071ffec 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog.class and b/Supermarket/bin/com/lingnan/supermarket/dialog/ProductionDialog.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dialog/SupplierInfDialog.class b/Supermarket/bin/com/lingnan/supermarket/dialog/SupplierInfDialog.class
index d2ff2fe..f33b384 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dialog/SupplierInfDialog.class and b/Supermarket/bin/com/lingnan/supermarket/dialog/SupplierInfDialog.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dto/Buffer.class b/Supermarket/bin/com/lingnan/supermarket/dto/Buffer.class
index 9064935..5e31969 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dto/Buffer.class and b/Supermarket/bin/com/lingnan/supermarket/dto/Buffer.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dto/OutOrder.class b/Supermarket/bin/com/lingnan/supermarket/dto/OutOrder.class
index 076b370..8d5750a 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dto/OutOrder.class and b/Supermarket/bin/com/lingnan/supermarket/dto/OutOrder.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dto/OutRecord.class b/Supermarket/bin/com/lingnan/supermarket/dto/OutRecord.class
index b638aa9..bf5f1cd 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dto/OutRecord.class and b/Supermarket/bin/com/lingnan/supermarket/dto/OutRecord.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dto/base/BaseDomain.class b/Supermarket/bin/com/lingnan/supermarket/dto/base/BaseDomain.class
index 9784ef6..d7d7aeb 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dto/base/BaseDomain.class and b/Supermarket/bin/com/lingnan/supermarket/dto/base/BaseDomain.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/dto/base/BaseProduction.class b/Supermarket/bin/com/lingnan/supermarket/dto/base/BaseProduction.class
index f07322e..54c198b 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/dto/base/BaseProduction.class and b/Supermarket/bin/com/lingnan/supermarket/dto/base/BaseProduction.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/table/InOrderTM.class b/Supermarket/bin/com/lingnan/supermarket/table/InOrderTM.class
index c9bf084..6797053 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/table/InOrderTM.class and b/Supermarket/bin/com/lingnan/supermarket/table/InOrderTM.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/table/InRecordTM.class b/Supermarket/bin/com/lingnan/supermarket/table/InRecordTM.class
index e5bda6a..358cc12 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/table/InRecordTM.class and b/Supermarket/bin/com/lingnan/supermarket/table/InRecordTM.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/table/SupplierTableModel.class b/Supermarket/bin/com/lingnan/supermarket/table/SupplierTableModel.class
index bd8e1a5..ca442db 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/table/SupplierTableModel.class and b/Supermarket/bin/com/lingnan/supermarket/table/SupplierTableModel.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/utils/DateUtil.class b/Supermarket/bin/com/lingnan/supermarket/utils/DateUtil.class
index 7129ff2..4dd8b81 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/utils/DateUtil.class and b/Supermarket/bin/com/lingnan/supermarket/utils/DateUtil.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/utils/EmailTest.class b/Supermarket/bin/com/lingnan/supermarket/utils/EmailTest.class
index 2a92b22..41a0d5c 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/utils/EmailTest.class and b/Supermarket/bin/com/lingnan/supermarket/utils/EmailTest.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/utils/TimeAndOrder.class b/Supermarket/bin/com/lingnan/supermarket/utils/TimeAndOrder.class
index d0c4b0e..afa3722 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/utils/TimeAndOrder.class and b/Supermarket/bin/com/lingnan/supermarket/utils/TimeAndOrder.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/view/ProdCatalogView$MyItemListener.class b/Supermarket/bin/com/lingnan/supermarket/view/ProdCatalogView$MyItemListener.class
index d5cd8dd..ef32f75 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/view/ProdCatalogView$MyItemListener.class and b/Supermarket/bin/com/lingnan/supermarket/view/ProdCatalogView$MyItemListener.class differ
diff --git a/Supermarket/bin/com/lingnan/supermarket/view/ProdCatalogView.class b/Supermarket/bin/com/lingnan/supermarket/view/ProdCatalogView.class
index 006a906..110284f 100644
Binary files a/Supermarket/bin/com/lingnan/supermarket/view/ProdCatalogView.class and b/Supermarket/bin/com/lingnan/supermarket/view/ProdCatalogView.class differ
diff --git a/Supermarket/src/com/lingnan/supermarket/dao/impl/productionImpl.java b/Supermarket/src/com/lingnan/supermarket/dao/impl/productionImpl.java
index 268b5f3..b5815b3 100644
--- a/Supermarket/src/com/lingnan/supermarket/dao/impl/productionImpl.java
+++ b/Supermarket/src/com/lingnan/supermarket/dao/impl/productionImpl.java
@@ -19,73 +19,73 @@ public class productionImpl implements productionService {
public Vector findAllproduction() {
Vector productions = new Vector();
- 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 productions = new Vector();
- 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 findProductionById2(String id) {
/**
- * 由一个商品类别id2查找并输出全部商品
+ * 由一个商品类别id2查找并输出全部商品
*/
Vector productions = new Vector();
- 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; // 返回操作结果
}
-
-}
+}
\ No newline at end of file
diff --git a/Supermarket/src/com/lingnan/supermarket/dialog/InDialog.java b/Supermarket/src/com/lingnan/supermarket/dialog/InDialog.java
index b0b28cb..0f720b0 100644
--- a/Supermarket/src/com/lingnan/supermarket/dialog/InDialog.java
+++ b/Supermarket/src/com/lingnan/supermarket/dialog/InDialog.java
@@ -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 v;
+ // 定义User对象,用于存储用户信息
private User user;
+ // 定义JFrame对象,用于存储父窗口
private JFrame JFramparent;
+ // 定义JComboBox对象和字符串数组,用于商品编号选择
private JComboBox combo;
private String allProdId[] = null;
private Vector vAll;
private static String catalog;
- public InDialog(JFrame parent,Vector 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 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(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(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 getVector(){
- return v;
+ // 获取商品数据集合的方法
+ public Vector 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(); // 关闭对话框
}
}
-
-
-}
+}
\ No newline at end of file
diff --git a/Supermarket/src/com/lingnan/supermarket/dialog/ProductionDialog.java b/Supermarket/src/com/lingnan/supermarket/dialog/ProductionDialog.java
index 152c9ae..0a00aa3 100644
--- a/Supermarket/src/com/lingnan/supermarket/dialog/ProductionDialog.java
+++ b/Supermarket/src/com/lingnan/supermarket/dialog/ProductionDialog.java
@@ -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 ArrayListalog=null;
- private ProdCatalogTM prodCatalogTM;
- private ProdCatalog pc;
- private prodCatalogImpl pci;
- private JComboBox combo;
- private String id2;
- private String name2;
-
- //下拉供应商类别
- private String superlier[]=null;
- private ArrayListasuperlier=null;
- private SupplierInf si;
- private SupplierInfImpl sii;
- private JComboBox combo1;
- private int supplyid;
-
- private StorageView storageView;
-
- private Production production;
-
+ // 下拉类别相关变量
+ private String log[] = null; // 商品类别名称数组
+ private ArrayList alog = null; // 商品类别名称列表
+ private ProdCatalogTM prodCatalogTM; // 商品类别表格模型
+ private ProdCatalog pc; // 商品类别对象
+ private prodCatalogImpl pci; // 商品类别服务实现类
+ private JComboBox combo; // 商品类别下拉框
+ private String id2; // 商品类别ID
+ private String name2; // 商品类别名称
+
+ // 下拉供应商类别相关变量
+ private String superlier[] = null; // 供应商名称数组
+ private ArrayList asuperlier = null; // 供应商名称列表
+ private SupplierInf si; // 供应商对象
+ private SupplierInfImpl sii; // 供应商服务实现类
+ private JComboBox 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(superlier);
- combo1.addItemListener(new MyItemListener1());
+ combo1 = new JComboBox(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(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(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 InOrders;
- private inOrderServiceImpl inOrderImpl= new inOrderServiceImpl();
- private InOrder inOrder ;
+ // 入库订单数据集合
+ private Vector 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();
+ InOrders = new Vector();
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];
}
-
-
-}
+}
\ No newline at end of file
diff --git a/Supermarket/src/com/lingnan/supermarket/table/InRecordTM.java b/Supermarket/src/com/lingnan/supermarket/table/InRecordTM.java
index e09bc0b..d5a65ed 100644
--- a/Supermarket/src/com/lingnan/supermarket/table/InRecordTM.java
+++ b/Supermarket/src/com/lingnan/supermarket/table/InRecordTM.java
@@ -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 InRecords;
+ // 入库记录数据集合
+ private Vector 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];
}
-
-
-}
+}
\ No newline at end of file
diff --git a/Supermarket/src/com/lingnan/supermarket/table/SupplierTableModel.java b/Supermarket/src/com/lingnan/supermarket/table/SupplierTableModel.java
index 479fa7a..1c42f62 100644
--- a/Supermarket/src/com/lingnan/supermarket/table/SupplierTableModel.java
+++ b/Supermarket/src/com/lingnan/supermarket/table/SupplierTableModel.java
@@ -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 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();
+ * }
+ */
+}
\ No newline at end of file
diff --git a/Supermarket/src/com/lingnan/supermarket/utils/DateUtil.java b/Supermarket/src/com/lingnan/supermarket/utils/DateUtil.java
index 8297759..6a08315 100644
--- a/Supermarket/src/com/lingnan/supermarket/utils/DateUtil.java
+++ b/Supermarket/src/com/lingnan/supermarket/utils/DateUtil.java
@@ -3,17 +3,8 @@ package com.lingnan.supermarket.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
-// DateUtil类,从名称可以推测是用于处理日期相关操作的工具类
+// 用于处理日期相关操作的工具类
public class DateUtil {
-
- /**
- * dateToString方法用于将给定的Date类型日期对象按照指定的格式转换为字符串表示形式。
- *
- * @param date 要进行格式化的Date类型日期对象,代表一个具体的时间点,例如某个操作发生的时间等。
- * @param pattern 用于指定日期格式化的模式字符串,例如"yyyy-MM-dd HH:mm:ss"表示年-月-日 时:分:秒的格式。
- * 如果传入的pattern为null,则默认使用"yyyy-MM-dd HH:mm:ss"格式进行格式化。
- * @return 返回一个按照指定格式(或默认格式)格式化后的日期字符串,方便在界面显示、数据存储等场景使用。
- */
public static String dateToString(Date date, String pattern) {
// 创建SimpleDateFormat对象,它是Java中用于格式化日期的类,通过指定的模式将日期转换为相应格式的字符串。
SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
diff --git a/Supermarket/src/com/lingnan/supermarket/utils/EmailTest.java b/Supermarket/src/com/lingnan/supermarket/utils/EmailTest.java
index 7fcaf89..103c0c5 100644
--- a/Supermarket/src/com/lingnan/supermarket/utils/EmailTest.java
+++ b/Supermarket/src/com/lingnan/supermarket/utils/EmailTest.java
@@ -3,7 +3,6 @@ package com.lingnan.supermarket.utils;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
-// EmailTest类
public class EmailTest {
//Java程序的入口点
diff --git a/Supermarket/src/com/lingnan/supermarket/utils/JDBCUtil.java b/Supermarket/src/com/lingnan/supermarket/utils/JDBCUtil.java
index 22a58b4..665556f 100644
--- a/Supermarket/src/com/lingnan/supermarket/utils/JDBCUtil.java
+++ b/Supermarket/src/com/lingnan/supermarket/utils/JDBCUtil.java
@@ -9,7 +9,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
-// JDBCUtil工具类,用于管理数据库连接相关的操作,如加载数据库配置、获取数据库连接以及释放相关资源等
+// 用于管理数据库连接相关的操作,如加载数据库配置、获取数据库连接以及释放相关资源等
public class JDBCUtil {
// 用于存储数据库连接相关的配置信息,通过读取配置文件将配置项加载到该对象中
diff --git a/Supermarket/src/com/lingnan/supermarket/utils/Test.java b/Supermarket/src/com/lingnan/supermarket/utils/Test.java
index ab6921b..5213aa7 100644
--- a/Supermarket/src/com/lingnan/supermarket/utils/Test.java
+++ b/Supermarket/src/com/lingnan/supermarket/utils/Test.java
@@ -1,6 +1,6 @@
package com.lingnan.supermarket.utils;
-//测试类,用于演示静态代码块的使用
+//用于演示静态代码块的使用
public class Test {
static {
System.out.println("tasdasd."); // 打印一条测试信息
diff --git a/Supermarket/src/com/lingnan/supermarket/utils/TimeAndOrder.java b/Supermarket/src/com/lingnan/supermarket/utils/TimeAndOrder.java
index 11d404f..e88deb4 100644
--- a/Supermarket/src/com/lingnan/supermarket/utils/TimeAndOrder.java
+++ b/Supermarket/src/com/lingnan/supermarket/utils/TimeAndOrder.java
@@ -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];
diff --git a/Supermarket/src/com/lingnan/supermarket/view/ProdCatalogView.java b/Supermarket/src/com/lingnan/supermarket/view/ProdCatalogView.java
index d41bef9..7a946b4 100644
--- a/Supermarket/src/com/lingnan/supermarket/view/ProdCatalogView.java
+++ b/Supermarket/src/com/lingnan/supermarket/view/ProdCatalogView.java
@@ -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 combo;
- private String log[]=null;
- private ArrayListalog=null;
- private ProdCatalogTM prodCatalogTM;
- private ProdCatalog pc;
- private prodCatalogImpl pci;
+ // 商品类别相关变量
+ private String catalog = "0"; // 当前选中的商品类别ID
+ private JComboBox combo; // 商品类别下拉框
+ private String log[] = null; // 商品类别名称数组
+ private ArrayList 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(log); // 创建商品类别下拉框
+ combo.addItemListener(new MyItemListener()); // 添加下拉框监听器
-
- combo = new JComboBox(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