diff --git a/project/.classpath b/project/.classpath new file mode 100644 index 0000000..b08ba4f --- /dev/null +++ b/project/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/project/.project b/project/.project new file mode 100644 index 0000000..2caf12f --- /dev/null +++ b/project/.project @@ -0,0 +1,36 @@ + + + jiatingshouzhiguanlixitong + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/project/.settings/org.eclipse.core.resources.prefs b/project/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/project/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/project/.settings/org.eclipse.jdt.core.prefs b/project/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/project/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/project/bin/config.properties b/project/bin/config.properties new file mode 100644 index 0000000..9576e1f --- /dev/null +++ b/project/bin/config.properties @@ -0,0 +1,6 @@ +driver=com.mysql.cj.jdbc.Driver +url=jdbc:mysql://localhost:3306/aproject?userSSL=flase&serverTimezone=UTC +user=root +password=123456 +userSSL=flase +serverTimezone=UTC diff --git a/project/bin/dao/GuanliyuanDao.class b/project/bin/dao/GuanliyuanDao.class new file mode 100644 index 0000000..257bae6 Binary files /dev/null and b/project/bin/dao/GuanliyuanDao.class differ diff --git a/project/bin/dao/ShouruqingkuangDao.class b/project/bin/dao/ShouruqingkuangDao.class new file mode 100644 index 0000000..415c303 Binary files /dev/null and b/project/bin/dao/ShouruqingkuangDao.class differ diff --git a/project/bin/dao/ZhichuqingkuangDao.class b/project/bin/dao/ZhichuqingkuangDao.class new file mode 100644 index 0000000..f353138 Binary files /dev/null and b/project/bin/dao/ZhichuqingkuangDao.class differ diff --git a/project/bin/dao/ZhuhuDao.class b/project/bin/dao/ZhuhuDao.class new file mode 100644 index 0000000..dbf82d2 Binary files /dev/null and b/project/bin/dao/ZhuhuDao.class differ diff --git a/project/bin/dao/impl/GuanliyuanImpl.class b/project/bin/dao/impl/GuanliyuanImpl.class new file mode 100644 index 0000000..4d34efc Binary files /dev/null and b/project/bin/dao/impl/GuanliyuanImpl.class differ diff --git a/project/bin/dao/impl/JDBCUtil.class b/project/bin/dao/impl/JDBCUtil.class new file mode 100644 index 0000000..f4ec125 Binary files /dev/null and b/project/bin/dao/impl/JDBCUtil.class differ diff --git a/project/bin/dao/impl/ShouruqingkuangImpl.class b/project/bin/dao/impl/ShouruqingkuangImpl.class new file mode 100644 index 0000000..872a46a Binary files /dev/null and b/project/bin/dao/impl/ShouruqingkuangImpl.class differ diff --git a/project/bin/dao/impl/ZhichuqingkuangImpl.class b/project/bin/dao/impl/ZhichuqingkuangImpl.class new file mode 100644 index 0000000..0f50b3f Binary files /dev/null and b/project/bin/dao/impl/ZhichuqingkuangImpl.class differ diff --git a/project/bin/dao/impl/ZhuhuImpl.class b/project/bin/dao/impl/ZhuhuImpl.class new file mode 100644 index 0000000..3ff598e Binary files /dev/null and b/project/bin/dao/impl/ZhuhuImpl.class differ diff --git a/project/bin/entity/Guanliyuan.class b/project/bin/entity/Guanliyuan.class new file mode 100644 index 0000000..e9678cc Binary files /dev/null and b/project/bin/entity/Guanliyuan.class differ diff --git a/project/bin/entity/Shouruqingkuang.class b/project/bin/entity/Shouruqingkuang.class new file mode 100644 index 0000000..67690f2 Binary files /dev/null and b/project/bin/entity/Shouruqingkuang.class differ diff --git a/project/bin/entity/Zhichuqingkuang.class b/project/bin/entity/Zhichuqingkuang.class new file mode 100644 index 0000000..1b8576e Binary files /dev/null and b/project/bin/entity/Zhichuqingkuang.class differ diff --git a/project/bin/entity/Zhuhu.class b/project/bin/entity/Zhuhu.class new file mode 100644 index 0000000..2a9721a Binary files /dev/null and b/project/bin/entity/Zhuhu.class differ diff --git a/project/bin/view/BackgroundPanel.class b/project/bin/view/BackgroundPanel.class new file mode 100644 index 0000000..601a77f Binary files /dev/null and b/project/bin/view/BackgroundPanel.class differ diff --git a/project/bin/view/GuanliyuanAddUI$1.class b/project/bin/view/GuanliyuanAddUI$1.class new file mode 100644 index 0000000..2823296 Binary files /dev/null and b/project/bin/view/GuanliyuanAddUI$1.class differ diff --git a/project/bin/view/GuanliyuanAddUI$2.class b/project/bin/view/GuanliyuanAddUI$2.class new file mode 100644 index 0000000..0591355 Binary files /dev/null and b/project/bin/view/GuanliyuanAddUI$2.class differ diff --git a/project/bin/view/GuanliyuanAddUI.class b/project/bin/view/GuanliyuanAddUI.class new file mode 100644 index 0000000..f10a4d4 Binary files /dev/null and b/project/bin/view/GuanliyuanAddUI.class differ diff --git a/project/bin/view/GuanliyuanManageUI.class b/project/bin/view/GuanliyuanManageUI.class new file mode 100644 index 0000000..9b8a6a3 Binary files /dev/null and b/project/bin/view/GuanliyuanManageUI.class differ diff --git a/project/bin/view/GuanliyuanManageUIListPanel$1.class b/project/bin/view/GuanliyuanManageUIListPanel$1.class new file mode 100644 index 0000000..684e789 Binary files /dev/null and b/project/bin/view/GuanliyuanManageUIListPanel$1.class differ diff --git a/project/bin/view/GuanliyuanManageUIListPanel$2.class b/project/bin/view/GuanliyuanManageUIListPanel$2.class new file mode 100644 index 0000000..9a6cc86 Binary files /dev/null and b/project/bin/view/GuanliyuanManageUIListPanel$2.class differ diff --git a/project/bin/view/GuanliyuanManageUIListPanel$3.class b/project/bin/view/GuanliyuanManageUIListPanel$3.class new file mode 100644 index 0000000..2b9eea3 Binary files /dev/null and b/project/bin/view/GuanliyuanManageUIListPanel$3.class differ diff --git a/project/bin/view/GuanliyuanManageUIListPanel$4.class b/project/bin/view/GuanliyuanManageUIListPanel$4.class new file mode 100644 index 0000000..f29f16f Binary files /dev/null and b/project/bin/view/GuanliyuanManageUIListPanel$4.class differ diff --git a/project/bin/view/GuanliyuanManageUIListPanel.class b/project/bin/view/GuanliyuanManageUIListPanel.class new file mode 100644 index 0000000..f40e4c9 Binary files /dev/null and b/project/bin/view/GuanliyuanManageUIListPanel.class differ diff --git a/project/bin/view/GuanliyuanUpdateUI$1.class b/project/bin/view/GuanliyuanUpdateUI$1.class new file mode 100644 index 0000000..2379dfe Binary files /dev/null and b/project/bin/view/GuanliyuanUpdateUI$1.class differ diff --git a/project/bin/view/GuanliyuanUpdateUI$2.class b/project/bin/view/GuanliyuanUpdateUI$2.class new file mode 100644 index 0000000..82b01cf Binary files /dev/null and b/project/bin/view/GuanliyuanUpdateUI$2.class differ diff --git a/project/bin/view/GuanliyuanUpdateUI.class b/project/bin/view/GuanliyuanUpdateUI.class new file mode 100644 index 0000000..5966e14 Binary files /dev/null and b/project/bin/view/GuanliyuanUpdateUI.class differ diff --git a/project/bin/view/LoginUI$1.class b/project/bin/view/LoginUI$1.class new file mode 100644 index 0000000..4285cc6 Binary files /dev/null and b/project/bin/view/LoginUI$1.class differ diff --git a/project/bin/view/LoginUI$2.class b/project/bin/view/LoginUI$2.class new file mode 100644 index 0000000..aae0897 Binary files /dev/null and b/project/bin/view/LoginUI$2.class differ diff --git a/project/bin/view/LoginUI$3.class b/project/bin/view/LoginUI$3.class new file mode 100644 index 0000000..08beabc Binary files /dev/null and b/project/bin/view/LoginUI$3.class differ diff --git a/project/bin/view/LoginUI.class b/project/bin/view/LoginUI.class new file mode 100644 index 0000000..21bd157 Binary files /dev/null and b/project/bin/view/LoginUI.class differ diff --git a/project/bin/view/MainUI$1.class b/project/bin/view/MainUI$1.class new file mode 100644 index 0000000..a30b345 Binary files /dev/null and b/project/bin/view/MainUI$1.class differ diff --git a/project/bin/view/MainUI$2.class b/project/bin/view/MainUI$2.class new file mode 100644 index 0000000..62f4e2a Binary files /dev/null and b/project/bin/view/MainUI$2.class differ diff --git a/project/bin/view/MainUI$3.class b/project/bin/view/MainUI$3.class new file mode 100644 index 0000000..bbeda1b Binary files /dev/null and b/project/bin/view/MainUI$3.class differ diff --git a/project/bin/view/MainUI$4.class b/project/bin/view/MainUI$4.class new file mode 100644 index 0000000..2cb8bdc Binary files /dev/null and b/project/bin/view/MainUI$4.class differ diff --git a/project/bin/view/MainUI$5.class b/project/bin/view/MainUI$5.class new file mode 100644 index 0000000..3344bc0 Binary files /dev/null and b/project/bin/view/MainUI$5.class differ diff --git a/project/bin/view/MainUI.class b/project/bin/view/MainUI.class new file mode 100644 index 0000000..d7596d8 Binary files /dev/null and b/project/bin/view/MainUI.class differ diff --git a/project/bin/view/RegistUI$1.class b/project/bin/view/RegistUI$1.class new file mode 100644 index 0000000..4f778e3 Binary files /dev/null and b/project/bin/view/RegistUI$1.class differ diff --git a/project/bin/view/RegistUI$2.class b/project/bin/view/RegistUI$2.class new file mode 100644 index 0000000..fca8b6c Binary files /dev/null and b/project/bin/view/RegistUI$2.class differ diff --git a/project/bin/view/RegistUI.class b/project/bin/view/RegistUI.class new file mode 100644 index 0000000..35905a1 Binary files /dev/null and b/project/bin/view/RegistUI.class differ diff --git a/project/bin/view/ShouruqingkuangAddUI$1.class b/project/bin/view/ShouruqingkuangAddUI$1.class new file mode 100644 index 0000000..826d931 Binary files /dev/null and b/project/bin/view/ShouruqingkuangAddUI$1.class differ diff --git a/project/bin/view/ShouruqingkuangAddUI$2.class b/project/bin/view/ShouruqingkuangAddUI$2.class new file mode 100644 index 0000000..aa64245 Binary files /dev/null and b/project/bin/view/ShouruqingkuangAddUI$2.class differ diff --git a/project/bin/view/ShouruqingkuangAddUI.class b/project/bin/view/ShouruqingkuangAddUI.class new file mode 100644 index 0000000..e45af9c Binary files /dev/null and b/project/bin/view/ShouruqingkuangAddUI.class differ diff --git a/project/bin/view/ShouruqingkuangManageUI.class b/project/bin/view/ShouruqingkuangManageUI.class new file mode 100644 index 0000000..3395c91 Binary files /dev/null and b/project/bin/view/ShouruqingkuangManageUI.class differ diff --git a/project/bin/view/ShouruqingkuangManageUIListPanel$1.class b/project/bin/view/ShouruqingkuangManageUIListPanel$1.class new file mode 100644 index 0000000..d9e37e0 Binary files /dev/null and b/project/bin/view/ShouruqingkuangManageUIListPanel$1.class differ diff --git a/project/bin/view/ShouruqingkuangManageUIListPanel$2.class b/project/bin/view/ShouruqingkuangManageUIListPanel$2.class new file mode 100644 index 0000000..549831d Binary files /dev/null and b/project/bin/view/ShouruqingkuangManageUIListPanel$2.class differ diff --git a/project/bin/view/ShouruqingkuangManageUIListPanel$3.class b/project/bin/view/ShouruqingkuangManageUIListPanel$3.class new file mode 100644 index 0000000..9fcc6d9 Binary files /dev/null and b/project/bin/view/ShouruqingkuangManageUIListPanel$3.class differ diff --git a/project/bin/view/ShouruqingkuangManageUIListPanel$4.class b/project/bin/view/ShouruqingkuangManageUIListPanel$4.class new file mode 100644 index 0000000..6c77a56 Binary files /dev/null and b/project/bin/view/ShouruqingkuangManageUIListPanel$4.class differ diff --git a/project/bin/view/ShouruqingkuangManageUIListPanel.class b/project/bin/view/ShouruqingkuangManageUIListPanel.class new file mode 100644 index 0000000..ecd0b94 Binary files /dev/null and b/project/bin/view/ShouruqingkuangManageUIListPanel.class differ diff --git a/project/bin/view/ShouruqingkuangUpdateUI$1.class b/project/bin/view/ShouruqingkuangUpdateUI$1.class new file mode 100644 index 0000000..242a02b Binary files /dev/null and b/project/bin/view/ShouruqingkuangUpdateUI$1.class differ diff --git a/project/bin/view/ShouruqingkuangUpdateUI$2.class b/project/bin/view/ShouruqingkuangUpdateUI$2.class new file mode 100644 index 0000000..2b55d67 Binary files /dev/null and b/project/bin/view/ShouruqingkuangUpdateUI$2.class differ diff --git a/project/bin/view/ShouruqingkuangUpdateUI.class b/project/bin/view/ShouruqingkuangUpdateUI.class new file mode 100644 index 0000000..9797e3b Binary files /dev/null and b/project/bin/view/ShouruqingkuangUpdateUI.class differ diff --git a/project/bin/view/Tableinter.class b/project/bin/view/Tableinter.class new file mode 100644 index 0000000..614e0a4 Binary files /dev/null and b/project/bin/view/Tableinter.class differ diff --git a/project/bin/view/ZhichuqingkuangAddUI$1.class b/project/bin/view/ZhichuqingkuangAddUI$1.class new file mode 100644 index 0000000..085beb0 Binary files /dev/null and b/project/bin/view/ZhichuqingkuangAddUI$1.class differ diff --git a/project/bin/view/ZhichuqingkuangAddUI$2.class b/project/bin/view/ZhichuqingkuangAddUI$2.class new file mode 100644 index 0000000..82946a4 Binary files /dev/null and b/project/bin/view/ZhichuqingkuangAddUI$2.class differ diff --git a/project/bin/view/ZhichuqingkuangAddUI.class b/project/bin/view/ZhichuqingkuangAddUI.class new file mode 100644 index 0000000..b9de9a1 Binary files /dev/null and b/project/bin/view/ZhichuqingkuangAddUI.class differ diff --git a/project/bin/view/ZhichuqingkuangManageUI.class b/project/bin/view/ZhichuqingkuangManageUI.class new file mode 100644 index 0000000..07bfba5 Binary files /dev/null and b/project/bin/view/ZhichuqingkuangManageUI.class differ diff --git a/project/bin/view/ZhichuqingkuangManageUIListPanel$1.class b/project/bin/view/ZhichuqingkuangManageUIListPanel$1.class new file mode 100644 index 0000000..282266b Binary files /dev/null and b/project/bin/view/ZhichuqingkuangManageUIListPanel$1.class differ diff --git a/project/bin/view/ZhichuqingkuangManageUIListPanel$2.class b/project/bin/view/ZhichuqingkuangManageUIListPanel$2.class new file mode 100644 index 0000000..64cefab Binary files /dev/null and b/project/bin/view/ZhichuqingkuangManageUIListPanel$2.class differ diff --git a/project/bin/view/ZhichuqingkuangManageUIListPanel$3.class b/project/bin/view/ZhichuqingkuangManageUIListPanel$3.class new file mode 100644 index 0000000..1d108d8 Binary files /dev/null and b/project/bin/view/ZhichuqingkuangManageUIListPanel$3.class differ diff --git a/project/bin/view/ZhichuqingkuangManageUIListPanel$4.class b/project/bin/view/ZhichuqingkuangManageUIListPanel$4.class new file mode 100644 index 0000000..ebab0ae Binary files /dev/null and b/project/bin/view/ZhichuqingkuangManageUIListPanel$4.class differ diff --git a/project/bin/view/ZhichuqingkuangManageUIListPanel.class b/project/bin/view/ZhichuqingkuangManageUIListPanel.class new file mode 100644 index 0000000..aa28ade Binary files /dev/null and b/project/bin/view/ZhichuqingkuangManageUIListPanel.class differ diff --git a/project/bin/view/ZhichuqingkuangUpdateUI$1.class b/project/bin/view/ZhichuqingkuangUpdateUI$1.class new file mode 100644 index 0000000..0f4e74a Binary files /dev/null and b/project/bin/view/ZhichuqingkuangUpdateUI$1.class differ diff --git a/project/bin/view/ZhichuqingkuangUpdateUI$2.class b/project/bin/view/ZhichuqingkuangUpdateUI$2.class new file mode 100644 index 0000000..14b910f Binary files /dev/null and b/project/bin/view/ZhichuqingkuangUpdateUI$2.class differ diff --git a/project/bin/view/ZhichuqingkuangUpdateUI.class b/project/bin/view/ZhichuqingkuangUpdateUI.class new file mode 100644 index 0000000..cc43284 Binary files /dev/null and b/project/bin/view/ZhichuqingkuangUpdateUI.class differ diff --git a/project/bin/view/ZhuhuAddUI$1.class b/project/bin/view/ZhuhuAddUI$1.class new file mode 100644 index 0000000..16c4528 Binary files /dev/null and b/project/bin/view/ZhuhuAddUI$1.class differ diff --git a/project/bin/view/ZhuhuAddUI$2.class b/project/bin/view/ZhuhuAddUI$2.class new file mode 100644 index 0000000..e8e5a82 Binary files /dev/null and b/project/bin/view/ZhuhuAddUI$2.class differ diff --git a/project/bin/view/ZhuhuAddUI.class b/project/bin/view/ZhuhuAddUI.class new file mode 100644 index 0000000..6d20e69 Binary files /dev/null and b/project/bin/view/ZhuhuAddUI.class differ diff --git a/project/bin/view/ZhuhuManageUI.class b/project/bin/view/ZhuhuManageUI.class new file mode 100644 index 0000000..7708110 Binary files /dev/null and b/project/bin/view/ZhuhuManageUI.class differ diff --git a/project/bin/view/ZhuhuManageUIListPanel$1.class b/project/bin/view/ZhuhuManageUIListPanel$1.class new file mode 100644 index 0000000..009f44a Binary files /dev/null and b/project/bin/view/ZhuhuManageUIListPanel$1.class differ diff --git a/project/bin/view/ZhuhuManageUIListPanel$2.class b/project/bin/view/ZhuhuManageUIListPanel$2.class new file mode 100644 index 0000000..b2dde12 Binary files /dev/null and b/project/bin/view/ZhuhuManageUIListPanel$2.class differ diff --git a/project/bin/view/ZhuhuManageUIListPanel$3.class b/project/bin/view/ZhuhuManageUIListPanel$3.class new file mode 100644 index 0000000..5cce1d1 Binary files /dev/null and b/project/bin/view/ZhuhuManageUIListPanel$3.class differ diff --git a/project/bin/view/ZhuhuManageUIListPanel$4.class b/project/bin/view/ZhuhuManageUIListPanel$4.class new file mode 100644 index 0000000..fff7932 Binary files /dev/null and b/project/bin/view/ZhuhuManageUIListPanel$4.class differ diff --git a/project/bin/view/ZhuhuManageUIListPanel.class b/project/bin/view/ZhuhuManageUIListPanel.class new file mode 100644 index 0000000..cab786a Binary files /dev/null and b/project/bin/view/ZhuhuManageUIListPanel.class differ diff --git a/project/bin/view/ZhuhuUpdateUI$1.class b/project/bin/view/ZhuhuUpdateUI$1.class new file mode 100644 index 0000000..49e34ca Binary files /dev/null and b/project/bin/view/ZhuhuUpdateUI$1.class differ diff --git a/project/bin/view/ZhuhuUpdateUI$2.class b/project/bin/view/ZhuhuUpdateUI$2.class new file mode 100644 index 0000000..c1ce834 Binary files /dev/null and b/project/bin/view/ZhuhuUpdateUI$2.class differ diff --git a/project/bin/view/ZhuhuUpdateUI.class b/project/bin/view/ZhuhuUpdateUI.class new file mode 100644 index 0000000..58696f9 Binary files /dev/null and b/project/bin/view/ZhuhuUpdateUI.class differ diff --git a/project/lib/datepicker.jar b/project/lib/datepicker.jar new file mode 100644 index 0000000..7c4aa2a Binary files /dev/null and b/project/lib/datepicker.jar differ diff --git a/project/lib/mysql-connector-j-8.0.33.jar b/project/lib/mysql-connector-j-8.0.33.jar new file mode 100644 index 0000000..3f741f5 Binary files /dev/null and b/project/lib/mysql-connector-j-8.0.33.jar differ diff --git a/project/lib/mysql-connector-java-5.0.8-bin.jar b/project/lib/mysql-connector-java-5.0.8-bin.jar new file mode 100644 index 0000000..0170c3e Binary files /dev/null and b/project/lib/mysql-connector-java-5.0.8-bin.jar differ diff --git a/project/src/config.properties b/project/src/config.properties new file mode 100644 index 0000000..9576e1f --- /dev/null +++ b/project/src/config.properties @@ -0,0 +1,6 @@ +driver=com.mysql.cj.jdbc.Driver +url=jdbc:mysql://localhost:3306/aproject?userSSL=flase&serverTimezone=UTC +user=root +password=123456 +userSSL=flase +serverTimezone=UTC diff --git a/project/src/dao/GuanliyuanDao.java b/project/src/dao/GuanliyuanDao.java new file mode 100644 index 0000000..4f866ec --- /dev/null +++ b/project/src/dao/GuanliyuanDao.java @@ -0,0 +1,14 @@ +package dao; + +import java.util.List; + +import entity.Guanliyuan; + +public interface GuanliyuanDao { + Guanliyuan findById(String id); + Guanliyuan findByUsername(String yonghuming); + List findAll(); + int modify(Guanliyuan guanliyuan); + int create(Guanliyuan guanliyuan); + int remove(Guanliyuan guanliyuan); +} diff --git a/project/src/dao/ShouruqingkuangDao.java b/project/src/dao/ShouruqingkuangDao.java new file mode 100644 index 0000000..2ec9e2a --- /dev/null +++ b/project/src/dao/ShouruqingkuangDao.java @@ -0,0 +1,13 @@ +package dao; + +import java.util.List; + +import entity.Shouruqingkuang; + +public interface ShouruqingkuangDao { + Shouruqingkuang findById(String id); + List findAll(); + int modify(Shouruqingkuang shouruqingkuang); + int create(Shouruqingkuang shouruqingkuang); + int remove(Shouruqingkuang shouruqingkuang); +} diff --git a/project/src/dao/ZhichuqingkuangDao.java b/project/src/dao/ZhichuqingkuangDao.java new file mode 100644 index 0000000..165ea19 --- /dev/null +++ b/project/src/dao/ZhichuqingkuangDao.java @@ -0,0 +1,13 @@ +package dao; + +import java.util.List; + +import entity.Zhichuqingkuang; + +public interface ZhichuqingkuangDao { + Zhichuqingkuang findById(String id); + List findAll(); + int modify(Zhichuqingkuang zhichuqingkuang); + int create(Zhichuqingkuang zhichuqingkuang); + int remove(Zhichuqingkuang zhichuqingkuang); +} diff --git a/project/src/dao/ZhuhuDao.java b/project/src/dao/ZhuhuDao.java new file mode 100644 index 0000000..47720f4 --- /dev/null +++ b/project/src/dao/ZhuhuDao.java @@ -0,0 +1,13 @@ +package dao; + +import java.util.List; + +import entity.Zhuhu; + +public interface ZhuhuDao { + Zhuhu findById(String id); + List findAll(); + int modify(Zhuhu zhushu); + int create(Zhuhu zhushu); + int remove(Zhuhu zhushu); +} diff --git a/project/src/dao/impl/GuanliyuanImpl.java b/project/src/dao/impl/GuanliyuanImpl.java new file mode 100644 index 0000000..58f7ed4 --- /dev/null +++ b/project/src/dao/impl/GuanliyuanImpl.java @@ -0,0 +1,165 @@ + +package dao.impl; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import dao.GuanliyuanDao; +import entity.Guanliyuan; + +public class GuanliyuanImpl implements GuanliyuanDao{ + + public Guanliyuan findById(String id) { + Guanliyuan acyc=new Guanliyuan(); + try { + + Connection conn = JDBCUtil.getConnection(); + String sql = "select*from guanliyuan where id = ?"; + PreparedStatement prestm=conn.prepareStatement(sql); + prestm.setInt(1, Integer.valueOf(id)); + ResultSet rs=prestm.executeQuery(); + + while(rs.next()) { + Guanliyuan guanliyuan=new Guanliyuan(); + guanliyuan.setId(rs.getInt("id")); + guanliyuan.setYonghumingyc(rs.getString("yonghumingyc")); + guanliyuan.setMimayc(rs.getString("mimayc")); + guanliyuan.setJiaoseyc(rs.getString("jiaoseyc")); + acyc=guanliyuan; + } + rs.close(); + prestm.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return acyc; + } + + + @Override + public List findAll() { + ArrayList zhushus=new ArrayList(); + try { + Connection conn = JDBCUtil.getConnection(); + + String sqlyc ="select *from guanliyuan"; + Statement stsyc =conn.createStatement(); + ResultSet rsyc=stsyc.executeQuery(sqlyc); + + while(rsyc.next()) { + Guanliyuan guanliyuan=new Guanliyuan(); + guanliyuan.setId(rsyc.getInt("id")); + guanliyuan.setYonghumingyc(rsyc.getString("yonghumingyc")); + guanliyuan.setMimayc(rsyc.getString("mimayc")); + guanliyuan.setJiaoseyc(rsyc.getString("jiaoseyc")); + zhushus.add(guanliyuan); + } + rsyc.close(); + stsyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + // TODO 自动生成的方法存根 + return zhushus; + } + + + @Override + public int modify(Guanliyuan guanliyuan) { + try { + Connection conn = JDBCUtil.getConnection(); + + String sqlyc ="update guanliyuan set yonghumingyc=?,mimayc=?,jiaoseyc=? where id=?"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setString(1,guanliyuan.getYonghumingyc()); + prestmyc.setString(2,guanliyuan.getMimayc()); + prestmyc.setString(3,guanliyuan.getJiaoseyc()); + prestmyc.setInt(4,guanliyuan.getId()); + prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return 0; + } + + + @Override + public int create(Guanliyuan guanliyuan) { + try { + Connection conn = JDBCUtil.getConnection(); + String sqlyc ="Insert into guanliyuan (yonghumingyc,mimayc,jiaoseyc) values(?,?,?)"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setString(1,guanliyuan.getYonghumingyc()); + prestmyc.setString(2,guanliyuan.getMimayc()); + prestmyc.setString(3,guanliyuan.getJiaoseyc()); + prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return 0; + } + + + @Override + public int remove(Guanliyuan guanliyuan) { + int flagyc=0; + try { + Connection conn = JDBCUtil.getConnection(); + String sqlyc ="delete from guanliyuan where id=?"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setInt(1, guanliyuan.getId()); + flagyc = prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return flagyc; + } + + + @Override + public Guanliyuan findByUsername(String yonghuming) { + Guanliyuan acyc=new Guanliyuan(); + try { + + Connection conn = JDBCUtil.getConnection(); + String sql = "select*from guanliyuan where yonghumingyc = ?"; + PreparedStatement prestm=conn.prepareStatement(sql); + prestm.setString(1, yonghuming); + ResultSet rs=prestm.executeQuery(); + + while(rs.next()) { + Guanliyuan guanliyuan=new Guanliyuan(); + guanliyuan.setId(rs.getInt("id")); + guanliyuan.setYonghumingyc(rs.getString("yonghumingyc")); + guanliyuan.setMimayc(rs.getString("mimayc")); + guanliyuan.setJiaoseyc(rs.getString("jiaoseyc")); + acyc=guanliyuan; + } + rs.close(); + prestm.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return acyc; + } + +} diff --git a/project/src/dao/impl/JDBCUtil.java b/project/src/dao/impl/JDBCUtil.java new file mode 100644 index 0000000..81f2e8d --- /dev/null +++ b/project/src/dao/impl/JDBCUtil.java @@ -0,0 +1,29 @@ +package dao.impl; + + +import java.io.InputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +public class JDBCUtil { + static String url; + static Properties info=new Properties(); + static { + InputStream input=JDBCUtil.class.getClassLoader().getResourceAsStream("config.properties"); + try { + info.load(input); + url=info.getProperty("url"); + Class.forName(info.getProperty("driver")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + public static Connection getConnection() throws SQLException { + Connection conn=DriverManager.getConnection(url,info); + return conn; +} + +} \ No newline at end of file diff --git a/project/src/dao/impl/ShouruqingkuangImpl.java b/project/src/dao/impl/ShouruqingkuangImpl.java new file mode 100644 index 0000000..c93cb68 --- /dev/null +++ b/project/src/dao/impl/ShouruqingkuangImpl.java @@ -0,0 +1,138 @@ +package dao.impl; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import dao.ShouruqingkuangDao; +import entity.Shouruqingkuang; + +public class ShouruqingkuangImpl implements ShouruqingkuangDao{ + + public Shouruqingkuang findById(String id) { + Shouruqingkuang acyc=new Shouruqingkuang(); + try { + + Connection conn = JDBCUtil.getConnection(); + String sql = "select*from shouruqingkuang where id = ?"; + PreparedStatement prestm=conn.prepareStatement(sql); + prestm.setInt(1, Integer.valueOf(id)); + ResultSet rs=prestm.executeQuery(); + + while(rs.next()) { + Shouruqingkuang shouruqingkuang=new Shouruqingkuang(); + shouruqingkuang.setId(rs.getInt("id")); + shouruqingkuang.setFashengfeiyongym(rs.getString("fashengfeiyongym")); + shouruqingkuang.setFashengriqiym(rs.getString("fashengriqiym")); + shouruqingkuang.setHuzhuym(rs.getString("huzhuym")); + shouruqingkuang.setMingxiym(rs.getString("mingxiym")); + acyc=shouruqingkuang; + } + rs.close(); + prestm.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return acyc; + } + + + @Override + public List findAll() { + ArrayList zhushus=new ArrayList(); + try { + Connection conn = JDBCUtil.getConnection(); + + String sqlyc ="select *from shouruqingkuang"; + Statement stsyc =conn.createStatement(); + ResultSet rs=stsyc.executeQuery(sqlyc); + + while(rs.next()) { + Shouruqingkuang shouruqingkuang=new Shouruqingkuang(); + shouruqingkuang.setId(rs.getInt("id")); + shouruqingkuang.setFashengfeiyongym(rs.getString("fashengfeiyongym")); + shouruqingkuang.setFashengriqiym(rs.getString("fashengriqiym")); + shouruqingkuang.setHuzhuym(rs.getString("huzhuym")); + shouruqingkuang.setMingxiym(rs.getString("mingxiym")); + zhushus.add(shouruqingkuang); + } + rs.close(); + stsyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + // TODO 自动生成的方法存根 + return zhushus; + } + + + @Override + public int modify(Shouruqingkuang shouruqingkuang) { + try { + Connection conn = JDBCUtil.getConnection(); + + String sqlyc ="update shouruqingkuang set fashengfeiyongym=?,fashengriqiym=?,huzhuym=?,mingxiym=? where id=?"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setString(1,shouruqingkuang.getFashengfeiyongym()); + prestmyc.setString(2,shouruqingkuang.getFashengriqiym()); + prestmyc.setString(3,shouruqingkuang.getHuzhuym()); + prestmyc.setString(4,shouruqingkuang.getMingxiym()); + prestmyc.setInt(5,shouruqingkuang.getId()); + prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return 0; + } + + + @Override + public int create(Shouruqingkuang shouruqingkuang) { + try { + Connection conn = JDBCUtil.getConnection(); + String sqlyc ="Insert into shouruqingkuang (fashengfeiyongym,fashengriqiym,huzhuym,mingxiym) values(?,?,?,?)"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setString(1,shouruqingkuang.getFashengfeiyongym()); + prestmyc.setString(2,shouruqingkuang.getFashengriqiym()); + prestmyc.setString(3,shouruqingkuang.getHuzhuym()); + prestmyc.setString(4,shouruqingkuang.getMingxiym()); + prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return 0; + } + + + @Override + public int remove(Shouruqingkuang shouruqingkuang) { + int flagyc=0; + try { + Connection conn = JDBCUtil.getConnection(); + String sqlyc ="delete from shouruqingkuang where id=?"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setInt(1, shouruqingkuang.getId()); + flagyc = prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return flagyc; + } + +} diff --git a/project/src/dao/impl/ZhichuqingkuangImpl.java b/project/src/dao/impl/ZhichuqingkuangImpl.java new file mode 100644 index 0000000..9324dbb --- /dev/null +++ b/project/src/dao/impl/ZhichuqingkuangImpl.java @@ -0,0 +1,139 @@ +package dao.impl; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import dao.ZhichuqingkuangDao; +import entity.Zhichuqingkuang; + +public class ZhichuqingkuangImpl implements ZhichuqingkuangDao{ + + + public Zhichuqingkuang findById(String id) { + Zhichuqingkuang acyc=new Zhichuqingkuang(); + try { + + Connection conn = JDBCUtil.getConnection(); + String sql = "select*from zhichuqingkuang where id = ?"; + PreparedStatement prestm=conn.prepareStatement(sql); + prestm.setInt(1, Integer.valueOf(id)); + ResultSet rs=prestm.executeQuery(); + + while(rs.next()) { + Zhichuqingkuang zhichuqingkuang=new Zhichuqingkuang(); + zhichuqingkuang.setId(rs.getInt("id")); + zhichuqingkuang.setFashengfeiyonghss(rs.getString("fashengfeiyonghss")); + zhichuqingkuang.setFashengriqihss(rs.getString("fashengriqihss")); + zhichuqingkuang.setHuzhuhss(rs.getString("huzhuhss")); + zhichuqingkuang.setMingxihss(rs.getString("mingxihss")); + acyc=zhichuqingkuang; + } + rs.close(); + prestm.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return acyc; + } + + + @Override + public List findAll() { + ArrayList zhushus=new ArrayList(); + try { + Connection conn = JDBCUtil.getConnection(); + + String sqlyc ="select *from zhichuqingkuang"; + Statement stsyc =conn.createStatement(); + ResultSet rs=stsyc.executeQuery(sqlyc); + + while(rs.next()) { + Zhichuqingkuang zhichuqingkuang=new Zhichuqingkuang(); + zhichuqingkuang.setId(rs.getInt("id")); + zhichuqingkuang.setFashengfeiyonghss(rs.getString("fashengfeiyonghss")); + zhichuqingkuang.setFashengriqihss(rs.getString("fashengriqihss")); + zhichuqingkuang.setHuzhuhss(rs.getString("huzhuhss")); + zhichuqingkuang.setMingxihss(rs.getString("mingxihss")); + zhushus.add(zhichuqingkuang); + } + rs.close(); + stsyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + // TODO 自动生成的方法存根 + return zhushus; + } + + + @Override + public int modify(Zhichuqingkuang zhichuqingkuang) { + try { + Connection conn = JDBCUtil.getConnection(); + + String sqlyc ="update zhichuqingkuang set fashengfeiyonghss=?,fashengriqihss=?,huzhuhss=?,mingxihss=? where id=?"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setString(1,zhichuqingkuang.getFashengfeiyonghss()); + prestmyc.setString(2,zhichuqingkuang.getFashengriqihss()); + prestmyc.setString(3,zhichuqingkuang.getHuzhuhss()); + prestmyc.setString(4,zhichuqingkuang.getMingxihss()); + prestmyc.setInt(5,zhichuqingkuang.getId()); + prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return 0; + } + + + @Override + public int create(Zhichuqingkuang zhichuqingkuang) { + try { + Connection conn = JDBCUtil.getConnection(); + String sqlyc ="Insert into zhichuqingkuang (fashengfeiyonghss,fashengriqihss,huzhuhss,mingxihss) values(?,?,?,?)"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setString(1,zhichuqingkuang.getFashengfeiyonghss()); + prestmyc.setString(2,zhichuqingkuang.getFashengriqihss()); + prestmyc.setString(3,zhichuqingkuang.getHuzhuhss()); + prestmyc.setString(4,zhichuqingkuang.getMingxihss()); + prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return 0; + } + + + @Override + public int remove(Zhichuqingkuang zhichuqingkuang) { + int flagyc=0; + try { + Connection conn = JDBCUtil.getConnection(); + String sqlyc ="delete from zhichuqingkuang where id=?"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setInt(1, zhichuqingkuang.getId()); + flagyc = prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return flagyc; + } + +} diff --git a/project/src/dao/impl/ZhuhuImpl.java b/project/src/dao/impl/ZhuhuImpl.java new file mode 100644 index 0000000..d59aca3 --- /dev/null +++ b/project/src/dao/impl/ZhuhuImpl.java @@ -0,0 +1,135 @@ +package dao.impl; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import dao.ZhuhuDao; +import entity.Zhuhu; + +public class ZhuhuImpl implements ZhuhuDao{ + + public Zhuhu findById(String id) { + Zhuhu acyc=new Zhuhu(); + try { + + Connection conn = JDBCUtil.getConnection(); + String sql = "select*from zhuhu where id = ?"; + PreparedStatement prestm=conn.prepareStatement(sql); + prestm.setInt(1, Integer.valueOf(id)); + ResultSet rs=prestm.executeQuery(); + + while(rs.next()) { + Zhuhu zhushu=new Zhuhu(); + zhushu.setId(rs.getInt("id")); + zhushu.setDizhidxy(rs.getString("dizhidxy")); + zhushu.setHuzhudxy(rs.getString("huzhudxy")); + zhushu.setLianxidianhuadxy(rs.getString("lianxidianhuadxy")); + acyc=zhushu; + } + rs.close(); + prestm.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return acyc; + } + + + @Override + public List findAll() { + ArrayList zhushus=new ArrayList(); + try { + Connection conn = JDBCUtil.getConnection(); + + String sqlyc ="select *from zhuhu"; + Statement stsyc =conn.createStatement(); + ResultSet rsyc=stsyc.executeQuery(sqlyc); + + while(rsyc.next()) { + Zhuhu zhushu=new Zhuhu(); + zhushu.setId(rsyc.getInt("id")); + zhushu.setDizhidxy(rsyc.getString("dizhidxy")); + zhushu.setHuzhudxy(rsyc.getString("huzhudxy")); + zhushu.setLianxidianhuadxy(rsyc.getString("lianxidianhuadxy")); + zhushus.add(zhushu); + } + rsyc.close(); + stsyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + // TODO 自动生成的方法存根 + return zhushus; + } + + + @Override + public int modify(Zhuhu zhuhu) { + try { + Connection conn = JDBCUtil.getConnection(); + + String sqlyc ="update zhuhu set huzhudxy=?,dizhidxy=?,lianxidianhuadxy=? where id=?"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setString(1,zhuhu.getHuzhudxy()); + prestmyc.setString(2,zhuhu.getDizhidxy()); + prestmyc.setString(3,zhuhu.getLianxidianhuadxy()); + prestmyc.setInt(4,zhuhu.getId()); + prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return 0; + } + + + @Override + public int create(Zhuhu zhuhu) { + try { + Connection conn = JDBCUtil.getConnection(); + String sqlyc ="Insert into zhuhu (huzhudxy,dizhidxy,lianxidianhuadxy) values(?,?,?)"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setString(1,zhuhu.getHuzhudxy()); + prestmyc.setString(2,zhuhu.getDizhidxy()); + prestmyc.setString(3,zhuhu.getLianxidianhuadxy()); + prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return 0; + } + + + @Override + public int remove(Zhuhu zhuhu) { + int flagyc=0; + try { + Connection conn = JDBCUtil.getConnection(); + String sqlyc ="delete from zhuhu where id=?"; + PreparedStatement prestmyc=conn.prepareStatement(sqlyc); + prestmyc.setInt(1, zhuhu.getId()); + flagyc = prestmyc.executeUpdate(); + prestmyc.close(); + conn.close(); + } + catch(Exception e) { + e.printStackTrace(); + } + return flagyc; + } + + +} diff --git a/project/src/entity/Guanliyuan.java b/project/src/entity/Guanliyuan.java new file mode 100644 index 0000000..d9c7bb2 --- /dev/null +++ b/project/src/entity/Guanliyuan.java @@ -0,0 +1,36 @@ +package entity; + +public class Guanliyuan { + + + private Integer id; + + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + private String yonghumingyc; + public String getYonghumingyc() { + return this.yonghumingyc; + } + public void setYonghumingyc(String yonghumingyc) { + this.yonghumingyc = yonghumingyc; + } + private String mimayc; + public String getMimayc() { + return this.mimayc; + } + public void setMimayc(String mimayc) { + this.mimayc = mimayc; + } + private String jiaoseyc; + public String getJiaoseyc() { + return this.jiaoseyc; + } + public void setJiaoseyc(String jiaoseyc) { + this.jiaoseyc = jiaoseyc; + } + +} diff --git a/project/src/entity/Shouruqingkuang.java b/project/src/entity/Shouruqingkuang.java new file mode 100644 index 0000000..1dbcddc --- /dev/null +++ b/project/src/entity/Shouruqingkuang.java @@ -0,0 +1,43 @@ +package entity; + +public class Shouruqingkuang { + + + private Integer id; + + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + private String mingxiym; + public String getMingxiym() { + return this.mingxiym; + } + public void setMingxiym(String mingxiym) { + this.mingxiym = mingxiym; + } + private String fashengriqiym; + public String getFashengriqiym() { + return this.fashengriqiym; + } + public void setFashengriqiym(String fashengriqiym) { + this.fashengriqiym = fashengriqiym; + } + private String fashengfeiyongym; + public String getFashengfeiyongym() { + return this.fashengfeiyongym; + } + public void setFashengfeiyongym(String fashengfeiyongym) { + this.fashengfeiyongym = fashengfeiyongym; + } + private String huzhuym; + public String getHuzhuym() { + return this.huzhuym; + } + public void setHuzhuym(String huzhuym) { + this.huzhuym = huzhuym; + } + +} diff --git a/project/src/entity/Zhichuqingkuang.java b/project/src/entity/Zhichuqingkuang.java new file mode 100644 index 0000000..386054d --- /dev/null +++ b/project/src/entity/Zhichuqingkuang.java @@ -0,0 +1,43 @@ +package entity; + +public class Zhichuqingkuang { + + + private Integer id; + + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + private String mingxihss; + public String getMingxihss() { + return this.mingxihss; + } + public void setMingxihss(String mingxihss) { + this.mingxihss = mingxihss; + } + private String fashengriqihss; + public String getFashengriqihss() { + return this.fashengriqihss; + } + public void setFashengriqihss(String fashengriqihss) { + this.fashengriqihss = fashengriqihss; + } + private String fashengfeiyonghss; + public String getFashengfeiyonghss() { + return this.fashengfeiyonghss; + } + public void setFashengfeiyonghss(String fashengfeiyonghss) { + this.fashengfeiyonghss = fashengfeiyonghss; + } + private String huzhuhss; + public String getHuzhuhss() { + return this.huzhuhss; + } + public void setHuzhuhss(String huzhuhss) { + this.huzhuhss = huzhuhss; + } + +} diff --git a/project/src/entity/Zhuhu.java b/project/src/entity/Zhuhu.java new file mode 100644 index 0000000..7399eb5 --- /dev/null +++ b/project/src/entity/Zhuhu.java @@ -0,0 +1,36 @@ +package entity; + +public class Zhuhu { + + + private Integer id; + + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + private String huzhudxy; + public String getHuzhudxy() { + return this.huzhudxy; + } + public void setHuzhudxy(String huzhudxy) { + this.huzhudxy = huzhudxy; + } + private String dizhidxy; + public String getDizhidxy() { + return this.dizhidxy; + } + public void setDizhidxy(String dizhidxy) { + this.dizhidxy = dizhidxy; + } + private String lianxidianhuadxy; + public String getLianxidianhuadxy() { + return this.lianxidianhuadxy; + } + public void setLianxidianhuadxy(String lianxidianhuadxy) { + this.lianxidianhuadxy = lianxidianhuadxy; + } + +} diff --git a/project/src/view/BackgroundPanel.java b/project/src/view/BackgroundPanel.java new file mode 100644 index 0000000..358da79 --- /dev/null +++ b/project/src/view/BackgroundPanel.java @@ -0,0 +1,15 @@ +package view; + +import java.awt.Image; + +import javax.swing.ImageIcon; +import javax.swing.JPanel; + +public class BackgroundPanel extends JPanel { + Image im; + + public BackgroundPanel() { + this.im = (new ImageIcon("")).getImage(); + this.setOpaque(true); + } +} \ No newline at end of file diff --git a/project/src/view/GuanliyuanAddUI.java b/project/src/view/GuanliyuanAddUI.java new file mode 100644 index 0000000..9162430 --- /dev/null +++ b/project/src/view/GuanliyuanAddUI.java @@ -0,0 +1,117 @@ +package view; + +import java.awt.Component; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +import dao.GuanliyuanDao; +import dao.impl.GuanliyuanImpl; +import entity.Guanliyuan; + + +public class GuanliyuanAddUI extends JFrame { + + private JPanel contentPane; + GuanliyuanDao dao = new GuanliyuanImpl(); + public GuanliyuanAddUI() { + init(null); + } + public GuanliyuanAddUI(Tableinter mui) { + init(mui); + } + public void init(Tableinter mui) { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 643, 646); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + JPanel panel = new JPanel(); + contentPane.add(panel); + panel.setLayout(new GridLayout(0, 2, 0, 0)); + JLabel yonghumingyclabel = new JLabel("用户名"); + yonghumingyclabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(yonghumingyclabel); + JTextField yonghumingyctextField = new JTextField(); + panel.add(yonghumingyctextField); + + JLabel mimayclabel = new JLabel("密码"); + mimayclabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(mimayclabel); + JTextField mimayctextField = new JTextField(); + panel.add(mimayctextField); + + JLabel jiaoseyclabel = new JLabel("角色"); + jiaoseyclabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(jiaoseyclabel); + JComboBox jiaoseyccomboBox = new JComboBox(); + jiaoseyccomboBox.setModel(new DefaultComboBoxModel(new String[] {"管理员"})); + panel.add(jiaoseyccomboBox); + + + + + + panel.setBounds(10, 10, 607, 90); + JButton button = new JButton("添加"); + /** + 新增按钮触发事件 + */ + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + Guanliyuan bean=new Guanliyuan(); + bean.setYonghumingyc(yonghumingyctextField.getText()); + + bean.setMimayc(mimayctextField.getText()); + + bean.setJiaoseyc(jiaoseyccomboBox.getSelectedItem().toString()); + + + dao.create(bean); + JOptionPane.showMessageDialog(null, "添加成功"); + if(mui!=null) + mui.refresh(dao.findAll()); + dispose(); + } + }); + button.setFont(new Font("宋体", Font.PLAIN, 20)); + button.setBounds(173, 550, 93, 47); + contentPane.add(button); + + JButton button_1 = new JButton("取消"); + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + dispose(); + } + }); + button_1.setFont(new Font("宋体", Font.PLAIN, 20)); + button_1.setBounds(334, 550, 93, 47); + contentPane.add(button_1); + + this.setLocationRelativeTo(null); + } + public String getRadioValue(JPanel panel){ + for(Component c:panel.getComponents()){ + if(c instanceof JRadioButton){ + if(((JRadioButton) c).isSelected()){ + return ((JRadioButton)c).getText(); + } + } + } + return ""; + } +} diff --git a/project/src/view/GuanliyuanManageUI.java b/project/src/view/GuanliyuanManageUI.java new file mode 100644 index 0000000..036f5ca --- /dev/null +++ b/project/src/view/GuanliyuanManageUI.java @@ -0,0 +1,28 @@ +package view; + +import java.awt.BorderLayout; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; + +public class GuanliyuanManageUI extends JFrame{ + + private JPanel contentPane; + + public static void main(String[] args) { + new GuanliyuanManageUI().setVisible(true); + } + public GuanliyuanManageUI() { + setTitle("管理员管理"); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 879, 665); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(new BorderLayout(0, 0)); + add(new GuanliyuanManageUIListPanel(""), BorderLayout.CENTER); + this.setLocationRelativeTo(null); + } + +} diff --git a/project/src/view/GuanliyuanManageUIListPanel.java b/project/src/view/GuanliyuanManageUIListPanel.java new file mode 100644 index 0000000..948f8f8 --- /dev/null +++ b/project/src/view/GuanliyuanManageUIListPanel.java @@ -0,0 +1,172 @@ +package view; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; +import java.util.Vector; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; + +import dao.GuanliyuanDao; +import dao.impl.GuanliyuanImpl; +import entity.Guanliyuan; + +public class GuanliyuanManageUIListPanel extends JPanel implements Tableinter{ + GuanliyuanDao dao = new GuanliyuanImpl(); + private JPanel contentPane; + + + + + private static String[] columnCount = { "id","用户名","密码","角色" }; + public JTable table; + private static DefaultTableModel tableModel; + private String mainid; + + public GuanliyuanManageUIListPanel(String mainid) { + this.mainid=mainid; + setLayout(new BorderLayout(0, 0)); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + contentPane.setLayout(new BorderLayout(0, 0)); + add(contentPane); + JScrollPane scrollPane = new JScrollPane(); + contentPane.add(scrollPane, BorderLayout.CENTER); + table = new JTable(); + scrollPane.setViewportView(table); + JPanel toppanel = new JPanel(); + contentPane.add(toppanel, BorderLayout.NORTH); + toppanel.setLayout(new GridLayout(2, 1, 0, 0)); + + JPanel btnpanel = new JPanel(); + btnpanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); + toppanel.add(btnpanel); + + + JButton button = new JButton("添加"); + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + new GuanliyuanAddUI(me()).setVisible(true); + } + }); + btnpanel.add(button); + + JButton button_1 = new JButton("删除"); + /** + 删除操作 + */ + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + int row = table.getSelectedRow(); + if (row == -1) { + JOptionPane.showMessageDialog(null, "请选择一行进行删除"); + return; + } + String keyvalue = (String) table.getValueAt(row, 0); + /** + 根据主键进行查询,如果查询到则删除 + */ + Guanliyuan gl=new Guanliyuan(); + gl.setId(Integer.valueOf(keyvalue)); + dao.remove(gl); + JOptionPane.showMessageDialog(null, "删除成功"); + refresh(dao.findAll()); + } + }); + btnpanel.add(button_1); + + JButton button_2 = new JButton("修改"); + /** + 修改操作 + */ + button_2.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + int row = table.getSelectedRow(); + if (row == -1) { + JOptionPane.showMessageDialog(null, "请选择一行进行修改"); + return; + } + //跳转到修改页面 + new GuanliyuanUpdateUI(me()).setVisible(true); + } + + }); + btnpanel.add(button_2); + refresh(dao.findAll()); + } + public GuanliyuanManageUIListPanel me(){ + return this; + } + //刷新表格列表 + public void refresh(List list){ + + + tableModel = new DefaultTableModel(transferList(list), columnCount){ + public Class getColumnClass(int column) { + Vector v = (Vector) dataVector.elementAt(0); + if(v.elementAt(column)!=null){ + return v.elementAt(column).getClass(); + }else{ + return String.class; + } + } + public boolean isCellEditable(int row, int col) { + Class columnClass = getColumnClass(col); + return columnClass != ImageIcon.class; + } + }; + table.setModel(tableModel); + + + updateRowHeights(); + } + //自动调整列高 + private void updateRowHeights() + { + for (int row = 0; row < table.getRowCount(); row++) + { + int rowHeight = table.getRowHeight(); + + for (int column = 0; column < table.getColumnCount(); column++) + { + Component comp = table.prepareRenderer(table.getCellRenderer(row, column), row, column); + rowHeight = Math.max(rowHeight, comp.getPreferredSize().height); + } + table.setRowHeight(row, rowHeight); + } + } + //将实体列表转换为表格实体 + public static Object[][] transferList(List list) { + Object[][] olist = new Object[list.size()][]; + for (int i = 0; i < list.size(); i++) { + Object str[] = {list.get(i).getId().toString(), list.get(i).getYonghumingyc(),list.get(i).getMimayc(),list.get(i).getJiaoseyc() }; + //如果包含图片格式则以图片形式显示 + for (int j = 0; j < str.length; j++) { + if(str[j]!=null&&(str[j].toString().contains("png")||str[j].toString().contains("jpg")||str[j].toString().contains("gif"))){ + str[j]=new ImageIcon(new ImageIcon(str[j].toString()).getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)); + } + } + olist[i] = str; + } + + return olist; + } + public JTable getTable() { + return table; + } + public String getMainid(){ + return mainid; + } +} diff --git a/project/src/view/GuanliyuanUpdateUI.java b/project/src/view/GuanliyuanUpdateUI.java new file mode 100644 index 0000000..8cf11a6 --- /dev/null +++ b/project/src/view/GuanliyuanUpdateUI.java @@ -0,0 +1,131 @@ +package view; + +import java.awt.Component; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +import dao.GuanliyuanDao; +import dao.impl.GuanliyuanImpl; +import entity.Guanliyuan; +public class GuanliyuanUpdateUI extends JFrame { + + private JPanel contentPane; + + + + GuanliyuanDao dao = new GuanliyuanImpl(); + public GuanliyuanUpdateUI() { + init(null); + } + public GuanliyuanUpdateUI(Tableinter mui) { + init(mui); + } + public void init(Tableinter mui) { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 643, 646); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + Guanliyuan guanliyuan=null; + guanliyuan = dao.findById((String) mui.getTable().getValueAt(mui.getTable().getSelectedRow(), 0)); + JPanel panel = new BackgroundPanel(); + contentPane.add(panel); + panel.setLayout(new GridLayout(0, 2, 0, 0)); + JLabel idlabel = new JLabel("id"); + idlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(idlabel); + JTextField idtextField = new JTextField(guanliyuan.getId().toString()); + idtextField.setEnabled(false); + panel.add(idtextField); + JLabel yonghumingyclabel = new JLabel("用户名"); + yonghumingyclabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(yonghumingyclabel); + JTextField yonghumingyctextField = new JTextField(guanliyuan.getYonghumingyc()); + panel.add(yonghumingyctextField); + + JLabel mimayclabel = new JLabel("密码"); + mimayclabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(mimayclabel); + JTextField mimayctextField = new JTextField(guanliyuan.getMimayc()); + panel.add(mimayctextField); + + JLabel jiaoseyclabel = new JLabel("角色"); + jiaoseyclabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(jiaoseyclabel); + JComboBox jiaoseyccomboBox = new JComboBox(); + jiaoseyccomboBox.setModel(new DefaultComboBoxModel(new String[] {"管理员"})); + jiaoseyccomboBox.setSelectedItem(guanliyuan.getJiaoseyc()); + panel.add(jiaoseyccomboBox); + + + + panel.setBounds(10, 10, 607, 120); + JButton button = new JButton("修改"); + /** + 修改按钮触发事件 + */ + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + +Guanliyuan bean=new Guanliyuan(); + bean.setYonghumingyc(yonghumingyctextField.getText()); + + bean.setMimayc(mimayctextField.getText()); + + bean.setJiaoseyc(jiaoseyccomboBox.getSelectedItem().toString()); + + bean.setId(Integer.valueOf(idtextField.getText())); + + + dao.modify(bean); + JOptionPane.showMessageDialog(null, "修改成功"); + //刷新主界面列表 + if(mui!=null) + mui.refresh(dao.findAll()); + dispose(); + } + }); + button.setFont(new Font("宋体", Font.PLAIN, 20)); + button.setBounds(173, 550, 93, 47); + contentPane.add(button); + + JButton button_1 = new JButton("取消"); + /** + 取消按钮触发事件 + */ + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + dispose(); + } + }); + button_1.setFont(new Font("宋体", Font.PLAIN, 20)); + button_1.setBounds(334, 550, 93, 47); + contentPane.add(button_1); + this.setLocationRelativeTo(null); + } + public String getRadioValue(JPanel panel){ + for(Component c:panel.getComponents()){ + if(c instanceof JRadioButton){ + if(((JRadioButton) c).isSelected()){ + return ((JRadioButton)c).getText(); + } + } + } + return ""; + } +} diff --git a/project/src/view/LoginUI.java b/project/src/view/LoginUI.java new file mode 100644 index 0000000..1579c1a --- /dev/null +++ b/project/src/view/LoginUI.java @@ -0,0 +1,132 @@ +package view; + +import java.awt.EventQueue; +import java.awt.Font; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; +import javax.swing.border.EmptyBorder; + +import dao.GuanliyuanDao; +import dao.impl.GuanliyuanImpl; +import entity.Guanliyuan; + +public class LoginUI extends JFrame { + + GuanliyuanDao dao = new GuanliyuanImpl(); + public static String username; + public static String role; + private JPanel contentPane; + private JTextField textField; + private JPasswordField textField_1; + private JComboBox comboBox; + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + LoginUI frame = new LoginUI(); + frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + public LoginUI() { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 643, 508); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + setTitle("家庭收支管理系统"); + JLabel label = new JLabel("用户名"); + label.setFont(new Font("楷体", Font.PLAIN, 20)); + label.setBounds(104, 125, 110, 32); + contentPane.add(label); + + textField = new JTextField(); + textField.setBounds(224, 119, 227, 38); + contentPane.add(textField); + textField.setColumns(10); + + JLabel label_1 = new JLabel("密码"); + label_1.setFont(new Font("楷体", Font.PLAIN, 20)); + label_1.setBounds(104, 210, 110, 32); + contentPane.add(label_1); + + textField_1 = new JPasswordField(); + textField_1.setColumns(10); + textField_1.setBounds(224, 204, 227, 38); + contentPane.add(textField_1); + + JButton button = new JButton("登录"); + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + Guanliyuan gl = dao.findByUsername(textField.getText()); + if(gl!=null){ + if(gl.getMimayc().equals(textField_1.getText())){ + username=gl.getYonghumingyc(); + role=gl.getJiaoseyc(); + if(!role.equals(comboBox.getSelectedItem().toString())){ + JOptionPane.showMessageDialog(null, "用户名或密码错误,登录失败"); + return; + } + JOptionPane.showMessageDialog(null, "登录成功"); + MainUI frame = new MainUI(); + frame.setVisible(true); + setVisible(false); + return; + } + } + + JOptionPane.showMessageDialog(null, "用户名或密码错误,登录失败"); + } + }); + button.setFont(new Font("楷体", Font.PLAIN, 20)); + button.setBounds(175, 371, 105, 38); + contentPane.add(button); + JButton button_1 = new JButton("注册"); + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + RegistUI frame = new RegistUI(); + frame.setVisible(true); + } + }); + button_1.setFont(new Font("楷体", Font.PLAIN, 20)); + button_1.setBounds(332, 371, 105, 38); + contentPane.add(button_1); + JLabel lblNewLabel = new JLabel("家庭收支管理系统"); + lblNewLabel.setFont(new Font("楷体", Font.PLAIN, 28)); + lblNewLabel.setBounds(235, 28, 497, 55); + contentPane.add(lblNewLabel); + + JLabel label_2 = new JLabel("角色"); + label_2.setFont(new Font("楷体", Font.PLAIN, 20)); + label_2.setBounds(104, 291, 110, 32); + contentPane.add(label_2); + + comboBox = new JComboBox(); + comboBox.setModel(new DefaultComboBoxModel(new String[] {"管理员"})); + comboBox.setBounds(224, 291, 227, 32); + contentPane.add(comboBox); + + this.setLocationRelativeTo(null); + } +} diff --git a/project/src/view/MainUI.java b/project/src/view/MainUI.java new file mode 100644 index 0000000..299ad92 --- /dev/null +++ b/project/src/view/MainUI.java @@ -0,0 +1,87 @@ +package view; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; +public class MainUI extends JFrame { + + private JPanel contentPane; + + public static void main(String[] args) { + MainUI frame = new MainUI(); + frame.setVisible(true); + } + + public MainUI() { + setTitle("家庭收支管理系统"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(100, 100, 1159, 793); + + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(new BorderLayout(0, 0)); + + JPanel toppanel = new JPanel(); + toppanel.setBorder(new LineBorder(new Color(0, 0, 0))); + FlowLayout flowLayout = (FlowLayout) toppanel.getLayout(); + flowLayout.setAlignment(FlowLayout.LEFT); + contentPane.add(toppanel, BorderLayout.NORTH); + + JButton GuanliyuanManageUI = new JButton("管理员管理"); + GuanliyuanManageUI.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + new GuanliyuanManageUI().setVisible(true); + } + }); + GuanliyuanManageUI.setFont(new Font("华文楷体", Font.PLAIN, 25)); + + toppanel.add(GuanliyuanManageUI); + JButton ZhuhuManageUI = new JButton("住户管理"); + ZhuhuManageUI.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + new ZhuhuManageUI().setVisible(true); + } + }); + ZhuhuManageUI.setFont(new Font("华文楷体", Font.PLAIN, 25)); + + toppanel.add(ZhuhuManageUI); + JButton ShouruqingkuangManageUI = new JButton("收入情况管理"); + ShouruqingkuangManageUI.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + new ShouruqingkuangManageUI().setVisible(true); + } + }); + ShouruqingkuangManageUI.setFont(new Font("华文楷体", Font.PLAIN, 25)); + + toppanel.add(ShouruqingkuangManageUI); + JButton ZhichuqingkuangManageUI = new JButton("支出情况管理"); + ZhichuqingkuangManageUI.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + new ZhichuqingkuangManageUI().setVisible(true); + } + }); + ZhichuqingkuangManageUI.setFont(new Font("华文楷体", Font.PLAIN, 25)); + + toppanel.add(ZhichuqingkuangManageUI); + JButton exitbutton = new JButton("退出"); + exitbutton.setFont(new Font("华文楷体", Font.PLAIN, 25)); + toppanel.add(exitbutton); + exitbutton.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + System.exit(0); + } + }); + + this.setLocationRelativeTo(null); + } +} diff --git a/project/src/view/RegistUI.java b/project/src/view/RegistUI.java new file mode 100644 index 0000000..8b4d398 --- /dev/null +++ b/project/src/view/RegistUI.java @@ -0,0 +1,94 @@ +package view; + +import java.awt.Component; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +import dao.GuanliyuanDao; +import dao.impl.GuanliyuanImpl; +import entity.Guanliyuan; +public class RegistUI extends JFrame { + + private JPanel contentPane; + GuanliyuanDao dao = new GuanliyuanImpl(); + public RegistUI() { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 643, 646); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + JPanel panel = new JPanel(); + + contentPane.add(panel); + panel.setLayout(new GridLayout(3, 2, 0, 0)); + JLabel yonghumingyclabel = new JLabel("用户名"); + yonghumingyclabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(yonghumingyclabel); + JTextField yonghumingyctextField = new JTextField(); + panel.add(yonghumingyctextField); + JLabel mimayclabel = new JLabel("密码"); + mimayclabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(mimayclabel); + JTextField mimayctextField = new JTextField(); + panel.add(mimayctextField); + JLabel jiaoseyclabel = new JLabel("角色"); + jiaoseyclabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(jiaoseyclabel); + JComboBox jiaoseyccomboBox = new JComboBox(); + jiaoseyccomboBox.setModel(new DefaultComboBoxModel(new String[] {"管理员"})); + panel.add(jiaoseyccomboBox); + + panel.setBounds(10, 10, 607, 90); + JButton button = new JButton("注册"); + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + Guanliyuan bean=new Guanliyuan(); + bean.setYonghumingyc(yonghumingyctextField.getText()); + bean.setMimayc(mimayctextField.getText()); + bean.setJiaoseyc(jiaoseyccomboBox.getSelectedItem().toString()); + dao.create(bean); + JOptionPane.showMessageDialog(null, "注册成功"); + dispose(); + } + }); + button.setFont(new Font("宋体", Font.PLAIN, 20)); + button.setBounds(173, 550, 93, 47); + contentPane.add(button); + + JButton button_1 = new JButton("取消"); + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + dispose(); + } + }); + button_1.setFont(new Font("宋体", Font.PLAIN, 20)); + button_1.setBounds(334, 550, 93, 47); + contentPane.add(button_1); + this.setLocationRelativeTo(null); + } + public String getRadioValue(JPanel panel){ + for(Component c:panel.getComponents()){ + if(c instanceof JRadioButton){ + if(((JRadioButton) c).isSelected()){ + return ((JRadioButton)c).getText(); + } + } + } + return ""; + } +} diff --git a/project/src/view/ShouruqingkuangAddUI.java b/project/src/view/ShouruqingkuangAddUI.java new file mode 100644 index 0000000..7da21a6 --- /dev/null +++ b/project/src/view/ShouruqingkuangAddUI.java @@ -0,0 +1,140 @@ +package view; + +import java.awt.Component; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +import com.eltima.components.ui.DatePicker; + +import dao.ShouruqingkuangDao; +import dao.ZhuhuDao; +import dao.impl.ShouruqingkuangImpl; +import dao.impl.ZhuhuImpl; +import entity.Shouruqingkuang; +import entity.Zhuhu; + +public class ShouruqingkuangAddUI extends JFrame { + + private JPanel contentPane; + ShouruqingkuangDao dao = new ShouruqingkuangImpl(); + ZhuhuDao zhuhuhuzhuymdao = new ZhuhuImpl(); + public ShouruqingkuangAddUI() { + init(null); + } + public ShouruqingkuangAddUI(Tableinter mui) { + init(mui); + } + public void init(Tableinter mui) { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 643, 646); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + JPanel panel = new JPanel(); + contentPane.add(panel); + panel.setLayout(new GridLayout(0, 2, 0, 0)); + JLabel mingxiymlabel = new JLabel("明细"); + mingxiymlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(mingxiymlabel); + JTextField mingxiymtextField = new JTextField(); + panel.add(mingxiymtextField); + + JLabel fashengriqiymlabel = new JLabel("发生日期"); + fashengriqiymlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(fashengriqiymlabel); + DatePicker fashengriqiymtextField = new DatePicker(this); + fashengriqiymtextField.setPattern("yyyy-MM-dd"); + fashengriqiymtextField.setTimePanleVisible(true); + fashengriqiymtextField.setEditorable(false); + panel.add(fashengriqiymtextField); + + JLabel fashengfeiyongymlabel = new JLabel("发生费用"); + fashengfeiyongymlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(fashengfeiyongymlabel); + JTextField fashengfeiyongymtextField = new JTextField(); + panel.add(fashengfeiyongymtextField); + + JLabel huzhuymlabel = new JLabel("户主"); + huzhuymlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(huzhuymlabel); + + JComboBox huzhuymcomboBox = new JComboBox(); + List zhuhuhuzhuymlist=zhuhuhuzhuymdao.findAll(); + huzhuymcomboBox.addItem(""); + for (int i = 0; i < zhuhuhuzhuymlist.size(); i++) { + huzhuymcomboBox.addItem(zhuhuhuzhuymlist.get(i).getHuzhudxy()); + } + panel.add(huzhuymcomboBox); + + + + panel.setBounds(10, 10, 607, 120); + JButton button = new JButton("添加"); + /** + 新增按钮触发事件 + */ + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + Shouruqingkuang bean=new Shouruqingkuang(); + bean.setMingxiym(mingxiymtextField.getText()); + + bean.setFashengriqiym(fashengriqiymtextField.getText()); + + bean.setFashengfeiyongym(fashengfeiyongymtextField.getText()); + + if(huzhuymcomboBox.getSelectedItem()!=null){ + bean.setHuzhuym(huzhuymcomboBox.getSelectedItem().toString()); + }else{ + bean.setHuzhuym(""); + } + + + dao.create(bean); + JOptionPane.showMessageDialog(null, "添加成功"); + if(mui!=null) + mui.refresh(dao.findAll()); + dispose(); + } + }); + button.setFont(new Font("宋体", Font.PLAIN, 20)); + button.setBounds(173, 550, 93, 47); + contentPane.add(button); + + JButton button_1 = new JButton("取消"); + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + dispose(); + } + }); + button_1.setFont(new Font("宋体", Font.PLAIN, 20)); + button_1.setBounds(334, 550, 93, 47); + contentPane.add(button_1); + + this.setLocationRelativeTo(null); + } + public String getRadioValue(JPanel panel){ + for(Component c:panel.getComponents()){ + if(c instanceof JRadioButton){ + if(((JRadioButton) c).isSelected()){ + return ((JRadioButton)c).getText(); + } + } + } + return ""; + } +} diff --git a/project/src/view/ShouruqingkuangManageUI.java b/project/src/view/ShouruqingkuangManageUI.java new file mode 100644 index 0000000..cbf9a9e --- /dev/null +++ b/project/src/view/ShouruqingkuangManageUI.java @@ -0,0 +1,28 @@ +package view; + +import java.awt.BorderLayout; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; + +public class ShouruqingkuangManageUI extends JFrame{ + + private JPanel contentPane; + + public static void main(String[] args) { + new ShouruqingkuangManageUI().setVisible(true); + } + public ShouruqingkuangManageUI() { + setTitle("收入情况管理"); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 879, 665); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(new BorderLayout(0, 0)); + add(new ShouruqingkuangManageUIListPanel(""), BorderLayout.CENTER); + this.setLocationRelativeTo(null); + } + +} diff --git a/project/src/view/ShouruqingkuangManageUIListPanel.java b/project/src/view/ShouruqingkuangManageUIListPanel.java new file mode 100644 index 0000000..ab2ae32 --- /dev/null +++ b/project/src/view/ShouruqingkuangManageUIListPanel.java @@ -0,0 +1,175 @@ +package view; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; +import java.util.Vector; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; + +import dao.ShouruqingkuangDao; +import dao.ZhuhuDao; +import dao.impl.ShouruqingkuangImpl; +import dao.impl.ZhuhuImpl; +import entity.Shouruqingkuang; + +public class ShouruqingkuangManageUIListPanel extends JPanel implements Tableinter{ + ShouruqingkuangDao dao = new ShouruqingkuangImpl(); + ZhuhuDao zhuhuhuzhuymdao = new ZhuhuImpl(); + private JPanel contentPane; + + + + + + private static String[] columnCount = { "id","明细","发生日期","发生费用","户主" }; + public JTable table; + private static DefaultTableModel tableModel; + private String mainid; + + public ShouruqingkuangManageUIListPanel(String mainid) { + this.mainid=mainid; + setLayout(new BorderLayout(0, 0)); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + contentPane.setLayout(new BorderLayout(0, 0)); + add(contentPane); + JScrollPane scrollPane = new JScrollPane(); + contentPane.add(scrollPane, BorderLayout.CENTER); + table = new JTable(); + scrollPane.setViewportView(table); + JPanel toppanel = new JPanel(); + contentPane.add(toppanel, BorderLayout.NORTH); + toppanel.setLayout(new GridLayout(2, 1, 0, 0)); + JPanel btnpanel = new JPanel(); + btnpanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); + toppanel.add(btnpanel); + + + JButton button = new JButton("添加"); + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + new ShouruqingkuangAddUI(me()).setVisible(true); + } + }); + btnpanel.add(button); + + JButton button_1 = new JButton("删除"); + /** + 删除操作 + */ + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + int row = table.getSelectedRow(); + if (row == -1) { + JOptionPane.showMessageDialog(null, "请选择一行进行删除"); + return; + } + String keyvalue = (String) table.getValueAt(row, 0); + /** + 根据主键进行查询,如果查询到则删除 + */ + Shouruqingkuang sf=new Shouruqingkuang(); + sf.setId(Integer.valueOf(keyvalue)); + dao.remove(sf); + JOptionPane.showMessageDialog(null, "删除成功"); + refresh(dao.findAll()); + } + }); + btnpanel.add(button_1); + + JButton button_2 = new JButton("修改"); + /** + 修改操作 + */ + button_2.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + int row = table.getSelectedRow(); + if (row == -1) { + JOptionPane.showMessageDialog(null, "请选择一行进行修改"); + return; + } + //跳转到修改页面 + new ShouruqingkuangUpdateUI(me()).setVisible(true); + } + + }); + btnpanel.add(button_2); + refresh(dao.findAll()); + } + public ShouruqingkuangManageUIListPanel me(){ + return this; + } + //刷新表格列表 + public void refresh(List list){ + + + tableModel = new DefaultTableModel(transferList(list), columnCount){ + public Class getColumnClass(int column) { + Vector v = (Vector) dataVector.elementAt(0); + if(v.elementAt(column)!=null){ + return v.elementAt(column).getClass(); + }else{ + return String.class; + } + } + public boolean isCellEditable(int row, int col) { + Class columnClass = getColumnClass(col); + return columnClass != ImageIcon.class; + } + }; + table.setModel(tableModel); + + + updateRowHeights(); + } + //自动调整列高 + private void updateRowHeights() + { + for (int row = 0; row < table.getRowCount(); row++) + { + int rowHeight = table.getRowHeight(); + + for (int column = 0; column < table.getColumnCount(); column++) + { + Component comp = table.prepareRenderer(table.getCellRenderer(row, column), row, column); + rowHeight = Math.max(rowHeight, comp.getPreferredSize().height); + } + table.setRowHeight(row, rowHeight); + } + } + //将实体列表转换为表格实体 + public static Object[][] transferList(List list) { + Object[][] olist = new Object[list.size()][]; + for (int i = 0; i < list.size(); i++) { + Object str[] = {list.get(i).getId().toString(), list.get(i).getMingxiym(),list.get(i).getFashengriqiym(),list.get(i).getFashengfeiyongym(),list.get(i).getHuzhuym() }; + //如果包含图片格式则以图片形式显示 + for (int j = 0; j < str.length; j++) { + if(str[j]!=null&&(str[j].toString().contains("png")||str[j].toString().contains("jpg")||str[j].toString().contains("gif"))){ + str[j]=new ImageIcon(new ImageIcon(str[j].toString()).getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)); + } + } + olist[i] = str; + } + + return olist; + } + public JTable getTable() { + return table; + } + public String getMainid(){ + return mainid; + } +} diff --git a/project/src/view/ShouruqingkuangUpdateUI.java b/project/src/view/ShouruqingkuangUpdateUI.java new file mode 100644 index 0000000..6a3ea09 --- /dev/null +++ b/project/src/view/ShouruqingkuangUpdateUI.java @@ -0,0 +1,163 @@ +package view; + +import java.awt.Component; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +import com.eltima.components.ui.DatePicker; + +import dao.ShouruqingkuangDao; +import dao.ZhuhuDao; +import dao.impl.ShouruqingkuangImpl; +import dao.impl.ZhuhuImpl; +import entity.Shouruqingkuang; +import entity.Zhuhu; +public class ShouruqingkuangUpdateUI extends JFrame { + + private JPanel contentPane; + + + + ShouruqingkuangDao dao = new ShouruqingkuangImpl(); + ZhuhuDao zhuhuhuzhuymdao = new ZhuhuImpl(); + public ShouruqingkuangUpdateUI() { + init(null); + } + public ShouruqingkuangUpdateUI(Tableinter mui) { + init(mui); + } + public void init(Tableinter mui) { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 643, 646); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + Shouruqingkuang shouruqingkuang = dao.findById((String) mui.getTable().getValueAt(mui.getTable().getSelectedRow(), 0)); + JPanel panel = new BackgroundPanel(); + contentPane.add(panel); + panel.setLayout(new GridLayout(0, 2, 0, 0)); + JLabel idlabel = new JLabel("id"); + idlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(idlabel); + JTextField idtextField = new JTextField(shouruqingkuang.getId().toString()); + idtextField.setEnabled(false); + panel.add(idtextField); + JLabel mingxiymlabel = new JLabel("明细"); + mingxiymlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(mingxiymlabel); + JTextField mingxiymtextField = new JTextField(shouruqingkuang.getMingxiym()); + panel.add(mingxiymtextField); + + JLabel fashengriqiymlabel = new JLabel("发生日期"); + fashengriqiymlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(fashengriqiymlabel); + DatePicker fashengriqiymtextField = new DatePicker(this); + fashengriqiymtextField.setPattern("yyyy-MM-dd"); + fashengriqiymtextField.setTimePanleVisible(true); + fashengriqiymtextField.setEditorable(false); + try { + fashengriqiymtextField.setDate(new SimpleDateFormat("yyyy-MM-dd").parse(shouruqingkuang.getFashengriqiym())); + } catch (ParseException e1) { + e1.printStackTrace(); + } + panel.add(fashengriqiymtextField); + + JLabel fashengfeiyongymlabel = new JLabel("发生费用"); + fashengfeiyongymlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(fashengfeiyongymlabel); + JTextField fashengfeiyongymtextField = new JTextField(shouruqingkuang.getFashengfeiyongym()); + panel.add(fashengfeiyongymtextField); + + JLabel huzhuymlabel = new JLabel("户主"); + huzhuymlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(huzhuymlabel); + + JComboBox huzhuymcomboBox = new JComboBox(); + List zhuhuhuzhuymlist=zhuhuhuzhuymdao.findAll(); + huzhuymcomboBox.addItem(""); + for (int i = 0; i < zhuhuhuzhuymlist.size(); i++) { + huzhuymcomboBox.addItem(zhuhuhuzhuymlist.get(i).getHuzhudxy()); + } + huzhuymcomboBox.setSelectedItem(shouruqingkuang.getHuzhuym()); + panel.add(huzhuymcomboBox); + + + + panel.setBounds(10, 10, 607, 150); + JButton button = new JButton("修改"); + /** + 修改按钮触发事件 + */ + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + +Shouruqingkuang bean=new Shouruqingkuang(); + bean.setMingxiym(mingxiymtextField.getText()); + + bean.setFashengriqiym(fashengriqiymtextField.getText()); + + bean.setFashengfeiyongym(fashengfeiyongymtextField.getText()); + + if(huzhuymcomboBox.getSelectedItem()!=null){ + bean.setHuzhuym(huzhuymcomboBox.getSelectedItem().toString()); + }else{ + bean.setHuzhuym(""); + } + + bean.setId(Integer.valueOf(idtextField.getText())); + + + dao.modify(bean); + JOptionPane.showMessageDialog(null, "修改成功"); + //刷新主界面列表 + if(mui!=null) + mui.refresh(dao.findAll()); + dispose(); + } + }); + button.setFont(new Font("宋体", Font.PLAIN, 20)); + button.setBounds(173, 550, 93, 47); + contentPane.add(button); + + JButton button_1 = new JButton("取消"); + /** + 取消按钮触发事件 + */ + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + dispose(); + } + }); + button_1.setFont(new Font("宋体", Font.PLAIN, 20)); + button_1.setBounds(334, 550, 93, 47); + contentPane.add(button_1); + this.setLocationRelativeTo(null); + } + public String getRadioValue(JPanel panel){ + for(Component c:panel.getComponents()){ + if(c instanceof JRadioButton){ + if(((JRadioButton) c).isSelected()){ + return ((JRadioButton)c).getText(); + } + } + } + return ""; + } +} diff --git a/project/src/view/Tableinter.java b/project/src/view/Tableinter.java new file mode 100644 index 0000000..95c258d --- /dev/null +++ b/project/src/view/Tableinter.java @@ -0,0 +1,11 @@ +package view; + +import java.util.List; + +import javax.swing.JTable; + +public interface Tableinter { + public void refresh(List list); + public JTable getTable(); + public String getMainid(); +} diff --git a/project/src/view/ZhichuqingkuangAddUI.java b/project/src/view/ZhichuqingkuangAddUI.java new file mode 100644 index 0000000..e7c31b1 --- /dev/null +++ b/project/src/view/ZhichuqingkuangAddUI.java @@ -0,0 +1,141 @@ +package view; + +import java.awt.Component; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +import com.eltima.components.ui.DatePicker; + +import dao.ZhichuqingkuangDao; +import dao.ZhuhuDao; +import dao.impl.ZhichuqingkuangImpl; +import dao.impl.ZhuhuImpl; +import entity.Zhichuqingkuang; +import entity.Zhuhu; + +public class ZhichuqingkuangAddUI extends JFrame { + + private JPanel contentPane; + + ZhichuqingkuangDao dao = new ZhichuqingkuangImpl(); + ZhuhuDao zhuhuhuzhuhssdao = new ZhuhuImpl(); + public ZhichuqingkuangAddUI() { + init(null); + } + public ZhichuqingkuangAddUI(Tableinter mui) { + init(mui); + } + public void init(Tableinter mui) { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 643, 646); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + JPanel panel = new JPanel(); + contentPane.add(panel); + panel.setLayout(new GridLayout(0, 2, 0, 0)); + JLabel mingxihsslabel = new JLabel("明细"); + mingxihsslabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(mingxihsslabel); + JTextField mingxihsstextField = new JTextField(); + panel.add(mingxihsstextField); + + JLabel fashengriqihsslabel = new JLabel("发生日期"); + fashengriqihsslabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(fashengriqihsslabel); + DatePicker fashengriqihsstextField = new DatePicker(this); + fashengriqihsstextField.setPattern("yyyy-MM-dd"); + fashengriqihsstextField.setTimePanleVisible(true); + fashengriqihsstextField.setEditorable(false); + panel.add(fashengriqihsstextField); + + JLabel fashengfeiyonghsslabel = new JLabel("发生费用"); + fashengfeiyonghsslabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(fashengfeiyonghsslabel); + JTextField fashengfeiyonghsstextField = new JTextField(); + panel.add(fashengfeiyonghsstextField); + + JLabel huzhuhsslabel = new JLabel("户主"); + huzhuhsslabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(huzhuhsslabel); + + JComboBox huzhuhsscomboBox = new JComboBox(); + List zhuhuhuzhuhsslist=zhuhuhuzhuhssdao.findAll(); + huzhuhsscomboBox.addItem(""); + for (int i = 0; i < zhuhuhuzhuhsslist.size(); i++) { + huzhuhsscomboBox.addItem(zhuhuhuzhuhsslist.get(i).getHuzhudxy()); + } + panel.add(huzhuhsscomboBox); + + + + panel.setBounds(10, 10, 607, 120); + JButton button = new JButton("添加"); + /** + 新增按钮触发事件 + */ + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + Zhichuqingkuang bean=new Zhichuqingkuang(); + bean.setMingxihss(mingxihsstextField.getText()); + + bean.setFashengriqihss(fashengriqihsstextField.getText()); + + bean.setFashengfeiyonghss(fashengfeiyonghsstextField.getText()); + + if(huzhuhsscomboBox.getSelectedItem()!=null){ + bean.setHuzhuhss(huzhuhsscomboBox.getSelectedItem().toString()); + }else{ + bean.setHuzhuhss(""); + } + + + dao.create(bean); + JOptionPane.showMessageDialog(null, "添加成功"); + if(mui!=null) + mui.refresh(dao.findAll()); + dispose(); + } + }); + button.setFont(new Font("宋体", Font.PLAIN, 20)); + button.setBounds(173, 550, 93, 47); + contentPane.add(button); + + JButton button_1 = new JButton("取消"); + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + dispose(); + } + }); + button_1.setFont(new Font("宋体", Font.PLAIN, 20)); + button_1.setBounds(334, 550, 93, 47); + contentPane.add(button_1); + + this.setLocationRelativeTo(null); + } + public String getRadioValue(JPanel panel){ + for(Component c:panel.getComponents()){ + if(c instanceof JRadioButton){ + if(((JRadioButton) c).isSelected()){ + return ((JRadioButton)c).getText(); + } + } + } + return ""; + } +} diff --git a/project/src/view/ZhichuqingkuangManageUI.java b/project/src/view/ZhichuqingkuangManageUI.java new file mode 100644 index 0000000..7f34ccc --- /dev/null +++ b/project/src/view/ZhichuqingkuangManageUI.java @@ -0,0 +1,28 @@ +package view; + +import java.awt.BorderLayout; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; + +public class ZhichuqingkuangManageUI extends JFrame{ + + private JPanel contentPane; + + public static void main(String[] args) { + new ZhichuqingkuangManageUI().setVisible(true); + } + public ZhichuqingkuangManageUI() { + setTitle("支出情况管理"); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 879, 665); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(new BorderLayout(0, 0)); + add(new ZhichuqingkuangManageUIListPanel(""), BorderLayout.CENTER); + this.setLocationRelativeTo(null); + } + +} diff --git a/project/src/view/ZhichuqingkuangManageUIListPanel.java b/project/src/view/ZhichuqingkuangManageUIListPanel.java new file mode 100644 index 0000000..3af8649 --- /dev/null +++ b/project/src/view/ZhichuqingkuangManageUIListPanel.java @@ -0,0 +1,175 @@ +package view; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; +import java.util.Vector; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; + +import dao.ZhichuqingkuangDao; +import dao.ZhuhuDao; +import dao.impl.ZhichuqingkuangImpl; +import dao.impl.ZhuhuImpl; +import entity.Zhichuqingkuang; + +public class ZhichuqingkuangManageUIListPanel extends JPanel implements Tableinter{ + ZhichuqingkuangDao dao = new ZhichuqingkuangImpl(); + ZhuhuDao zhuhuhuzhuhssdao = new ZhuhuImpl(); + private JPanel contentPane; + + + + + + private static String[] columnCount = { "id","明细","发生日期","发生费用","户主" }; + public JTable table; + private static DefaultTableModel tableModel; + private String mainid; + + public ZhichuqingkuangManageUIListPanel(String mainid) { + this.mainid=mainid; + setLayout(new BorderLayout(0, 0)); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + contentPane.setLayout(new BorderLayout(0, 0)); + add(contentPane); + JScrollPane scrollPane = new JScrollPane(); + contentPane.add(scrollPane, BorderLayout.CENTER); + table = new JTable(); + scrollPane.setViewportView(table); + JPanel toppanel = new JPanel(); + contentPane.add(toppanel, BorderLayout.NORTH); + toppanel.setLayout(new GridLayout(2, 1, 0, 0)); + JPanel btnpanel = new JPanel(); + btnpanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); + toppanel.add(btnpanel); + + + JButton button = new JButton("添加"); + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + new ZhichuqingkuangAddUI(me()).setVisible(true); + } + }); + btnpanel.add(button); + + JButton button_1 = new JButton("删除"); + /** + 删除操作 + */ + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + int row = table.getSelectedRow(); + if (row == -1) { + JOptionPane.showMessageDialog(null, "请选择一行进行删除"); + return; + } + String keyvalue = (String) table.getValueAt(row, 0); + /** + 根据主键进行查询,如果查询到则删除 + */ + Zhichuqingkuang zx=new Zhichuqingkuang(); + zx.setId(Integer.valueOf(keyvalue)); + dao.remove(zx); + JOptionPane.showMessageDialog(null, "删除成功"); + refresh(dao.findAll()); + } + }); + btnpanel.add(button_1); + + JButton button_2 = new JButton("修改"); + /** + 修改操作 + */ + button_2.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + int row = table.getSelectedRow(); + if (row == -1) { + JOptionPane.showMessageDialog(null, "请选择一行进行修改"); + return; + } + //跳转到修改页面 + new ZhichuqingkuangUpdateUI(me()).setVisible(true); + } + + }); + btnpanel.add(button_2); + refresh(dao.findAll()); + } + public ZhichuqingkuangManageUIListPanel me(){ + return this; + } + //刷新表格列表 + public void refresh(List list){ + + + tableModel = new DefaultTableModel(transferList(list), columnCount){ + public Class getColumnClass(int column) { + Vector v = (Vector) dataVector.elementAt(0); + if(v.elementAt(column)!=null){ + return v.elementAt(column).getClass(); + }else{ + return String.class; + } + } + public boolean isCellEditable(int row, int col) { + Class columnClass = getColumnClass(col); + return columnClass != ImageIcon.class; + } + }; + table.setModel(tableModel); + + + updateRowHeights(); + } + //自动调整列高 + private void updateRowHeights() + { + for (int row = 0; row < table.getRowCount(); row++) + { + int rowHeight = table.getRowHeight(); + + for (int column = 0; column < table.getColumnCount(); column++) + { + Component comp = table.prepareRenderer(table.getCellRenderer(row, column), row, column); + rowHeight = Math.max(rowHeight, comp.getPreferredSize().height); + } + table.setRowHeight(row, rowHeight); + } + } + //将实体列表转换为表格实体 + public static Object[][] transferList(List list) { + Object[][] olist = new Object[list.size()][]; + for (int i = 0; i < list.size(); i++) { + Object str[] = {list.get(i).getId().toString(), list.get(i).getMingxihss(),list.get(i).getFashengriqihss(),list.get(i).getFashengfeiyonghss(),list.get(i).getHuzhuhss() }; + //如果包含图片格式则以图片形式显示 + for (int j = 0; j < str.length; j++) { + if(str[j]!=null&&(str[j].toString().contains("png")||str[j].toString().contains("jpg")||str[j].toString().contains("gif"))){ + str[j]=new ImageIcon(new ImageIcon(str[j].toString()).getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)); + } + } + olist[i] = str; + } + + return olist; + } + public JTable getTable() { + return table; + } + public String getMainid(){ + return mainid; + } +} diff --git a/project/src/view/ZhichuqingkuangUpdateUI.java b/project/src/view/ZhichuqingkuangUpdateUI.java new file mode 100644 index 0000000..14c94fc --- /dev/null +++ b/project/src/view/ZhichuqingkuangUpdateUI.java @@ -0,0 +1,163 @@ +package view; + +import java.awt.Component; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +import com.eltima.components.ui.DatePicker; + +import dao.ZhichuqingkuangDao; +import dao.ZhuhuDao; +import dao.impl.ZhichuqingkuangImpl; +import dao.impl.ZhuhuImpl; +import entity.Zhichuqingkuang; +import entity.Zhuhu; +public class ZhichuqingkuangUpdateUI extends JFrame { + + private JPanel contentPane; + + + + ZhichuqingkuangDao dao = new ZhichuqingkuangImpl(); + ZhuhuDao zhuhuhuzhuhssdao = new ZhuhuImpl(); + public ZhichuqingkuangUpdateUI() { + init(null); + } + public ZhichuqingkuangUpdateUI(Tableinter mui) { + init(mui); + } + public void init(Tableinter mui) { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 643, 646); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + Zhichuqingkuang zhichuqingkuang = dao.findById( (String) mui.getTable().getValueAt(mui.getTable().getSelectedRow(), 0)); + JPanel panel = new BackgroundPanel(); + contentPane.add(panel); + panel.setLayout(new GridLayout(0, 2, 0, 0)); + JLabel idlabel = new JLabel("id"); + idlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(idlabel); + JTextField idtextField = new JTextField(zhichuqingkuang.getId().toString()); + idtextField.setEnabled(false); + panel.add(idtextField); + JLabel mingxihsslabel = new JLabel("明细"); + mingxihsslabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(mingxihsslabel); + JTextField mingxihsstextField = new JTextField(zhichuqingkuang.getMingxihss()); + panel.add(mingxihsstextField); + + JLabel fashengriqihsslabel = new JLabel("发生日期"); + fashengriqihsslabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(fashengriqihsslabel); + DatePicker fashengriqihsstextField = new DatePicker(this); + fashengriqihsstextField.setPattern("yyyy-MM-dd"); + fashengriqihsstextField.setTimePanleVisible(true); + fashengriqihsstextField.setEditorable(false); + try { + fashengriqihsstextField.setDate(new SimpleDateFormat("yyyy-MM-dd").parse(zhichuqingkuang.getFashengriqihss())); + } catch (ParseException e1) { + e1.printStackTrace(); + } + panel.add(fashengriqihsstextField); + + JLabel fashengfeiyonghsslabel = new JLabel("发生费用"); + fashengfeiyonghsslabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(fashengfeiyonghsslabel); + JTextField fashengfeiyonghsstextField = new JTextField(zhichuqingkuang.getFashengfeiyonghss()); + panel.add(fashengfeiyonghsstextField); + + JLabel huzhuhsslabel = new JLabel("户主"); + huzhuhsslabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(huzhuhsslabel); + + JComboBox huzhuhsscomboBox = new JComboBox(); + List zhuhuhuzhuhsslist=zhuhuhuzhuhssdao.findAll(); + huzhuhsscomboBox.addItem(""); + for (int i = 0; i < zhuhuhuzhuhsslist.size(); i++) { + huzhuhsscomboBox.addItem(zhuhuhuzhuhsslist.get(i).getHuzhudxy()); + } + huzhuhsscomboBox.setSelectedItem(zhichuqingkuang.getHuzhuhss()); + panel.add(huzhuhsscomboBox); + + + + panel.setBounds(10, 10, 607, 150); + JButton button = new JButton("修改"); + /** + 修改按钮触发事件 + */ + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + +Zhichuqingkuang bean=new Zhichuqingkuang(); + bean.setMingxihss(mingxihsstextField.getText()); + + bean.setFashengriqihss(fashengriqihsstextField.getText()); + + bean.setFashengfeiyonghss(fashengfeiyonghsstextField.getText()); + + if(huzhuhsscomboBox.getSelectedItem()!=null){ + bean.setHuzhuhss(huzhuhsscomboBox.getSelectedItem().toString()); + }else{ + bean.setHuzhuhss(""); + } + + bean.setId(Integer.valueOf(idtextField.getText())); + + + dao.modify(bean); + JOptionPane.showMessageDialog(null, "修改成功"); + //刷新主界面列表 + if(mui!=null) + mui.refresh(dao.findAll()); + dispose(); + } + }); + button.setFont(new Font("宋体", Font.PLAIN, 20)); + button.setBounds(173, 550, 93, 47); + contentPane.add(button); + + JButton button_1 = new JButton("取消"); + /** + 取消按钮触发事件 + */ + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + dispose(); + } + }); + button_1.setFont(new Font("宋体", Font.PLAIN, 20)); + button_1.setBounds(334, 550, 93, 47); + contentPane.add(button_1); + this.setLocationRelativeTo(null); + } + public String getRadioValue(JPanel panel){ + for(Component c:panel.getComponents()){ + if(c instanceof JRadioButton){ + if(((JRadioButton) c).isSelected()){ + return ((JRadioButton)c).getText(); + } + } + } + return ""; + } +} diff --git a/project/src/view/ZhuhuAddUI.java b/project/src/view/ZhuhuAddUI.java new file mode 100644 index 0000000..1ac4bff --- /dev/null +++ b/project/src/view/ZhuhuAddUI.java @@ -0,0 +1,112 @@ +package view; + +import java.awt.Component; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +import dao.ZhuhuDao; +import dao.impl.ZhuhuImpl; +import entity.Zhuhu; + + +public class ZhuhuAddUI extends JFrame { + + private JPanel contentPane; + ZhuhuDao dao = new ZhuhuImpl(); + public ZhuhuAddUI() { + init(null); + } + public ZhuhuAddUI(Tableinter mui) { + init(mui); + } + public void init(Tableinter mui) { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 643, 646); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + JPanel panel = new JPanel(); + contentPane.add(panel); + panel.setLayout(new GridLayout(0, 2, 0, 0)); + JLabel huzhudxylabel = new JLabel("户主"); + huzhudxylabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(huzhudxylabel); + JTextField huzhudxytextField = new JTextField(); + panel.add(huzhudxytextField); + + JLabel dizhidxylabel = new JLabel("地址"); + dizhidxylabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(dizhidxylabel); + JTextField dizhidxytextField = new JTextField(); + panel.add(dizhidxytextField); + + JLabel lianxidianhuadxylabel = new JLabel("联系电话"); + lianxidianhuadxylabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(lianxidianhuadxylabel); + JTextField lianxidianhuadxytextField = new JTextField(); + panel.add(lianxidianhuadxytextField); + + + + panel.setBounds(10, 10, 607, 90); + JButton button = new JButton("添加"); + /** + 新增按钮触发事件 + */ + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + Zhuhu bean=new Zhuhu(); + bean.setHuzhudxy(huzhudxytextField.getText()); + + bean.setDizhidxy(dizhidxytextField.getText()); + + bean.setLianxidianhuadxy(lianxidianhuadxytextField.getText()); + + + dao.create(bean); + JOptionPane.showMessageDialog(null, "添加成功"); + if(mui!=null) + mui.refresh(dao.findAll()); + dispose(); + } + }); + button.setFont(new Font("宋体", Font.PLAIN, 20)); + button.setBounds(173, 550, 93, 47); + contentPane.add(button); + + JButton button_1 = new JButton("取消"); + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + dispose(); + } + }); + button_1.setFont(new Font("宋体", Font.PLAIN, 20)); + button_1.setBounds(334, 550, 93, 47); + contentPane.add(button_1); + + this.setLocationRelativeTo(null); + } + public String getRadioValue(JPanel panel){ + for(Component c:panel.getComponents()){ + if(c instanceof JRadioButton){ + if(((JRadioButton) c).isSelected()){ + return ((JRadioButton)c).getText(); + } + } + } + return ""; + } +} diff --git a/project/src/view/ZhuhuManageUI.java b/project/src/view/ZhuhuManageUI.java new file mode 100644 index 0000000..7b74180 --- /dev/null +++ b/project/src/view/ZhuhuManageUI.java @@ -0,0 +1,28 @@ +package view; + +import java.awt.BorderLayout; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; + +public class ZhuhuManageUI extends JFrame{ + + private JPanel contentPane; + + public static void main(String[] args) { + new ZhuhuManageUI().setVisible(true); + } + public ZhuhuManageUI() { + setTitle("住户管理"); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 879, 665); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(new BorderLayout(0, 0)); + add(new ZhuhuManageUIListPanel(""), BorderLayout.CENTER); + this.setLocationRelativeTo(null); + } + +} diff --git a/project/src/view/ZhuhuManageUIListPanel.java b/project/src/view/ZhuhuManageUIListPanel.java new file mode 100644 index 0000000..1675837 --- /dev/null +++ b/project/src/view/ZhuhuManageUIListPanel.java @@ -0,0 +1,172 @@ +package view; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; +import java.util.Vector; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; + +import dao.ZhuhuDao; +import dao.impl.ZhuhuImpl; +import entity.Zhuhu; + +public class ZhuhuManageUIListPanel extends JPanel implements Tableinter{ + ZhuhuDao dao = new ZhuhuImpl(); + private JPanel contentPane; + + + + + private static String[] columnCount = { "id","户主","地址","联系电话" }; + public JTable table; + private static DefaultTableModel tableModel; + private String mainid; + + public ZhuhuManageUIListPanel(String mainid) { + this.mainid=mainid; + setLayout(new BorderLayout(0, 0)); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + contentPane.setLayout(new BorderLayout(0, 0)); + add(contentPane); + JScrollPane scrollPane = new JScrollPane(); + contentPane.add(scrollPane, BorderLayout.CENTER); + table = new JTable(); + scrollPane.setViewportView(table); + JPanel toppanel = new JPanel(); + contentPane.add(toppanel, BorderLayout.NORTH); + toppanel.setLayout(new GridLayout(2, 1, 0, 0)); + JPanel btnpanel = new JPanel(); + btnpanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); + toppanel.add(btnpanel); + + + JButton button = new JButton("添加"); + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + new ZhuhuAddUI(me()).setVisible(true); + } + }); + btnpanel.add(button); + + JButton button_1 = new JButton("删除"); + /** + 删除操作 + */ + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + int row = table.getSelectedRow(); + if (row == -1) { + JOptionPane.showMessageDialog(null, "请选择一行进行删除"); + return; + } + String keyvalue = (String) table.getValueAt(row, 0); + /** + 根据主键进行查询,如果查询到则删除 + */ + Zhuhu zh=new Zhuhu(); + zh.setId(Integer.valueOf(keyvalue)); + dao.remove(zh); + JOptionPane.showMessageDialog(null, "删除成功"); + refresh(dao.findAll()); + } + }); + btnpanel.add(button_1); + + JButton button_2 = new JButton("修改"); + /** + 修改操作 + */ + button_2.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + int row = table.getSelectedRow(); + if (row == -1) { + JOptionPane.showMessageDialog(null, "请选择一行进行修改"); + return; + } + //跳转到修改页面 + new ZhuhuUpdateUI(me()).setVisible(true); + } + + }); + btnpanel.add(button_2); + System.out.println(dao.findAll().size()); + refresh(dao.findAll()); + } + public ZhuhuManageUIListPanel me(){ + return this; + } + //刷新表格列表 + public void refresh(List list){ + + + tableModel = new DefaultTableModel(transferList(list), columnCount){ + public Class getColumnClass(int column) { + Vector v = (Vector) dataVector.elementAt(0); + if(v.elementAt(column)!=null){ + return v.elementAt(column).getClass(); + }else{ + return String.class; + } + } + public boolean isCellEditable(int row, int col) { + Class columnClass = getColumnClass(col); + return columnClass != ImageIcon.class; + } + }; + table.setModel(tableModel); + + + updateRowHeights(); + } + //自动调整列高 + private void updateRowHeights() + { + for (int row = 0; row < table.getRowCount(); row++) + { + int rowHeight = table.getRowHeight(); + + for (int column = 0; column < table.getColumnCount(); column++) + { + Component comp = table.prepareRenderer(table.getCellRenderer(row, column), row, column); + rowHeight = Math.max(rowHeight, comp.getPreferredSize().height); + } + table.setRowHeight(row, rowHeight); + } + } + //将实体列表转换为表格实体 + public static Object[][] transferList(List list) { + Object[][] olist = new Object[list.size()][]; + for (int i = 0; i < list.size(); i++) { + Object str[] = {list.get(i).getId().toString(), list.get(i).getHuzhudxy(),list.get(i).getDizhidxy(),list.get(i).getLianxidianhuadxy() }; + //如果包含图片格式则以图片形式显示 + for (int j = 0; j < str.length; j++) { + if(str[j]!=null&&(str[j].toString().contains("png")||str[j].toString().contains("jpg")||str[j].toString().contains("gif"))){ + str[j]=new ImageIcon(new ImageIcon(str[j].toString()).getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)); + } + } + olist[i] = str; + } + + return olist; + } + public JTable getTable() { + return table; + } + public String getMainid(){ + return mainid; + } +} diff --git a/project/src/view/ZhuhuUpdateUI.java b/project/src/view/ZhuhuUpdateUI.java new file mode 100644 index 0000000..52b1057 --- /dev/null +++ b/project/src/view/ZhuhuUpdateUI.java @@ -0,0 +1,126 @@ +package view; + +import java.awt.Component; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; + +import dao.ZhuhuDao; +import dao.impl.ZhuhuImpl; +import entity.Zhuhu; +public class ZhuhuUpdateUI extends JFrame { + + private JPanel contentPane; + + + + ZhuhuDao dao = new ZhuhuImpl(); + public ZhuhuUpdateUI() { + init(null); + } + public ZhuhuUpdateUI(Tableinter mui) { + init(mui); + } + public void init(Tableinter mui) { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 643, 646); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + Zhuhu zhuhu = dao.findById((String) mui.getTable().getValueAt(mui.getTable().getSelectedRow(), 0)); + JPanel panel = new BackgroundPanel(); + contentPane.add(panel); + panel.setLayout(new GridLayout(0, 2, 0, 0)); + JLabel idlabel = new JLabel("id"); + idlabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(idlabel); + JTextField idtextField = new JTextField(zhuhu.getId().toString()); + idtextField.setEnabled(false); + panel.add(idtextField); + JLabel huzhudxylabel = new JLabel("户主"); + huzhudxylabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(huzhudxylabel); + JTextField huzhudxytextField = new JTextField(zhuhu.getHuzhudxy()); + panel.add(huzhudxytextField); + + JLabel dizhidxylabel = new JLabel("地址"); + dizhidxylabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(dizhidxylabel); + JTextField dizhidxytextField = new JTextField(zhuhu.getDizhidxy()); + panel.add(dizhidxytextField); + + JLabel lianxidianhuadxylabel = new JLabel("联系电话"); + lianxidianhuadxylabel.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(lianxidianhuadxylabel); + JTextField lianxidianhuadxytextField = new JTextField(zhuhu.getLianxidianhuadxy()); + panel.add(lianxidianhuadxytextField); + + + + panel.setBounds(10, 10, 607, 120); + JButton button = new JButton("修改"); + /** + 修改按钮触发事件 + */ + button.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + +Zhuhu bean=new Zhuhu(); + bean.setHuzhudxy(huzhudxytextField.getText()); + + bean.setDizhidxy(dizhidxytextField.getText()); + + bean.setLianxidianhuadxy(lianxidianhuadxytextField.getText()); + + bean.setId(Integer.valueOf(idtextField.getText())); + + + dao.modify(bean); + JOptionPane.showMessageDialog(null, "修改成功"); + //刷新主界面列表 + if(mui!=null) + mui.refresh(dao.findAll()); + dispose(); + } + }); + button.setFont(new Font("宋体", Font.PLAIN, 20)); + button.setBounds(173, 550, 93, 47); + contentPane.add(button); + + JButton button_1 = new JButton("取消"); + /** + 取消按钮触发事件 + */ + button_1.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + dispose(); + } + }); + button_1.setFont(new Font("宋体", Font.PLAIN, 20)); + button_1.setBounds(334, 550, 93, 47); + contentPane.add(button_1); + this.setLocationRelativeTo(null); + } + public String getRadioValue(JPanel panel){ + for(Component c:panel.getComponents()){ + if(c instanceof JRadioButton){ + if(((JRadioButton) c).isSelected()){ + return ((JRadioButton)c).getText(); + } + } + } + return ""; + } +}