diff --git a/.idea/misc.xml b/.idea/misc.xml index c5b887b..d7d11dc 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/Supermarket/.classpath b/Supermarket/.classpath index 9593e8c..f2404ae 100644 --- a/Supermarket/.classpath +++ b/Supermarket/.classpath @@ -6,6 +6,6 @@ - + diff --git a/Supermarket/.idea/dataSources.local.xml b/Supermarket/.idea/dataSources.local.xml index 0006d1b..4d6a9c3 100644 --- a/Supermarket/.idea/dataSources.local.xml +++ b/Supermarket/.idea/dataSources.local.xml @@ -2,7 +2,7 @@ - + #@ ` diff --git a/Supermarket/Supermarket.iml b/Supermarket/Supermarket.iml index d37468f..ae3b314 100644 --- a/Supermarket/Supermarket.iml +++ b/Supermarket/Supermarket.iml @@ -1,9 +1,9 @@ - - - + + + @@ -47,6 +47,5 @@ - \ No newline at end of file diff --git a/Supermarket/bin/.classpath b/Supermarket/bin/.classpath index 9593e8c..f2404ae 100644 --- a/Supermarket/bin/.classpath +++ b/Supermarket/bin/.classpath @@ -6,6 +6,6 @@ - + diff --git a/Supermarket/bin/.idea/dataSources.local.xml b/Supermarket/bin/.idea/dataSources.local.xml index 0006d1b..4d6a9c3 100644 --- a/Supermarket/bin/.idea/dataSources.local.xml +++ b/Supermarket/bin/.idea/dataSources.local.xml @@ -2,7 +2,7 @@ - + #@ ` diff --git a/Supermarket/bin/.idea/dataSources/5b23e521-053a-47c0-ae28-a98b513bc6ec.xml b/Supermarket/bin/.idea/dataSources/5b23e521-053a-47c0-ae28-a98b513bc6ec.xml index a48e493..7c2a72a 100644 --- a/Supermarket/bin/.idea/dataSources/5b23e521-053a-47c0-ae28-a98b513bc6ec.xml +++ b/Supermarket/bin/.idea/dataSources/5b23e521-053a-47c0-ae28-a98b513bc6ec.xml @@ -1,32 +1,13 @@ -<<<<<<< HEAD lower/lower InnoDB InnoDB - |root||root|localhost|ALLOW_NONEXISTENT_DEFINER|G -|root||root|localhost|ALTER|G + |root||root|localhost|ALTER|G |root||root|localhost|ALTER ROUTINE|G -|root||root|localhost|APPLICATION_PASSWORD_ADMIN|G -|root||mysql.infoschema|localhost|AUDIT_ABORT_EXEMPT|G -|root||mysql.session|localhost|AUDIT_ABORT_EXEMPT|G -|root||mysql.sys|localhost|AUDIT_ABORT_EXEMPT|G -|root||root|localhost|AUDIT_ABORT_EXEMPT|G -|root||root|localhost|AUDIT_ADMIN|G -|root||mysql.session|localhost|AUTHENTICATION_POLICY_ADMIN|G -|root||root|localhost|AUTHENTICATION_POLICY_ADMIN|G -|root||mysql.session|localhost|BACKUP_ADMIN|G -|root||root|localhost|BACKUP_ADMIN|G -|root||root|localhost|BINLOG_ADMIN|G -|root||root|localhost|BINLOG_ENCRYPTION_ADMIN|G -|root||mysql.session|localhost|CLONE_ADMIN|G -|root||root|localhost|CLONE_ADMIN|G -|root||mysql.session|localhost|CONNECTION_ADMIN|G -|root||root|localhost|CONNECTION_ADMIN|G |root||root|localhost|CREATE|G -|root||root|localhost|CREATE ROLE|G |root||root|localhost|CREATE ROUTINE|G |root||root|localhost|CREATE TABLESPACE|G |root||root|localhost|CREATE TEMPORARY TABLES|G @@ -34,1665 +15,1319 @@ |root||root|localhost|CREATE VIEW|G |root||root|localhost|DELETE|G |root||root|localhost|DROP|G -|root||root|localhost|DROP ROLE|G -|root||root|localhost|ENCRYPTION_KEY_ADMIN|G |root||root|localhost|EVENT|G |root||root|localhost|EXECUTE|G |root||root|localhost|FILE|G -|root||mysql.infoschema|localhost|FIREWALL_EXEMPT|G -|root||mysql.session|localhost|FIREWALL_EXEMPT|G -|root||mysql.sys|localhost|FIREWALL_EXEMPT|G -|root||root|localhost|FIREWALL_EXEMPT|G -|root||root|localhost|FLUSH_OPTIMIZER_COSTS|G -|root||root|localhost|FLUSH_PRIVILEGES|G -|root||root|localhost|FLUSH_STATUS|G -|root||root|localhost|FLUSH_TABLES|G -|root||root|localhost|FLUSH_USER_RESOURCES|G -|root||root|localhost|GROUP_REPLICATION_ADMIN|G -|root||root|localhost|GROUP_REPLICATION_STREAM|G |root||root|localhost|INDEX|G -|root||root|localhost|INNODB_REDO_LOG_ARCHIVE|G -|root||root|localhost|INNODB_REDO_LOG_ENABLE|G |root||root|localhost|INSERT|G |root||root|localhost|LOCK TABLES|G -|root||root|localhost|OPTIMIZE_LOCAL_TABLE|G -|root||root|localhost|PASSWORDLESS_USER_ADMIN|G -|root||mysql.session|localhost|PERSIST_RO_VARIABLES_ADMIN|G -|root||root|localhost|PERSIST_RO_VARIABLES_ADMIN|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|REPLICATION_APPLIER|G -|root||root|localhost|REPLICATION_SLAVE_ADMIN|G -|root||root|localhost|RESOURCE_GROUP_ADMIN|G -|root||root|localhost|RESOURCE_GROUP_USER|G -|root||root|localhost|ROLE_ADMIN|G -|root||mysql.infoschema|localhost|SELECT|G |root||root|localhost|SELECT|G -|root||root|localhost|SENSITIVE_VARIABLES_OBSERVER|G -|root||root|localhost|SERVICE_CONNECTION_ADMIN|G -|root||mysql.session|localhost|SESSION_VARIABLES_ADMIN|G -|root||root|localhost|SESSION_VARIABLES_ADMIN|G -|root||root|localhost|SET_ANY_DEFINER|G |root||root|localhost|SHOW DATABASES|G |root||root|localhost|SHOW VIEW|G -|root||root|localhost|SHOW_ROUTINE|G -|root||mysql.session|localhost|SHUTDOWN|G |root||root|localhost|SHUTDOWN|G |root||mysql.session|localhost|SUPER|G |root||root|localhost|SUPER|G -|root||mysql.infoschema|localhost|SYSTEM_USER|G -|root||mysql.session|localhost|SYSTEM_USER|G -|root||mysql.sys|localhost|SYSTEM_USER|G -|root||root|localhost|SYSTEM_USER|G -|root||mysql.session|localhost|SYSTEM_VARIABLES_ADMIN|G -|root||root|localhost|SYSTEM_VARIABLES_ADMIN|G -|root||root|localhost|TABLE_ENCRYPTION_ADMIN|G -|root||root|localhost|TELEMETRY_LOG_ADMIN|G -|root||root|localhost|TRANSACTION_GTID_TAG|G |root||root|localhost|TRIGGER|G |root||root|localhost|UPDATE|G -|root||root|localhost|XA_RECOVER_ADMIN|G |root||root|localhost|grant option|G performance_schema|schema||mysql.session|localhost|SELECT|G sys|schema||mysql.sys|localhost|TRIGGER|G - 8.4.0 + 5.7.44 - - armscii8 - - - armscii8 -======= - big5 ->>>>>>> remotes/origin/developer 1 - - ascii + + big5 - - ascii + + dec8 1 - - big5 + + dec8 - - big5 + + cp850 1 - - binary + + cp850 + + + hp8 1 - - cp1250 + + hp8 - - cp1250 + + koi8r + 1 - - cp1250 + + koi8r - - cp1250 + + latin1 + + + latin1 1 - - cp1250 + + latin1 - - cp1251 + + latin1 - - cp1251 + + latin1 - - cp1251 - 1 + + latin1 - - cp1251 + + latin1 - - cp1251 + + latin1 - - cp1256 + + latin2 - - cp1256 + + latin2 1 - - cp1257 - - - cp1257 - 1 + + latin2 - - cp1257 + + latin2 - - cp850 + + latin2 - - cp850 + + swe7 1 - - cp852 + + swe7 - - cp852 + + ascii 1 - - cp866 + + ascii - - cp866 + + ujis 1 - - cp932 + + ujis - - cp932 + + sjis 1 - - dec8 + + sjis - - dec8 + + hebrew 1 - - eucjpms + + hebrew - - eucjpms + + tis620 1 - - euckr + + tis620 euckr 1 - - gb18030 + + euckr - - gb18030 + + koi8u 1 - - gb18030 - - - gb2312 + + koi8u - + gb2312 1 - - gbk - - - gbk - 1 - - - geostd8 + + gb2312 - - geostd8 + + greek 1 - + greek - - greek + + cp1250 1 - - hebrew - - - hebrew - 1 + + cp1250 - - hp8 + + cp1250 - - hp8 - 1 + + cp1250 - - keybcs2 + + cp1250 - - keybcs2 + + gbk 1 - - koi8r + + gbk - - koi8r + + latin5 1 - - koi8u + + latin5 - - koi8u + + armscii8 1 - - latin1 - - - latin1 + + armscii8 - - latin1 + + utf8 + 1 - - latin1 + + utf8 - - latin1 + + utf8 - - latin1 + + utf8 - - latin1 + + utf8 - - latin1 - 1 + + utf8 - - latin2 + + utf8 - - latin2 + + utf8 - - latin2 + + utf8 - - latin2 - 1 + + utf8 - - latin2 + + utf8 - - latin5 + + utf8 - - latin5 - 1 + + utf8 - - latin7 + + utf8 - - latin7 + + utf8 - - latin7 - 1 + + utf8 - - latin7 + + utf8 - - macce + + utf8 - - macce - 1 + + utf8 - - macroman + + utf8 - - macroman - 1 + + utf8 - - sjis + + utf8 - - sjis - 1 + + utf8 - - swe7 + + utf8 - - swe7 - 1 + + utf8 - - tis620 + + utf8 - - tis620 - 1 + + utf8 - + ucs2 + 1 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - 1 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - + ucs2 - - ujis - - - ujis + + cp866 1 - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 + + cp866 - - utf16 + + keybcs2 1 - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16le + + keybcs2 - - utf16le + + macce 1 - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 + + macce - - utf32 + + macroman 1 - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 + + macroman - - utf8mb3 + + cp852 1 - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 + + cp852 - - utf8mb3 + + latin7 - - utf8mb3 + + latin7 + 1 - - utf8mb3 + + latin7 - - utf8mb3 + + 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 - - utf8mb4 + + cp1251 - - utf8mb4 + + cp1251 - - utf8mb4 + + cp1251 - - utf8mb4 + + cp1251 + 1 - - utf8mb4 + + cp1251 - - utf8mb4 + + utf16 + 1 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16 - - utf8mb4 + + utf16le + 1 - - utf8mb4 + + utf16le - - utf8mb4 + + cp1256 + 1 - - utf8mb4 + + cp1256 - - utf8mb4 + + cp1257 - - utf8mb4 + + cp1257 - - utf8mb4 + + cp1257 + 1 - - utf8mb4 + + utf32 + 1 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4 + + utf32 - - utf8mb4_0900_ai_ci - - - utf8mb4_0900_ai_ci - - - utf8mb4_0900_ai_ci - - - utf8mb4_0900_ai_ci - - - utf8mb3_general_ci - - - utf8mb4_0900_ai_ci - - - utf8mb4_0900_ai_ci - - - utf8mb4_0900_ai_ci - - - utf8mb4_0900_ai_ci - - - utf8mb4_0900_ai_ci - - - utf8mb4_0900_ai_ci + + utf32 + + + binary + 1 + + + geostd8 + 1 + + + geostd8 + + + cp932 + 1 + + + cp932 + + + eucjpms + 1 + + + eucjpms + + + gb18030 + 1 + + + gb18030 + + + gb18030 + + + utf8_general_ci - - utf8mb4_0900_ai_ci + + latin1_swedish_ci - - utf8mb4_0900_ai_ci + + latin1_swedish_ci - - utf8mb4_0900_ai_ci + + latin1_swedish_ci - - utf8mb4_0900_ai_ci + + utf8_general_ci - - utf8mb4_0900_ai_ci + + latin1_swedish_ci - - utf8mb4_0900_ai_ci + + utf8mb4_unicode_ci - - utf8mb4_0900_ai_ci + + utf8_general_ci - - utf8mb4_0900_ai_ci + + utf8mb4_general_ci - - 0 - localhost - caching_sha2_password - - - 0 + localhost - caching_sha2_password - - 0 + localhost - caching_sha2_password - + localhost - caching_sha2_password - - root@localhost - procedure - 320 - - - root@localhost - procedure - 196 - - - root@localhost - procedure - 199 - - - root@localhost - procedure - 184 - - +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- +
InnoDB - utf8mb4_0900_ai_ci + utf8mb4_unicode_ci
- - varchar(30)|0s - 1 - - - timestamp|0s - 2 - - - varchar(20)|0s - 3 - - - int|0s - 4 - - - float|0s - 5 - - - varchar(10)|0s - 1 - - - int|0s - 2 - - - varchar(10)|0s - 1 - - - int|0s - 2 - - - varchar(30)|0s - 1 - - - timestamp|0s - 2 - - - varchar(20)|0s - 3 - - - int|0s - 4 - - - float|0s - 5 - - + varchar(20)|0s 1 1 - + varchar(20)|0s 2 - + float|0s 3 - + float|0s 4 - - int|0s + + int(11)|0s 5 - - int|0s + + int(11)|0s 6 - - int|0s + + int(11)|0s 7 - + varchar(20)|0s 8 - + varchar(20)|0s 9 - + float|0s 10 - - int|0s + + 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|0s + + int(11)|0s 2 5 - - int|0s + + int(11)|0s 1 6 - + iNumber btree 1 - + 1 1 PRIMARY - + varchar(30)|0s 1 - + varchar(20)|0s 2 - - int|0s + + 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|0s + + int(11)|0s 5 - - int|0s + + int(11)|0s 6 - - int|0s + + int(11)|0s 7 - + varchar(20)|0s 8 - + varchar(20)|0s 9 - + float|0s 10 - - int|0s + + 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|0s + + int(11)|0s 1 5 - + oNumber btree 1 - + 1 1 PRIMARY - + varchar(30)|0s 1 - + varchar(20)|0s 2 - - int|0s + + 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|0s + + int(11)|0s 5 - - int|0s + + int(11)|0s 6 - - int|0s + + int(11)|0s 7 - + varchar(20)|0s 8 - + varchar(20)|0s 9 - + float|0s 10 - - int|0s + + 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|0s + + int(11)|0s 5 - - 8 - int|0s + + 9 + int(11)|0s 1 1 - + varchar(30)|0s 2 - + varchar(50)|0s 3 - + varchar(11)|0s 4 - + varchar(50)|0s 5 - - int|0s + + int(11)|0s 1 6 - + id btree 1 - + name btree 1 - + 1 1 PRIMARY - + name - - 5 - int|0s + + 7 + int(11)|0s 1 1 - + varchar(15)|0s 2 - - varchar(15)|0s + + varchar(255)|0s 3 - + varchar(20)|0s 1 4 - + varchar(11)|0s 5 - - int|0s + + int(11)|0s 1 6 - + varchar(50)|0s 7 - - int|0s + + int(11)|0s 1 8 - + id btree 1 - + name btree 1 - + 1 1 PRIMARY - + name
diff --git a/Supermarket/bin/Supermarket.iml b/Supermarket/bin/Supermarket.iml index d37468f..ae3b314 100644 --- a/Supermarket/bin/Supermarket.iml +++ b/Supermarket/bin/Supermarket.iml @@ -1,9 +1,9 @@ - - - + + + @@ -47,6 +47,5 @@ - \ No newline at end of file diff --git a/Supermarket/bin/com/lingnan/supermarket/componet/BGPanel.class b/Supermarket/bin/com/lingnan/supermarket/componet/BGPanel.class index 6b0e55c..a42e4a1 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/componet/BGPanel.class and b/Supermarket/bin/com/lingnan/supermarket/componet/BGPanel.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/dao/impl/outOrderServiceImpl.class b/Supermarket/bin/com/lingnan/supermarket/dao/impl/outOrderServiceImpl.class index 21ab99d..d1062dc 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/dao/impl/outOrderServiceImpl.class and b/Supermarket/bin/com/lingnan/supermarket/dao/impl/outOrderServiceImpl.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/dao/impl/outRecordServiceImpl.class b/Supermarket/bin/com/lingnan/supermarket/dao/impl/outRecordServiceImpl.class index 7baa27c..c84096e 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/dao/impl/outRecordServiceImpl.class and b/Supermarket/bin/com/lingnan/supermarket/dao/impl/outRecordServiceImpl.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/dao/impl/prodCatalogImpl.class b/Supermarket/bin/com/lingnan/supermarket/dao/impl/prodCatalogImpl.class index cf4cbfd..dfab04b 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/dao/impl/prodCatalogImpl.class and b/Supermarket/bin/com/lingnan/supermarket/dao/impl/prodCatalogImpl.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/dao/impl/storageRecordImpl.class b/Supermarket/bin/com/lingnan/supermarket/dao/impl/storageRecordImpl.class index 696d216..a4ab5e5 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/dao/impl/storageRecordImpl.class and b/Supermarket/bin/com/lingnan/supermarket/dao/impl/storageRecordImpl.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/utils/CreateOrder.class b/Supermarket/bin/com/lingnan/supermarket/utils/CreateOrder.class index 57d07cd..b89e86a 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/utils/CreateOrder.class and b/Supermarket/bin/com/lingnan/supermarket/utils/CreateOrder.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/utils/DateUtil.class b/Supermarket/bin/com/lingnan/supermarket/utils/DateUtil.class index 7129ff2..1c69283 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/JDBCUtil.class b/Supermarket/bin/com/lingnan/supermarket/utils/JDBCUtil.class index ffef5cd..c16b29d 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/utils/JDBCUtil.class and b/Supermarket/bin/com/lingnan/supermarket/utils/JDBCUtil.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/utils/Test.class b/Supermarket/bin/com/lingnan/supermarket/utils/Test.class index 2d1db8c..689a24d 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/utils/Test.class and b/Supermarket/bin/com/lingnan/supermarket/utils/Test.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/utils/TimeAndOrder.class b/Supermarket/bin/com/lingnan/supermarket/utils/TimeAndOrder.class index 73eb6dd..b65128c 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/utils/tplbTest$1.class b/Supermarket/bin/com/lingnan/supermarket/utils/tplbTest$1.class index d530c2e..4f46f87 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/utils/tplbTest$1.class and b/Supermarket/bin/com/lingnan/supermarket/utils/tplbTest$1.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/utils/tplbTest.class b/Supermarket/bin/com/lingnan/supermarket/utils/tplbTest.class index eea6747..8eb35e4 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/utils/tplbTest.class and b/Supermarket/bin/com/lingnan/supermarket/utils/tplbTest.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/view/InView$MyItemListener.class b/Supermarket/bin/com/lingnan/supermarket/view/InView$MyItemListener.class index 8dc13e9..998ea75 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/view/InView$MyItemListener.class and b/Supermarket/bin/com/lingnan/supermarket/view/InView$MyItemListener.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/view/InView.class b/Supermarket/bin/com/lingnan/supermarket/view/InView.class index ac7d0fc..c6d8d22 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/view/InView.class and b/Supermarket/bin/com/lingnan/supermarket/view/InView.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/view/MainView.class b/Supermarket/bin/com/lingnan/supermarket/view/MainView.class index 3e699f8..929ad49 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/view/MainView.class and b/Supermarket/bin/com/lingnan/supermarket/view/MainView.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/view/Nimbus.class b/Supermarket/bin/com/lingnan/supermarket/view/Nimbus.class index 1705b38..8416915 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/view/Nimbus.class and b/Supermarket/bin/com/lingnan/supermarket/view/Nimbus.class differ diff --git a/Supermarket/bin/com/lingnan/supermarket/view/base/BaseView.class b/Supermarket/bin/com/lingnan/supermarket/view/base/BaseView.class index b5217a2..0f912c1 100644 Binary files a/Supermarket/bin/com/lingnan/supermarket/view/base/BaseView.class and b/Supermarket/bin/com/lingnan/supermarket/view/base/BaseView.class differ diff --git a/Supermarket/bin/config/jdbc.properties b/Supermarket/bin/config/jdbc.properties index 90df4ad..f14ded9 100644 --- a/Supermarket/bin/config/jdbc.properties +++ b/Supermarket/bin/config/jdbc.properties @@ -1,4 +1,4 @@ -driver=com.mysql.cj.jdbc.Driver -url=jdbc:mysql://localhost:3306/supermarket?serverTimezone=UTC +driver=com.mysql.jdbc.Driver +url=jdbc:mysql://localhost:3306/supermarket user=root password=123456 \ No newline at end of file diff --git a/Supermarket/bin/jdbc.properties b/Supermarket/bin/jdbc.properties index 90df4ad..f14ded9 100644 --- a/Supermarket/bin/jdbc.properties +++ b/Supermarket/bin/jdbc.properties @@ -1,4 +1,4 @@ -driver=com.mysql.cj.jdbc.Driver -url=jdbc:mysql://localhost:3306/supermarket?serverTimezone=UTC +driver=com.mysql.jdbc.Driver +url=jdbc:mysql://localhost:3306/supermarket user=root password=123456 \ No newline at end of file diff --git a/Supermarket/config/jdbc.properties b/Supermarket/config/jdbc.properties index 90df4ad..f14ded9 100644 --- a/Supermarket/config/jdbc.properties +++ b/Supermarket/config/jdbc.properties @@ -1,4 +1,4 @@ -driver=com.mysql.cj.jdbc.Driver -url=jdbc:mysql://localhost:3306/supermarket?serverTimezone=UTC +driver=com.mysql.jdbc.Driver +url=jdbc:mysql://localhost:3306/supermarket user=root password=123456 \ No newline at end of file diff --git a/Supermarket/src/com/lingnan/supermarket/componet/BGPanel.java b/Supermarket/src/com/lingnan/supermarket/componet/BGPanel.java index 44f891d..a953dc7 100644 --- a/Supermarket/src/com/lingnan/supermarket/componet/BGPanel.java +++ b/Supermarket/src/com/lingnan/supermarket/componet/BGPanel.java @@ -8,16 +8,16 @@ public class BGPanel extends JPanel{ private Image image; public BGPanel(Image image) { - // 定义构造方法 + // 定义一个构造方法,接收一个Image类型的参数image,用于创建BGPanel对象时传入要显示的图像 this.image = image; // 将传入的参数image赋值给类的成员变量image int width = Toolkit.getDefaultToolkit().getScreenSize().width; - // 通过默认工具包(Toolkit)获取屏幕的宽度 + // 通过默认工具包(Toolkit)获取屏幕的宽度,存储在局部变量width中 int height = Toolkit.getDefaultToolkit().getScreenSize().height; - // 通过默认工具包(Toolkit)获取屏幕的高度 + // 通过默认工具包(Toolkit)获取屏幕的高度,存储在局部变量height中 this.setSize(width, height); - // 设置该面板的大小为整个屏幕的大小 + // 设置该面板(BGPanel)的大小为整个屏幕的大小,即宽度和高度分别为获取到的屏幕宽高 } public BGPanel(Image image, int width, int height) { @@ -37,6 +37,7 @@ public class BGPanel extends JPanel{ // 调用父类(JPanel)的paintComponent方法,以确保完成一些默认的绘制操作,比如背景清除等 g.drawImage(image, 0, 0, getWidth(), getHeight(), this); + // 使用传入的Graphics对象g在面板上绘制图像,参数含义如下: // image:要绘制的图像对象,就是之前保存的成员变量image // 0, 0:表示在面板上绘制图像的起始坐标(x坐标和y坐标),这里从面板的左上角(0, 0)位置开始绘制 // getWidth(), getHeight():获取当前面板的宽度和高度,用于指定绘制图像时按照面板的实际大小进行拉伸或缩放,确保图像填满整个面板 diff --git a/Supermarket/src/com/lingnan/supermarket/dao/BufferService.java b/Supermarket/src/com/lingnan/supermarket/dao/BufferService.java index 9c643c8..b0e39e1 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/BufferService.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/BufferService.java @@ -7,10 +7,10 @@ import com.lingnan.supermarket.dto.Production; public interface BufferService { /*主要用于更新操作*/ - + /*根据商品id判断delmark是0还是1,即是否是新添加的商品返回2,还是已经添加的商品返回1,还是不存在的商品返回0*/ public Vector allOutBuffer(); - public Buffer findOutBufferbyId(String id) ; + public Buffer findOutBufferbyId(String id) ; public boolean addOutBufferNewProd(String id,int sum); public boolean addOutBufferExeistProd(String id,int sum,Buffer buffer); /*public Buffer findOutBufferSumAndOutPrice(String id);*/ @@ -20,11 +20,11 @@ public interface BufferService { public boolean DelAllOutBuffer(); public boolean DelOutBufferById(String id); public boolean UpdateOutBufferById(String id,int sum); - - + + /*进货模块*/ public Vector allInBuffer(); - public Buffer findInBufferbyId(String id) ; + public Buffer findInBufferbyId(String id) ; public boolean addInBufferNewProd(String id,int sum); public boolean addInBufferExeistProd(String id,int sum,Buffer buffer); /*public Buffer findInBufferSumAndInPrice(String id);*/ diff --git a/Supermarket/src/com/lingnan/supermarket/dao/SupplierInfService.java b/Supermarket/src/com/lingnan/supermarket/dao/SupplierInfService.java index 3b1285b..4be1b7a 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/SupplierInfService.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/SupplierInfService.java @@ -8,25 +8,25 @@ import com.lingnan.supermarket.dto.User; public interface SupplierInfService { //查询操作 加where default==1 - Vector findAllSupplierInf(); - - Vector findByNameSupplierInf(SupplierInf supplierInf); + Vector findAllSupplierInf(); + + Vector findByNameSupplierInf(SupplierInf supplierInf); // SupplierInf findByNameSupplierInf(String name); - + //根据id增加 int addSupplierInf(SupplierInf s); - + //根据id删除 //int deleteSupplierInf(String id); - + //根据id更新 int updateSupplierInf(SupplierInf supplierInf); int deleteSupplierInf(int id); - + //输出所有供应商名字 ArrayList findNameSupplier(); - + //通过供应商名查找并输出id int findIdSupplierByName(String name); - } +} diff --git a/Supermarket/src/com/lingnan/supermarket/dao/impl/BufferImpl.java b/Supermarket/src/com/lingnan/supermarket/dao/impl/BufferImpl.java index 6133106..55f4dee 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/impl/BufferImpl.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/impl/BufferImpl.java @@ -515,13 +515,13 @@ public class BufferImpl implements BufferService { /*如果delmark是1,即是已经添加的商品*/ - // 更新已存在商品的进货缓冲区记录 - // 方法名称:addInBufferExeistProd - // 参数: - // id - 商品的唯一标识符 - // sum - 要添加的商品数量 - // buffer - 包含商品信息的缓冲区对象 - // 返回值:布尔值,表示更新操作是否成功 + // 更新已存在商品的进货缓冲区记录 + // 方法名称:addInBufferExeistProd + // 参数: + // id - 商品的唯一标识符 + // sum - 要添加的商品数量 + // buffer - 包含商品信息的缓冲区对象 + // 返回值:布尔值,表示更新操作是否成功 public boolean addInBufferExeistProd(String id,int sum,Buffer buffer){ boolean flag = false; // 初始化标志为false Connection conn = JDBCUtil.getConn(); // 获取数据库连接 @@ -666,16 +666,16 @@ public class BufferImpl implements BufferService { - /*更改记录通过id*/ - // 更新进货缓冲区记录 - /** - * 更新进货缓冲区中指定商品ID的数量。 - * - * @param id 商品的ID - * @param sum 更新后的商品数量 - * @return 返回更新是否成功的标志 - */ -public boolean UpdateInBufferById(String id,int sum) { + /*更改记录通过id*/ + // 更新进货缓冲区记录 + /** + * 更新进货缓冲区中指定商品ID的数量。 + * + * @param id 商品的ID + * @param sum 更新后的商品数量 + * @return 返回更新是否成功的标志 + */ + public boolean UpdateInBufferById(String id,int sum) { boolean flag = false; // 初始化标志为false Connection conn = JDBCUtil.getConn(); // 获取数据库连接 PreparedStatement pstmt = null; // 初始化预编译语句对象 diff --git a/Supermarket/src/com/lingnan/supermarket/dao/impl/inRecordServiceImpl.java b/Supermarket/src/com/lingnan/supermarket/dao/impl/inRecordServiceImpl.java index 9964df6..ab277d2 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/impl/inRecordServiceImpl.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/impl/inRecordServiceImpl.java @@ -52,12 +52,12 @@ public class inRecordServiceImpl implements inRecordService{ /** - * 根据进货单号查询进货记录 - * - * @param iNumber 进货单号 - * @return 包含符合条件的进货记录的向量 - */ -@Override + * 根据进货单号查询进货记录 + * + * @param iNumber 进货单号 + * @return 包含符合条件的进货记录的向量 + */ + @Override public Vector findByIdinRecord(String iNumber) { InRecord inRecord; // 声明一个进货记录对象 Vector v = new Vector(); // 创建一个向量用于存储进货记录 @@ -91,7 +91,7 @@ public class inRecordServiceImpl implements inRecordService{ // 该方法用于将进货记录添加到数据库中。 // 参数 ir 是一个包含进货信息的对象。 // 返回值 flag 表示插入的结果,1表示成功,-1表示失败。 -public int addinRecord(InRecord ir) { + public int addinRecord(InRecord ir) { int flag = 0; // 初始化标志为0 String iNumber = ir.getiNumber(); // 获取进货单号 @@ -121,7 +121,7 @@ public int addinRecord(InRecord ir) { // 删除进货记录方法,根据进货单号进行删除操作 -@Override + @Override public int deleteinRecord(String iNumber) { int flag = 0; // 初始化标志为0 @@ -143,14 +143,14 @@ public int addinRecord(InRecord ir) { return flag; // 返回删除结果标志 } - /** - * 将进货记录插入到数据库中 - * - * @param iNumber 进货单号 - * @param p 进货的商品对象 - * @return 成功插入返回true,失败返回false - */ -public boolean insertInRecord(String iNumber,Production p) { + /** + * 将进货记录插入到数据库中 + * + * @param iNumber 进货单号 + * @param p 进货的商品对象 + * @return 成功插入返回true,失败返回false + */ + public boolean insertInRecord(String iNumber,Production p) { boolean flag = false; // 初始化标志为false Connection conn = JDBCUtil.getConn(); // 获取数据库连接 PreparedStatement preparedStatement = null; // 初始化预编译语句对象 diff --git a/Supermarket/src/com/lingnan/supermarket/dao/impl/outOrderServiceImpl.java b/Supermarket/src/com/lingnan/supermarket/dao/impl/outOrderServiceImpl.java index bcdd022..7c7fd2c 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/impl/outOrderServiceImpl.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/impl/outOrderServiceImpl.java @@ -13,29 +13,21 @@ import com.lingnan.supermarket.dto.InOrder; import com.lingnan.supermarket.dto.OutOrder; import com.lingnan.supermarket.utils.JDBCUtil; -// 实现outOrderService接口--用于处理与出库订单相关的数据访问操作 -public class outOrderServiceImpl implements outOrderService { +public class outOrderServiceImpl implements outOrderService{ - // 查询所有出库订单信息,并按照日期降序排列返回 @Override public Vector findAllOutOrder() { - // 存储查询到的所有出库订单信息的向量集合 Vector outOrders = new Vector(); - // 获取数据库连接 Connection conn = JDBCUtil.getConn(); PreparedStatement preparedStatement = null; - ResultSet resultSet = null; + ResultSet resultSet=null; - // 从OutOrder表中查询所有记录,并按oDate字段降序排序 String SQL = "select * from OutOrder order by oDate desc"; try { - // 根据SQL语句创建预编译的Statement对象 preparedStatement = conn.prepareStatement(SQL); - // 执行查询操作 resultSet = preparedStatement.executeQuery(); - // 遍历结果集,将每条记录封装成OutOrder对象,并添加到outOrders集合中 - while (resultSet.next()) { + while(resultSet.next()) { OutOrder outOrder = new OutOrder(); outOrder.setoNumber(resultSet.getString("oNumber")); outOrder.setAllOutPrice(resultSet.getFloat("allOutPrice")); @@ -47,143 +39,113 @@ public class outOrderServiceImpl implements outOrderService { } catch (SQLException e) { e.printStackTrace(); } finally { - // 关闭结果集、预编译语句以及数据库连接,释放相关资源 JDBCUtil.close(resultSet, preparedStatement, conn); } return outOrders; } - // 根据订单编号查询对应的出库订单信息 @Override public OutOrder findByIdOutOrder(String oNumber) { - // 用于存储查询到的出库订单信息的对象 OutOrder outOrder = new OutOrder(); - // 获取数据库连接 Connection conn = JDBCUtil.getConn(); PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { - // 根据订单编号查询对应的出库订单记录 - preparedStatement = conn.prepareStatement("select * from outOrder where oNumber =?"); - // 设置查询的订单编号 + preparedStatement = conn.prepareStatement("select * from outOrder where oNumber = ?"); preparedStatement.setString(1, oNumber); - // 执行查询操作 resultSet = preparedStatement.executeQuery(); - // 如果结果集中有记录,说明找到了对应的订单,则将记录中的各字段值封装到outOrder对象中 if (resultSet.next()) { outOrder.setoNumber(resultSet.getString("oNumber")); outOrder.setAllOutPrice(resultSet.getFloat("allOutPrice")); outOrder.setoDate(resultSet.getDate("oDate")); outOrder.setPrincipal(resultSet.getString("principal")); } else { - // 如果结果集中没有记录,说明没有找到该订单或订单不存在,返回null - return null; + return null; // 没有找到该订单或订单不存在,返回null } } catch (SQLException e) { e.printStackTrace(); } finally { - // 关闭结果集、预编译语句以及数据库连接,释放相关资源 JDBCUtil.close(resultSet, preparedStatement, conn); } return outOrder; + } - // 向数据库中添加一条出库订单记录 @Override public int addOutOrder(String oNumber, float allOutPrice) { int flag = 0; - // 获取当前系统时间戳,用于作为出库订单的日期(oDate)字段值,表示订单创建时间 Timestamp oDate = new Timestamp(System.currentTimeMillis()); - // 获取数据库连接 Connection conn = JDBCUtil.getConn(); PreparedStatement preparedStatement = null; try { - // 创建预编译的SQL插入语句,向outOrder表中插入一条记录 - preparedStatement = conn.prepareStatement("insert into outOrder values (?,?,?,?)"); - // 设置预编译语句中的参数,依次为订单编号、总出库价格、订单日期、负责人(此处写死为"a1",可能后续需要改进) + preparedStatement = conn.prepareStatement + ("insert into outOrder values (?,?,?,?)"); preparedStatement.setString(1, oNumber); preparedStatement.setFloat(2, allOutPrice); preparedStatement.setTimestamp(3, oDate); preparedStatement.setString(4, "a1"); - // 执行插入操作 preparedStatement.executeUpdate(); - // 如果插入成功,将标志位flag设置为1,表示操作成功 flag = 1; } catch (SQLException e) { - // 如果插入出现异常,将标志位flag设置为 -1,表示操作失败 flag = -1; e.printStackTrace(); } finally { - // 关闭预编译语句以及数据库连接,释放相关资源 - JDBCUtil.close(null, preparedStatement, conn); + JDBCUtil.close(null,preparedStatement, conn); } return flag; } - // 根据订单编号从数据库中删除对应的出库订单记录 @Override public int deleteOutOrder(String oNumber) { int flag = 0; - // 获取数据库连接 Connection conn = JDBCUtil.getConn(); PreparedStatement preparedStatement = null; try { - // 创建预编译的SQL删除语句,根据订单编号(oNumber)删除对应的出库订单记录 - preparedStatement = conn.prepareStatement("delete from outOrder where oNumber =?"); - // 设置预编译语句中的参数,即要删除的订单编号 + preparedStatement = conn.prepareStatement + ("delete from outOrder where oNumber = ?"); preparedStatement.setString(1, oNumber); - // 执行删除操作 preparedStatement.executeUpdate(); - // 如果删除成功,将标志位flag设置为1,表示操作成功 flag = 1; } catch (SQLException e) { - // 如果删除出现异常,将标志位flag设置为 -1,表示操作失败 flag = -1; e.printStackTrace(); } finally { - // 关闭预编译语句以及数据库连接,释放相关资源 - JDBCUtil.close(null, preparedStatement, conn); + JDBCUtil.close(null,preparedStatement, conn); } return flag; } - // 获取指定日期的今日出库金额总和(此处方法名可能有点混淆,从代码逻辑看是获取指定日期的出库金额总和) + + //获取今日进货金额 public Float TodayOutPrice(String date) { - // 创建一个InOrder对象 + InOrder inOrder = new InOrder(); - // 获取数据库连接 Connection conn = JDBCUtil.getConn(); PreparedStatement preparedStatement = null; ResultSet resultSet = null; - // 用于存储查询到的今日出库金额总和,初始为0 - Float allInPrice = (float) 0; + Float allInPrice=(float) 0; try { - // 通过求和函数查询指定日期范围内的总出库价格 preparedStatement = conn.prepareStatement("select sum(allOutPrice) from outOrder where oDate>=? and oDate<=date_add(?,interval 1 day)"); - // 设置两个参数均为传入的日期值,用于限定查询的日期范围 preparedStatement.setString(1, date); preparedStatement.setString(2, date); - // 执行查询操作 resultSet = preparedStatement.executeQuery(); - // 如果结果集中有记录,说明查询到了对应的金额数据,则将其取出赋值给allInPrice变量 if (resultSet.next()) { - allInPrice = resultSet.getFloat("sum(allOutPrice)"); + allInPrice=resultSet.getFloat("sum(allOutPrice)"); } } catch (SQLException e) { e.printStackTrace(); } finally { - // 关闭结果集、预编译语句以及数据库连接,释放相关资源 JDBCUtil.close(resultSet, preparedStatement, conn); } return allInPrice; } -} \ No newline at end of file +} diff --git a/Supermarket/src/com/lingnan/supermarket/dao/impl/outRecordServiceImpl.java b/Supermarket/src/com/lingnan/supermarket/dao/impl/outRecordServiceImpl.java index 98f4958..9015ef1 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/impl/outRecordServiceImpl.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/impl/outRecordServiceImpl.java @@ -12,29 +12,21 @@ import com.lingnan.supermarket.dto.InRecord; import com.lingnan.supermarket.dto.OutRecord; import com.lingnan.supermarket.utils.JDBCUtil; -// 实现了outRecordService接口--用于处理出库记录相关的数据操作逻辑 -public class outRecordServiceImpl implements outRecordService { +public class outRecordServiceImpl implements outRecordService{ - // 查询所有出库记录信息 @Override public Vector findAllOutRecord() { - // 用于存储查询到的所有出库记录信息的向量集合 Vector outRecords = new Vector(); - // 通过JDBCUtil工具类的静态方法来获取数据库连接 Connection conn = JDBCUtil.getConn(); PreparedStatement preparedStatement = null; - ResultSet resultSet = null; + ResultSet resultSet=null; - // 从outRecord表中获取所有记录 String SQL = "select * from outRecord"; try { - // 根据SQL语句创建预编译的Statement对象 preparedStatement = conn.prepareStatement(SQL); - // 执行查询操作 resultSet = preparedStatement.executeQuery(); - // 遍历结果集,将每条记录封装成OutRecord对象,并添加到outRecords集合中 - while (resultSet.next()) { + while(resultSet.next()) { OutRecord outRecord = new OutRecord(); outRecord.setoNumber(resultSet.getString("oNumber")); outRecord.setSum(resultSet.getInt("sum")); @@ -45,33 +37,24 @@ public class outRecordServiceImpl implements outRecordService { } catch (SQLException e) { e.printStackTrace(); } finally { - // 关闭结果集、预编译语句以及数据库连接,释放相关资源 JDBCUtil.close(resultSet, preparedStatement, conn); } return outRecords; } - // 根据订单编号查询对应的出库记录信息,返回符合条件的多条记录 @Override public Vector findByIdOutRecordr(String oNumber) { - // 用于临时存储单个出库记录信息的对象 - OutRecord outRecord; - // 获取数据库连接 + OutRecord outRecord ; Connection conn = JDBCUtil.getConn(); PreparedStatement preparedStatement = null; ResultSet resultSet = null; - // 存储查询到的符合条件的所有出库记录信息的向量集合 Vector v = new Vector(); try { - //根据给定的订单编号查询outRecord表中对应的记录 - preparedStatement = conn.prepareStatement("select * from outRecord where oNumber =?"); - // 设置要查询的订单编号 + preparedStatement = conn.prepareStatement("select * from outRecord where oNumber = ?"); preparedStatement.setString(1, oNumber); - // 执行查询操作,获取结果集 resultSet = preparedStatement.executeQuery(); - // 遍历结果集,将每条符合条件的记录封装成OutRecord对象,并添加到向量集合v中 while (resultSet.next()) { outRecord = new OutRecord(); outRecord.setoNumber(resultSet.getString("oNumber")); @@ -84,78 +67,63 @@ public class outRecordServiceImpl implements outRecordService { } catch (SQLException e) { e.printStackTrace(); } finally { - // 关闭结果集、预编译语句以及数据库连接,释放相关资源 JDBCUtil.close(resultSet, preparedStatement, conn); } return v; } - // 向数据库中添加一条出库记录信息 @Override public int addoutRecord(OutRecord or) { + int flag = 0; - // 获取要添加的出库记录对象中的订单编号 String oNumber = or.getoNumber(); - // 获取要添加的出库记录对象中的数量 int sum = or.getSum(); - // 获取要添加的出库记录对象中的出库价格 Float outPrice = or.getOutPrice(); - // 获取数据库连接 Connection conn = JDBCUtil.getConn(); PreparedStatement preparedStatement = null; try { - // 创建预编译的SQL插入语句,向outRecord表中插入一条记录,包含订单编号、数量、出库价格三个字段的值 - preparedStatement = conn.prepareStatement("insert into outRecord values (?,?,?)"); - // 设置预编译语句中的参数,依次为订单编号、数量、出库价格 + preparedStatement = conn.prepareStatement + ("insert into outRecord values (?,?,?)"); preparedStatement.setString(1, oNumber); preparedStatement.setInt(2, sum); preparedStatement.setFloat(3, outPrice); - // 执行插入操作 preparedStatement.executeUpdate(); - // 如果插入成功,将标志位flag设置为1,表示操作成功 flag = 1; } catch (SQLException e) { - // 如果插入出现异常,将标志位flag设置为 -1,表示操作失败 flag = -1; e.printStackTrace(); } finally { - // 关闭预编译语句以及数据库连接,释放相关资源,此处结果集为null - JDBCUtil.close(null, preparedStatement, conn); + JDBCUtil.close(null,preparedStatement, conn); } return flag; } - // 根据订单编号从数据库中删除对应的出库记录信息 @Override public int deleteOutOrder(String oNumber) { int flag = 0; - // 获取数据库连接 Connection conn = JDBCUtil.getConn(); PreparedStatement preparedStatement = null; try { - // 创建预编译的SQL删除语句,根据给定的订单编号删除outRecord表中对应的记录 - preparedStatement = conn.prepareStatement("delete from outRecord where oNumber =?"); - // 设置要删除的订单编号 + preparedStatement = conn.prepareStatement + ("delete from outRecord where oNumber = ?"); preparedStatement.setString(1, oNumber); - // 执行删除操作 preparedStatement.executeUpdate(); - // 如果删除成功,将标志位flag设置为1,表示操作成功 flag = 1; } catch (SQLException e) { - // 如果删除出现异常,将标志位flag设置为 -1,表示操作失败 flag = -1; e.printStackTrace(); } finally { - // 关闭预编译语句以及数据库连接,释放相关资源,此处结果集为null - JDBCUtil.close(null, preparedStatement, conn); + JDBCUtil.close(null,preparedStatement, conn); } return flag; } -} \ No newline at end of file + + +} diff --git a/Supermarket/src/com/lingnan/supermarket/dao/impl/prodCatalogImpl.java b/Supermarket/src/com/lingnan/supermarket/dao/impl/prodCatalogImpl.java index 917c235..f7c35bd 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/impl/prodCatalogImpl.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/impl/prodCatalogImpl.java @@ -12,241 +12,214 @@ import com.lingnan.supermarket.dao.prodCatalogService; import com.lingnan.supermarket.dto.ProdCatalog; import com.lingnan.supermarket.utils.JDBCUtil; -// 实现prodCatalogService接口--用于处理商品目录相关的数据持久化操作 -public class prodCatalogImpl implements prodCatalogService { +public class prodCatalogImpl implements prodCatalogService{ - // 将商品目录表和商品表联合查询,获取商品目录及相关商品信息 + /*将商品目录表和商品表联合查询*/ @Override public Vector findProdCatalogAndProd() { - // 通过JDBCUtil工具类来获取已经配置好的连接对象 - Connection conn = JDBCUtil.getConn(); - // 创建一个Vector容器,存放查询到的ProdCatalog对象 + Connection conn=JDBCUtil.getConn(); Vector v = new Vector(); ProdCatalog prodCatalog; PreparedStatement pstmt = null; - ResultSet resultSet = null; + ResultSet resultSet=null; try { - // 通过预编译语句准备调用存储过程allProdCatalog pstmt = conn.prepareStatement("call allProdCatalog()"); - // 执行查询操作 resultSet = pstmt.executeQuery(); - // 遍历结果集,将每一条记录封装成ProdCatalog对象,并添加到Vector容器中 - while (resultSet.next()) { + while(resultSet.next()){ prodCatalog = new ProdCatalog(); - // 设置ProdCatalog对象的id属性 prodCatalog.setId(resultSet.getString("id")); - // 设置ProdCatalog对象的name属性 prodCatalog.setName(resultSet.getString("name")); v.add(prodCatalog); } } catch (SQLException e) { - // 若出现SQL异常,打印异常栈信息 + // TODO Auto-generated catch block e.printStackTrace(); - } finally { - // 通过JDBCUtil工具类提供的方法进行关闭操作 + }finally{ JDBCUtil.close(resultSet, pstmt, conn); } + return v; + } - // 根据给定的id1查找商品目录名称 + @Override - public String findProdCatalog(String id1) { - // 获取数据库连接 - Connection conn = JDBCUtil.getConn(); + public String findProdCatalog(String id1 ) { + Connection conn=JDBCUtil.getConn(); PreparedStatement pstmt = null; - ResultSet resultSet = null; - String catalog = null; + ResultSet resultSet=null; + String catalog=null; try { - // 预编译SQL语句,用于根据给定的id2查询prodCatalog表中的记录 pstmt = conn.prepareStatement("select *from prodCatalog where id2 =?"); - // 设置SQL语句中的参数,将传入的id1赋值给查询语句中的占位符 - pstmt.setString(1, id1); + pstmt.setString(1,id1); + - // 执行查询操作 resultSet = pstmt.executeQuery(); - // 如果结果集中有下一条记录,则获取对应记录中的name1字段值作为商品目录名称 - if (resultSet.next()) { - catalog = resultSet.getString("name1"); + if(resultSet.next()){ + catalog=resultSet.getString("name1"); } } catch (SQLException e) { + // TODO Auto-generated catch block e.printStackTrace(); - } finally { - // 关闭相关资源 + }finally{ JDBCUtil.close(resultSet, pstmt, conn); } + return catalog; + } - // 向商品目录表prodCatalog中添加一条记录 @Override public int addProdCatalog(String id1, String id2) { - int flag = 0; - String name1 = null; - // 根据传入的id1判断商品类别名称,01对应食品,02对应电器,03对应生活用品,04对应其他 - if (id1.equals("01")) - name1 = "食品"; - else if (id1.equals("02")) - name1 = "电器"; - else if (id1.equals("03")) - name1 = "生活用品"; + int flag=0; + String name1=null; + //01 食品 02 电器 03 生活用品 04 其他 + if(id1.equals("01")) + name1="食品"; + else if(id1.equals("02")) + name1="电器"; + else if(id1.equals("03")) + name1="生活用品"; else - name1 = "其他"; + name1="其他"; - // 获取数据库连接 - Connection conn = JDBCUtil.getConn(); + //连接jdbc + Connection conn=JDBCUtil.getConn(); PreparedStatement pstmt = null; - ResultSet resultSet = null; + ResultSet resultSet=null; try { - // 预编译插入数据的SQL语句,向prodCatalog表中插入三条数据 pstmt = conn.prepareStatement("insert into prodCatalog values(?,?,?)"); - // 设置SQL语句中的第一个参数 - pstmt.setString(1, id1); - // 设置SQL语句中的第二个参数 - pstmt.setString(2, name1); - // 设置SQL语句中的第三个参数 - pstmt.setString(3, id2); - - // 执行插入操作,若插入成功,将flag置为1,表示添加成功 + pstmt.setString(1,id1); + pstmt.setString(2,name1); + pstmt.setString(3,id2); + + pstmt.executeUpdate(); - flag = 1; + flag=1; } catch (SQLException e) { e.printStackTrace(); - } finally { - // 关闭相关资源 + }finally{ JDBCUtil.close(resultSet, pstmt, conn); } return flag; } - // 根据给定的id2删除商品目录表prodCatalog中的一条记录 + @Override public int deleteProdCatalog(String id2) { - int flag = 0; - // 获取数据库连接 - Connection conn = JDBCUtil.getConn(); + int flag=0; + //连接jdbc + Connection conn=JDBCUtil.getConn(); PreparedStatement pstmt = null; - ResultSet resultSet = null; + ResultSet resultSet=null; try { - // 预编译删除数据的SQL语句,根据传入的id2作为条件,从prodCatalog表中删除对应的记录 pstmt = conn.prepareStatement("delete from prodCatalog where id2=?"); - // 设置SQL语句中的参数,将传入的id2赋值给查询语句中的占位符(?) - pstmt.setString(1, id2); - // 执行删除操作,若删除成功,将flag置为1,表示删除成功 + pstmt.setString(1,id2); pstmt.executeUpdate(); - flag = 1; + flag=1; } catch (SQLException e) { - // 若出现SQL异常打印异常栈信息 + // TODO Auto-generated catch block e.printStackTrace(); - } finally { - // 关闭相关资源 + }finally{ JDBCUtil.close(resultSet, pstmt, conn); } return flag; } - // 根据商品类production的name查询并输出类别id,如果传入的name为"全部",则直接返回默认的catalogid "0" + @Override + //根据商品类production的name查询并输出类别id public String findProdCatalogByname(String name) { - Connection conn = JDBCUtil.getConn(); + Connection conn=JDBCUtil.getConn(); PreparedStatement pstmt = null; - ResultSet resultSet = null; + ResultSet resultSet=null; - String catalogid = "0"; + String catalogid="0"; try { - // 如果传入的商品名称为"全部",则直接返回默认的catalogid - if (name.equals("全部")) { + if(name.equals("全部")){ return catalogid; } - // 预编译SQL语句,用于根据给定的商品名称查询prodCatalog表中的记录,获取对应的类别id pstmt = conn.prepareStatement("select * from prodCatalog where name =?"); - // 设置SQL语句中的参数,将传入的name赋值给查询语句中的占位符 - pstmt.setString(1, name); + pstmt.setString(1,name); + - // 执行查询操作,获取结果集 resultSet = pstmt.executeQuery(); - // 如果结果集中有下一条记录,则获取对应记录中的id字段值作为类别id - if (resultSet.next()) { - catalogid = resultSet.getString("id"); + if(resultSet.next()){ + catalogid=resultSet.getString("id"); } } catch (SQLException e) { - // 若出现SQL异常,打印异常栈信息 + // TODO Auto-generated catch block e.printStackTrace(); - } finally { - // 关闭相关资源 + }finally{ JDBCUtil.close(resultSet, pstmt, conn); } + return catalogid; } - /* - public static void main(String[] args) { - ProdCatalog p = new ProdCatalog(); - prodCatalogImpl pi = new prodCatalogImpl(); - p.setName("全部"); - System.out.println(pi.findProdCatalogByname(p.getName())); - } - */ - - // 查询商品目录表prodCatalog中的所有商品类别名称,并添加"全部"作为第一个元素后返回 +/* public static void main(String[] args) { + ProdCatalog p=new ProdCatalog(); + prodCatalogImpl pi=new prodCatalogImpl(); + p.setName("全部"); + System.out.println(pi.findProdCatalogByname(p.getName())); + }*/ + + @Override public ArrayList findNameProdCatalog() { - Connection conn = JDBCUtil.getConn(); + Connection conn=JDBCUtil.getConn(); ArrayList v = new ArrayList(); - // 先添加"全部"作为默认的第一个类别名称 v.add("全部"); ProdCatalog prodCatalog; PreparedStatement pstmt = null; - ResultSet resultSet = null; + ResultSet resultSet=null; try { - // 预编译查询所有记录的SQL语句,用于获取prodCatalog表中的所有商品类别名称 pstmt = conn.prepareStatement("select * from prodCatalog"); - // 执行查询操作 resultSet = pstmt.executeQuery(); - // 遍历结果集,将每条记录中的商品类别名称添加到ArrayList容器中 - while (resultSet.next()) { + while(resultSet.next()){ v.add(resultSet.getString("name")); } } catch (SQLException e) { - // 若出现SQL异常,打印异常栈信息 + // TODO Auto-generated catch block e.printStackTrace(); - } finally { - // 关闭相关资源 + }finally{ JDBCUtil.close(resultSet, pstmt, conn); } + return v; } - /* - public static void main(String[] args) { - prodCatalogImpl pi = new prodCatalogImpl(); - ArrayList log = null; - - - log = pi.findNameProdCatalog(); - String[] s = new String[log.size()]; - for (int i = 0; i < log.size(); i++) { - s[i] = log.get(i); - System.out.println(log.get(i)); - } - for (int i = 0; i < s.length; i++) { - System.out.println(s[i]); - } - - - } - */ -} \ No newline at end of file + /*public static void main(String[] args) { + prodCatalogImpl pi=new prodCatalogImpl(); + ArrayListlog=null; + + + log=pi.findNameProdCatalog(); + String []s=new String[log.size()]; + for(int i=0;i>>>>>> remotes/origin/main +// 导入相关的业务逻辑接口、数据传输对象以及工具类,用于数据库操作和日期处理等功能 +>>>>>>> developer import com.lingnan.supermarket.dao.storageRecordService; import com.lingnan.supermarket.dto.StorageRecord; import com.lingnan.supermarket.utils.DateUtil; import com.lingnan.supermarket.utils.JDBCUtil; -// 实现storageRecordService接口--用于处理库存记录相关的数据持久化操作 public class storageRecordImpl implements storageRecordService { <<<<<<< HEAD - // 查询所有库存记录信息,并以Vector容器存储返回 - @Override - public Vector findAllStorageRecord() { - // 创建一个Vector容器,用于存放查询到的StorageRecord对象 - Vector v = new Vector(); - - // 获取数据库连接,通过JDBCUtil工具类来获取已经配置好的连接对象 - Connection conn = JDBCUtil.getConn(); - PreparedStatement pstmt = null; - ResultSet resultSet = null; - try { - // 编写SQL查询语句,从storageRecord表中查询所有记录,并按照cDate字段降序排序 - String sql = "select * from storageRecord order by cDate desc"; - // 使用获取到的数据库连接对象,预编译SQL语句 - pstmt = conn.prepareStatement(sql); - - // 执行查询操作 - resultSet = pstmt.executeQuery(); - // 遍历结果集,将每一条记录封装成StorageRecord对象,并添加到Vector容器中 - while (resultSet.next()) { - StorageRecord sr = new StorageRecord(); - // 设置StorageRecord对象的id属性 - sr.setId(resultSet.getString("id")); - // 设置StorageRecord对象的库存编号属性 - sr.setTheNumber(resultSet.getString("theNumber")); - // 设置StorageRecord对象的数量属性 - sr.setNum(resultSet.getInt("num")); - // 设置StorageRecord对象的执行情况属性 - sr.setExecute(resultSet.getString("execute")); - // 通过DateUtil工具类的dateToString方法将数据库中获取的时间戳类型的日期数据转换为字符串类型,方便后续使用(第二个参数为null可能表示使用默认的日期格式转换,具体看DateUtil实现) -======= /** * 获取所有存储记录 * @@ -89,81 +57,100 @@ public class storageRecordImpl implements storageRecordService { sr.setNum(resultSet.getInt("num")); // 设置数量字段 sr.setExecute(resultSet.getString("execute")); // 设置执行状态字段 // 设置创建日期字段,并通过DateUtil工具类格式化日期 ->>>>>>> remotes/origin/main +======= + // 查询所有库存记录信息,并以Vector容器存储返回 + @Override + public Vector findAllStorageRecord() { + // 创建一个Vector容器,用于存放查询到的StorageRecord对象 + Vector v = new Vector(); + + // 获取数据库连接,通过JDBCUtil工具类来获取已经配置好的连接对象 + Connection conn = JDBCUtil.getConn(); + PreparedStatement pstmt = null; + ResultSet resultSet = null; + try { + // 编写SQL查询语句,从storageRecord表中查询所有记录,并按照cDate字段降序排序 + String sql = "select * from storageRecord order by cDate desc"; + // 使用获取到的数据库连接对象,预编译SQL语句 + pstmt = conn.prepareStatement(sql); + + // 执行查询操作 + resultSet = pstmt.executeQuery(); + // 遍历结果集,将每一条记录封装成StorageRecord对象,并添加到Vector容器中 + while (resultSet.next()) { + StorageRecord sr = new StorageRecord(); + // 设置StorageRecord对象的id属性 + sr.setId(resultSet.getString("id")); + // 设置StorageRecord对象的库存编号属性 + sr.setTheNumber(resultSet.getString("theNumber")); + // 设置StorageRecord对象的数量属性 + sr.setNum(resultSet.getInt("num")); + // 设置StorageRecord对象的执行情况属性 + sr.setExecute(resultSet.getString("execute")); + // 通过DateUtil工具类的dateToString方法将数据库中获取的时间戳类型的日期数据转换为字符串类型,方便后续使用(第二个参数为null可能表示使用默认的日期格式转换,具体看DateUtil实现) + +>>>>>>> developer sr.setcDate(DateUtil.dateToString(resultSet.getTimestamp("cDate"), null)); // 将StorageRecord对象添加到Vector中 v.add(sr); } <<<<<<< HEAD - } catch (SQLException e) { - // 若出现SQL异常,打印异常栈信息 + // 如果出现SQL异常,打印错误信息 e.printStackTrace(); } finally { - // 通过JDBCUtil工具类提供的方法进行关闭操作 + // 确保资源被关闭,避免内存泄漏 JDBCUtil.close(resultSet, pstmt, conn); - } + // 返回所有存储记录的Vector return v; } - // 根据给定的库存编号(theNumber)查找对应的库存记录信息并返回 + /** + * 根据存储记录编号查找存储记录 + * + * @param theNumber 存储记录编号 + * @return StorageRecord 查找到的存储记录对象,如果未找到则为null + */ @Override public StorageRecord findByIdStorageRecord(String theNumber) { - // 初始化一个StorageRecord对象为null,用于存放查询到的库存记录信息,如果没查到则返回null + + // 创建一个空的StorageRecord对象,用于存储查询结果 StorageRecord sr = null; + // 获取数据库连接 Connection conn = JDBCUtil.getConn(); + + // 声明PreparedStatement和ResultSet对象 ======= + } catch (SQLException e) { - // 如果出现SQL异常,打印错误信息 + // 若出现SQL异常,打印异常栈信息 e.printStackTrace(); } finally { - // 确保资源被关闭,避免内存泄漏 + // 通过JDBCUtil工具类提供的方法进行关闭操作 JDBCUtil.close(resultSet, pstmt, conn); + } - // 返回所有存储记录的Vector return v; } - /** - * 根据存储记录编号查找存储记录 - * - * @param theNumber 存储记录编号 - * @return StorageRecord 查找到的存储记录对象,如果未找到则为null - */ + // 根据给定的库存编号(theNumber)查找对应的库存记录信息并返回 @Override public StorageRecord findByIdStorageRecord(String theNumber) { - - // 创建一个空的StorageRecord对象,用于存储查询结果 + // 初始化一个StorageRecord对象为null,用于存放查询到的库存记录信息,如果没查到则返回null StorageRecord sr = null; - // 获取数据库连接 Connection conn = JDBCUtil.getConn(); - - // 声明PreparedStatement和ResultSet对象 ->>>>>>> remotes/origin/main +>>>>>>> developer PreparedStatement pstmt = null; ResultSet resultSet = null; try { <<<<<<< HEAD - // 创建一个新的StorageRecord对象,用于后续封装查询到的数据 - sr = new StorageRecord(); - // 预编译SQL语句,用于根据给定的库存编号(theNumber)查询storageRecord表中的记录 - pstmt = conn.prepareStatement("select *from storageRecord where theNumber=?"); - // 设置SQL语句中的参数,将传入的库存编号赋值给查询语句中的占位符 - pstmt.setString(1, theNumber); - // 执行查询操作,获取结果集 - resultSet = pstmt.executeQuery(); - // 如果结果集中有下一条记录,则将对应记录中的各字段值封装到StorageRecord对象中 - if (resultSet.next()) { - sr.setTheNumber((resultSet.getString("theNumber"))); - sr.setId((resultSet.getString("id"))); -======= // 初始化StorageRecord对象 sr = new StorageRecord(); @@ -180,32 +167,26 @@ public class storageRecordImpl implements storageRecordService { if (resultSet.next()) { sr.setTheNumber(resultSet.getString("theNumber")); sr.setId(resultSet.getString("id")); ->>>>>>> remotes/origin/main +======= + // 创建一个新的StorageRecord对象,用于后续封装查询到的数据 + sr = new StorageRecord(); + // 预编译SQL语句,用于根据给定的库存编号(theNumber)查询storageRecord表中的记录 + pstmt = conn.prepareStatement("select *from storageRecord where theNumber=?"); + // 设置SQL语句中的参数,将传入的库存编号赋值给查询语句中的占位符 + pstmt.setString(1, theNumber); + // 执行查询操作,获取结果集 + resultSet = pstmt.executeQuery(); + // 如果结果集中有下一条记录,则将对应记录中的各字段值封装到StorageRecord对象中 + if (resultSet.next()) { + sr.setTheNumber((resultSet.getString("theNumber"))); + sr.setId((resultSet.getString("id"))); +>>>>>>> developer sr.setNum(resultSet.getInt("num")); sr.setExecute(resultSet.getString("execute")); // 设置存储记录的创建日期,并进行格式化 sr.setcDate(DateUtil.dateToString(resultSet.getTimestamp("cDate"), null)); } <<<<<<< HEAD - - } catch (SQLException e) { - // 若出现SQL异常,打印异常栈信息 - e.printStackTrace(); - } finally { - // 关闭相关资源 - JDBCUtil.close(resultSet, pstmt, conn); - } - - return sr; - } - - // 向库存记录表storageRecord中插入一条新的库存记录信息 - public boolean insertStorageRecord(String iNumber, String time, String prodId, String execute, int sum) { - // 定义一个布尔变量用于标记插入操作是否成功,初始化为false - boolean flag = false; - // 获取数据库连接 - Connection conn = JDBCUtil.getConn(); -======= } catch (SQLException e) { // 如果发生SQLException,打印堆栈信息 e.printStackTrace(); @@ -237,29 +218,7 @@ public class storageRecordImpl implements storageRecordService { Connection conn = JDBCUtil.getConn(); // 声明PreparedStatement和ResultSet对象 ->>>>>>> remotes/origin/main - PreparedStatement pstmt = null; - ResultSet resultSet = null; - - try { -<<<<<<< HEAD - // 预编译插入数据的SQL语句,向storageRecord表中插入五条数据 - pstmt = conn.prepareStatement("insert into storageRecord values(?,?,?,?,?) "); - // 设置SQL语句中的第一个参数 - pstmt.setString(1, iNumber); - // 设置SQL语句中的第二个参数 - pstmt.setString(2, time); - // 设置SQL语句中的第三个参数 - pstmt.setString(3, prodId); - // 设置SQL语句中的第四个参数 - pstmt.setString(4, execute); - // 设置SQL语句中的第五个参数 - pstmt.setInt(5, sum); - - // 执行插入操作,若受影响的行数为1,则将flag置为true,表示插入成功 - if (pstmt.executeUpdate() == 1) { - flag = true; - } +======= } catch (SQLException e) { // 若出现SQL异常,打印异常栈信息 @@ -269,7 +228,21 @@ public class storageRecordImpl implements storageRecordService { JDBCUtil.close(resultSet, pstmt, conn); } -======= + return sr; + } + + // 向库存记录表storageRecord中插入一条新的库存记录信息 + public boolean insertStorageRecord(String iNumber, String time, String prodId, String execute, int sum) { + // 定义一个布尔变量用于标记插入操作是否成功,初始化为false + boolean flag = false; + // 获取数据库连接 + Connection conn = JDBCUtil.getConn(); +>>>>>>> developer + PreparedStatement pstmt = null; + ResultSet resultSet = null; + + try { +<<<<<<< HEAD // 编写SQL插入语句,将数据插入到storageRecord表中 pstmt = conn.prepareStatement("insert into storageRecord values(?,?,?,?,?)"); @@ -304,7 +277,33 @@ public class storageRecordImpl implements storageRecordService { } // 返回插入操作的结果(成功返回true,失败返回false) ->>>>>>> remotes/origin/main +======= + // 预编译插入数据的SQL语句,向storageRecord表中插入五条数据 + pstmt = conn.prepareStatement("insert into storageRecord values(?,?,?,?,?) "); + // 设置SQL语句中的第一个参数 + pstmt.setString(1, iNumber); + // 设置SQL语句中的第二个参数 + pstmt.setString(2, time); + // 设置SQL语句中的第三个参数 + pstmt.setString(3, prodId); + // 设置SQL语句中的第四个参数 + pstmt.setString(4, execute); + // 设置SQL语句中的第五个参数 + pstmt.setInt(5, sum); + + // 执行插入操作,若受影响的行数为1,则将flag置为true,表示插入成功 + if (pstmt.executeUpdate() == 1) { + flag = true; + } + + } catch (SQLException e) { + // 若出现SQL异常,打印异常栈信息 + e.printStackTrace(); + } finally { + // 关闭相关资源 + JDBCUtil.close(resultSet, pstmt, conn); + } +>>>>>>> developer return flag; } -} \ No newline at end of file +} diff --git a/Supermarket/src/com/lingnan/supermarket/dao/inOrderService.java b/Supermarket/src/com/lingnan/supermarket/dao/inOrderService.java index 293aa66..a295369 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/inOrderService.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/inOrderService.java @@ -9,7 +9,7 @@ public interface inOrderService { Vector findAllInOrder (); //查询某个进货订单 InOrder findByIdinOrder (String iNumber); - + //默认princial为a1. 创建时new一个时间插入,总价随机模拟 int addInOrder(String iNumber,float allInPrice ); int deleteInOrder(String iNumber); diff --git a/Supermarket/src/com/lingnan/supermarket/dao/inRecordService.java b/Supermarket/src/com/lingnan/supermarket/dao/inRecordService.java index 84b6d44..48bfac7 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/inRecordService.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/inRecordService.java @@ -10,7 +10,7 @@ public interface inRecordService { Vector findAllinRecord(); //查询某个进货详细订单 public Vector findByIdinRecord(String iNumber); - + //默认princial为a1. 创建时new一个时间插入,总价随机模拟 int addinRecord(InRecord ir ); int deleteinRecord(String iNumber); diff --git a/Supermarket/src/com/lingnan/supermarket/dao/outOrderService.java b/Supermarket/src/com/lingnan/supermarket/dao/outOrderService.java index 9b10c5c..2934436 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/outOrderService.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/outOrderService.java @@ -10,7 +10,7 @@ public interface outOrderService { Vector findAllOutOrder (); //查询某个进货订单 OutOrder findByIdOutOrder (String oNumber ); - + //默认princial为a1. 创建时new一个时间插入,总价随机模拟 int addOutOrder(String oNumber ,float allOutPrice ); int deleteOutOrder(String oNumber ); diff --git a/Supermarket/src/com/lingnan/supermarket/dao/outRecordService.java b/Supermarket/src/com/lingnan/supermarket/dao/outRecordService.java index 729976a..e2998ce 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/outRecordService.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/outRecordService.java @@ -9,8 +9,8 @@ public interface outRecordService { Vector findAllOutRecord (); //查询某个进货订单 Vector findByIdOutRecordr (String oNumber ); - - + + int addoutRecord(OutRecord or); - int deleteOutOrder(String oNumber); + int deleteOutOrder(String oNumber); } diff --git a/Supermarket/src/com/lingnan/supermarket/dao/prodCatalogService.java b/Supermarket/src/com/lingnan/supermarket/dao/prodCatalogService.java index 6fbb624..75dc9a3 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/prodCatalogService.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/prodCatalogService.java @@ -11,12 +11,12 @@ public interface prodCatalogService { String findProdCatalog(String id1 ); int addProdCatalog(String id1,String id2); int deleteProdCatalog(String id2); - + //根据商品类production的name查询并输出类别id String findProdCatalogByname(String name ); - + //查找所有商品类的类名并以数组输出 ArrayList findNameProdCatalog(); - + } diff --git a/Supermarket/src/com/lingnan/supermarket/dao/productionService.java b/Supermarket/src/com/lingnan/supermarket/dao/productionService.java index 0e81865..ed6ae75 100644 --- a/Supermarket/src/com/lingnan/supermarket/dao/productionService.java +++ b/Supermarket/src/com/lingnan/supermarket/dao/productionService.java @@ -9,23 +9,23 @@ public interface productionService { //查找并输出全部商品 Vector findAllproduction (); //由一个商品名查找并输出全部商品 - Vector findproduction (String name); + Vector findproduction (String name); Production findByNameProduction(String name); - + //由一个商品类别id2查找并输出全部商品 - Vector findProductionById2 (String id); + Vector findProductionById2 (String id); /*通过id查找商品*/ public Production findByIdProduction(String id); //根据id增加 int addProduction(Production p); - + //根据id删除 public int deleteProduction(String id) ; - + //根据id更新 - int updateProduction(Production p) ; - - boolean updateProductionSum(String prodId,int sum); + int updateProduction(Production p) ; + + boolean updateProductionSum(String prodId,int sum); } diff --git a/Supermarket/src/com/lingnan/supermarket/dialog/ChangeStatusDialog.java b/Supermarket/src/com/lingnan/supermarket/dialog/ChangeStatusDialog.java index cf943a4..359f118 100644 --- a/Supermarket/src/com/lingnan/supermarket/dialog/ChangeStatusDialog.java +++ b/Supermarket/src/com/lingnan/supermarket/dialog/ChangeStatusDialog.java @@ -170,7 +170,7 @@ public class ChangeStatusDialog extends JDialog implements ActionListener{ } else if (catalog1.equals("取消订单")) { catalog = 3; - } + } } diff --git a/Supermarket/src/com/lingnan/supermarket/dialog/UserInfDialog.java b/Supermarket/src/com/lingnan/supermarket/dialog/UserInfDialog.java index 3590fe4..6798f90 100644 --- a/Supermarket/src/com/lingnan/supermarket/dialog/UserInfDialog.java +++ b/Supermarket/src/com/lingnan/supermarket/dialog/UserInfDialog.java @@ -210,9 +210,9 @@ public class UserInfDialog extends JDialog implements ActionListener { else if (sSuper1.equals("收银员")) sSuper = 2; // 收银员权限 else if (sSuper1.equals("管理员")) // 新增权限角色 - sSuper = 1; - else if (sSuper1.equals("进货员")) // 新增权限角色 - sSuper = 3; + sSuper = 1; + else if (sSuper1.equals("进货员")) // 新增权限角色 + sSuper = 3; else sSuper = 0; // 超级管理员 } diff --git a/Supermarket/src/com/lingnan/supermarket/dto/OutOrder.java b/Supermarket/src/com/lingnan/supermarket/dto/OutOrder.java index 464ea7f..c9dae83 100644 --- a/Supermarket/src/com/lingnan/supermarket/dto/OutOrder.java +++ b/Supermarket/src/com/lingnan/supermarket/dto/OutOrder.java @@ -3,11 +3,11 @@ 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; + private int delmark; public String getoNumber() { return oNumber; } diff --git a/Supermarket/src/com/lingnan/supermarket/dto/OutRecord.java b/Supermarket/src/com/lingnan/supermarket/dto/OutRecord.java index 6abc8c3..b1b8ba5 100644 --- a/Supermarket/src/com/lingnan/supermarket/dto/OutRecord.java +++ b/Supermarket/src/com/lingnan/supermarket/dto/OutRecord.java @@ -3,9 +3,9 @@ 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; + private String oNumber; + private int sum; + private Float outPrice; public String getoNumber() { return oNumber; } diff --git a/Supermarket/src/com/lingnan/supermarket/dto/Production.java b/Supermarket/src/com/lingnan/supermarket/dto/Production.java index 92b48db..8735e19 100644 --- a/Supermarket/src/com/lingnan/supermarket/dto/Production.java +++ b/Supermarket/src/com/lingnan/supermarket/dto/Production.java @@ -4,5 +4,5 @@ import com.lingnan.supermarket.dto.base.BaseProduction; import com.lingnan.supermarket.dto.base.BsDomain; public class Production extends BaseProduction{ - + } \ No newline at end of file diff --git a/Supermarket/src/com/lingnan/supermarket/utils/CreateOrder.java b/Supermarket/src/com/lingnan/supermarket/utils/CreateOrder.java index 7acb4ca..2822243 100644 --- a/Supermarket/src/com/lingnan/supermarket/utils/CreateOrder.java +++ b/Supermarket/src/com/lingnan/supermarket/utils/CreateOrder.java @@ -5,21 +5,9 @@ import java.util.Vector; import com.lingnan.supermarket.dto.Buffer; import com.lingnan.supermarket.dto.Production; -// 用于创建订单相关文本内容 public class CreateOrder { <<<<<<< HEAD - // 用于生成一个完整的订单文本信息,接收商品信息向量、订单编号、时间、总价以及负责人用户名等参数 - public String CreateOrder(Vector v, String oNumber, String time, Float allPrice, String username) { - // 分割线 - String xx = "----------------------------------------------------------------------------\r\n"; - // 初始化订单文本内容 - String InRequireText = time + "\r\n" + xx; - - // 添加订单小票中商品信息展示的表头部分 - InRequireText += "#名称 #单价 #数量 #金额\r\n"; - //循环遍历传入的商品信息向量,将每个商品的具体信息按照设定的格式拼接添加到订单文本中 -======= // 方法:生成订单小票文本 public String CreateOrder(Vector v, String oNumber, String time, Float allPrice, String username) { // 初始化分隔符 @@ -32,31 +20,23 @@ public class CreateOrder { InRequireText += "#名称 #单价 #数量 #金额\r\n"; // 遍历商品列表,生成订单项信息 ->>>>>>> remotes/origin/main +======= + // 用于生成一个完整的订单文本信息,接收商品信息向量、订单编号、时间、总价以及负责人用户名等参数 + public String CreateOrder(Vector v, String oNumber, String time, Float allPrice, String username) { + // 分割线 + String xx = "----------------------------------------------------------------------------\r\n"; + // 初始化订单文本内容 + String InRequireText = time + "\r\n" + xx; + + // 添加订单小票中商品信息展示的表头部分 + InRequireText += "#名称 #单价 #数量 #金额\r\n"; + //循环遍历传入的商品信息向量,将每个商品的具体信息按照设定的格式拼接添加到订单文本中 +>>>>>>> developer for (Production p : v) { InRequireText += p.getName() + " " + p.getInPrice() + " " + p.getSum() + " " + p.getPrice() + "\r\n"; } <<<<<<< HEAD - // 添加一条分割线 - InRequireText += "\r\n" + xx; - - // 显示本次进货的总价金额 - InRequireText += "#总进货金额:" + allPrice + "元"; - // 显示订单的负责人 - InRequireText += "\r\n#负责人:" + username; - // 添加订单编号信息到订单文本中 - InRequireText += "\r\n#订单编号:" + oNumber; - // 添加超市地址信息到订单文本中,注明订单对应的收货地址等相关信息 - InRequireText += "\r\n#地址:新民超市"; - // 添加联系电话信息到订单文本中 - InRequireText += "\r\n#联系电话:xxx"; - - // 返回最终生成的完整订单文本内容 - return InRequireText; - } -} -======= // 订单总金额 InRequireText += "\r\n" + xx; InRequireText += "#总进货金额:" + allPrice + "元"; @@ -126,5 +106,23 @@ public class CreateOrder { return orderList.toString(); } +======= + // 添加一条分割线 + InRequireText += "\r\n" + xx; + + // 显示本次进货的总价金额 + InRequireText += "#总进货金额:" + allPrice + "元"; + // 显示订单的负责人 + InRequireText += "\r\n#负责人:" + username; + // 添加订单编号信息到订单文本中 + InRequireText += "\r\n#订单编号:" + oNumber; + // 添加超市地址信息到订单文本中,注明订单对应的收货地址等相关信息 + InRequireText += "\r\n#地址:新民超市"; + // 添加联系电话信息到订单文本中 + InRequireText += "\r\n#联系电话:xxx"; + + // 返回最终生成的完整订单文本内容 + return InRequireText; + } +>>>>>>> developer } ->>>>>>> remotes/origin/main diff --git a/Supermarket/src/com/lingnan/supermarket/utils/DateUtil.java b/Supermarket/src/com/lingnan/supermarket/utils/DateUtil.java index 8297759..16be79a 100644 --- a/Supermarket/src/com/lingnan/supermarket/utils/DateUtil.java +++ b/Supermarket/src/com/lingnan/supermarket/utils/DateUtil.java @@ -3,23 +3,20 @@ 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 返回一个按照指定格式(或默认格式)格式化后的日期字符串,方便在界面显示、数据存储等场景使用。 + * 格式化日期 + * @param date + * @param pattern + * @return */ - public static String dateToString(Date date, String pattern) { - // 创建SimpleDateFormat对象,它是Java中用于格式化日期的类,通过指定的模式将日期转换为相应格式的字符串。 + public static String dateToString(Date date,String pattern) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(); - // 使用applyPattern方法设置日期格式化的模式。如果传入的pattern为null,就使用默认的"yyyy-MM-dd HH:mm:ss"格式。 - simpleDateFormat.applyPattern(pattern == null? "yyyy-MM-dd HH:mm:ss" : pattern); - // 调用format方法,将传入的Date对象按照设置好的模式进行格式化,最终返回格式化后的日期字符串。 + simpleDateFormat.applyPattern(pattern==null?"yyyy-MM-dd HH:mm:ss":pattern); return simpleDateFormat.format(date); } -} \ No newline at end of file + + +} diff --git a/Supermarket/src/com/lingnan/supermarket/utils/EmailTest.java b/Supermarket/src/com/lingnan/supermarket/utils/EmailTest.java index 7fcaf89..f3769fb 100644 --- a/Supermarket/src/com/lingnan/supermarket/utils/EmailTest.java +++ b/Supermarket/src/com/lingnan/supermarket/utils/EmailTest.java @@ -3,12 +3,12 @@ package com.lingnan.supermarket.utils; import javax.mail.MessagingException; import javax.mail.internet.AddressException; -// EmailTest类 public class EmailTest { - //Java程序的入口点 - // 这里声明抛出AddressException和MessagingException异常,意味着在方法执行过程中如果出现邮件地址相关或邮件发送相关的异常,将直接向上抛出,由调用者处理 public static void main(String[] args) throws AddressException, MessagingException { // TODO Auto-generated method stub + + } -} \ No newline at end of file + +} diff --git a/Supermarket/src/com/lingnan/supermarket/utils/JDBCUtil.java b/Supermarket/src/com/lingnan/supermarket/utils/JDBCUtil.java index 4da3682..d520088 100644 --- a/Supermarket/src/com/lingnan/supermarket/utils/JDBCUtil.java +++ b/Supermarket/src/com/lingnan/supermarket/utils/JDBCUtil.java @@ -10,60 +10,57 @@ import java.sql.Statement; import java.util.Properties; <<<<<<< HEAD -// JDBCUtil工具类,用于管理数据库连接相关的操作,如加载数据库配置、获取数据库连接以及释放相关资源等 public class JDBCUtil { - // 用于存储数据库连接相关的配置信息,通过读取配置文件将配置项加载到该对象中 + // Properties对象用于加载配置文件 ======= +// JDBCUtil工具类,用于管理数据库连接相关的操作,如加载数据库配置、获取数据库连接以及释放相关资源等 public class JDBCUtil { - // Properties对象用于加载配置文件 ->>>>>>> remotes/origin/main + // 用于存储数据库连接相关的配置信息,通过读取配置文件将配置项加载到该对象中 +>>>>>>> developer private static Properties properties; - // 数据库连接的URL地址 private static String url; - // 数据库连接的用户名 private static String user; - // 数据库连接的密码 private static String password; <<<<<<< HEAD - // 静态代码块,在类加载时执行,主要用于加载数据库配置文件并注册数据库驱动,同时获取配置文件中的连接相关信息 - static { - // 通过类加载器获取配置文件的输入流,该文件应位于类路径下,以便能够正确读取 - InputStream inputStream = JDBCUtil.class.getClassLoader().getResourceAsStream("jdbc.properties"); - - // 创建一个Properties对象,用于存储键值对形式的配置信息 -======= // 静态代码块用于加载配置文件和数据库驱动 static { // 获取配置文件输入流 InputStream inputStream = JDBCUtil.class.getClassLoader().getResourceAsStream("jdbc.properties"); // 初始化Properties对象 ->>>>>>> remotes/origin/main properties = new Properties(); try { -<<<<<<< HEAD - // 将从输入流中读取配置文件的内容加载到Properties对象中 + // 加载配置文件 properties.load(inputStream); } catch (IOException e) { - // 若加载配置文件出现IO异常,打印异常栈信息 + // 如果加载配置文件失败,打印错误信息 e.printStackTrace(); } finally { - // 在完成配置文件读取后释放资源 - if (inputStream!= null) { + // 关闭输入流 + if (inputStream != null) { ======= - // 加载配置文件 + // 静态代码块,在类加载时执行,主要用于加载数据库配置文件并注册数据库驱动,同时获取配置文件中的连接相关信息 + static { + // 通过类加载器获取配置文件的输入流,该文件应位于类路径下,以便能够正确读取 + InputStream inputStream = JDBCUtil.class.getClassLoader().getResourceAsStream("jdbc.properties"); + + // 创建一个Properties对象,用于存储键值对形式的配置信息 + properties = new Properties(); + + try { + // 将从输入流中读取配置文件的内容加载到Properties对象中 properties.load(inputStream); } catch (IOException e) { - // 如果加载配置文件失败,打印错误信息 + // 若加载配置文件出现IO异常,打印异常栈信息 e.printStackTrace(); } finally { - // 关闭输入流 - if (inputStream != null) { ->>>>>>> remotes/origin/main + // 在完成配置文件读取后释放资源 + if (inputStream!= null) { +>>>>>>> developer try { inputStream.close(); } catch (IOException e) { @@ -74,48 +71,48 @@ public class JDBCUtil { } <<<<<<< HEAD - // 注册数据库驱动 + // 注册JDBC驱动 try { - // 从配置文件中获取驱动类名属性,并加载该驱动类,类加载过程会执行驱动类中相关的静态代码,完成驱动在系统中的注册 + // 加载JDBC驱动类 Class.forName(properties.getProperty("driver")); - // 从配置文件中获取数据库连接的URL地址属性 + // 获取数据库连接信息 url = properties.getProperty("url"); - // 从配置文件中获取数据库连接的用户名属性 user = properties.getProperty("user"); - // 从配置文件中获取数据库连接的密码属性 password = properties.getProperty("password"); + } catch (ClassNotFoundException e) { - // 若找不到指定的驱动类,打印异常栈信息 + // 如果驱动类加载失败,打印错误信息 ======= - // 注册JDBC驱动 + // 注册数据库驱动 try { - // 加载JDBC驱动类 + // 从配置文件中获取驱动类名属性,并加载该驱动类,类加载过程会执行驱动类中相关的静态代码,完成驱动在系统中的注册 Class.forName(properties.getProperty("driver")); - // 获取数据库连接信息 + // 从配置文件中获取数据库连接的URL地址属性 url = properties.getProperty("url"); + // 从配置文件中获取数据库连接的用户名属性 user = properties.getProperty("user"); + // 从配置文件中获取数据库连接的密码属性 password = properties.getProperty("password"); - } catch (ClassNotFoundException e) { - // 如果驱动类加载失败,打印错误信息 ->>>>>>> remotes/origin/main + // 若找不到指定的驱动类,打印异常栈信息 +>>>>>>> developer e.printStackTrace(); } } /** <<<<<<< HEAD + * 获取数据库连接 + * + * @return 数据库连接 +======= * 获取数据库连接的方法,通过DriverManager根据之前从配置文件中读取并设置好的URL、用户名和密码来建立数据库连接,并返回该连接对象。 * 如果建立连接过程中出现SQL异常,会打印异常栈信息,并返回null,表示获取连接失败。 * * @return 返回建立好的数据库连接对象,若失败则返回null -======= - * 获取数据库连接 - * - * @return 数据库连接 ->>>>>>> remotes/origin/main +>>>>>>> developer */ public static Connection getConn() { try { @@ -130,28 +127,6 @@ public class JDBCUtil { /** <<<<<<< HEAD - * 释放数据库相关资源的方法,用于关闭ResultSet(结果集)、Statement(语句执行对象)以及Connection(数据库连接对象),避免资源泄漏。 - * 分别判断传入的对象是否为null,若不为null则调用相应的close方法进行关闭操作,若关闭过程中出现SQL异常,会打印异常栈信息。 - * - * @param resultSet 要关闭的结果集对象,通常是执行查询语句后返回的结果集,可为null - * @param statement 要关闭的语句执行对象,如PreparedStatement、Statement等,用于执行SQL语句,可为null - * @param connection 要关闭的数据库连接对象,用于与数据库建立连接,可为null - */ - public static void close(ResultSet resultSet, Statement statement, Connection connection) { - try { - // 如果结果集对象不为null,则关闭结果集,释放相关资源 - if (resultSet!= null) { - resultSet.close(); - } - // 如果语句执行对象不为null,则关闭语句执行对象,释放相关资源 - if (statement!= null) { - statement.close(); - } - // 如果数据库连接对象不为null,则关闭数据库连接,释放相关资源 - if (connection!= null) { - connection.close(); - } -======= * 释放数据库资源 * * @param resultSet 结果集对象 @@ -175,15 +150,35 @@ public class JDBCUtil { connection.close(); } ->>>>>>> remotes/origin/main +======= + * 释放数据库相关资源的方法,用于关闭ResultSet(结果集)、Statement(语句执行对象)以及Connection(数据库连接对象),避免资源泄漏。 + * 分别判断传入的对象是否为null,若不为null则调用相应的close方法进行关闭操作,若关闭过程中出现SQL异常,会打印异常栈信息。 + * + * @param resultSet 要关闭的结果集对象,通常是执行查询语句后返回的结果集,可为null + * @param statement 要关闭的语句执行对象,如PreparedStatement、Statement等,用于执行SQL语句,可为null + * @param connection 要关闭的数据库连接对象,用于与数据库建立连接,可为null + */ + public static void close(ResultSet resultSet, Statement statement, Connection connection) { + try { + // 如果结果集对象不为null,则关闭结果集,释放相关资源 + if (resultSet!= null) { + resultSet.close(); + } + // 如果语句执行对象不为null,则关闭语句执行对象,释放相关资源 + if (statement!= null) { + statement.close(); + } + // 如果数据库连接对象不为null,则关闭数据库连接,释放相关资源 + if (connection!= null) { + connection.close(); + } +>>>>>>> developer } catch (SQLException e) { // 如果关闭资源时发生错误,打印错误信息 e.printStackTrace(); } } <<<<<<< HEAD -} -======= /** * 打印当前数据库配置信息(用于调试) @@ -243,5 +238,6 @@ public class JDBCUtil { private static void logCloseConnection() { System.out.println("数据库连接已关闭。"); } +======= +>>>>>>> developer } ->>>>>>> remotes/origin/main diff --git a/Supermarket/src/com/lingnan/supermarket/utils/SendQQMailUtil.java b/Supermarket/src/com/lingnan/supermarket/utils/SendQQMailUtil.java index 3736a31..e29392e 100644 --- a/Supermarket/src/com/lingnan/supermarket/utils/SendQQMailUtil.java +++ b/Supermarket/src/com/lingnan/supermarket/utils/SendQQMailUtil.java @@ -12,23 +12,23 @@ import javax.mail.internet.MimeMessage; import com.lingnan.supermarket.dto.*; public class SendQQMailUtil { - + private String FromEamil; private String Stmt; private String ToEmail; private String Title; private String txtFile; - - + + public SendQQMailUtil (String setFromEamil,String Stmt,String ToEmail,String Title,String txtFile) throws AddressException, MessagingException{ - this.FromEamil=setFromEamil; - this.Stmt=Stmt; - this.ToEmail=ToEmail; - this.Title=Title; - this.txtFile=txtFile; - - System.out.println("Stmt="+Stmt); + this.FromEamil=setFromEamil; + this.Stmt=Stmt; + this.ToEmail=ToEmail; + this.Title=Title; + this.txtFile=txtFile; + + System.out.println("Stmt="+Stmt); Properties properties = new Properties(); properties.put("mail.transport.protocol", "smtp");// 连接协议 diff --git a/Supermarket/src/com/lingnan/supermarket/utils/Test.java b/Supermarket/src/com/lingnan/supermarket/utils/Test.java index ab6921b..0a416b5 100644 --- a/Supermarket/src/com/lingnan/supermarket/utils/Test.java +++ b/Supermarket/src/com/lingnan/supermarket/utils/Test.java @@ -1,9 +1,9 @@ package com.lingnan.supermarket.utils; -//测试类,用于演示静态代码块的使用 public class Test { + static { - System.out.println("tasdasd."); // 打印一条测试信息 + System.out.println("tasdasd."); } -} \ No newline at end of file +} diff --git a/Supermarket/src/com/lingnan/supermarket/utils/TimeAndOrder.java b/Supermarket/src/com/lingnan/supermarket/utils/TimeAndOrder.java index bf7d9cf..87d5101 100644 --- a/Supermarket/src/com/lingnan/supermarket/utils/TimeAndOrder.java +++ b/Supermarket/src/com/lingnan/supermarket/utils/TimeAndOrder.java @@ -4,11 +4,44 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Random; -//具类,用于生成订单号和时间戳 public class TimeAndOrder { /** <<<<<<< HEAD + * 生成一个包含订单号和时间的字符串数组 + * @param username 用户名,用于生成订单号 + * @return 一个包含订单号和当前时间的字符串数组 + */ + public static String[] TimeAndOrder(String username) { + // 创建一个长度为2的字符串数组,用于存储订单号和当前时间 + String[] s = new String[2]; + + // 创建两个SimpleDateFormat对象,分别用于不同格式的日期输出 + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 当前时间的格式 + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMddHHmmss"); // 订单号日期格式(年月日时分秒) + + // 获取当前时间 + Calendar cal = Calendar.getInstance(); + String date1 = sdf1.format(cal.getTime()); // 当前日期时间 + String date2 = sdf2.format(cal.getTime()); // 订单号使用的时间 + + // 生成随机数,以增加订单号的随机性 + Random random = new Random(); + int result1 = random.nextInt(10); // 随机生成一个0到9之间的数字 + int result2 = random.nextInt(10); // 随机生成另一个0到9之间的数字 + + // 生成订单号,将用户名、时间和随机数拼接在一起 + s[0] = username + result1 + date2 + result2; + + // 生成当前时间字符串 + s[1] = date1; + + // 打印生成的订单号和时间(调试用) + System.out.println(s[0]); + System.out.println(s[1]); + + // 返回包含订单号和时间的字符串数组 +======= * 生成订单号和当前时间戳。 * 订单号由用户名、随机数、当前时间戳和另一个随机数组成。 * 时间戳格式为 "yyyy-MM-dd HH:mm:ss"。 @@ -49,63 +82,13 @@ public class TimeAndOrder { System.out.println(s[1]); // 打印时间戳 // 返回包含订单号和时间戳的字符串数组 -======= - * 生成一个包含订单号和时间的字符串数组 - * @param username 用户名,用于生成订单号 - * @return 一个包含订单号和当前时间的字符串数组 - */ - public static String[] TimeAndOrder(String username) { - // 创建一个长度为2的字符串数组,用于存储订单号和当前时间 - String[] s = new String[2]; - - // 创建两个SimpleDateFormat对象,分别用于不同格式的日期输出 - SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 当前时间的格式 - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMddHHmmss"); // 订单号日期格式(年月日时分秒) - - // 获取当前时间 - Calendar cal = Calendar.getInstance(); - String date1 = sdf1.format(cal.getTime()); // 当前日期时间 - String date2 = sdf2.format(cal.getTime()); // 订单号使用的时间 - // 生成随机数,以增加订单号的随机性 - Random random = new Random(); - int result1 = random.nextInt(10); // 随机生成一个0到9之间的数字 - int result2 = random.nextInt(10); // 随机生成另一个0到9之间的数字 - - // 生成订单号,将用户名、时间和随机数拼接在一起 - s[0] = username + result1 + date2 + result2; - - // 生成当前时间字符串 - s[1] = date1; - - // 打印生成的订单号和时间(调试用) - System.out.println(s[0]); - System.out.println(s[1]); - - // 返回包含订单号和时间的字符串数组 ->>>>>>> remotes/origin/main +>>>>>>> developer return s; } /** <<<<<<< HEAD - * 生成当前日期,格式为 "yyyy-MM-dd"。 - * - * @return 返回当前日期的字符串表示。 - */ - public static String yMdTime() { - // 创建一个SimpleDateFormat对象,用于格式化日期 - SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期为 "yyyy-MM-dd" - - // 获取当前时间的Calendar实例 - Calendar cal = Calendar.getInstance(); - - // 获取当前日期并格式化为字符串 - String date = sdf1.format(cal.getTime()); // 格式化日期为 "yyyy-MM-dd" - - // 返回当前日期的字符串表示 - return date; -======= * 获取当前日期(不包含时间) * @return 当前日期的字符串(格式:yyyy-MM-dd) */ @@ -138,6 +121,24 @@ public class TimeAndOrder { private static void logMethodCall(String methodName) { // 模拟打印方法调用日志 System.out.println("Method " + methodName + " was called."); ->>>>>>> remotes/origin/main +======= + * 生成当前日期,格式为 "yyyy-MM-dd"。 + * + * @return 返回当前日期的字符串表示。 + */ + public static String yMdTime() { + // 创建一个SimpleDateFormat对象,用于格式化日期 + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); // 格式化日期为 "yyyy-MM-dd" + + // 获取当前时间的Calendar实例 + Calendar cal = Calendar.getInstance(); + + // 获取当前日期并格式化为字符串 + String date = sdf1.format(cal.getTime()); // 格式化日期为 "yyyy-MM-dd" + + // 返回当前日期的字符串表示 + return date; +>>>>>>> developer } -} \ No newline at end of file + +} diff --git a/Supermarket/src/com/lingnan/supermarket/utils/tplbTest.java b/Supermarket/src/com/lingnan/supermarket/utils/tplbTest.java index c466bd4..77d3635 100644 --- a/Supermarket/src/com/lingnan/supermarket/utils/tplbTest.java +++ b/Supermarket/src/com/lingnan/supermarket/utils/tplbTest.java @@ -1,26 +1,23 @@ package com.lingnan.supermarket.utils; - -import java.awt.*; +import java.awt. *; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; -import javax.swing.*; + +import javax.swing. *; + + + import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Scanner; import java.awt.event.*; +public class tplbTest extends JFrame implements ActionListener +{ + static tplbTest tplb=new tplbTest(); + static JLabel pan=new JLabel(); -//用于展示图片轮播效果 -public class tplbTest extends JFrame implements ActionListener { - - // 创建一个tplbTest实例 - static tplbTest tplb = new tplbTest(); - - // 创建一个JLabel用于显示图片 - static JLabel pan = new JLabel(); - - // 定义图片数组,包含多个图片路径 static ImageIcon[] imgs = { new ImageIcon("static\\bg\\bg1.jpg"), new ImageIcon("static\\bg\\bg2.jpg"), @@ -32,48 +29,54 @@ public class tplbTest extends JFrame implements ActionListener { new ImageIcon("static\\bg\\bg8.jpg"), }; - //设置窗口的基本属性 - public static void settplb() { - tplb.setTitle("图片轮播测试"); // 设置窗口标题 - tplb.setLayout(null); // 设置布局为空布局 - tplb.setSize(700, 800); // 设置窗口大小 - tplb.setResizable(false); // 设置窗口不可调整大小 - tplb.setLocationRelativeTo(null); // 设置窗口居中显示 - tplb.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 设置关闭窗口时退出程序 - tplb.setVisible(true); // 设置窗口可见 + public static void settplb()/*�ܿ��*/ + { + tplb.setTitle("ͼƬ�ֲ�����"); + tplb.setLayout(null); + tplb.setSize(700,800); + tplb.setResizable(false); + tplb.setLocationRelativeTo(null);/*���þ���*/ + tplb.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);/*�رճ���*/ + tplb.setVisible(true); } - //设置图片显示区域,并启动定时器实现图片轮播 - public static void setpan() { - pan.setBounds(50, 50, 500, 500); // 设置图片显示区域的坐标和大小 - tplb.add(pan); // 将图片显示区域添加到窗口中 - // 创建一个定时器,每隔1000毫秒(1秒)触发一次 - Timer timer = new Timer(1000, L); - timer.start(); // 启动定时器 + public static void setpan() + { + pan.setBounds(50, 50, 500, 500); + tplb.add(pan); + Timer timer = new Timer(1000,L); + timer.start(); } - //定义一个ActionListener,用于定时切换图片 - static ActionListener L = new ActionListener() { - int index; // 图片索引 - + static ActionListener L=new ActionListener() + { + int index; @Override - public void actionPerformed(ActionEvent e) { - pan.setIcon(imgs[index]); // 设置当前显示的图片 - index++; // 图片索引加1 - if (index == 7) // 如果索引超出图片数组范围 - index = 0; // 重置索引为0 + public void actionPerformed(ActionEvent e) + { + pan.setIcon(imgs[index]); + index++; + if(index==7) + index=0; } }; + + + public static void main(String[] args) { - settplb(); // 设置窗口属性 - setpan(); // 设置图片显示区域并启动定时器 + settplb(); + setpan(); } - //实现ActionListener接口的方法,用于处理事件 + @Override public void actionPerformed(ActionEvent e) { - // 未实现 + // TODO �Զ����ɵķ������ + } -} \ No newline at end of file + + + +} diff --git a/Supermarket/src/com/lingnan/supermarket/view/InView.java b/Supermarket/src/com/lingnan/supermarket/view/InView.java index 47112d0..69d994a 100644 --- a/Supermarket/src/com/lingnan/supermarket/view/InView.java +++ b/Supermarket/src/com/lingnan/supermarket/view/InView.java @@ -20,6 +20,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.text.html.HTMLDocument.Iterator; import com.lingnan.supermarket.componet.BGPanel; import com.lingnan.supermarket.dao.impl.BufferImpl; @@ -43,6 +44,13 @@ import com.lingnan.supermarket.utils.TimeAndOrder; import com.lingnan.supermarket.view.ProdCatalogView.MyItemListener; <<<<<<< HEAD +public class InView extends JPanel implements ActionListener{ + + + //上面 + private JPanel toolBarPanel; + +======= /** * 用于显示进货系统的界面。 * 包含进货系统的各种操作按钮、搜索框、表格等组件。 @@ -53,213 +61,93 @@ public class InView extends JPanel implements ActionListener { private JPanel toolBarPanel; // 搜索面板 -======= -public class InView extends JPanel implements ActionListener{ - - - //上面 - private JPanel toolBarPanel; - ->>>>>>> remotes/origin/main +>>>>>>> developer private JPanel searchPanel; - private JLabel nameLabel, locationLabel; + private JLabel nameLabel,locationLabel; private JTextField nameSearchTF; <<<<<<< HEAD - private JButton searchBtn, StockBtn, exitBtn; + private JButton searchBtn,StockBtn,exitBtn; - // 操作面板 private JPanel opePanel; - private JButton addBtn, updateBtn, deleteBtn, historyBtn, backBtn, detailBtn; + private JButton addBtn,updateBtn,deleteBtn,historyBtn,backBtn,detailBtn; - // 中间表格区域 + //中间 private JScrollPane tableScrollPane; private JTable inTable; - // 底部面板 - private JPanel bottomPanel, bottomPanelLeft, bottomPanelRight; - private JLabel countInfoLabel, countInfoLabel2; + //下面 + private JPanel bottomPanel,bottomPanelLeft,bottomPanelRight; + private JLabel countInfoLabel,countInfoLabel2; - // 缓冲区对象 private Buffer Buffer; private BufferImpl BufferImpl; - // 商品向量 - private static Vector v = new Vector(); + private static Vector v = new Vector(); - // 状态下拉框 ======= - private JButton searchBtn,StockBtn,exitBtn; + private JButton searchBtn, StockBtn, exitBtn; + // 操作面板 private JPanel opePanel; - private JButton addBtn,updateBtn,deleteBtn,historyBtn,backBtn,detailBtn; + private JButton addBtn, updateBtn, deleteBtn, historyBtn, backBtn, detailBtn; - //中间 + // 中间表格区域 private JScrollPane tableScrollPane; private JTable inTable; - //下面 - private JPanel bottomPanel,bottomPanelLeft,bottomPanelRight; - private JLabel countInfoLabel,countInfoLabel2; + // 底部面板 + private JPanel bottomPanel, bottomPanelLeft, bottomPanelRight; + private JLabel countInfoLabel, countInfoLabel2; + // 缓冲区对象 private Buffer Buffer; private BufferImpl BufferImpl; - private static Vector v = new Vector(); + // 商品向量 + private static Vector v = new Vector(); ->>>>>>> remotes/origin/main + // 状态下拉框 +>>>>>>> developer private JComboBox combo; - private String[] status = {"全部", "已入库", "待入库", "已取消"}; + private String[] status ={"全部","已入库","待入库","已取消"}; private int catalog; <<<<<<< HEAD - // 主窗口和用户信息 private JFrame jFrame; private User user; - // 表格模型 - private InTableModel inTableModel; + private InTableModel inTableModel ; - // 缓冲区实现类 private BufferImpl bufferImpl = new BufferImpl(); - // 标记从提醒那里来1是进货表,0是提醒过来的表 - private int mark; + private int mark;/*标记从提醒那里来1是进货表,0是提醒过来的表*/ - // 进货订单服务实现类 private inOrderServiceImpl inOrderImpl; - // 总价和行数 ======= + // 主窗口和用户信息 private JFrame jFrame; private User user; - private InTableModel inTableModel ; + // 表格模型 + private InTableModel inTableModel; + // 缓冲区实现类 private BufferImpl bufferImpl = new BufferImpl(); - private int mark;/*标记从提醒那里来1是进货表,0是提醒过来的表*/ + // 标记从提醒那里来1是进货表,0是提醒过来的表 + private int mark; + // 进货订单服务实现类 private inOrderServiceImpl inOrderImpl; ->>>>>>> remotes/origin/main + // 总价和行数 +>>>>>>> developer private Float allPrice; private int row; private String uname; <<<<<<< HEAD - //构造函数 - - public InView(JFrame jFrame, User user, Vector v, int mark) { - this.setLayout(new BorderLayout()); // 设置布局为BorderLayout - this.jFrame = jFrame; // 设置主窗口 - this.user = user; // 设置用户信息 - // 获得进货缓冲区的保存的货物并删除缓冲区 - this.v = bufferImpl.allInBuffer(); // 从缓冲区获取商品数据 - bufferImpl.DelAllInBuffer(); // 清空缓冲区 - - this.mark = mark; // 设置标记 - System.out.println("mark=" + mark); // 打印标记值 - uname = user.getUsername(); // 获取用户名 - initView(); // 初始化界面 - } - - // 初始化界面组件。 - private void initView() { - toolBarPanel = new JPanel(new BorderLayout()); // 创建顶部工具栏面板 - - searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建搜索面板 - nameLabel = new JLabel("订单号"); // 创建订单号标签 - nameSearchTF = new JTextField(20); // 创建订单号搜索文本框 - searchBtn = new JButton(new ImageIcon("static\\icon\\search.png")); // 创建搜索按钮 - searchBtn.addActionListener(this); // 为搜索按钮添加事件监听器 - locationLabel = new JLabel("当前位置>进货系统"); // 创建位置标签 - locationLabel.setFont(new FontUtil().userFont); // 设置字体 - locationLabel.setForeground(new Color(18, 150, 219)); // 设置颜色 - - combo = new JComboBox(status); // 创建状态下拉框 - combo.addItemListener(new MyItemListener()); // 为下拉框添加事件监听器 - - opePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建操作面板 - addBtn = new JButton(new ImageIcon("static\\icon\\add.png")); // 创建添加按钮 - updateBtn = new JButton(new ImageIcon("static\\icon\\change.png")); // 创建更新按钮 - deleteBtn = new JButton(new ImageIcon("static\\icon\\delete.png")); // 创建删除按钮 - historyBtn = new JButton(new ImageIcon("static\\icon\\history.png")); // 创建历史记录按钮 - backBtn = new JButton(new ImageIcon("static\\icon\\back.png")); // 创建返回按钮 - detailBtn = new JButton(new ImageIcon("static\\icon\\detail.png")); // 创建详情按钮 - - addBtn.addActionListener(this); // 为添加按钮添加事件监听器 - updateBtn.addActionListener(this); // 为更新按钮添加事件监听器 - deleteBtn.addActionListener(this); // 为删除按钮添加事件监听器 - historyBtn.addActionListener(this); // 为历史记录按钮添加事件监听器 - backBtn.addActionListener(this); // 为返回按钮添加事件监听器 - detailBtn.addActionListener(this); // 为详情按钮添加事件监听器 - - backBtn.setVisible(false); // 隐藏返回按钮 - detailBtn.setVisible(false); // 隐藏详情按钮 - - opePanel.add(addBtn); // 添加添加按钮到操作面板 - opePanel.add(backBtn); // 添加返回按钮到操作面板 - opePanel.add(detailBtn); // 添加详情按钮到操作面板 - opePanel.add(updateBtn); // 添加更新按钮到操作面板 - opePanel.add(deleteBtn); // 添加删除按钮到操作面板 - opePanel.add(historyBtn); // 添加历史记录按钮到操作面板 - - searchPanel.add(locationLabel); // 添加位置标签到搜索面板 - searchPanel.add(nameLabel); // 添加订单号标签到搜索面板 - searchPanel.add(nameSearchTF); // 添加订单号搜索文本框到搜索面板 - searchPanel.add(searchBtn); // 添加搜索按钮到搜索面板 - searchPanel.add(combo); // 添加状态下拉框到搜索面板 - - toolBarPanel.add(searchPanel, "West"); // 将搜索面板添加到工具栏面板的西侧 - toolBarPanel.add(opePanel, "East"); // 将操作面板添加到工具栏面板的东侧 - - // 中间表 - inTableModel = new InTableModel(v); // 创建表格模型 - - inTable = new JTable(inTableModel); // 创建表格 - inTable.setFont(FontUtil.tableFont); // 设置表格字体 - inTable.setRowHeight(50); // 设置表格行高 - tableScrollPane = new JScrollPane(inTable); // 创建表格滚动面板 - - allPrice = inTableModel.getAllPrice(); // 获取总价 - row = inTableModel.getRowCount(); // 获取行数 - - // 下面 - bottomPanelLeft = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建底部左侧面板 - countInfoLabel = new JLabel("商品种类:" + row + ",总价:" + allPrice); // 创建商品种类和总价标签 - bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板 - - bottomPanelRight = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建底部右侧面板 - StockBtn = new JButton(new ImageIcon("static\\icon\\stock.png")); // 创建结账按钮 - exitBtn = new JButton(new ImageIcon("static\\icon\\exit.png")); // 创建退出按钮 - StockBtn.addActionListener(this); // 为结账按钮添加事件监听器 - exitBtn.addActionListener(this); // 为退出按钮添加事件监听器 - bottomPanelRight.add(StockBtn); // 将结账按钮添加到底部右侧面板 - bottomPanelRight.add(exitBtn); // 将退出按钮添加到底部右侧面板 - - bottomPanel = new JPanel(new BorderLayout()); // 创建底部面板 - bottomPanel.add(bottomPanelRight, "East"); // 将底部右侧面板添加到底部面板的东侧 - bottomPanel.add(bottomPanelLeft, "West"); // 将底部左侧面板添加到底部面板的西侧 - - this.add(toolBarPanel, "North"); // 将工具栏面板添加到顶部 - this.add(tableScrollPane, "Center"); // 将表格滚动面板添加到中间 - this.add(bottomPanel, "South"); // 将底部面板添加到底部 - - if (mark == 1) { // 判断是否从提醒那里过来的 - refreshBuffer(v); // 刷新缓冲区 - } else if (mark == 0) { - InOrderRecord(); // 调出进货订单表 - } - - setVisible(true); // 设置可见 - } - //获取商品数量 - public static Vector getVector() { - return v; - } - - //处理状态下拉框的选项变化 -======= public InView(JFrame jFrame,User user,Vector v,int mark) { this.setLayout(new BorderLayout()); this.jFrame = jFrame; @@ -395,75 +283,173 @@ public class InView extends JPanel implements ActionListener{ } ->>>>>>> remotes/origin/main - public class MyItemListener implements ItemListener { - - @Override - public void itemStateChanged(ItemEvent e) { -<<<<<<< HEAD - JComboBox cb = (JComboBox) e.getSource(); // 获取事件源 - String catalog1 = (String) cb.getSelectedItem(); // 获取选中的状态 - if (catalog1.equals("全部")) - catalog = 0; - else if (catalog1.equals("已入库")) - catalog = 1; - else if (catalog1.equals("待入库")) - catalog = 2; - else if (catalog1.equals("已取消")) - catalog = 3; ======= - JComboBox cb = (JComboBox) e.getSource(); - String catalog1 = (String) cb.getSelectedItem(); - if(catalog1.equals("全部")) - catalog=0; - else if(catalog1.equals("已入库")) - catalog=1; - else if(catalog1.equals("待入库")) - catalog=2; - else if(catalog1.equals("已取消")) - catalog=3; - - resultOfFindStatus(catalog); ->>>>>>> remotes/origin/main + //构造函数 - resultOfFindStatus(catalog); // 根据状态查询结果 - } - } + public InView(JFrame jFrame, User user, Vector v, int mark) { + this.setLayout(new BorderLayout()); // 设置布局为BorderLayout + this.jFrame = jFrame; // 设置主窗口 + this.user = user; // 设置用户信息 + // 获得进货缓冲区的保存的货物并删除缓冲区 + this.v = bufferImpl.allInBuffer(); // 从缓冲区获取商品数据 + bufferImpl.DelAllInBuffer(); // 清空缓冲区 -<<<<<<< HEAD - //按钮组件隐藏。 -======= + this.mark = mark; // 设置标记 + System.out.println("mark=" + mark); // 打印标记值 + uname = user.getUsername(); // 获取用户名 + initView(); // 初始化界面 } + // 初始化界面组件。 + private void initView() { + toolBarPanel = new JPanel(new BorderLayout()); // 创建顶部工具栏面板 + searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建搜索面板 + nameLabel = new JLabel("订单号"); // 创建订单号标签 + nameSearchTF = new JTextField(20); // 创建订单号搜索文本框 + searchBtn = new JButton(new ImageIcon("static\\icon\\search.png")); // 创建搜索按钮 + searchBtn.addActionListener(this); // 为搜索按钮添加事件监听器 + locationLabel = new JLabel("当前位置>进货系统"); // 创建位置标签 + locationLabel.setFont(new FontUtil().userFont); // 设置字体 + locationLabel.setForeground(new Color(18, 150, 219)); // 设置颜色 + combo = new JComboBox(status); // 创建状态下拉框 + combo.addItemListener(new MyItemListener()); // 为下拉框添加事件监听器 - //按钮组件隐藏 ->>>>>>> remotes/origin/main - public void OrderView() { - backBtn.setVisible(true); // 显示返回按钮 - detailBtn.setVisible(true); // 显示详情按钮 - updateBtn.setVisible(true); // 显示更新按钮 - deleteBtn.setVisible(true); // 显示删除按钮 - addBtn.setVisible(false); // 隐藏添加按钮 - historyBtn.setVisible(false); // 隐藏历史记录按钮 - } + opePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建操作面板 + addBtn = new JButton(new ImageIcon("static\\icon\\add.png")); // 创建添加按钮 + updateBtn = new JButton(new ImageIcon("static\\icon\\change.png")); // 创建更新按钮 + deleteBtn = new JButton(new ImageIcon("static\\icon\\delete.png")); // 创建删除按钮 + historyBtn = new JButton(new ImageIcon("static\\icon\\history.png")); // 创建历史记录按钮 + backBtn = new JButton(new ImageIcon("static\\icon\\back.png")); // 创建返回按钮 + detailBtn = new JButton(new ImageIcon("static\\icon\\detail.png")); // 创建详情按钮 -<<<<<<< HEAD - //根据订单号查询结果 - public void resultOfNumber(String iNumber) { - this.mark = 0; // 设置标记为0 - InOrderTM inOrderTM = new InOrderTM(); // 创建进货订单表格模型 - inOrderTM.resultOfNumber(iNumber); // 根据订单号查询结果 - inTable.setModel(inOrderTM); // 设置表格模型 - bottomPanelLeft.removeAll(); // 清空底部左侧面板 - countInfoLabel = new JLabel("共" + inOrderTM.getRowCount() + "条记录"); // 创建记录数标签 + addBtn.addActionListener(this); // 为添加按钮添加事件监听器 + updateBtn.addActionListener(this); // 为更新按钮添加事件监听器 + deleteBtn.addActionListener(this); // 为删除按钮添加事件监听器 + historyBtn.addActionListener(this); // 为历史记录按钮添加事件监听器 + backBtn.addActionListener(this); // 为返回按钮添加事件监听器 + detailBtn.addActionListener(this); // 为详情按钮添加事件监听器 + + backBtn.setVisible(false); // 隐藏返回按钮 + detailBtn.setVisible(false); // 隐藏详情按钮 + + opePanel.add(addBtn); // 添加添加按钮到操作面板 + opePanel.add(backBtn); // 添加返回按钮到操作面板 + opePanel.add(detailBtn); // 添加详情按钮到操作面板 + opePanel.add(updateBtn); // 添加更新按钮到操作面板 + opePanel.add(deleteBtn); // 添加删除按钮到操作面板 + opePanel.add(historyBtn); // 添加历史记录按钮到操作面板 + + searchPanel.add(locationLabel); // 添加位置标签到搜索面板 + searchPanel.add(nameLabel); // 添加订单号标签到搜索面板 + searchPanel.add(nameSearchTF); // 添加订单号搜索文本框到搜索面板 + searchPanel.add(searchBtn); // 添加搜索按钮到搜索面板 + searchPanel.add(combo); // 添加状态下拉框到搜索面板 + + toolBarPanel.add(searchPanel, "West"); // 将搜索面板添加到工具栏面板的西侧 + toolBarPanel.add(opePanel, "East"); // 将操作面板添加到工具栏面板的东侧 + + // 中间表 + inTableModel = new InTableModel(v); // 创建表格模型 + + inTable = new JTable(inTableModel); // 创建表格 + inTable.setFont(FontUtil.tableFont); // 设置表格字体 + inTable.setRowHeight(50); // 设置表格行高 + tableScrollPane = new JScrollPane(inTable); // 创建表格滚动面板 + + allPrice = inTableModel.getAllPrice(); // 获取总价 + row = inTableModel.getRowCount(); // 获取行数 + + // 下面 + bottomPanelLeft = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建底部左侧面板 + countInfoLabel = new JLabel("商品种类:" + row + ",总价:" + allPrice); // 创建商品种类和总价标签 bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板 - OrderView(); // 调用OrderView方法 + + bottomPanelRight = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建底部右侧面板 + StockBtn = new JButton(new ImageIcon("static\\icon\\stock.png")); // 创建结账按钮 + exitBtn = new JButton(new ImageIcon("static\\icon\\exit.png")); // 创建退出按钮 + StockBtn.addActionListener(this); // 为结账按钮添加事件监听器 + exitBtn.addActionListener(this); // 为退出按钮添加事件监听器 + bottomPanelRight.add(StockBtn); // 将结账按钮添加到底部右侧面板 + bottomPanelRight.add(exitBtn); // 将退出按钮添加到底部右侧面板 + + bottomPanel = new JPanel(new BorderLayout()); // 创建底部面板 + bottomPanel.add(bottomPanelRight, "East"); // 将底部右侧面板添加到底部面板的东侧 + bottomPanel.add(bottomPanelLeft, "West"); // 将底部左侧面板添加到底部面板的西侧 + + this.add(toolBarPanel, "North"); // 将工具栏面板添加到顶部 + this.add(tableScrollPane, "Center"); // 将表格滚动面板添加到中间 + this.add(bottomPanel, "South"); // 将底部面板添加到底部 + + if (mark == 1) { // 判断是否从提醒那里过来的 + refreshBuffer(v); // 刷新缓冲区 + } else if (mark == 0) { + InOrderRecord(); // 调出进货订单表 + } + + setVisible(true); // 设置可见 + } + //获取商品数量 + public static Vector getVector() { + return v; } - //根据状态查询结果 + //处理状态下拉框的选项变化 + +>>>>>>> developer + public class MyItemListener implements ItemListener { + + @Override + public void itemStateChanged(ItemEvent e) { +<<<<<<< HEAD + JComboBox cb = (JComboBox) e.getSource(); + String catalog1 = (String) cb.getSelectedItem(); + if(catalog1.equals("全部")) + catalog=0; + else if(catalog1.equals("已入库")) + catalog=1; + else if(catalog1.equals("待入库")) + catalog=2; + else if(catalog1.equals("已取消")) + catalog=3; + + resultOfFindStatus(catalog); ======= + JComboBox cb = (JComboBox) e.getSource(); // 获取事件源 + String catalog1 = (String) cb.getSelectedItem(); // 获取选中的状态 + if (catalog1.equals("全部")) + catalog = 0; + else if (catalog1.equals("已入库")) + catalog = 1; + else if (catalog1.equals("待入库")) + catalog = 2; + else if (catalog1.equals("已取消")) + catalog = 3; +>>>>>>> developer + + } + +<<<<<<< HEAD + } + + + + + //按钮组件隐藏 +======= + //按钮组件隐藏。 +>>>>>>> developer + public void OrderView() { + backBtn.setVisible(true); + detailBtn.setVisible(true); + updateBtn.setVisible(true); + deleteBtn.setVisible(true); + addBtn.setVisible(false); + historyBtn.setVisible(false); + } + +<<<<<<< HEAD public void resultOfNumber(String iNumber) { this.mark=0; @@ -476,11 +462,12 @@ public class InView extends JPanel implements ActionListener{ OrderView(); } ->>>>>>> remotes/origin/main - public void resultOfFindStatus(int catalog) { +======= + //根据订单号查询结果 + public void resultOfNumber(String iNumber) { this.mark = 0; // 设置标记为0 InOrderTM inOrderTM = new InOrderTM(); // 创建进货订单表格模型 - inOrderTM.resultOfFind(catalog); // 根据状态查询结果 + inOrderTM.resultOfNumber(iNumber); // 根据订单号查询结果 inTable.setModel(inOrderTM); // 设置表格模型 bottomPanelLeft.removeAll(); // 清空底部左侧面板 countInfoLabel = new JLabel("共" + inOrderTM.getRowCount() + "条记录"); // 创建记录数标签 @@ -488,39 +475,20 @@ public class InView extends JPanel implements ActionListener{ OrderView(); // 调用OrderView方法 } -<<<<<<< HEAD - //刷新缓冲区 - public void refreshBuffer(Vector v) { - this.mark = 1; // 设置标记为1 - - InTableModel inTableModel = new InTableModel(v); // 创建表格模型 - inTable.setModel(inTableModel); // 设置表格模型 - bottomPanelLeft.removeAll(); // 清空底部左侧面板 - countInfoLabel = new JLabel("商品种类:" + inTableModel.getRowCount() + ",总价:" + inTableModel.getAllPrice()); // 创建商品种类和总价标签 - bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板 - backBtn.setVisible(false); // 隐藏返回按钮 - detailBtn.setVisible(false); // 隐藏详情按钮 - historyBtn.setVisible(true); // 显示历史记录按钮 - updateBtn.setVisible(true); // 显示更新按钮 - addBtn.setVisible(true); // 显示添加按钮 - deleteBtn.setVisible(true); // 显示删除按钮 - - allPrice = inTableModel.getAllPrice(); // 获取总价 - row = inTableModel.getRowCount(); // 获取行数 + //根据状态查询结果 +>>>>>>> developer + public void resultOfFindStatus(int catalog) { + this.mark=0; + InOrderTM inOrderTM = new InOrderTM(); + inOrderTM.resultOfFind(catalog); + inTable.setModel(inOrderTM); + bottomPanelLeft.removeAll(); + countInfoLabel = new JLabel("共"+inOrderTM.getRowCount()+"条记录"); + bottomPanelLeft.add(countInfoLabel); + OrderView(); } - //调出进货订单表。 - public void InOrderRecord() { - this.mark = 0; // 设置标记为0 - InOrderTM inOrderTM = new InOrderTM(); // 创建进货订单表格模型 - inOrderTM.allInOrderRecord(); // 查询所有进货订单记录 - inTable.setModel(inOrderTM); // 设置表格模型 - bottomPanelLeft.removeAll(); // 清空底部左侧面板 - countInfoLabel = new JLabel("共" + inOrderTM.getRowCount() + "条记录"); // 创建记录数标签 - bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板 - OrderView(); // 调用OrderView方法 - } -======= +<<<<<<< HEAD /*刷新*/ public void refreshBuffer(Vector v) { @@ -576,160 +544,45 @@ public class InView extends JPanel implements ActionListener{ ->>>>>>> remotes/origin/main +======= + //刷新缓冲区 + public void refreshBuffer(Vector v) { + this.mark = 1; // 设置标记为1 - // 调出进货订单表 - public void InRecord(String iNumber) { - this.mark = 2; // 设置标记为2 - InRecordTM inRecordTM = new InRecordTM(iNumber); // 创建进货记录表格模型 - inRecordTM.findInRecordByINumber(); // 根据订单号查询进货记录 - inTable.setModel(inRecordTM); // 设置表格模型 + InTableModel inTableModel = new InTableModel(v); // 创建表格模型 + inTable.setModel(inTableModel); // 设置表格模型 bottomPanelLeft.removeAll(); // 清空底部左侧面板 - countInfoLabel = new JLabel("订单号@" + iNumber + "共有" + inRecordTM.getRowCount() + "条记录"); // 创建记录数标签 + countInfoLabel = new JLabel("商品种类:" + inTableModel.getRowCount() + ",总价:" + inTableModel.getAllPrice()); // 创建商品种类和总价标签 bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板 - backBtn.setVisible(true); // 显示返回按钮 + backBtn.setVisible(false); // 隐藏返回按钮 detailBtn.setVisible(false); // 隐藏详情按钮 - updateBtn.setVisible(false); // 隐藏更新按钮 - addBtn.setVisible(false); // 隐藏添加按钮 - historyBtn.setVisible(false); // 隐藏历史记录按钮 - deleteBtn.setVisible(false); // 隐藏删除按钮 + historyBtn.setVisible(true); // 显示历史记录按钮 + updateBtn.setVisible(true); // 显示更新按钮 + addBtn.setVisible(true); // 显示添加按钮 + deleteBtn.setVisible(true); // 显示删除按钮 + + allPrice = inTableModel.getAllPrice(); // 获取总价 + row = inTableModel.getRowCount(); // 获取行数 } - //按钮监听事件 + //调出进货订单表。 + public void InOrderRecord() { + this.mark = 0; // 设置标记为0 + InOrderTM inOrderTM = new InOrderTM(); // 创建进货订单表格模型 + inOrderTM.allInOrderRecord(); // 查询所有进货订单记录 + inTable.setModel(inOrderTM); // 设置表格模型 + bottomPanelLeft.removeAll(); // 清空底部左侧面板 + countInfoLabel = new JLabel("共" + inOrderTM.getRowCount() + "条记录"); // 创建记录数标签 + bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板 + OrderView(); // 调用OrderView方法 + } + +>>>>>>> developer + + /*按钮监听时间*/ @Override public void actionPerformed(ActionEvent e) { <<<<<<< HEAD - BufferImpl = new BufferImpl(); // 获取购物车 - Object source = e.getSource(); // 获取事件源 - - if (searchBtn == source) { // 如果是搜索按钮 - String number = nameSearchTF.getText(); // 获取搜索的订单号 - System.out.println("搜索后的订单:" + number); // 打印订单号 - resultOfNumber(number); // 根据订单号查询结果 - } else if (addBtn == source) { // 如果是添加按钮 - InDialog outDialog = new InDialog(jFrame, v, user); // 创建添加对话框 - outDialog.setVisible(true); // 显示对话框 - v = outDialog.getVector(); // 获取更新后的商品向量 - refreshBuffer(v); // 刷新缓冲区 - } else if (updateBtn == source) { // 如果是更新按钮 - System.out.println("mark=" + mark); // 打印标记值 - int rowIndex = inTable.getSelectedRow(); // 获取选中的行 - if (rowIndex == -1) { // 如果没有选中行 - JOptionPane.showMessageDialog(this, "请选中一条进行更改数量"); // 提示用户选中行 - return; - } - // 进货表修改 - if (mark == 1) { - String id = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的ID - ChangeSumDialog changesumDialog = new ChangeSumDialog(jFrame, id, "In", v); // 创建更改数量对话框 - changesumDialog.setVisible(true); // 显示对话框 - v = changesumDialog.getVector(); // 获取更新后的商品向量 - System.out.println("更改状态后v.size=" + v.size()); // 打印商品向量大小 - refreshBuffer(v); // 刷新缓冲区 - } - // inOrder修改,修改状态 - else if (mark == 0) { - String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号 - String status = (String) inTable.getValueAt(rowIndex, 4); // 获取选中行的状态 - if (status.equals("已入库")) { // 如果状态是已入库 - JOptionPane.showMessageDialog(this, "订单上的货物已入库无法修改状态", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户无法修改状态 - return; - } - - ChangeStatusDialog changeStatusDialog = new ChangeStatusDialog(jFrame, iNumber, status); // 创建更改状态对话框 - changeStatusDialog.setVisible(true); // 显示对话框 - MainView.refreshRemind(); // 刷新提醒 - HomeView.refreshHome(); // 刷新主页 - InOrderRecord(); // 调出进货订单表 - } - } else if (deleteBtn == source) { // 如果是删除按钮 - int rowIndex = inTable.getSelectedRow(); // 获取选中的行 - if (rowIndex == -1) { // 如果没有选中行 - JOptionPane.showMessageDialog(this, "请选中一条"); // 提示用户选中行 - return; - } - - /* 删除进货表的 */ - if (mark == 1) { - System.out.println("删除进货表"); // 打印日志 - String id = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的ID - int select = JOptionPane.showConfirmDialog(this, "是否删除id为" + id + "的记录", "提示", JOptionPane.YES_NO_OPTION); // 提示用户确认删除 - if (select == JOptionPane.YES_OPTION) { // 如果用户选择是 - for (int i = 0; i < v.size(); i++) { // 遍历商品向量 - System.out.println("开始删除"); // 打印日志 - if (v.elementAt(i).getId().equals(id)) { // 如果找到对应的商品 - v.remove(i); // 删除商品 - JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户删除成功 - break; - } - } - refreshBuffer(v); // 刷新缓冲区 - } - } - // 删除进货订单 - else if (mark == 0) { - System.out.println("删除订单表"); // 打印日志 - String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号 - int select = JOptionPane.showConfirmDialog(this, "是否删除订单为" + iNumber + "的记录", "提示", JOptionPane.YES_NO_OPTION); // 提示用户确认删除 - if (select == JOptionPane.YES_OPTION) { // 如果用户选择是 - System.out.println("iNumber=" + iNumber); // 打印订单号 - inOrderImpl = new inOrderServiceImpl(); // 创建进货订单服务实现类 - inOrderImpl.deleteInOrder(iNumber); // 删除订单 - JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户删除成功 - InOrderRecord(); // 调出进货订单表 - } - } - } else if (historyBtn == source) { // 如果是历史记录按钮 - InOrderRecord(); // 调出进货订单表 - } else if (backBtn == source) { // 如果是返回按钮 - if (mark == 0) - refreshBuffer(v); // 刷新缓冲区 - else if (mark == 2) - InOrderRecord(); // 调出进货订单表 - } else if (detailBtn == source) { // 如果是详情按钮 - int rowIndex = inTable.getSelectedRow(); // 获取选中的行 - if (rowIndex == -1) { // 如果没有选中行 - JOptionPane.showMessageDialog(this, "请选中一条查看订单详细信息"); // 提示用户选中行 - return; - } - String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号 - System.out.println("详情订单号为=" + iNumber); // 打印订单号 - InRecord(iNumber); // 调出进货记录表 - } else if (StockBtn == source) { // 如果是结账按钮 - refreshBuffer(v); // 刷新缓冲区 - - if (v.size() == 0) { // 如果购物车为空 - JOptionPane.showMessageDialog(null, "您的进货页面为空", "提示", JOptionPane.YES_OPTION); // 提示用户购物车为空 - } else { // 如果购物车不为空 - int res = JOptionPane.showConfirmDialog(null, "进价总金额:" + allPrice + "元\r\n负责人:" + uname + "\r\n发送邮件至 re@qq.com", "提交订单", JOptionPane.YES_NO_OPTION); // 提示用户确认提交订单 - if (res == JOptionPane.YES_OPTION) { // 如果用户选择是 - /* 获得时间和订单号,s[0]为订单号,s[1]为时间 */ - String[] s = TimeAndOrder.TimeAndOrder(uname); // 获取时间和订单号 - - /* 往订单表插入一条记录 */ - inOrderServiceImpl inOrderImpl = new inOrderServiceImpl(); // 创建进货订单服务实现类 - inOrderImpl.InsertInOrder(s[0], allPrice, s[1], uname, 2); // 插入订单记录 - - /* 往inRecord表添加数据 */ - inRecordServiceImpl inRecordImpl = new inRecordServiceImpl(); // 创建进货记录服务实现类 - for (Production p : v) { // 遍历商品向量 - inRecordImpl.insertInRecord(s[0], p); // 插入进货记录 - } - - /* 生成订单文本 */ - CreateOrder createOrder = new CreateOrder(); // 创建订单生成工具类 - String OrderText = createOrder.CreateOrder(v, s[0], s[1], allPrice, uname); // 生成订单文本 - try { // 发送邮件 - SendQQMailUtil QQEmail = new SendQQMailUtil("cwfeng5@qq.com", "wlcinslohrgpdiac", "1912638153@qq.com", "@新民超市进货需求申请", OrderText); // 创建邮件发送工具类 - } catch (MessagingException e1) { // 捕获异常 - e1.printStackTrace(); // 打印异常信息 - } - v = new Vector(); // 清空商品向量 - refreshBuffer(v); // 刷新缓冲区 - MainView.refreshRemind(); // 刷新提醒 - JOptionPane.showConfirmDialog(null, "发送邮件成功\r\n订单号:" + s[0] + "\r\n负责人:" + uname, "提示", JOptionPane.YES_OPTION); // 提示用户发送邮件成功 - } -======= BufferImpl = new BufferImpl();/*获得购物车*/ Object source = e.getSource(); @@ -897,7 +750,142 @@ public class InView extends JPanel implements ActionListener{ v=new Vector();/*将数组置空*/ refreshBuffer(v); JOptionPane.showConfirmDialog(null,"退出成功", "提示", JOptionPane.PLAIN_MESSAGE); ->>>>>>> remotes/origin/main + } + } + } +} +======= + BufferImpl = new BufferImpl(); // 获取购物车 + Object source = e.getSource(); // 获取事件源 + + if (searchBtn == source) { // 如果是搜索按钮 + String number = nameSearchTF.getText(); // 获取搜索的订单号 + System.out.println("搜索后的订单:" + number); // 打印订单号 + resultOfNumber(number); // 根据订单号查询结果 + } else if (addBtn == source) { // 如果是添加按钮 + InDialog outDialog = new InDialog(jFrame, v, user); // 创建添加对话框 + outDialog.setVisible(true); // 显示对话框 + v = outDialog.getVector(); // 获取更新后的商品向量 + refreshBuffer(v); // 刷新缓冲区 + } else if (updateBtn == source) { // 如果是更新按钮 + System.out.println("mark=" + mark); // 打印标记值 + int rowIndex = inTable.getSelectedRow(); // 获取选中的行 + if (rowIndex == -1) { // 如果没有选中行 + JOptionPane.showMessageDialog(this, "请选中一条进行更改数量"); // 提示用户选中行 + return; + } + // 进货表修改 + if (mark == 1) { + String id = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的ID + ChangeSumDialog changesumDialog = new ChangeSumDialog(jFrame, id, "In", v); // 创建更改数量对话框 + changesumDialog.setVisible(true); // 显示对话框 + v = changesumDialog.getVector(); // 获取更新后的商品向量 + System.out.println("更改状态后v.size=" + v.size()); // 打印商品向量大小 + refreshBuffer(v); // 刷新缓冲区 + } + // inOrder修改,修改状态 + else if (mark == 0) { + String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号 + String status = (String) inTable.getValueAt(rowIndex, 4); // 获取选中行的状态 + if (status.equals("已入库")) { // 如果状态是已入库 + JOptionPane.showMessageDialog(this, "订单上的货物已入库无法修改状态", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户无法修改状态 + return; + } + + ChangeStatusDialog changeStatusDialog = new ChangeStatusDialog(jFrame, iNumber, status); // 创建更改状态对话框 + changeStatusDialog.setVisible(true); // 显示对话框 + MainView.refreshRemind(); // 刷新提醒 + HomeView.refreshHome(); // 刷新主页 + InOrderRecord(); // 调出进货订单表 + } + } else if (deleteBtn == source) { // 如果是删除按钮 + int rowIndex = inTable.getSelectedRow(); // 获取选中的行 + if (rowIndex == -1) { // 如果没有选中行 + JOptionPane.showMessageDialog(this, "请选中一条"); // 提示用户选中行 + return; + } + + /* 删除进货表的 */ + if (mark == 1) { + System.out.println("删除进货表"); // 打印日志 + String id = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的ID + int select = JOptionPane.showConfirmDialog(this, "是否删除id为" + id + "的记录", "提示", JOptionPane.YES_NO_OPTION); // 提示用户确认删除 + if (select == JOptionPane.YES_OPTION) { // 如果用户选择是 + for (int i = 0; i < v.size(); i++) { // 遍历商品向量 + System.out.println("开始删除"); // 打印日志 + if (v.elementAt(i).getId().equals(id)) { // 如果找到对应的商品 + v.remove(i); // 删除商品 + JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户删除成功 + break; + } + } + refreshBuffer(v); // 刷新缓冲区 + } + } + // 删除进货订单 + else if (mark == 0) { + System.out.println("删除订单表"); // 打印日志 + String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号 + int select = JOptionPane.showConfirmDialog(this, "是否删除订单为" + iNumber + "的记录", "提示", JOptionPane.YES_NO_OPTION); // 提示用户确认删除 + if (select == JOptionPane.YES_OPTION) { // 如果用户选择是 + System.out.println("iNumber=" + iNumber); // 打印订单号 + inOrderImpl = new inOrderServiceImpl(); // 创建进货订单服务实现类 + inOrderImpl.deleteInOrder(iNumber); // 删除订单 + JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户删除成功 + InOrderRecord(); // 调出进货订单表 + } + } + } else if (historyBtn == source) { // 如果是历史记录按钮 + InOrderRecord(); // 调出进货订单表 + } else if (backBtn == source) { // 如果是返回按钮 + if (mark == 0) + refreshBuffer(v); // 刷新缓冲区 + else if (mark == 2) + InOrderRecord(); // 调出进货订单表 + } else if (detailBtn == source) { // 如果是详情按钮 + int rowIndex = inTable.getSelectedRow(); // 获取选中的行 + if (rowIndex == -1) { // 如果没有选中行 + JOptionPane.showMessageDialog(this, "请选中一条查看订单详细信息"); // 提示用户选中行 + return; + } + String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号 + System.out.println("详情订单号为=" + iNumber); // 打印订单号 + InRecord(iNumber); // 调出进货记录表 + } else if (StockBtn == source) { // 如果是结账按钮 + refreshBuffer(v); // 刷新缓冲区 + + if (v.size() == 0) { // 如果购物车为空 + JOptionPane.showMessageDialog(null, "您的进货页面为空", "提示", JOptionPane.YES_OPTION); // 提示用户购物车为空 + } else { // 如果购物车不为空 + int res = JOptionPane.showConfirmDialog(null, "进价总金额:" + allPrice + "元\r\n负责人:" + uname + "\r\n发送邮件至 re@qq.com", "提交订单", JOptionPane.YES_NO_OPTION); // 提示用户确认提交订单 + if (res == JOptionPane.YES_OPTION) { // 如果用户选择是 + /* 获得时间和订单号,s[0]为订单号,s[1]为时间 */ + String[] s = TimeAndOrder.TimeAndOrder(uname); // 获取时间和订单号 + + /* 往订单表插入一条记录 */ + inOrderServiceImpl inOrderImpl = new inOrderServiceImpl(); // 创建进货订单服务实现类 + inOrderImpl.InsertInOrder(s[0], allPrice, s[1], uname, 2); // 插入订单记录 + + /* 往inRecord表添加数据 */ + inRecordServiceImpl inRecordImpl = new inRecordServiceImpl(); // 创建进货记录服务实现类 + for (Production p : v) { // 遍历商品向量 + inRecordImpl.insertInRecord(s[0], p); // 插入进货记录 + } + + /* 生成订单文本 */ + CreateOrder createOrder = new CreateOrder(); // 创建订单生成工具类 + String OrderText = createOrder.CreateOrder(v, s[0], s[1], allPrice, uname); // 生成订单文本 + try { // 发送邮件 + SendQQMailUtil QQEmail = new SendQQMailUtil("cwfeng5@qq.com", "wlcinslohrgpdiac", "1912638153@qq.com", "@新民超市进货需求申请", OrderText); // 创建邮件发送工具类 + } catch (MessagingException e1) { // 捕获异常 + e1.printStackTrace(); // 打印异常信息 + } + v = new Vector(); // 清空商品向量 + refreshBuffer(v); // 刷新缓冲区 + MainView.refreshRemind(); // 刷新提醒 + JOptionPane.showConfirmDialog(null, "发送邮件成功\r\n订单号:" + s[0] + "\r\n负责人:" + uname, "提示", JOptionPane.YES_OPTION); // 提示用户发送邮件成功 + } + } } else if (exitBtn == source) { // 如果是退出按钮 int res = JOptionPane.showConfirmDialog(null, "确定退出并清空购物车吗", "结账", JOptionPane.YES_NO_OPTION); // 提示用户确认退出 @@ -908,8 +896,5 @@ public class InView extends JPanel implements ActionListener{ } } } -<<<<<<< HEAD -} -======= } ->>>>>>> remotes/origin/main +>>>>>>> developer diff --git a/Supermarket/src/com/lingnan/supermarket/view/MainView.java b/Supermarket/src/com/lingnan/supermarket/view/MainView.java index 0dfd24f..7e7817e 100644 --- a/Supermarket/src/com/lingnan/supermarket/view/MainView.java +++ b/Supermarket/src/com/lingnan/supermarket/view/MainView.java @@ -40,282 +40,337 @@ import com.lingnan.supermarket.view.base.BaseView; import java.awt.*; -//主界面类,继承自BaseView,实现了ActionListener、MouseListener和WindowListener接口。 - -public class MainView extends BaseView implements ActionListener, MouseListener, WindowListener { - - JMenuBar menuBar; // 菜单栏 - JMenu settingMenu, helpMenu; // 设置菜单和帮助菜单 - JMenuItem skinMenuItem, configMenuItem; // 皮肤菜单项和配置菜单项 - JSplitPane containerPanel; // 主界面容器,分为左右两部分 - CardLayout rightPanelLayout; // 右侧面板的布局管理器 - JPanel leftPanel, rightPanel; // 左侧和右侧的面板 - - /* 菜单栏 */ - JLabel logoLabel, userMenuLabel1, homeMenuLabel, userMenuLabel, inMenuLabel, - outMenuLabel, storageMenuLabel, supplierMenuLabel, catalogMenuLabel; - - static JLabel remindMenuLabel; // 全局调用刷新的提醒标签 - - JPanel bottomPanel; // 底部面板 - JLabel timeLabel; // 显示时间的标签 - JPanel purposePanel, timePanel; // 显示当前位置和时间的面板 - JLabel purposeLabel; // 显示当前位置的标签 - - JButton saveBtn, unSaveBtn, cancleBtn; // 退出时的按钮 - - Timer timer; // 定时器,用于更新时间 - - private User user; // 从登录界面传过来的用户信息 - private BufferImpl bufferImpl; // 缓存实现类 - private Image bgImage; // 背景图片 - private String iconSkin; // 图标皮肤 - private int skin; // 当前皮肤编号 - private Vector vP = new Vector(); // 用于进货缓存 - private int location; // 当前界面的位置 - private int sSuper = -1; // 界面权限 - - private static inOrderServiceImpl inOrderImpl = new inOrderServiceImpl(); // 进货订单服务实现类 - private static int unConfirmmark; // 未确认订单数量 - - //构造函数,初始化主界面并设置用户信息和皮肤 - public MainView(User user, int skin, String iconSkin) { - super(1300, 850, "新民超市管理系统欢迎您", user, skin); - timer = new Timer(1000, this); // 创建定时器,每秒触发一次 - timer.start(); // 启动定时器 - this.user = user; // 设置用户信息 - this.sSuper = user.getUsuper(); // 获取用户权限 - System.out.println("userid=" + user.getId()); // 打印用户ID - this.addWindowListener(this); // 添加窗口监听器 - this.skin = skin; // 设置皮肤编号 - this.iconSkin = iconSkin; // 设置图标皮肤路径 - ImageIcon icon = new ImageIcon(iconSkin); // 创建图标 - this.setIconImage(icon.getImage()); // 设置窗口图标 - - // 获取未进货的信息 +public class MainView extends BaseView implements ActionListener, MouseListener,WindowListener{ + + + JMenuBar menuBar; + JMenu settingMenu,helpMenu; + + JMenuItem skinMenuItem,configMenuItem; + + + JSplitPane containerPanel; + + CardLayout rightPanelLayout; + JPanel leftPanel,rightPanel; + + /*菜单栏*/ + JLabel logoLabel,userMenuLabel1,homeMenuLabel,userMenuLabel,inMenuLabel, + outMenuLabel,storageMenuLabel,supplierMenuLabel,catalogMenuLabel; + + static JLabel remindMenuLabel;/*全局调用刷新*/ + + JPanel bottomPanel; + + JLabel timeLabel; + + JPanel purposePanel,timePanel; + JLabel purposeLabel; + + + JButton saveBtn,unSaveBtn,cancleBtn;/*退出时按钮*/ + + // + Timer timer; + + private User user ;/*从登录界面传过来的用户信息*/ + + private BufferImpl bufferImpl; + + private Image bgImage ; + private String iconSkin; + private int skin; + + private Vector vP=new Vector() ;/*用于进货缓存*/ + + + private int location; + + private int sSuper=-1;//界面权限 + + private static inOrderServiceImpl inOrderImpl = new inOrderServiceImpl(); + private static int unConfirmmark;/*未确认订单*/ + + public MainView(User user,int skin,String iconSkin) { + super(1300,850,"新民超市管理系统欢迎您",user,skin); + timer = new Timer(1000,this); + timer.start(); + this.user = user; + + this.sSuper=user.getUsuper();//界面权限 + System.out.println("userid="+user.getId()); + this.addWindowListener(this); + + this.skin = skin; + this.iconSkin = iconSkin; + ImageIcon icon=new ImageIcon(iconSkin); //xxx代表图片存放路径,2.png图片名称及格式 + this.setIconImage(icon.getImage()); + + //获得未进货的信息 Vector vInOrder; - vInOrder = inOrderImpl.findUnconfirmInOrder(); // 查找未确认的进货订单 - unConfirmmark = vInOrder.size(); // 设置未确认订单数量 + vInOrder = inOrderImpl.findUnconfirmInOrder(); + unConfirmmark=vInOrder.size(); + - initView(user, skin); // 初始化界面 + initView(user,skin); } - //构造函数,初始化主界面并设置用户信息 public MainView(User user) { - super(1300, 850, "新民超市管理系统欢迎您"); - timer = new Timer(1000, this); // 创建定时器,每秒触发一次 - timer.start(); // 启动定时器 - this.user = user; // 设置用户信息 - this.sSuper = user.getUsuper(); // 获取用户权限 - System.out.println("userid=" + user.getId()); // 打印用户ID - this.addWindowListener(this); // 添加窗口监听器 - - // 获取未进货的信息 + super(1300,850,"新民超市管理系统欢迎您"); + timer = new Timer(1000,this); + timer.start(); + this.user = user; + + this.sSuper=user.getUsuper();//界面权限 + System.out.println("userid="+user.getId()); + this.addWindowListener(this); + + + //获得未进货的信息 Vector vInOrder; - vInOrder = inOrderImpl.findUnconfirmInOrder(); // 查找未确认的进货订单 - unConfirmmark = vInOrder.size(); // 设置未确认订单数量 + vInOrder = inOrderImpl.findUnconfirmInOrder(); + unConfirmmark=vInOrder.size(); + - initView(user, skin); // 初始化界面 + initView(user,skin); } - //刷新提醒标签,更新未确认订单数量 public static void refreshRemind() { Vector vInOrder; - vInOrder = inOrderImpl.findUnconfirmInOrder(); // 查找未确认的进货订单 - unConfirmmark = vInOrder.size(); // 更新未确认订单数量 - remindMenuLabel.setText("待确认进货:" + unConfirmmark); // 更新提醒标签的文本 + vInOrder = inOrderImpl.findUnconfirmInOrder(); + unConfirmmark=vInOrder.size(); + remindMenuLabel.setText("待确认进货:"+unConfirmmark); } - //初始化界面,设置菜单栏、左侧菜单栏、右侧内容面板等 + + + + +/* public static User getUserInf() { + return user; + }*/ + @Override - protected void initView(User user, int skin) { - /* 菜单栏 */ - menuBar = new JMenuBar(); // 创建菜单栏 - settingMenu = new JMenu("设置"); // 创建设置菜单 - helpMenu = new JMenu("帮助"); // 创建帮助菜单 - skinMenuItem = new JMenuItem("随机切换皮肤", new ImageIcon("static\\icon\\skin.png")); // 创建皮肤菜单项 - configMenuItem = new JMenuItem("参数设置", new ImageIcon("static\\icon\\setting.png")); // 创建配置菜单项 - skinMenuItem.addActionListener(this); // 为皮肤菜单项添加事件监听器 - settingMenu.add(configMenuItem); // 将配置菜单项添加到设置菜单 - settingMenu.add(skinMenuItem); // 将皮肤菜单项添加到设置菜单 - menuBar.add(settingMenu); // 将设置菜单添加到菜单栏 - menuBar.add(helpMenu); // 将帮助菜单添加到菜单栏 - setJMenuBar(menuBar); // 设置窗口的菜单栏 - - //左边菜单栏设置 + protected void initView(User user,int skin) { + + + + + /*菜单栏*/ + menuBar = new JMenuBar(); + + settingMenu = new JMenu("设置"); + + helpMenu = new JMenu("帮助"); + + skinMenuItem = new JMenuItem("随机切换皮肤",new ImageIcon("static\\icon\\skin.png")); + +/* for(int i = 3;i<9;i++) { + + }*/ + configMenuItem = new JMenuItem("参数设置",new ImageIcon("static\\icon\\setting.png")); + skinMenuItem.addActionListener(this); + + settingMenu.add(configMenuItem); + settingMenu.add(skinMenuItem); + menuBar.add(settingMenu); + menuBar.add(helpMenu); + + setJMenuBar(menuBar); + + + /*左边菜单栏设置*/ + + try { - bgImage = ImageIO.read(new File("static\\bg\\bg" + skin + ".jpg")); // 读取背景图片 + bgImage = ImageIO.read(new File("static\\bg\\bg"+skin+".jpg")); } catch (IOException e) { - e.printStackTrace(); // 捕获并打印异常 + // TODO Auto-generated catch block + e.printStackTrace(); } - leftPanel = new BGPanel(bgImage); // 创建带有背景图片的面板 - leftPanel.setLayout(null); // 设置布局为空,自定义布局 - - //菜单栏:用户登录信息 - System.out.println("用户头像地址==" + user.getImg()); // 打印用户头像地址 - JLabel logoLabel = new JLabel(new ImageIcon(user.getImg()), JLabel.LEFT); // 创建用户头像标签 - System.out.println(user.getImg()); // 打印用户头像地址 - leftPanel.add(logoLabel); // 将用户头像标签添加到左侧面板 - logoLabel.setBounds(25, 30, 150, 150); // 设置用户头像标签的位置和大小 - - //账号名字 - String x = UsuperIcon(user.getUsuper()); // 根据用户权限返回对应的图标地址 - System.out.println("身份地址:" + x); // 打印身份图标地址 - userMenuLabel1 = new JLabel("|" + user.getUsername() + "|" + user.getRname(), new ImageIcon(x), JLabel.LEFT); // 创建用户信息标签 - userMenuLabel1.setFont(FontUtil.userFont); // 设置字体 - userMenuLabel1.addMouseListener(this); // 添加鼠标监听器 - userMenuLabel1.setBounds(20, 170, 180, 32); // 设置位置和大小 - userMenuLabel1.setForeground(Color.white); // 设置字体颜色为白色 - leftPanel.add(userMenuLabel1); // 将用户信息标签添加到左侧面板 - - // 菜单栏:首页 - homeMenuLabel = new JLabel("新民首页", new ImageIcon("static\\icon\\home1.png"), JLabel.LEFT); // 创建首页标签 - homeMenuLabel.setFont(FontUtil.menuFont); // 设置字体 - homeMenuLabel.addMouseListener(this); // 添加鼠标监听器 - homeMenuLabel.setBounds(20, 250, 150, 32); // 设置位置和大小 - homeMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - leftPanel.add(homeMenuLabel); // 将首页标签添加到左侧面板 - - // 菜单栏:人员管理 - userMenuLabel = new JLabel("人员管理", new ImageIcon("static\\icon\\user1.png"), JLabel.LEFT); // 创建人员管理标签 - userMenuLabel.setFont(FontUtil.menuFont); // 设置字体 - userMenuLabel.addMouseListener(this); // 添加鼠标监听器 - userMenuLabel.setBounds(20, 300, 150, 32); // 设置位置和大小 - userMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - leftPanel.add(userMenuLabel); // 将人员管理标签添加到左侧面板 - - // 菜单栏:进货系统 - inMenuLabel = new JLabel("进货系统", new ImageIcon("static\\icon\\in1.png"), JLabel.LEFT); // 创建进货系统标签 - inMenuLabel.setFont(FontUtil.menuFont); // 设置字体 - inMenuLabel.addMouseListener(this); // 添加鼠标监听器 - inMenuLabel.setBounds(20, 350, 150, 32); // 设置位置和大小 - inMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - leftPanel.add(inMenuLabel); // 将进货系统标签添加到左侧面板 - - // 菜单栏:收银系统 - outMenuLabel = new JLabel("收银系统", new ImageIcon("static\\icon\\out1.png"), JLabel.LEFT); // 创建收银系统标签 - outMenuLabel.setFont(FontUtil.menuFont); // 设置字体 - outMenuLabel.addMouseListener(this); // 添加鼠标监听器 - outMenuLabel.setBounds(20, 400, 150, 32); // 设置位置和大小 - outMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - leftPanel.add(outMenuLabel); // 将收银系统标签添加到左侧面板 - - // 菜单栏:库存 - storageMenuLabel = new JLabel("商品库存", new ImageIcon("static\\icon\\storage1.png"), JLabel.LEFT); // 创建库存标签 - storageMenuLabel.setFont(FontUtil.menuFont); // 设置字体 - storageMenuLabel.addMouseListener(this); // 添加鼠标监听器 - storageMenuLabel.setBounds(20, 450, 150, 32); // 设置位置和大小 - storageMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - leftPanel.add(storageMenuLabel); // 将库存标签添加到左侧面板 - - // 菜单栏:供应商 - supplierMenuLabel = new JLabel("供应商", new ImageIcon("static\\icon\\supplier1.png"), JLabel.LEFT); // 创建供应商标签 - supplierMenuLabel.setFont(FontUtil.menuFont); // 设置字体 - supplierMenuLabel.addMouseListener(this); // 添加鼠标监听器 - supplierMenuLabel.setBounds(20, 500, 150, 32); // 设置位置和大小 - supplierMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - leftPanel.add(supplierMenuLabel); // 将供应商标签添加到左侧面板 - - // 菜单栏:商品目录 - catalogMenuLabel = new JLabel("商品目录", new ImageIcon("static\\icon\\catalog1.png"), JLabel.LEFT); // 创建商品目录标签 - catalogMenuLabel.setFont(FontUtil.menuFont); // 设置字体 - catalogMenuLabel.addMouseListener(this); // 添加鼠标监听器 - catalogMenuLabel.setBounds(20, 550, 150, 32); // 设置位置和大小 - catalogMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - leftPanel.add(catalogMenuLabel); // 将商品目录标签添加到左侧面板 - - // 提醒进货确认模块 - remindMenuLabel = new JLabel("待确认进货:" + unConfirmmark, new ImageIcon("static\\icon\\remind1.png"), JLabel.LEFT); // 创建提醒标签 - remindMenuLabel.setFont(FontUtil.remindFont); // 设置字体 - remindMenuLabel.addMouseListener(this); // 添加鼠标监听器 - remindMenuLabel.setBounds(0, 650, 200, 32); // 设置位置和大小 - remindMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - leftPanel.add(remindMenuLabel); // 将提醒标签添加到左侧面板 - - rightPanelLayout = new CardLayout(); // 创建卡片布局管理器 - - // 0.超市首页展示 - JPanel homePanel = new HomeView(this); // 创建首页面板 - - // 1.用户管理界面:用户的列表 - JPanel userPanel = new UserView(this); // 创建用户管理面板 - - // 2.进货系统界面 - JPanel inPanel = new InView(this, user, vP, 1); // 创建进货系统面板 - - // 3收银系统界面 - JPanel outPanel = new OutView(this, user); // 创建收银系统面板 - - // 4.库存系统界面 - JPanel storagePanel = new StorageView(this); // 创建库存系统面板 - - // 5.供应商界面 - JPanel supplierPanel = new SupplierView(this); // 创建供应商面板 - - // 6商品目录界面 - JPanel ProdCatalogPanel = new ProdCatalogView(this); // 创建商品目录面板 - - // 7商品目录界面 - JPanel superPanel = new SuperView(this); // 创建普通用户界面 - - // 8进货信息提示 - JPanel inPanel2 = new InView(this, user, vP, 0); // 创建进货信息提示面板 - - /* 添加界面并给索引 */ - rightPanel = new JPanel(rightPanelLayout); // 创建右侧内容面板 - rightPanel.add(homePanel, "0"); // 添加首页面板并设置索引 - rightPanel.add(userPanel, "1"); // 添加用户管理面板并设置索引 - rightPanel.add(inPanel, "2"); // 添加进货系统面板并设置索引 - rightPanel.add(outPanel, "3"); // 添加收银系统面板并设置索引 - rightPanel.add(storagePanel, "4"); // 添加库存系统面板并设置索引 - rightPanel.add(supplierPanel, "5"); // 添加供应商面板并设置索引 - rightPanel.add(ProdCatalogPanel, "6"); // 添加商品目录面板并设置索引 - rightPanel.add(superPanel, "7"); // 添加普通用户面板并设置索引 - rightPanel.add(inPanel2, "8"); // 添加进货信息提示面板并设置索引 - - containerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); // 创建左右分割面板 - containerPanel.setDividerLocation(180); // 设置分割位置 - containerPanel.setDividerSize(0); // 设置分割线宽度为0 - - bottomPanel = new JPanel(); // 创建底部面板 - bottomPanel.setBackground(Color.WHITE); // 设置背景颜色为白色 - bottomPanel.setLayout(new BorderLayout()); // 设置布局为边界布局 - - purposePanel = new JPanel(); // 创建当前位置面板 - purposePanel.setLayout(new FlowLayout(FlowLayout.LEFT)); // 设置布局为流式布局(左对齐) - purposePanel.setBackground(Color.WHITE); // 设置背景颜色为白色 - purposeLabel = new JLabel("当前位置是:超市首页"); // 创建当前位置标签 - purposePanel.add(purposeLabel); // 将当前位置标签添加到当前位置面板 - - timePanel = new JPanel(); // 创建时间面板 - timePanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); // 设置布局为流式布局(右对齐) - timePanel.setBackground(Color.WHITE); // 设置背景颜色为白色 - timeLabel = new JLabel(DateUtil.dateToString(new Date(), null)); // 创建时间标签 - timePanel.add(timeLabel); // 将时间标签添加到时间面板 - - bottomPanel.add(purposePanel, "West"); // 将当前位置面板添加到底部面板的左侧 - bottomPanel.add(timePanel, "East"); // 将时间面板添加到底部面板的右侧 - Container container = getContentPane(); // 获取内容面板 - container.add(containerPanel, "Center"); // 将主界面容器添加到内容面板的中间 - container.add(bottomPanel, "South"); // 将底部面板添加到内容面板的底部 + leftPanel = new BGPanel(bgImage);/*皮肤*/ + leftPanel.setLayout(null); + + + /*菜单栏:用户登录信息*/ + System.out.println("用户头像地址=="+user.getImg()); + JLabel logoLabel = new JLabel(new ImageIcon(user.getImg()),JLabel.LEFT); + System.out.println(user.getImg()); + leftPanel.add(logoLabel); + logoLabel.setBounds(25, 30,150,150); + + /*账号名字*/ + String x = UsuperIcon(user.getUsuper());/*判断权限返回icon地址*/ + System.out.println("身份地址:"+x); + userMenuLabel1 = new JLabel("|"+user.getUsername()+"|"+user.getRname(),new ImageIcon(x),JLabel.LEFT); + userMenuLabel1.setFont(FontUtil.userFont); + userMenuLabel1.addMouseListener(this); + userMenuLabel1.setBounds(20, 170,180,32); + userMenuLabel1.setForeground(Color.white); + leftPanel.add(userMenuLabel1);/*添加用户选项到菜单栏*/ + + + + /*菜单栏:首页*/ + homeMenuLabel = new JLabel("新民首页",new ImageIcon("static\\icon\\home1.png"),JLabel.LEFT); + homeMenuLabel.setFont(FontUtil.menuFont); + homeMenuLabel.addMouseListener(this); + homeMenuLabel.setBounds(20, 250,150,32); + homeMenuLabel.setForeground(Color.white); + leftPanel.add(homeMenuLabel);/*添加用户选项到菜单栏*/ + + + + /*菜单栏:人员管理*/ + userMenuLabel = new JLabel("人员管理",new ImageIcon("static\\icon\\user1.png"),JLabel.LEFT); + userMenuLabel.setFont(FontUtil.menuFont); + userMenuLabel.addMouseListener(this); + userMenuLabel.setBounds(20, 300,150,32); + userMenuLabel.setForeground(Color.white); + leftPanel.add(userMenuLabel);/*添加用户选项到菜单栏*/ + + /*菜单栏:进货系统*/ + inMenuLabel = new JLabel("进货系统",new ImageIcon("static\\icon\\in1.png") ,JLabel.LEFT); + inMenuLabel.setFont(FontUtil.menuFont); + inMenuLabel.addMouseListener(this); + inMenuLabel.setBounds(20, 350,150,32); + inMenuLabel.setForeground(Color.white); + leftPanel.add(inMenuLabel); + + /*菜单栏:收银系统*/ + outMenuLabel = new JLabel("收银系统",new ImageIcon("static\\icon\\out1.png") ,JLabel.LEFT); + outMenuLabel.setFont(FontUtil.menuFont); + outMenuLabel.addMouseListener(this); + outMenuLabel.setBounds(20, 400,150,32); + outMenuLabel.setForeground(Color.white); + leftPanel.add(outMenuLabel); + + /*菜单栏:库存*/ + storageMenuLabel = new JLabel("商品库存",new ImageIcon("static\\icon\\storage1.png") ,JLabel.LEFT); + storageMenuLabel.setFont(FontUtil.menuFont); + storageMenuLabel.addMouseListener(this); + storageMenuLabel.setBounds(20, 450,150,32); + storageMenuLabel.setForeground(Color.white); + leftPanel.add(storageMenuLabel); + + /*菜单栏:供应商*/ + supplierMenuLabel = new JLabel("供应商",new ImageIcon("static\\icon\\supplier1.png") ,JLabel.LEFT); + supplierMenuLabel.setFont(FontUtil.menuFont); + supplierMenuLabel.addMouseListener(this); + supplierMenuLabel.setBounds(20, 500,150,32); + supplierMenuLabel.setForeground(Color.white); + leftPanel.add(supplierMenuLabel); + + /*菜单栏:商品目录*/ + catalogMenuLabel = new JLabel("商品目录",new ImageIcon("static\\icon\\catalog1.png") ,JLabel.LEFT); + catalogMenuLabel.setFont(FontUtil.menuFont); + catalogMenuLabel.addMouseListener(this); + catalogMenuLabel.setBounds(20,550,150,32); + catalogMenuLabel.setForeground(Color.white); + leftPanel.add(catalogMenuLabel); + + /*提醒进货确认模块*/ + remindMenuLabel = new JLabel("待确认进货:"+unConfirmmark,new ImageIcon("static\\icon\\remind1.png") ,JLabel.LEFT); + remindMenuLabel.setFont(FontUtil.remindFont); + remindMenuLabel.addMouseListener(this); + remindMenuLabel.setBounds(0,650,200,32); + remindMenuLabel.setForeground(Color.white); + leftPanel.add(remindMenuLabel); + + + rightPanelLayout = new CardLayout(); + + //0.超市首页展示 + JPanel homePanel = new HomeView(this); + + //1.用户管理界面:用户的列表 + JPanel userPanel = new UserView(this); + + //2.进货系统界面 + JPanel inPanel = new InView(this,user,vP,1); + + //3收银系统界面 + JPanel outPanel = new OutView(this,user); + + //4.库存系统界面 + JPanel storagePanel = new StorageView(this); + + //5.供应商界面 + JPanel supplierPanel = new SupplierView(this); + + //6商品目录界面 + JPanel ProdCatalogPanel = new ProdCatalogView(this); + + //7商品目录界面 + JPanel superPanel = new SuperView(this); + + //8进货信息提示 + JPanel inPanel2 = new InView(this,user,vP,0); + + /*添加界面并给索引*/ + rightPanel = new JPanel(rightPanelLayout); + rightPanel.add(homePanel, "0"); + rightPanel.add(userPanel, "1"); + rightPanel.add(inPanel, "2"); + rightPanel.add(outPanel, "3"); + rightPanel.add(storagePanel, "4"); + rightPanel.add(supplierPanel, "5"); + rightPanel.add(ProdCatalogPanel, "6"); + rightPanel.add(superPanel, "7"); + rightPanel.add(inPanel2, "8"); + + + containerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPanel,rightPanel); + containerPanel.setDividerLocation(180); + containerPanel.setDividerSize(0); + + bottomPanel = new JPanel();//默认的布局是流式布局 + + bottomPanel.setBackground(Color.WHITE); + bottomPanel.setLayout(new BorderLayout()); + + purposePanel = new JPanel(); + purposePanel.setLayout(new FlowLayout(FlowLayout.LEFT)); + purposePanel.setBackground(Color.WHITE); + purposeLabel = new JLabel("当前位置是:超市首页"); + purposePanel.add(purposeLabel); + + timePanel=new JPanel(); + timePanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); + timePanel.setBackground(Color.WHITE); + timeLabel = new JLabel(DateUtil.dateToString(new Date(),null)); + timePanel.add(timeLabel); + + bottomPanel.add(purposePanel,"West"); + bottomPanel.add(timePanel,"East"); + Container container = getContentPane(); + container.add(containerPanel,"Center"); + container.add(bottomPanel,"South"); } @Override public void actionPerformed(ActionEvent e) { - Object source = e.getSource(); // 获取事件来源 - timeLabel.setText(DateUtil.dateToString(new Date(), null)); // 更新时间标签 - if (source == skinMenuItem) /* 换肤 */ { - System.out.println("切换皮肤"); // 打印日志 - Random random = new Random(); // 创建随机数生成器 - skin = random.nextInt(10); // 随机生成皮肤编号 - this.dispose(); // 关闭当前窗口 - new MainView(user, skin, iconSkin); // 重新创建主界面 + Object source = e.getSource(); + timeLabel.setText(DateUtil.dateToString(new Date(),null)); + if(source==skinMenuItem)/*换肤*/{ + System.out.println("切换皮肤"); + Random random=new Random(); + skin=random.nextInt(10); + this.dispose(); + new MainView(user,skin,iconSkin); } + } - //左侧菜单栏点击事件处理方法。 + + /** + * cwf 2024/12/11 + * 修改不同权限用户的功能代码 + */ + @Override + /* 左侧菜单栏点击事件 */ public void mouseClicked(MouseEvent e) { Object source = e.getSource(); // 获取点击事件的来源 @@ -422,146 +477,175 @@ public class MainView extends BaseView implements ActionListener, MouseListener, refreshRemove(); // 刷新当前界面的位置信息 } - //刷新当前界面的位置信息。 - public void refreshRemove() { - purposePanel.removeAll(); // 移除当前位置面板的所有组件 - if (location == 0) { - purposeLabel = new JLabel("当前位置是:" + homeMenuLabel.getText()); // 设置当前位置为首页 - } else if (location == 1) { - purposeLabel = new JLabel("当前位置是:" + userMenuLabel.getText()); // 设置当前位置为人员管理 - } else if (location == 2) { - purposeLabel = new JLabel("当前位置是:" + inMenuLabel.getText()); // 设置当前位置为进货系统 - } else if (location == 3) { - purposeLabel = new JLabel("当前位置是:" + outMenuLabel.getText()); // 设置当前位置为收银系统 - } else if (location == 4) { - purposeLabel = new JLabel("当前位置是:" + storageMenuLabel.getText()); // 设置当前位置为库存系统 - } else if (location == 5) { - purposeLabel = new JLabel("当前位置是:" + supplierMenuLabel.getText()); // 设置当前位置为供应商 - } else { - purposeLabel = new JLabel("当前位置是:" + catalogMenuLabel.getText()); // 设置当前位置为商品目录 + //获取当前位置 + public void refreshRemove(){ + + purposePanel.removeAll(); + if(location==0){ + purposeLabel = new JLabel("当前位置是:"+homeMenuLabel.getText()); + + }else if(location==1){ + purposeLabel = new JLabel("当前位置是:"+userMenuLabel.getText()); + + }else if(location==2){ + purposeLabel = new JLabel("当前位置是:"+inMenuLabel.getText()); + + }else if(location==3){ + purposeLabel = new JLabel("当前位置是:"+outMenuLabel.getText()); + + }else if(location==4){ + purposeLabel = new JLabel("当前位置是:"+storageMenuLabel.getText()); + + }else if(location==5){ + purposeLabel = new JLabel("当前位置是:"+supplierMenuLabel.getText()); + + }else{ + purposeLabel = new JLabel("当前位置是:"+catalogMenuLabel.getText()); } - purposePanel.add(purposeLabel); // 将当前位置标签添加到当前位置面板 + purposePanel.add(purposeLabel); + } @Override public void mousePressed(MouseEvent e) { - // 鼠标按下事件,暂未实现 + // TODO Auto-generated method stub + } @Override public void mouseReleased(MouseEvent e) { - // 鼠标释放事件,暂未实现 + // TODO Auto-generated method stub + } - @Override - // 鼠标焦点时 + @Override/*鼠标焦点时*/ public void mouseEntered(MouseEvent e) { - Object source = e.getSource(); // 获取事件来源 - if (source == homeMenuLabel) { - homeMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色 - homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home2.png")); // 设置图标 + Object source = e.getSource(); + if(source==homeMenuLabel) { + homeMenuLabel.setForeground(new Color(18, 150, 219)); + homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home2.png")); } - if (source == userMenuLabel) { - userMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色 - userMenuLabel.setIcon(new ImageIcon("static\\icon\\user2.png")); // 设置图标 - } else if (source == inMenuLabel) { - inMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色 - inMenuLabel.setIcon(new ImageIcon("static\\icon\\in2.png")); // 设置图标 - } else if (source == outMenuLabel) { - outMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色 - outMenuLabel.setIcon(new ImageIcon("static\\icon\\out2.png")); // 设置图标 - } else if (source == storageMenuLabel) { - storageMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色 - storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage2.png")); // 设置图标 - } else if (source == supplierMenuLabel) { - supplierMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色 - supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier2.png")); // 设置图标 - } else if (source == catalogMenuLabel) { - catalogMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色 - catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog2.png")); // 设置图标 - } else if (source == userMenuLabel1) { - userMenuLabel1.setForeground(new Color(18, 150, 219)); // 设置字体颜色 + if(source==userMenuLabel) { + userMenuLabel.setForeground(new Color(18, 150, 219)); + userMenuLabel.setIcon(new ImageIcon("static\\icon\\user2.png")); + }else if(source==inMenuLabel) { + inMenuLabel.setForeground(new Color(18, 150, 219)); + inMenuLabel.setIcon(new ImageIcon("static\\icon\\in2.png")); + }else if(source==outMenuLabel) { + outMenuLabel.setForeground(new Color(18, 150, 219)); + outMenuLabel.setIcon(new ImageIcon("static\\icon\\out2.png")); + }else if(source==storageMenuLabel) { + storageMenuLabel.setForeground(new Color(18, 150, 219)); + storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage2.png")); + }else if(source==supplierMenuLabel) { + supplierMenuLabel.setForeground(new Color(18, 150, 219)); + supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier2.png")); + }else if(source==catalogMenuLabel) { + catalogMenuLabel.setForeground(new Color(18, 150, 219)); + catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog2.png")); + } else if(source==userMenuLabel1) { + userMenuLabel1.setForeground(new Color(18, 150, 219)); + } } @Override public void mouseExited(MouseEvent e) { - Object source = e.getSource(); // 获取事件来源 - if (source == homeMenuLabel) { - homeMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home1.png")); // 设置图标 - } else if (source == userMenuLabel) { - userMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - userMenuLabel.setIcon(new ImageIcon("static\\icon\\user1.png")); // 设置图标 - } else if (source == inMenuLabel) { - inMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - inMenuLabel.setIcon(new ImageIcon("static\\icon\\in1.png")); // 设置图标 - } else if (source == outMenuLabel) { - outMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - outMenuLabel.setIcon(new ImageIcon("static\\icon\\out1.png")); // 设置图标 - } else if (source == storageMenuLabel) { - storageMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage1.png")); // 设置图标 - } else if (source == supplierMenuLabel) { - supplierMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier1.png")); // 设置图标 - } else if (source == catalogMenuLabel) { - catalogMenuLabel.setForeground(Color.white); // 设置字体颜色为白色 - catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog1.png")); // 设置图标 - } else { - userMenuLabel1.setForeground(Color.white); // 设置字体颜色为白色 + Object source = e.getSource(); + if(source==homeMenuLabel) { + homeMenuLabel.setForeground(Color.white); + homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home1.png")); + } else if(source==userMenuLabel) { + userMenuLabel.setForeground(Color.white); + userMenuLabel.setIcon(new ImageIcon("static\\icon\\user1.png")); + }else if(source==inMenuLabel) { + inMenuLabel.setForeground(Color.white); + inMenuLabel.setIcon(new ImageIcon("static\\icon\\in1.png")); + }else if(source==outMenuLabel) { + outMenuLabel.setForeground(Color.white); + outMenuLabel.setIcon(new ImageIcon("static\\icon\\out1.png")); + }else if(source==storageMenuLabel) { + storageMenuLabel.setForeground(Color.white); + storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage1.png")); + }else if(source==supplierMenuLabel) { + supplierMenuLabel.setForeground(Color.white); + supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier1.png")); + }else if(source==catalogMenuLabel) { + catalogMenuLabel.setForeground(Color.white); + catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog1.png")); + } else { + userMenuLabel1.setForeground(Color.white); + } + } + @Override protected void initView() { - // 初始化界面,未实现 + // TODO Auto-generated method stub + } @Override public void windowOpened(WindowEvent e) { - // 窗口打开事件,未实现 + // TODO Auto-generated method stub + } @Override public void windowClosing(WindowEvent e) { - Object source = e.getSource(); // 获取事件来源 - if (source == this) { // 关闭窗口时检查进货系统和出货系统是否还有记录 - this.vP = InView.getVector(); // 获取进货缓存 - System.out.println("v的size=" + vP.size()); // 打印进货缓存大小 - bufferImpl = new BufferImpl(); // 创建缓存实现类 - if (vP.size() != 0 || bufferImpl.allOutBuffer().size() != 0) { // 如果购物车还有记录 - CloseDialog closeDialog = new CloseDialog(this, vP); // 创建关闭对话框 - closeDialog.setVisible(true); // 显示关闭对话框 - } else { - System.exit(0); // 退出程序 - } + // TODO Auto-generated method stub + Object source = e.getSource(); + if(source==this) {/*关闭窗口时检查进货系统和出货系统是否还有记录*/ + this.vP =InView.getVector(); + System.out.println("v的size="+vP.size()); + bufferImpl = new BufferImpl(); + if(vP.size()!=0||bufferImpl.allOutBuffer().size()!=0) {/*如果购物车还有记录*/ + CloseDialog closeDialog = new CloseDialog(this,vP); + closeDialog.setVisible(true); + }else + System.exit(0); + + } } @Override public void windowClosed(WindowEvent e) { - // 窗口关闭事件,未实现 + // TODO Auto-generated method stub + } @Override public void windowIconified(WindowEvent e) { - // 窗口最小化事件,未实现 + // TODO Auto-generated method stub + } @Override public void windowDeiconified(WindowEvent e) { - // 窗口恢复事件,未实现 + // TODO Auto-generated method stub + } @Override public void windowActivated(WindowEvent e) { - // 窗口激活事件,未实现 + // TODO Auto-generated method stub + } @Override public void windowDeactivated(WindowEvent e) { - // 窗口失活事件,未实现 + // TODO Auto-generated method stub + } -} \ No newline at end of file + + + + + + + +} diff --git a/Supermarket/src/com/lingnan/supermarket/view/Nimbus.java b/Supermarket/src/com/lingnan/supermarket/view/Nimbus.java index 906fae8..b7336fb 100644 --- a/Supermarket/src/com/lingnan/supermarket/view/Nimbus.java +++ b/Supermarket/src/com/lingnan/supermarket/view/Nimbus.java @@ -1,18 +1,14 @@ package com.lingnan.supermarket.view; - import javax.swing.UIManager; -// 用于设置Java Swing界面的Nimbus风格 public class Nimbus { - // 用于设置Java Swing界面呈现为Nimbus风格 + /*nimbus风格*/ public static void Nimbus() { try { - // 通过UIManager的setLookAndFeel方法来设置界面的外观风格为Nimbus风格 UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (Exception e) { - // 如果在设置外观风格的过程中出现异常,则打印异常堆栈信息 e.printStackTrace(); } } -} \ No newline at end of file +} diff --git a/Supermarket/src/com/lingnan/supermarket/view/StorageView.java b/Supermarket/src/com/lingnan/supermarket/view/StorageView.java index d58d876..8814bfb 100644 --- a/Supermarket/src/com/lingnan/supermarket/view/StorageView.java +++ b/Supermarket/src/com/lingnan/supermarket/view/StorageView.java @@ -230,7 +230,7 @@ public class StorageView extends JPanel implements ActionListener{ // 定义Stor } - - - + + + } \ No newline at end of file diff --git a/Supermarket/src/com/lingnan/supermarket/view/UserView.java b/Supermarket/src/com/lingnan/supermarket/view/UserView.java index 47edf1f..d8eec3c 100644 --- a/Supermarket/src/com/lingnan/supermarket/view/UserView.java +++ b/Supermarket/src/com/lingnan/supermarket/view/UserView.java @@ -38,7 +38,7 @@ public class UserView extends JPanel implements ActionListener { // 用于触发搜索操作的按钮 private JButton searchBtn; - // 用于存放操作按钮的面板 + // 用于存放操作按钮(添加、更新、删除等)的面板 private JPanel opePanel; // 用于触发添加用户操作的按钮 private JButton addBtn, updateBtn, deleteBtn; @@ -86,9 +86,9 @@ public class UserView extends JPanel implements ActionListener { searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建一个显示当前位置提示信息的标签,这里显示为"当前位置>人员管理" locationLabel = new JLabel("当前位置>人员管理"); - // 设置标签的字体为通过FontUtil类获取的特定字体 + // 设置标签的字体为通过FontUtil类获取的特定字体(这里假设FontUtil类用于统一管理字体相关设置) locationLabel.setFont(new FontUtil().userFont); - // 设置标签的前景色为特定的蓝色 + // 设置标签的前景色(文字颜色)为特定的蓝色(RGB值为18, 150, 219) locationLabel.setForeground(new Color(18, 150, 219)); // 创建一个显示"姓名"文字的标签,用于提示用户在旁边的文本框中输入姓名进行搜索 nameLabel = new JLabel("姓名"); @@ -97,7 +97,7 @@ public class UserView extends JPanel implements ActionListener { // 创建一个按钮,使用指定路径下的图标文件作为按钮的图标,用于触发搜索操作 searchBtn = new JButton(new ImageIcon("static\\icon\\search.png")); - // 创建一个新的面板opePanel,设置其布局为FlowLayout,且组件右对齐,用于存放操作按钮 + // 创建一个新的面板opePanel,设置其布局为FlowLayout,且组件右对齐,用于存放操作按钮(添加、更新、删除) opePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建一个按钮,使用指定路径下的图标文件("static\\icon\\add.png")作为按钮的图标,用于触发添加用户操作 addBtn = new JButton(new ImageIcon("static\\icon\\add.png")); @@ -106,7 +106,7 @@ public class UserView extends JPanel implements ActionListener { // 创建一个按钮,使用指定路径下的图标文件("static\\icon\\delete.png")作为按钮的图标,用于触发删除用户操作 deleteBtn = new JButton(new ImageIcon("static\\icon\\delete.png")); - // 为添加、更新、删除和搜索按钮添加点击事件监听器,将按钮的点击事件绑定到当前类的actionPerformed方法上,以便处理相应的操作逻辑 + // 为添加、更新、删除和搜索按钮添加点击事件监听器,将按钮的点击事件绑定到当前类(实现了ActionListener接口)的actionPerformed方法上,以便处理相应的操作逻辑 addBtn.addActionListener(this); updateBtn.addActionListener(this); deleteBtn.addActionListener(this); @@ -123,18 +123,18 @@ public class UserView extends JPanel implements ActionListener { searchPanel.add(nameSearchTF); searchPanel.add(searchBtn); - // 将搜索面板添加到toolBarPanel的西边区域,将操作按钮面板添加到toolBarPanel的东边区域 + // 将搜索面板添加到toolBarPanel的西边(左侧)区域,将操作按钮面板添加到toolBarPanel的东边(右侧)区域 toolBarPanel.add(searchPanel, "West"); toolBarPanel.add(opePanel, "East"); // 创建用户表格数据模型对象 userTableModel = new UserTableModel(); - // 调用数据模型的方法获取所有用户数据,用于初始化表格显示内容 + // 调用数据模型的方法获取所有用户数据,用于初始化表格显示内容(这里假设UserTableModel类中的all方法用于从数据库等数据源获取全部用户数据并填充到模型中) userTableModel.all(); // 创建一个JTable对象,使用前面创建的用户表格数据模型userTableModel来管理表格中的数据展示和交互 userTable = new JTable(userTableModel); - // 设置表格的字体为通过FontUtil类获取的适用于表格的特定字体 + // 设置表格的字体为通过FontUtil类获取的适用于表格的特定字体(假设FontUtil类中定义了相关字体常量) userTable.setFont(FontUtil.tableFont); // 设置表格每行的高度为50像素,调整表格的显示样式 userTable.setRowHeight(50); @@ -143,29 +143,29 @@ public class UserView extends JPanel implements ActionListener { // 创建一个新的面板bottomPanel,设置其布局为FlowLayout,且组件左对齐,用于存放记录数相关提示信息 bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - // 创建一个显示用户记录总数的标签,初始文本为"总共"加上通过用户表格数据模型获取的行数 + // 创建一个显示用户记录总数的标签,初始文本为"总共"加上通过用户表格数据模型获取的行数(假设UserTableModel类的getRowCount方法返回当前模型中的数据行数)以及"条"字 countInfoLabel = new JLabel("总共" + userTableModel.getRowCount() + "条"); // 将记录数标签添加到bottomPanel面板中 bottomPanel.add(countInfoLabel); - // 将顶部工具栏面板添加到当前面板的北部区域 + // 将顶部工具栏面板添加到当前面板(UserView)的北部(上方)区域 this.add(toolBarPanel, "North"); - // 将包含用户表格的滚动面板添加到当前面板的中部区域,使其在界面中间显示 + // 将包含用户表格的滚动面板添加到当前面板(UserView)的中部区域,使其在界面中间显示 this.add(tableScrollPane, "Center"); - // 将记录数面板添加到当前面板的南部区域 + // 将记录数面板添加到当前面板(UserView)的南部(下方)区域 this.add(bottomPanel, "South"); - // 设置当前面板可见,使其在界面上显示出来 + // 设置当前面板(UserView)可见,使其在界面上显示出来 setVisible(true); } // 处理按钮点击等用户交互动作的方法,实现了ActionListener接口中的方法 @Override public void actionPerformed(ActionEvent e) { - // 获取触发事件的源组件 + // 获取触发事件的源组件(即被点击的按钮等组件) Object source = e.getSource(); if (addBtn == source) { - // 如果点击的是添加按钮执行以下操作: + // 如果点击的是添加按钮,执行以下操作: // 创建一个用于添加用户信息的对话框 UserDialog userDialog = new UserDialog(jFrame); @@ -189,9 +189,9 @@ public class UserView extends JPanel implements ActionListener { // 弹出确认对话框,询问用户是否确定删除指定id的用户记录,提供"是"和"否"两个选项,返回用户选择的结果 int select = JOptionPane.showConfirmDialog(this, "是否删除id=" + id, "提示", JOptionPane.YES_NO_OPTION); if (select == JOptionPane.YES_OPTION) { - // 如果用户选择了是,执行以下操作: + // 如果用户选择了"是"(确认删除),执行以下操作: - // 调用用户服务接口的删除用户方法,传入要删除的用户id,尝试从数据库中删除对应的用户记录,并获取返回结果 + // 调用用户服务接口的删除用户方法,传入要删除的用户id,尝试从数据库中删除对应的用户记录,并获取返回结果(假设返回1表示删除成功,其他值表示失败) if (userService.deleteUser(id) == 1) { // 如果删除成功,弹出提示框显示"删除成功"的消息,提示框的图标为信息图标 JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE); @@ -203,7 +203,7 @@ public class UserView extends JPanel implements ActionListener { // 无论删除操作是否成功,都调用刷新用户数据的方法,更新界面上的用户数据显示,确保表格等显示内容与数据库中的最新数据一致 refreshUser(); } else { - // 如果点击的是搜索按钮,执行以下操作: + // 如果点击的是搜索按钮(即其他未明确匹配的按钮点击情况,这里目前代码逻辑中只存在搜索按钮可能进入此分支),执行以下操作: System.out.println("搜索"); // 调用刷新按姓名搜索结果的方法,根据用户在姓名搜索文本框中输入的内容进行数据刷新和表格显示更新 diff --git a/Supermarket/src/com/lingnan/supermarket/view/base/BaseView.java b/Supermarket/src/com/lingnan/supermarket/view/base/BaseView.java index 256c187..4bd41ff 100644 --- a/Supermarket/src/com/lingnan/supermarket/view/base/BaseView.java +++ b/Supermarket/src/com/lingnan/supermarket/view/base/BaseView.java @@ -2,92 +2,70 @@ package com.lingnan.supermarket.view.base; import java.awt.Toolkit; import java.util.Vector; + import javax.swing.JFrame; -// 导入相关的业务数据对象类,用于在视图相关操作中可能涉及的数据传递等情况 import com.lingnan.supermarket.dto.Production; import com.lingnan.supermarket.dto.User; -// 定义抽象类BaseView继承自JFrame,用于统一管理视图的一些通用属性和行为 public abstract class BaseView extends JFrame { - // 基本构造方法,用于创建一个具有指定初始宽度、高度和标题的窗口,并进行一些初始化设置 - public BaseView(int initWidth, int initHeigth, String title) { - // 设置窗口的标题 + public BaseView(int initWidth,int initHeigth,String title) { this.setTitle(title); - // 设置窗口的初始大小 - this.setSize(initWidth, initHeigth); - - // 通过Toolkit.getDefaultToolkit().getScreenSize()方法获取屏幕尺寸信息 + this.setSize(initWidth,initHeigth); int width = Toolkit.getDefaultToolkit().getScreenSize().width; int height = Toolkit.getDefaultToolkit().getScreenSize().height; - // 通过计算屏幕中心与窗口大小差值的一半来确定窗口左上角坐标 - this.setLocation((width - getWidth()) / 2, (height - getHeight()) / 2); + this.setLocation((width-getWidth())/2,(height-getHeight())/2); - // 调用抽象方法initView() initView(); - // 设置窗口为可见状态,使其显示出来 this.setVisible(true); - // 设置窗口关闭操作的默认行为,当关闭窗口时,整个应用程序将退出 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } - // 用于创建一个具有指定初始宽度、高度、标题以及关联用户信息和皮肤相关参数的窗口,并进行一些初始化设置 - public BaseView(int initWidth, int initHeigth, String title, User user, int skin) { - // 设置窗口的标题 + /*带对象参数的构造方法*/ + public BaseView(int initWidth,int initHeigth,String title,User user,int skin) { this.setTitle(title); - // 设置窗口的初始大小 - this.setSize(initWidth, initHeigth); - - // 获取屏幕的宽度和高度 + this.setSize(initWidth,initHeigth); int width = Toolkit.getDefaultToolkit().getScreenSize().width; int height = Toolkit.getDefaultToolkit().getScreenSize().height; - // 设置窗口在屏幕中的位置,使其居中显示 - this.setLocation((width - getWidth()) / 2, (height - getHeight()) / 2); + this.setLocation((width-getWidth())/2,(height-getHeight())/2); + + - // 设置窗口为可见状态,使其显示出来 this.setVisible(true); - // 设置窗口关闭操作的默认行为,这里设置为DO_NOTHING_ON_CLOSE,表示关闭窗口时不执行任何默认操作,通常由子类根据具体需求自定义关闭行为 this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); } - // 抽象方法,由具体的子类实现,用于进行特定视图的初始化操作,比如添加各种组件、设置布局等 + + protected abstract void initView(); + protected abstract void initView(User user,int skin); - // 抽象方法,由具体的子类实现,用于进行特定视图的初始化操作 - protected abstract void initView(User user, int skin); - // 根据传入的权限值判断对应的权限角色,并返回相应的角色名称字符串 + /*判断权限并返回字符*/ public String Usuper(int usuper) { - String x = null; - // 如果权限值为0,则对应的角色是管理员 - if (usuper == 0) - x = "管理员"; - // 如果权限值为1,则对应的角色是进货员 - else if (usuper == 1) - x = "进货员"; - // 如果权限值为2,则对应的角色是收银员 - else if (usuper == 2) - x = "收银员"; - // 如果权限值为3,则对应的角色是超级管理员 - else if (usuper == 3) - x = "超级管理员"; + String x=null; + if(usuper==0) + x="管理员"; + else if(usuper==1) + x="进货员"; + else if(usuper==2) + x="收银员"; return x; } - // 根据传入的权限值判断对应的权限角色,并返回相应角色对应的图标文件地址字符串 + /*判断权限并返回icon地址*/ public String UsuperIcon(int usuper) { - String x = null; - // 如果权限值为0,则返回管理员角色对应的图标文件地址 - if (usuper == 0) - x = "static\\icon\\admin.png"; - // 如果权限值为1,则返回进货员角色对应的图标文件地址 - else if (usuper == 1) - x = "static\\icon\\carrier.png"; - // 如果权限值为2,则返回收银员角色对应的图标文件地址 - else if (usuper == 2) - x = "static\\icon\\cashier.png"; + String x=null; + if(usuper==0) + x="static\\icon\\admin.png"; + else if(usuper==1) + x="static\\icon\\carrier.png"; + else if(usuper==2) + x="static\\icon\\cashier.png"; return x; } -} \ No newline at end of file + + +}