基于Java swing+mysql+eclipse的【水电费管理系统】

基于Java swing+mysql+eclipse的【水电费管理系统】本项目为前几天收费帮学妹做的一个项目,Javaswing项目,在工作环境中基本使用不到,但是很多学校把这个当做编程入门的项目来做,故分享出本项目供初学者参考。CSDN9.9赞助下载:https://download.csdn.net/download/weixin_44893902/20545860白嫖:加QQ68872185一、效果演示主要功能:普通用户:用户用水用电查询(根据时间查询、导出Excel)管理员用户:用户信息管理>>平台用户信息查询(修改信.

大家好,又见面了,我是你们的朋友全栈君。

本项目为前几天收费帮学妹做的一个项目,Java swing项目,在工作环境中基本使用不到,但是很多学校把这个当做编程入门的项目来做,故分享出本项目供初学者参考。

CSDN9.9赞助下载: https://download.csdn.net/download/weixin_44893902/50635859

一、效果演示

主要功能:

普通用户:

  • 用户用水用电查询(根据时间查询、导出Excel)

管理员用户:

  • 用户信息管理 >> 平台用户信息查询(修改信息、新增用户、删除用户、根据编号查询)
  • 水电费管理 >> 用户水电费查询 (修改信息、新增用户、删除用户、根据日期查询、根据户主编号查询、导出数据到Excel)
  • 管理员账户管理 >> 管理后台(管理员添加、删除、修改、编号账户查询)

1、用户登录

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2、“普通用户” 主界面

2.1 用户水电费查询

在这里插入图片描述

3、“管理员用户” 界面

在这里插入图片描述

3.1 用户信息管理

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

3.2 水电费管理

在这里插入图片描述

3.3 管理员账户管理

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4、导出功能

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

二、核心代码

(1)数据库【utilitiessys】:

在这里插入图片描述

① admin(管理员表)

-- ----------------------------
-- Table structure for admin
-- ----------------------------
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin`  (
  `id` int(30) NOT NULL AUTO_INCREMENT COMMENT '编号',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '姓名',
  `account` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '账户',
  `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of admin
-- ----------------------------
INSERT INTO `admin` VALUES (1, '杨明金', 'ymj', '123456');
INSERT INTO `admin` VALUES (2, '肖波', 'xb', '123123');

② feeinfo(收费信息表)


-- ----------------------------
-- Table structure for feeinfo
-- ----------------------------
DROP TABLE IF EXISTS `feeinfo`;
CREATE TABLE `feeinfo`  (
  `id` int(30) NOT NULL AUTO_INCREMENT COMMENT '订单号',
  `userid` int(30) NULL DEFAULT NULL COMMENT '户主id',
  `watertype` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用水类型',
  `water` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '水费单价',
  `watersum` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用水总量',
  `monthwater` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '本月水费',
  `electricitytype` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用电类型',
  `electricity` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电费单价',
  `electricitysum` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用电总量',
  `monthelectricity` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '本月电费',
  `years` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '年份',
  `month` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '月份',
  `cost` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '总费用',
  `costime` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '收费时间',
  `adminid` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作员',
  `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 41 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of feeinfo
-- ----------------------------
INSERT INTO `feeinfo` VALUES (1, 1, '商业用电', '20', '50', '200', '商业用电', '30', '500', '200', '2021年', '3月', '300', '4000', '杨明金', '备注');
INSERT INTO `feeinfo` VALUES (2, 1, '家庭用电', '20', '50', '200', '家庭用电', '20', '20', '20', '2021年', '5月', '300', '2000', 'mj', '背后');
INSERT INTO `feeinfo` VALUES (3, 3, '居民家庭用水', '20', '50', '200', '一般工商业用电', '30', '500', '200', '2021年', '3月', '300', '4000', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (4, 4, '城市居民家庭用水', '20', '50', '200', '一般工商业用电', '20', '20', '20', '2021年', '5月', '300', '2000', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (5, 5, '农民家庭用水', '21', '51', '201', '家庭用电', '21', '21', '21', '2021年', '6月', '301', '2001', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (6, 6, '公共供水站用水', '22', '52', '202', '一般工商业用电', '22', '22', '22', '2019年', '7月', '302', '2002', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (7, 7, '公共服务用水', '23', '53', '203', '居民生活用电', '23', '23', '23', '2021年', '8月', '303', '2003', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (8, 8, '公共设施服务用水', '24', '54', '204', '大工业用电', '24', '24', '24', '2019年', '9月', '304', '2004', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (9, 9, '社会服务业用水', '25', '55', '205', '一般工商业用电', '25', '25', '25', '2021年', '10月', '305', '2005', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (10, 10, '批发和零售贸易业用水', '26', '56', '206', '一般工商业用电', '26', '26', '26', '2019年', '11月', '306', '2006', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (11, 11, '餐饮业、旅馆业用水', '27', '57', '207', '居民生活用电', '27', '27', '27', '2019年', '12月', '307', '2007', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (12, 12, '卫生事业用水', '28', '58', '208', '大工业用电', '28', '28', '28', '2021年', '3月', '308', '2008', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (13, 13, '文娱体育事业、文艺广电业用水', '29', '59', '209', '居民生活用电', '29', '29', '29', '2019年', '5月', '309', '2009', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (14, 14, '教育事业用水', '30', '60', '210', '大工业用电', '30', '30', '30', '2021年', '5月', '310', '2010', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (15, 15, '科学研究和综合技术服务业用水', '31', '61', '211', '大工业用电', '31', '31', '31', '2021年', '6月', '311', '2011', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (16, 16, '社会福利保障业用水', '32', '62', '212', '大工业用电', '32', '32', '32', '2019年', '5月', '312', '2012', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (17, 17, '金融、保险、房地产业用水', '33', '63', '213', '商业用电', '33', '33', '33', '2021年', '8月', '313', '2013', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (18, 18, '机关、企事业管理机构和社会团体用水', '34', '64', '214', '居民生活用电', '34', '34', '34', '2021年', '9月', '314', '2014', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (19, 19, '其他公共服务用水', '35', '65', '215', '居民生活用电', '35', '35', '35', '2021年', '5月', '315', '2015', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (20, 20, '生产运营用水', '36', '66', '216', '商业用电', '36', '36', '36', '2019年', '2月', '316', '2016', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (21, 21, '农、林、牧、渔业用水', '37', '67', '217', '农业生产用电', '37', '37', '37', '2021年', '5月', '317', '2017', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (22, 22, '采掘业用水', '38', '68', '218', '农业生产用电', '38', '38', '38', '2021年', '12月', '318', '2018', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (23, 23, '家庭用电', '39', '69', '219', '农业生产用电', '39', '39', '39', '2021年', '12月', '319', '2019', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (24, 24, '家庭用电', '40', '70', '220', '居民生活用电', '40', '40', '40', '2021年', '5月', '320', '2020', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (25, 25, '家庭用电', '41', '71', '221', '农业生产用电', '41', '41', '41', '2021年', '1月', '321', '2021', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (26, 26, '家庭用电', '42', '72', '222', '农业生产用电', '42', '42', '42', '2021年', '2月', '322', '2022', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (27, 27, '家庭用电', '43', '73', '223', '居民生活用电', '43', '43', '43', '2021年', '5月', '323', '2023', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (28, 1, '居民家庭用水', '20', '50', '200', '一般工商业用电', '30', '500', '200', '2021年', '3月', '300', '4000', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (29, 1, '城市居民家庭用水', '20', '50', '200', '一般工商业用电', '20', '20', '20', '2021年', '5月', '300', '2000', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (30, 1, '农民家庭用水', '21', '51', '201', '家庭用电', '21', '21', '21', '2021年', '6月', '301', '2001', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (31, 1, '公共供水站用水', '22', '52', '202', '一般工商业用电', '22', '22', '22', '2019年', '7月', '302', '2002', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (32, 1, '公共服务用水', '23', '53', '203', '居民生活用电', '23', '23', '23', '2021年', '8月', '303', '2003', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (33, 1, '公共设施服务用水', '24', '54', '204', '大工业用电', '24', '24', '24', '2019年', '9月', '304', '2004', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (34, 1, '社会服务业用水', '25', '55', '205', '一般工商业用电', '25', '25', '25', '2021年', '10月', '305', '2005', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (35, 1, '批发和零售贸易业用水', '26', '56', '206', '一般工商业用电', '26', '26', '26', '2019年', '11月', '306', '2006', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (36, 1, '餐饮业、旅馆业用水', '27', '57', '207', '居民生活用电', '27', '27', '27', '2019年', '12月', '307', '2007', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (37, 1, '卫生事业用水', '28', '58', '208', '大工业用电', '28', '28', '28', '2021年', '3月', '308', '2008', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (39, 1, '教育事业用水', '30', '60', '210', '大工业用电', '30', '30', '30', '2021年', '5月', '310', '2010', '杨明金', '已缴纳');
INSERT INTO `feeinfo` VALUES (40, 1, '科学研究和综合技术服务业用水', '31', '61', '211', '大工业用电', '31', '31', '31', '2021年', '6月', '311', '2011', '杨明金', '已缴纳');

③ users(用户表)


-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users`  (
  `id` int(30) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '户主姓名',
  `account` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '账户',
  `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',
  `sex` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '性别',
  `idcard` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '身份证号码',
  `phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电话号码',
  `address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '居住地址',
  `usertime` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 28 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of users
-- ----------------------------
INSERT INTO `users` VALUES (1, '杨明金', 'ymj', '123456', '女', '5323456', '1886454551', '云南昆明22', '22');
INSERT INTO `users` VALUES (2, '李华', 'lh', '123123', '女', '5653464', '656564555', '河北', '200');
INSERT INTO `users` VALUES (3, '董志豪', 'dzh', '123456', '男', '532123200103060023', '18214211253', '云南省昆明市五华区茭菱路128号', '20210701');
INSERT INTO `users` VALUES (4, '曾跃', 'cy', '123456', '女', '532123200103060023', '18214211254', '云南省昆明市五华区茭菱路129号', '20210702');
INSERT INTO `users` VALUES (5, '崔任松', 'crs', '123456', '男', '532123200103060023', '18214211255', '云南省昆明市五华区茭菱路130号', '20210703');
INSERT INTO `users` VALUES (6, '赵驰', 'zc', '123456', '女', '532123200103060023', '18214211256', '云南省昆明市五华区茭菱路131号', '20210704');
INSERT INTO `users` VALUES (7, '余靖', 'yj', '123456', '男', '532123200103060023', '18214211257', '云南省昆明市五华区茭菱路132号', '20210705');
INSERT INTO `users` VALUES (8, '李银娇', 'lyj', '123456', '男', '532123200103060023', '18214211258', '云南省昆明市五华区茭菱路133号', '20210706');
INSERT INTO `users` VALUES (9, '杨志兴', 'yzx', '123456', '男', '532123200103060023', '18214211259', '云南省昆明市五华区茭菱路134号', '20210707');
INSERT INTO `users` VALUES (10, '许应烨', 'xyy', '123456', '女', '532123200103060023', '18214211260', '云南省昆明市五华区茭菱路135号', '20210708');
INSERT INTO `users` VALUES (11, '何鸿廷', 'hht', '123456', '男', '532123200103060023', '18214211261', '云南省昆明市五华区茭菱路136号', '20210709');
INSERT INTO `users` VALUES (12, '郭超', 'gc', '123456', '男', '532123200103060023', '18214211262', '云南省昆明市五华区茭菱路137号', '20210710');
INSERT INTO `users` VALUES (13, '夏明方', 'xmf', '123456', '男', '532123200103060023', '18214211263', '云南省昆明市五华区茭菱路138号', '20210711');
INSERT INTO `users` VALUES (14, '杜顺昌', 'dsc', '123456', '女', '532123200103060023', '18214211264', '云南省昆明市五华区茭菱路139号', '20210712');
INSERT INTO `users` VALUES (15, '杨雄美', 'yxm', '123456', '男', '532123200103060023', '18214211265', '云南省昆明市五华区茭菱路140号', '20210713');
INSERT INTO `users` VALUES (16, '杨金明', 'yjm', '123456', '男', '532123200103060023', '18214211266', '云南省昆明市五华区茭菱路141号', '20210714');
INSERT INTO `users` VALUES (17, '李骥', 'lj', '123456', '男', '532123200103060023', '18214211267', '云南省昆明市五华区茭菱路142号', '20210715');
INSERT INTO `users` VALUES (18, '严卓琳', 'yzl', '123456', '女', '532123200103060023', '18214211268', '云南省昆明市五华区茭菱路143号', '20210716');
INSERT INTO `users` VALUES (19, '宋廷虎', 'sth', '123456', '女', '532123200103060023', '18214211269', '云南省昆明市五华区茭菱路144号', '20210717');
INSERT INTO `users` VALUES (20, '马士颖', 'msy', '123456', '男', '532123200103060023', '18214211270', '云南省昆明市五华区茭菱路145号', '20210718');
INSERT INTO `users` VALUES (21, '陆振黎', 'lzl', '123456', '女', '532123200103060023', '18214211271', '云南省昆明市五华区茭菱路146号', '20210719');
INSERT INTO `users` VALUES (22, '何忠礼', 'hzl', '123456', '男', '532123200103060023', '18214211272', '云南省昆明市五华区茭菱路147号', '20210720');
INSERT INTO `users` VALUES (23, '毕猛', 'bm', '123456', '女', '532123200103060023', '18214211273', '云南省昆明市五华区茭菱路148号', '20210721');
INSERT INTO `users` VALUES (24, '李映权', 'lyq', '123456', '女', '532123200103060023', '18214211274', '云南省昆明市五华区茭菱路149号', '20210722');
INSERT INTO `users` VALUES (25, '王明炜', 'wmw', '123456', '男', '532123200103060023', '18214211275', '云南省昆明市五华区茭菱路150号', '20210723');
INSERT INTO `users` VALUES (26, '周子龙', 'zzl', '123456', '女', '532123200103060023', '18214211276', '云南省昆明市五华区茭菱路151号', '20210724');
INSERT INTO `users` VALUES (27, '方晨晓', 'fcx', '123456', '男', '532123200103060023', '18214211277', '云南省昆明市五华区茭菱路152号', '20210725');

(2)JAVA:

在这里插入图片描述

1、Bean包【存放实体包】

① Admin(管理员类)

package com.ynavc.Bean;

import java.io.Serializable;

/** * @description admin * @author ymjin.blog.csdn.net/ * @date 2021-07-01 */
public class Admin implements Serializable { 
   

    private static final long serialVersionUID = 1L;

    /** * 编号 */
    private Integer id;

    /** * 姓名 */
    private String name;

    /** * 账户 */
    private String account;

    /** * 密码 */
    private String password;
    
    public Integer getId() { 
   
		return id;
	}

	public void setId(Integer id) { 
   
		this.id = id;
	}

	public String getName() { 
   
		return name;
	}

	public void setName(String name) { 
   
		this.name = name;
	}

	public String getAccount() { 
   
		return account;
	}

	public void setAccount(String account) { 
   
		this.account = account;
	}

	public String getPassword() { 
   
		return password;
	}

	public void setPassword(String password) { 
   
		this.password = password;
	}

	public static long getSerialversionuid() { 
   
		return serialVersionUID;
	}

	public Admin() { 
   }

	public Admin(Integer id, String name, String account, String password) { 
   
		super();
		this.id = id;
		this.name = name;
		this.account = account;
		this.password = password;
	}

	@Override
	public String toString() { 
   
		return "Admin [id=" + id + ", name=" + name + ", account=" + account + ", password=" + password + "]";
	}
	
}

② Feeinfo(收费信息类)

package com.ynavc.Bean;

import java.io.Serializable;

/** * @description feeinfo * @author ymjin.blog.csdn.net/ * @date 2021-07-01 */
public class Feeinfo implements Serializable { 
   

    private static final long serialVersionUID = 1L;

    /** * 订单号 */
    private Integer id;

    /** * 户主id */
    private Integer userid;

    /** * 用水类型 */
    private String watertype;

    /** * 水费单价 */
    private String water;

    /** * 用水总量 */
    private String watersum;

    /** * 本月水费 */
    private String monthwater;

    /** * 用电类型 */
    private String electricitytype;

    /** * 电费单价 */
    private String electricity;

    /** * 用电总量 */
    private String electricitysum;

    /** * 本月电费 */
    private String monthelectricity;

    /** * 年份 */
    private String years;

    /** * 月份 */
    private String month;

    /** * 总费用 */
    private String cost;

    /** * 收费时间 */
    private String costime;

    /** * 操作员 */
    private String adminid;

    /** * 备注 */
    private String note;

    public Feeinfo() { 
   }

	public Feeinfo(Integer id, Integer userid, String watertype, String water, String watersum, String monthwater,
			String electricitytype, String electricity, String electricitysum, String monthelectricity, String years,
			String month, String cost, String costime, String adminid, String note) { 
   
		super();
		this.id = id;
		this.userid = userid;
		this.watertype = watertype;
		this.water = water;
		this.watersum = watersum;
		this.monthwater = monthwater;
		this.electricitytype = electricitytype;
		this.electricity = electricity;
		this.electricitysum = electricitysum;
		this.monthelectricity = monthelectricity;
		this.years = years;
		this.month = month;
		this.cost = cost;
		this.costime = costime;
		this.adminid = adminid;
		this.note = note;
	}

	@Override
	public String toString() { 
   
		return "Feeinfo [id=" + id + ", userid=" + userid + ", watertype=" + watertype + ", water=" + water
				+ ", watersum=" + watersum + ", monthwater=" + monthwater + ", electricitytype=" + electricitytype
				+ ", electricity=" + electricity + ", electricitysum=" + electricitysum + ", monthelectricity="
				+ monthelectricity + ", years=" + years + ", month=" + month + ", cost=" + cost + ", costime=" + costime
				+ ", adminid=" + adminid + ", note=" + note + "]";
	}

	public Integer getId() { 
   
		return id;
	}

	public void setId(Integer id) { 
   
		this.id = id;
	}

	public Integer getUserid() { 
   
		return userid;
	}

	public void setUserid(Integer userid) { 
   
		this.userid = userid;
	}

	public String getWatertype() { 
   
		return watertype;
	}

	public void setWatertype(String watertype) { 
   
		this.watertype = watertype;
	}

	public String getWater() { 
   
		return water;
	}

	public void setWater(String water) { 
   
		this.water = water;
	}

	public String getWatersum() { 
   
		return watersum;
	}

	public void setWatersum(String watersum) { 
   
		this.watersum = watersum;
	}

	public String getMonthwater() { 
   
		return monthwater;
	}

	public void setMonthwater(String monthwater) { 
   
		this.monthwater = monthwater;
	}

	public String getElectricitytype() { 
   
		return electricitytype;
	}

	public void setElectricitytype(String electricitytype) { 
   
		this.electricitytype = electricitytype;
	}

	public String getElectricity() { 
   
		return electricity;
	}

	public void setElectricity(String electricity) { 
   
		this.electricity = electricity;
	}

	public String getElectricitysum() { 
   
		return electricitysum;
	}

	public void setElectricitysum(String electricitysum) { 
   
		this.electricitysum = electricitysum;
	}

	public String getMonthelectricity() { 
   
		return monthelectricity;
	}

	public void setMonthelectricity(String monthelectricity) { 
   
		this.monthelectricity = monthelectricity;
	}

	public String getYears() { 
   
		return years;
	}

	public void setYears(String years) { 
   
		this.years = years;
	}

	public String getMonth() { 
   
		return month;
	}

	public void setMonth(String month) { 
   
		this.month = month;
	}

	public String getCost() { 
   
		return cost;
	}

	public void setCost(String cost) { 
   
		this.cost = cost;
	}

	public String getCostime() { 
   
		return costime;
	}

	public void setCostime(String costime) { 
   
		this.costime = costime;
	}

	public String getAdminid() { 
   
		return adminid;
	}

	public void setAdminid(String adminid) { 
   
		this.adminid = adminid;
	}

	public String getNote() { 
   
		return note;
	}

	public void setNote(String note) { 
   
		this.note = note;
	}
    
    
}

③ Feeinfo(收费信息实现类)

package com.ynavc.Bean;

import java.io.Serializable;

/** * @description feeinfo * @author ymjin.blog.csdn.net/ * @date 2021-07-01 */
public class FeeinfoImp implements Serializable { 
   

    private static final long serialVersionUID = 1L;

    /** * 订单号 */
    private Integer id;

    /** * 户主id */
    private Integer userid;

    /** /** * 户主姓名 */
    private String userName;
    
    /** * 用水类型 */
    private String watertype;

    /** * 水费单价 */
    private String water;

    /** * 用水总量 */
    private String watersum;

    /** * 本月水费 */
    private String monthwater;

    /** * 用电类型 */
    private String electricitytype;

    /** * 电费单价 */
    private String electricity;

    /** * 用电总量 */
    private String electricitysum;

    /** * 本月电费 */
    private String monthelectricity;

    /** * 年份 */
    private String years;

    /** * 月份 */
    private String month;

    /** * 总费用 */
    private String cost;

    /** * 收费时间 */
    private String costime;

    /** * 操作员 */
    private String adminid;

    /** * 备注 */
    private String note;

	@Override
	public String toString() { 
   
		return "FeeinfoImp [id=" + id + ", userid=" + userid + ", userName=" + userName + ", watertype=" + watertype
				+ ", water=" + water + ", watersum=" + watersum + ", monthwater=" + monthwater + ", electricitytype="
				+ electricitytype + ", electricity=" + electricity + ", electricitysum=" + electricitysum
				+ ", monthelectricity=" + monthelectricity + ", years=" + years + ", month=" + month + ", cost=" + cost
				+ ", costime=" + costime + ", adminid=" + adminid + ", note=" + note + "]";
	}

	public FeeinfoImp() { 
   
		super();
	}

	public FeeinfoImp(Integer id, Integer userid, String usename, String watertype, String water, String watersum,
			String monthwater, String electricitytype, String electricity, String electricitysum,
			String monthelectricity, String years, String month, String cost, String costime, String adminid,
			String note) { 
   
		super();
		this.id = id;
		this.userid = userid;
		this.userName = usename;
		this.watertype = watertype;
		this.water = water;
		this.watersum = watersum;
		this.monthwater = monthwater;
		this.electricitytype = electricitytype;
		this.electricity = electricity;
		this.electricitysum = electricitysum;
		this.monthelectricity = monthelectricity;
		this.years = years;
		this.month = month;
		this.cost = cost;
		this.costime = costime;
		this.adminid = adminid;
		this.note = note;
	}

	public Integer getId() { 
   
		return id;
	}

	public void setId(Integer id) { 
   
		this.id = id;
	}

	public Integer getUserid() { 
   
		return userid;
	}

	public void setUserid(Integer userid) { 
   
		this.userid = userid;
	}

	public String getUserName() { 
   
		return userName;
	}

	public void setUserName(String userName) { 
   
		this.userName = userName;
	}

	public String getWatertype() { 
   
		return watertype;
	}

	public void setWatertype(String watertype) { 
   
		this.watertype = watertype;
	}

	public String getWater() { 
   
		return water;
	}

	public void setWater(String water) { 
   
		this.water = water;
	}

	public String getWatersum() { 
   
		return watersum;
	}

	public void setWatersum(String watersum) { 
   
		this.watersum = watersum;
	}

	public String getMonthwater() { 
   
		return monthwater;
	}

	public void setMonthwater(String monthwater) { 
   
		this.monthwater = monthwater;
	}

	public String getElectricitytype() { 
   
		return electricitytype;
	}

	public void setElectricitytype(String electricitytype) { 
   
		this.electricitytype = electricitytype;
	}

	public String getElectricity() { 
   
		return electricity;
	}

	public void setElectricity(String electricity) { 
   
		this.electricity = electricity;
	}

	public String getElectricitysum() { 
   
		return electricitysum;
	}

	public void setElectricitysum(String electricitysum) { 
   
		this.electricitysum = electricitysum;
	}

	public String getMonthelectricity() { 
   
		return monthelectricity;
	}

	public void setMonthelectricity(String monthelectricity) { 
   
		this.monthelectricity = monthelectricity;
	}

	public String getYears() { 
   
		return years;
	}

	public void setYears(String years) { 
   
		this.years = years;
	}

	public String getMonth() { 
   
		return month;
	}

	public void setMonth(String month) { 
   
		this.month = month;
	}

	public String getCost() { 
   
		return cost;
	}

	public void setCost(String cost) { 
   
		this.cost = cost;
	}

	public String getCostime() { 
   
		return costime;
	}

	public void setCostime(String costime) { 
   
		this.costime = costime;
	}

	public String getAdminid() { 
   
		return adminid;
	}

	public void setAdminid(String adminid) { 
   
		this.adminid = adminid;
	}

	public String getNote() { 
   
		return note;
	}

	public void setNote(String note) { 
   
		this.note = note;
	}
    
}

④ Users(用户类)

package com.ynavc.Bean;

import java.io.Serializable;

/** * @description users * @author ymjin.blog.csdn.net/ * @date 2021-07-01 */
public class Users implements Serializable { 
   

    private static final long serialVersionUID = 1L;

    /** * id */
    private Integer id;

    /** * 户主姓名 */
    private String username;

    /** * 账户 */
    private String account;

    /** * 密码 */
    private String password;

    /** * 性别 */
    private String sex;

    /** * 身份证号码 */
    private String idcard;

    /** * 电话号码 */
    private String phone;

    /** * 居住地址 */
    private String address;

    /** * 备注 */
    private String usertime;

    public Users() { 
   }

	public Users(Integer id, String username, String account, String password, String sex, String idcard, String phone,
			String address, String usertime) { 
   
		super();
		this.id = id;
		this.username = username;
		this.account = account;
		this.password = password;
		this.sex = sex;
		this.idcard = idcard;
		this.phone = phone;
		this.address = address;
		this.usertime = usertime;
	}

	@Override
	public String toString() { 
   
		return "Users [id=" + id + ", username=" + username + ", account=" + account + ", password=" + password
				+ ", sex=" + sex + ", idcard=" + idcard + ", phone=" + phone + ", address=" + address + ", usertime="
				+ usertime + "]";
	}

	public Integer getId() { 
   
		return id;
	}

	public void setId(Integer id) { 
   
		this.id = id;
	}

	public String getUsername() { 
   
		return username;
	}

	public void setUsername(String username) { 
   
		this.username = username;
	}

	public String getAccount() { 
   
		return account;
	}

	public void setAccount(String account) { 
   
		this.account = account;
	}

	public String getPassword() { 
   
		return password;
	}

	public void setPassword(String password) { 
   
		this.password = password;
	}

	public String getSex() { 
   
		return sex;
	}

	public void setSex(String sex) { 
   
		this.sex = sex;
	}

	public String getIdcard() { 
   
		return idcard;
	}

	public void setIdcard(String idcard) { 
   
		this.idcard = idcard;
	}

	public String getPhone() { 
   
		return phone;
	}

	public void setPhone(String phone) { 
   
		this.phone = phone;
	}

	public String getAddress() { 
   
		return address;
	}

	public void setAddress(String address) { 
   
		this.address = address;
	}

	public String getUsertime() { 
   
		return usertime;
	}

	public void setUsertime(String usertime) { 
   
		this.usertime = usertime;
	}

	public static long getSerialversionuid() { 
   
		return serialVersionUID;
	}
    
    
}

2、Controller包【数据库交互控制包】

① Select(查询类)

package com.ynavc.Controller;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.mysql.jdbc.PreparedStatement;
import com.ynavc.Bean.Admin;
import com.ynavc.Bean.Feeinfo;
import com.ynavc.Bean.FeeinfoImp;
import com.ynavc.Bean.Users;
import com.ynavc.Dao.DbConnection;

public class Select { 
   
	// 查询全部管理员用户信息
	public Object[][] getAdminInfo() { 
   
		String sql = "SELECT * FROM admin";
		Connection conn = DbConnection.getConnection();
		PreparedStatement stmt = null;
		;
		ResultSet rs = null;
		ArrayList<Admin> list = new ArrayList<Admin>();
		try { 
   
			stmt = (PreparedStatement) conn.prepareStatement(sql);
			rs = stmt.executeQuery();
			while (rs.next()) { 
   
				Admin admin = new Admin();
				admin.setId(rs.getInt(1));
				admin.setName(rs.getString(2));
				admin.setAccount(rs.getString(3));
				admin.setPassword(rs.getString(4));
				list.add(admin);
			}
		} catch (SQLException e1) { 
   
			e1.printStackTrace();
		} finally { 
   
			try { 
   
				DbConnection.colse(rs, stmt, conn);
			} catch (Exception e) { 
   
				e.printStackTrace();
			}
		}
		Object[][] objects = new Object[list.size()][4];
		for (int i = 0; i < list.size(); i++) { 
   
			objects[i][0] = list.get(i).getId();
			objects[i][1] = list.get(i).getName();
			objects[i][2] = list.get(i).getAccount();
			objects[i][3] = list.get(i).getPassword();
		}
		return objects;
	}

	// 查询全部管理员用户信息
	public Object[][] getAdminInfoBykey(String name, String id) { 
   
		if (name.equals("") && !id.equals("")) { 
   
			name = "null";
		} else if (id.equals("") && !name.equals("")) { 
   
			id = "null";
		}

		String sql = "SELECT * FROM admin WHERE account LIKE '%" + name + "%' OR id LIKE '%" + id + "%'";
		Connection conn = DbConnection.getConnection();
		PreparedStatement stmt = null;
		;
		ResultSet rs = null;
		ArrayList<Admin> list = new ArrayList<Admin>();
		try { 
   
			stmt = (PreparedStatement) conn.prepareStatement(sql);
			rs = stmt.executeQuery();
			while (rs.next()) { 
   
				Admin admin = new Admin();
				admin.setId(rs.getInt(1));
				admin.setName(rs.getString(2));
				admin.setAccount(rs.getString(3));
				admin.setPassword(rs.getString(4));
				list.add(admin);
			}
		} catch (SQLException e) { 
   
			e.printStackTrace();
		} finally { 
   
			try { 
   
				DbConnection.colse(rs, stmt, conn);
			} catch (Exception e) { 
   
				e.printStackTrace();
			}
		}
		Object[][] objects = new Object[list.size()][4];
		for (int i = 0; i < list.size(); i++) { 
   
			objects[i][0] = list.get(i).getId();
			objects[i][1] = list.get(i).getName();
			objects[i][2] = list.get(i).getAccount();
			objects[i][3] = list.get(i).getPassword();
		}
		return objects;
	}

	// 查询全部管理员用户信息
	public Object[][] getUserInfo(String id) { 
   
		String sql = null;
		if (id.equals("")) { 
   
			sql = "SELECT * FROM users";
		} else { 
   
			sql = "SELECT * FROM users WHERE id='" + id + "'";
		}
		Connection conn = DbConnection.getConnection();
		PreparedStatement stmt = null;
		;
		ResultSet rs = null;
		ArrayList<Users> list = new ArrayList<Users>();
		try { 
   
			stmt = (PreparedStatement) conn.prepareStatement(sql);
			rs = stmt.executeQuery();
			while (rs.next()) { 
   
				Users users = new Users();
				users.setId(rs.getInt(1));
				users.setUsername(rs.getString(2));
				users.setAccount(rs.getString(3));
				users.setPassword(rs.getString(4));
				users.setSex(rs.getString(5));
				users.setIdcard(rs.getString(6));
				users.setPhone(rs.getString(7));
				users.setAddress(rs.getString(8));
				users.setUsertime(rs.getString(9));
				list.add(users);
			}
		} catch (SQLException e1) { 
   
			e1.printStackTrace();
		} finally { 
   
			try { 
   
				DbConnection.colse(rs, stmt, conn);
			} catch (Exception e) { 
   
				e.printStackTrace();
			}
		}
		Object[][] objects = new Object[list.size()][9];
		for (int i = 0; i < list.size(); i++) { 
   
			objects[i][0] = list.get(i).getId();
			objects[i][1] = list.get(i).getUsername();
			objects[i][2] = list.get(i).getAccount();
			objects[i][3] = list.get(i).getPassword();
			objects[i][4] = list.get(i).getSex();
			objects[i][5] = list.get(i).getIdcard();
			objects[i][6] = list.get(i).getPhone();
			objects[i][7] = list.get(i).getAddress();
			objects[i][8] = list.get(i).getUsertime();
		}
		return objects;
	}

	// 管理员查询收费信息
	public Object[][] getFeeInfo(String id) { 
   
		String sql = null;
		if (id.equals("")) { 
   
			sql = "SELECT f.id,u.id,u.username,watertype,water,watersum,monthwater,electricity,electricitytype,electricitysum,monthelectricity,years,`month`,cost,costime,adminid,note FROM feeinfo f,users u WHERE f.userid=u.id";
		} else { 
   
			sql = "SELECT f.id,u.id,u.username,watertype,water,watersum,monthwater,electricity,electricitytype,electricitysum,monthelectricity,years,`month`,cost,costime,adminid,note FROM feeinfo f,users u WHERE f.userid=u.id and u.id="
					+ id;
		}
		Connection conn = DbConnection.getConnection();
		PreparedStatement stmt = null;
		;
		ResultSet rs = null;
		ArrayList<FeeinfoImp> list = new ArrayList<FeeinfoImp>();
		try { 
   
			stmt = (PreparedStatement) conn.prepareStatement(sql);
			rs = stmt.executeQuery();
			while (rs.next()) { 
   
				FeeinfoImp feeinfoImp = new FeeinfoImp(rs.getInt(1), rs.getInt(2), rs.getString(3), rs.getString(4),
						rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8), rs.getString(9),
						rs.getString(10), rs.getString(11), rs.getString(12), rs.getString(13), rs.getString(14),
						rs.getString(15), rs.getString(16), rs.getString(17));
				list.add(feeinfoImp);
			}
		} catch (SQLException e1) { 
   
			e1.printStackTrace();
		} finally { 
   
			try { 
   
				DbConnection.colse(rs, stmt, conn);
			} catch (Exception e) { 
   
				e.printStackTrace();
			}
		}
		Object[][] objects = new Object[list.size()][17];
		for (int i = 0; i < list.size(); i++) { 
   
			objects[i][0] = list.get(i).getId();
			objects[i][1] = list.get(i).getUserName();
			objects[i][2] = list.get(i).getWatertype();
			objects[i][3] = list.get(i).getWater();
			objects[i][4] = list.get(i).getWatersum();
			objects[i][5] = list.get(i).getMonthwater();
			objects[i][6] = list.get(i).getElectricitytype();
			objects[i][7] = list.get(i).getElectricity();
			objects[i][8] = list.get(i).getElectricitysum();
			objects[i][9] = list.get(i).getMonthelectricity();
			objects[i][10] = list.get(i).getYears();
			objects[i][11] = list.get(i).getMonth();
			objects[i][12] = list.get(i).getCost();
			objects[i][13] = list.get(i).getCostime();
			objects[i][14] = list.get(i).getAdminid();
			objects[i][15] = list.get(i).getNote();
			objects[i][16] = list.get(i).getUserid();
		}
		return objects;
	}

	// 根据日期查询收费信息
	public Object[][] getFeeInfoByMonth(String id, String years, String month) { 
   
		String sql = null;
		if (years.equals("全部年份")||month.equals("全部月份")&&id.equals("")) { 
   
			sql = "SELECT f.id,u.id,u.username,watertype,water,watersum,monthwater,electricity,electricitytype,electricitysum,monthelectricity,years,`month`,cost,costime,adminid,note FROM feeinfo f,users u WHERE f.userid=u.id";
		}else if (years.equals("全部年份")||month.equals("全部月份")&&!id.equals("")) { 
   
			sql = "SELECT f.id,u.id,u.username,watertype,water,watersum,monthwater,electricity,electricitytype,electricitysum,monthelectricity,years,`month`,cost,costime,adminid,note FROM feeinfo f,users u WHERE f.userid=u.id and u.id="+id;
		}else if (!years.equals("")||!month.equals("")&&id.equals("")) { 
   
			sql = "SELECT f.id,u.id,u.username,watertype,water,watersum,monthwater,electricity,electricitytype,electricitysum,monthelectricity,years,`month`,cost,costime,adminid,note FROM feeinfo f,users u WHERE f.userid=u.id and years='" + years + "' and `month`='" + month + "'";
		}else if (!years.equals("")&&!month.equals("")&&!id.equals("")) { 
   
			sql = "SELECT f.id,u.id,u.username,watertype,water,watersum,monthwater,electricity,electricitytype,electricitysum,monthelectricity,years,`month`,cost,costime,adminid,note FROM feeinfo f,users u WHERE f.userid=u.id and u.id="
					+ id + " and years='" + years + "' and `month`='" + month + "'";
		}else { 
   
			sql = "SELECT f.id,u.id,u.username,watertype,water,watersum,monthwater,electricity,electricitytype,electricitysum,monthelectricity,years,`month`,cost,costime,adminid,note FROM feeinfo f,users u WHERE f.userid=u.id";
		}
		Connection conn = DbConnection.getConnection();
		PreparedStatement stmt = null;
		;
		ResultSet rs = null;
		ArrayList<FeeinfoImp> list = new ArrayList<FeeinfoImp>();
		try { 
   
			System.out.println(sql);
			stmt = (PreparedStatement) conn.prepareStatement(sql);
			rs = stmt.executeQuery();
			while (rs.next()) { 
   
				FeeinfoImp feeinfoImp = new FeeinfoImp(rs.getInt(1), rs.getInt(2), rs.getString(3), rs.getString(4),
						rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8), rs.getString(9),
						rs.getString(10), rs.getString(11), rs.getString(12), rs.getString(13), rs.getString(14),
						rs.getString(15), rs.getString(16), rs.getString(17));
				list.add(feeinfoImp);
			}
		} catch (SQLException e1) { 
   
			e1.printStackTrace();
		} finally { 
   
			try { 
   
				DbConnection.colse(rs, stmt, conn);
			} catch (Exception e) { 
   
				e.printStackTrace();
			}
		}
		Object[][] objects = new Object[list.size()][17];
		for (int i = 0; i < list.size(); i++) { 
   
			objects[i][0] = list.get(i).getId();
			objects[i][1] = list.get(i).getUserName();
			objects[i][2] = list.get(i).getWatertype();
			objects[i][3] = list.get(i).getWater();
			objects[i][4] = list.get(i).getWatersum();
			objects[i][5] = list.get(i).getMonthwater();
			objects[i][6] = list.get(i).getElectricitytype();
			objects[i][7] = list.get(i).getElectricity();
			objects[i][8] = list.get(i).getElectricitysum();
			objects[i][9] = list.get(i).getMonthelectricity();
			objects[i][10] = list.get(i).getYears();
			objects[i][11] = list.get(i).getMonth();
			objects[i][12] = list.get(i).getCost();
			objects[i][13] = list.get(i).getCostime();
			objects[i][14] = list.get(i).getAdminid();
			objects[i][15] = list.get(i).getNote();
			objects[i][16] = list.get(i).getUserid();
		}
		return objects;
	}

	// 查询执行行数
	public int userloginSelect(String sql) { 
   
		// String sql="select * from users where password='"+password+"' and
		// username='"+username+"'";
		ResultSet resultSet = DbConnection.query(sql);
		int a = 0;
		try { 
   
			while (resultSet.next()) { 
   
				a = resultSet.getInt(1);
			}
		} catch (SQLException e) { 
   
			e.printStackTrace();
		}
		return a;
	}
	
	// 查询用户ID
	public int userloginSelectByid(String sql) { 
   
		ResultSet resultSet = DbConnection.query(sql);
		int a = 0;
		try { 
   
			while (resultSet.next()) { 
   
				a = resultSet.getInt(1);
			}
		} catch (SQLException e) { 
   
			e.printStackTrace();
		}
		return a;
	}
	// 查询用户ID
	public String getStr(String sql) { 
   
		ResultSet resultSet = DbConnection.query(sql);
		String a = null;
		try { 
   
			while (resultSet.next()) { 
   
				a = resultSet.getString(1);
			}
		} catch (SQLException e) { 
   
			e.printStackTrace();
		}
		return a;
	}

}

② Updata(增删改查类)


package com.ynavc.Controller;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JOptionPane;

import com.ynavc.Dao.DbConnection;

public class Updata { 
   
	// 添加数据
	public int addData(String sql) { 
   
		Connection conn = DbConnection.getConnection();
		// 获取连接
		PreparedStatement stmt = null;
		ResultSet rs = null;
		try { 
   
			System.out.println(sql);
			stmt = conn.prepareStatement(sql);
			int executeUpdate = stmt.executeUpdate();
			return executeUpdate;
		} catch (SQLException e) { 
   
			JOptionPane.showMessageDialog(null, "执行语句出错\n" + e.toString());
			e.printStackTrace();
		}finally { 
   
			try { 
   
				DbConnection.colse(rs, stmt, conn);
			} catch (Exception e) { 
   
				e.printStackTrace();
			}
		}
		return 0;
	}
}

3、Dao包【数据库链接工具包】

① DbConnection(数据库连接类)

package com.ynavc.Dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JOptionPane;

import com.mysql.jdbc.Statement;

public class DbConnection { 
   
	// 驱动类的类名
	private static final String DRIVERNAME = "com.mysql.jdbc.Driver";
	// 连接数据的URL路径
	private static final String URL = "jdbc:mysql://127.0.0.1:3306/utilitiessys?useUnicode=true&characterEncoding=UTF-8&useSSL=false";
	// 数据库登录账号
	private static final String USER = "root";
	// 数据库登录密码
	private static final String PASSWORD = "123456";
	// 加载驱动
	static { 
   
		try { 
   
			Class.forName(DRIVERNAME);
		} catch (ClassNotFoundException e) { 
   
			e.printStackTrace();
		}
	}

	// 获取数据库连接
	public static Connection getConnection() { 
   
		try { 
   
			return DriverManager.getConnection(URL, USER, PASSWORD);
		} catch (SQLException e) { 
   
			e.printStackTrace();
		}
		return null;
	}

	// 查询
	public static ResultSet query(String sql) { 
   
		System.out.println(sql);
		// 获取连接
		Connection connection = getConnection();
		PreparedStatement psd;
		try { 
   
			psd = connection.prepareStatement(sql);
			return psd.executeQuery();
		} catch (SQLException e) { 
   
			JOptionPane.showMessageDialog(null, "执行语句出错\n" + e.toString());
			e.printStackTrace();
		}
		return null;
	}

	// 增、删、改、查
	public static int updataInfo(String sql) { 
   
		System.out.println(sql);
		// 获取连接
		Connection connection = getConnection();
		try { 
   
			PreparedStatement psd = connection.prepareStatement(sql);
			return psd.executeUpdate();
		} catch (SQLException e) { 
   
			JOptionPane.showMessageDialog(null, "执行语句出错\n" + e.toString());
			e.printStackTrace();
		}
		return 0;
	}

	// 关闭连接
	public static void colse(ResultSet rs, PreparedStatement stmt, Connection conn) throws Exception { 
   
		try { 
   
			if (rs != null) { 
   
				rs.close();
			}
			if (stmt != null) { 
   
				stmt.cancel();
			}
			if (conn != null) { 
   
				conn.close();
			}
		} catch (Exception e) { 
   
			e.printStackTrace();
			throw new Exception();
		}
	}

	public static void main(String[] args) { 
   
		
	}
}

4、Test包【测试包】

① Main(运行入口)

package com.ynavc.Test;

import com.ynavc.Vive.UserLogin;

public class Main { 
   
	
	public static void main(String[] args) { 
   
		new UserLogin().setVisible(true);
	}
}

5、View包【视图包】

① AdminFeeView(水电费管理系统>用户水电费查询)

package com.ynavc.Vive;

import javax.swing.JFrame;
import javax.swing.JScrollPane;

import com.ynavc.Bean.Admin;
import com.ynavc.Bean.FeeinfoImp;
import com.ynavc.Controller.Select;
import com.ynavc.Controller.Updata;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JComboBox;

import java.awt.Color;
import java.awt.FileDialog;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.JButton;

public class AdminFeeView extends JFrame { 
   

	JTable jtable;
	Select select = new Select();
	Updata updata = new Updata();
	Object[] header = { 
    "订单号", "户主", "用水分类", "水费单价", "水费总量", "本月水费", "用电类型", "电费单价", "电总量", "本月电费", "年份", "月份", "应缴纳费用",
			"收费时间", "开票人", "备注" };
	Object[][] data = null;
	DefaultTableModel df = null;
	int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
	int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
	private JTextField textField;

	public AdminFeeView() { 
   
		super("水电费管理系统--用户水电费查询");
		Updata updata = new Updata();
		this.setBounds(0, 0, 1235, 550);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);
		getContentPane().setLayout(null);

		data = select.getFeeInfo("");
		df = new DefaultTableModel(data, header);
		jtable = new JTable(df);// 创建表格
		jtable.getTableHeader().setFont(new Font(null, Font.BOLD, 14)); // 设置表头名称字体样式
		jtable.getTableHeader().setForeground(Color.black); // 设置表头名称字体颜色
		// jTable.getTableHeader().setResizingAllowed(false); // 设置不允许手动改变列宽
		jtable.getTableHeader().setReorderingAllowed(false);// 设置表头不允许拖动
		int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;// 水平滚动条
		int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;// 垂直滚动条
		this.addWindowListener(new WindowAdapter() { 
   

			public void windowClosing(WindowEvent e) { 
   
				super.windowClosing(e);
				new AdminView().setVisible(true);
				// 加入动作
// GoodsManagement m = new GoodsManagement();
// m.setVisible(true);
			}
		});
		JScrollPane jsp = new JScrollPane(jtable, v, h);
		jsp.setBounds(26, 105, 1178, 331);
		getContentPane().add(jsp);

		JPanel panel = new JPanel();
		panel.setBorder(new TitledBorder(null, "条件查询", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel.setBounds(26, 13, 623, 78);
		getContentPane().add(panel);
		
		JLabel label = new JLabel("户主编号:");
		panel.add(label);
		
		textField = new JTextField();
		panel.add(textField);
		textField.setColumns(10);

		JLabel label_1 = new JLabel("年份:");
		panel.add(label_1);
		
		JComboBox comboBox = new JComboBox();
		panel.add(comboBox);
		comboBox.addItem("全部年份");
		for (int i = 2016; i < 2026; i++) { 
   
			comboBox.addItem(i + "年");
		}

		JLabel label_2 = new JLabel("月份");
		panel.add(label_2);

		JComboBox comboBox_1 = new JComboBox();
		panel.add(comboBox_1);
		comboBox_1.addItem("全部月份");
		for (int i = 1; i <= 12; i++) { 
   
			comboBox_1.addItem(i + "月");
		}
		
		comboBox.setSelectedItem("2021年");
		comboBox_1.setSelectedItem("7月");

		JButton button = new JButton("查询");
		button.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				String years = comboBox.getItemAt(comboBox.getSelectedIndex()).toString();
				String mouth = comboBox_1.getItemAt(comboBox_1.getSelectedIndex()).toString();
				Object[][] data = select.getFeeInfoByMonth(textField.getText(), years, mouth);
				df.setDataVector(data, header);
			}
		});
		panel.add(button);

		JButton btnNewButton = new JButton("显示全部");
		btnNewButton.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				Object[][] data = select.getFeeInfo("");
				df.setDataVector(data, header);
			}
		});
		btnNewButton.setBounds(797, 47, 113, 27);
		getContentPane().add(btnNewButton);
		
		JButton button_1 = new JButton("删除");
		button_1.addActionListener(new ActionListener() { 
   
			@Override
			public void actionPerformed(ActionEvent e) { 
   
				if (jtable.getSelectedColumn() < 0) { 
   
					JOptionPane.showMessageDialog(null, "请选中要删除的数据!");
				} else { 
   
					int userid = Integer.parseInt(jtable.getValueAt(jtable.getSelectedRow(), 0).toString());
					String dsql = "delete from feeinfo where id=" + userid;
					int result = updata.addData(dsql);
					if (result > 0) { 
   
						JOptionPane.showMessageDialog(null, "删除成功!");
						Object[][] data = select.getFeeInfo("");
						df.setDataVector(data, header);
					} else { 
   
						JOptionPane.showMessageDialog(null, "删除失败!");
					}
				}
			}
		});
		
		// // 创建表模型
		// df = new DefaultTableModel(data, header) { 
   
		// // 设置表格内容不可被编辑
		// public boolean isCellEditable(int row, int column) { 
   
		// return false;// 返回true表示能编辑,false表示不能编辑
		// }
		// };
		
				JButton btnexcel = new JButton("导出数据导Excel");
				btnexcel.setBounds(997, 47, 147, 27);
				getContentPane().add(btnexcel);
				btnexcel.addActionListener(new ActionListener() { 
   
					public void actionPerformed(ActionEvent e) { 
   
						jButtonActionPerformed(e);
					}
				});
		button_1.setBounds(797, 462, 113, 27);
		getContentPane().add(button_1);
		
		JButton button_2 = new JButton("修改");
		button_2.setBounds(950, 462, 113, 27);
		button_2.addActionListener(new ActionListener() { 
   
			@Override
			public void actionPerformed(ActionEvent e) { 
   
				if (jtable.getSelectedColumn() < 0) { 
   
					JOptionPane.showMessageDialog(null, "请选择要修改的数据!");
				} else { 
   
					FeeinfoImp feeinfoImp = new FeeinfoImp();
					feeinfoImp.setId(Integer.parseInt(jtable.getValueAt(jtable.getSelectedRow(), 0).toString()));
					feeinfoImp.setUserName(jtable.getValueAt(jtable.getSelectedRow(), 1).toString());
					feeinfoImp.setWatertype(jtable.getValueAt(jtable.getSelectedRow(), 2).toString());
					feeinfoImp.setWater(jtable.getValueAt(jtable.getSelectedRow(), 3).toString());
					feeinfoImp.setWatersum(jtable.getValueAt(jtable.getSelectedRow(), 4).toString());
					feeinfoImp.setMonthwater(jtable.getValueAt(jtable.getSelectedRow(), 5).toString());
					feeinfoImp.setElectricitytype(jtable.getValueAt(jtable.getSelectedRow(), 6).toString());
					feeinfoImp.setElectricity(jtable.getValueAt(jtable.getSelectedRow(), 7).toString());
					feeinfoImp.setElectricitysum(jtable.getValueAt(jtable.getSelectedRow(), 8).toString());
					feeinfoImp.setMonthelectricity(jtable.getValueAt(jtable.getSelectedRow(), 9).toString());
					feeinfoImp.setYears(jtable.getValueAt(jtable.getSelectedRow(), 10).toString());
					feeinfoImp.setMonth(jtable.getValueAt(jtable.getSelectedRow(), 11).toString());
					feeinfoImp.setCost(jtable.getValueAt(jtable.getSelectedRow(), 12).toString());
					feeinfoImp.setCostime(jtable.getValueAt(jtable.getSelectedRow(), 13).toString());
					feeinfoImp.setAdminid(jtable.getValueAt(jtable.getSelectedRow(), 14).toString());
					feeinfoImp.setNote(jtable.getValueAt(jtable.getSelectedRow(), 15).toString());
					
					System.out.println(feeinfoImp);
					new AdminFeeViewUpd(feeinfoImp).setVisible(true);;
					
				}
			}
		});
		getContentPane().add(button_2);
		
		JButton button_2_1 = new JButton("增加");
		button_2_1.setBounds(1091, 462, 113, 27);
		getContentPane().add(button_2_1);
		button_2_1.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				new AdminFeeViewAdd().setVisible(true);
			}
		});
		
		
		// 设置单元格内容居中显示
		DefaultTableCellRenderer r = new DefaultTableCellRenderer();
		r.setHorizontalAlignment(JLabel.CENTER);
		jtable.setDefaultRenderer(Object.class, r);
		// Object[][] data = select.getAdminInfo();
		df.setDataVector(data, header);
		
	}

	// 导出
	private void jButtonActionPerformed(java.awt.event.ActionEvent evt) { 
   
		FileDialog fd = new FileDialog(this, "将数据保存到", FileDialog.SAVE);
		fd.setLocation(1100, 600);
		fd.setVisible(true);
		String stringfile = fd.getDirectory() + fd.getFile() + ".xlsx";
		try { 
   
			this.exportTable(jtable, new File(stringfile));
		} catch (IOException ex) { 
   
			ex.printStackTrace();
		}
		
	}

	/** 导出JTable到excel */
	public void exportTable(JTable table, File file) throws IOException { 
   
		TableModel model = table.getModel();
		BufferedWriter bWriter = new BufferedWriter(new FileWriter(file));
		for (int i = 0; i < model.getColumnCount(); i++) { 
   
			bWriter.write(model.getColumnName(i));
			bWriter.write("\t");
		}
		bWriter.newLine();
		for (int i = 0; i < model.getRowCount(); i++) { 
   
			for (int j = 0; j < model.getColumnCount(); j++) { 
   
				bWriter.write(model.getValueAt(i, j).toString());
				bWriter.write("\t");
			}
			bWriter.newLine();
		}
		bWriter.close();
	}
	
	public void refresh() { 
   
		Object[][] data = select.getFeeInfo("");
		df.setDataVector(data, header);
	}
//
// public static void main(String[] args) { 
   
// new AdminFeeView().setVisible(true);
// }
}

② AdminFeeViewAdd(水电费管理系统>用户水电费添加)

package com.ynavc.Vive;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.TitledBorder;

import com.ynavc.Controller.Updata;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.JComboBox;
import java.awt.Color;

public class AdminFeeViewAdd extends JFrame{ 
   

	private JTextField userid;
	private JTextField admin;
	private JTextField watertype;
	private JTextField watersum;
	private JTextField water;
	private JTextField monthwater;
	private JTextField electricitytype;
	private JTextField electricitysum;
	private JTextField monthelectricity;
	private JTextField electricity;
	private JTextField cost;
	private JTextField node;
	
	public AdminFeeViewAdd() { 
   
		super("水电费管理系统--用户水电费管理--收费信息添加");
		this.setBounds(0, 0, 900, 500);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);// 让窗口大小不可改变
		getContentPane().setLayout(null);
		
		Updata updata = new Updata();
		
		JLabel label = new JLabel("户主编号:");
		label.setBounds(25, 123, 83, 18);
		getContentPane().add(label);
		
		userid = new JTextField();
		userid.setBounds(117, 120, 196, 24);
		getContentPane().add(userid);
		userid.setColumns(10);
		
		JLabel label_1 = new JLabel("开票人:");
		label_1.setBounds(618, 120, 60, 18);
		getContentPane().add(label_1);
		
		admin = new JTextField();
		admin.setColumns(10);
		admin.setBounds(677, 117, 196, 24);
		getContentPane().add(admin);
		
		JLabel label_2 = new JLabel("水电费添加");
		label_2.setFont(new Font("宋体", Font.BOLD, 20));
		label_2.setBounds(363, 28, 123, 28);
		getContentPane().add(label_2);
		
		JButton addBtn = new JButton("确认添加");
		addBtn.setBounds(389, 425, 113, 27);
		addBtn.setIcon(new ImageIcon(AdminSysViewAdd.class.getResource("/images/add.png")));
		getContentPane().add(addBtn);
		
		JPanel panel = new JPanel();
		panel.setBounds(17, 184, 419, 130);
		panel.setBorder(new TitledBorder(null, "水费信息", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		getContentPane().add(panel);
		panel.setLayout(null);
		
		JLabel label_3 = new JLabel("用水类型:");
		label_3.setBounds(14, 47, 75, 18);
		panel.add(label_3);
		
		watertype = new JTextField();
		watertype.setBounds(103, 44, 86, 24);
		panel.add(watertype);
		watertype.setColumns(10);
		
		JLabel label_4 = new JLabel("用水量:");
		label_4.setBounds(230, 47, 75, 18);
		panel.add(label_4);
		
		watersum = new JTextField();
		watersum.setBounds(319, 44, 86, 24);
		panel.add(watersum);
		watersum.setColumns(10);
		
		JLabel lblNewLabel = new JLabel("水费单价:");
		lblNewLabel.setBounds(14, 91, 75, 18);
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		panel.add(lblNewLabel);
		
		water = new JTextField();
		water.setBounds(103, 88, 86, 24);
		panel.add(water);
		water.setColumns(10);
		
		JLabel label_5 = new JLabel("本月水费:");
		label_5.setBounds(230, 91, 75, 18);
		panel.add(label_5);
		
		monthwater = new JTextField();
		monthwater.setBounds(319, 88, 86, 24);
		panel.add(monthwater);
		monthwater.setColumns(10);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new TitledBorder(null, "电费信息", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_1.setBounds(454, 184, 419, 130);
		getContentPane().add(panel_1);
		panel_1.setLayout(null);
		
		JLabel label_3_1 = new JLabel("用电类型:");
		label_3_1.setBounds(14, 40, 75, 18);
		panel_1.add(label_3_1);
		
		electricitytype = new JTextField();
		electricitytype.setColumns(10);
		electricitytype.setBounds(103, 37, 86, 24);
		panel_1.add(electricitytype);
		
		JLabel label_4_1 = new JLabel("用电量:");
		label_4_1.setBounds(230, 40, 75, 18);
		panel_1.add(label_4_1);
		
		electricitysum = new JTextField();
		electricitysum.setColumns(10);
		electricitysum.setBounds(319, 37, 86, 24);
		panel_1.add(electricitysum);
		
		monthelectricity = new JTextField();
		monthelectricity.setColumns(10);
		monthelectricity.setBounds(319, 81, 86, 24);
		panel_1.add(monthelectricity);
		
		JLabel label_5_1 = new JLabel("本月电费:");
		label_5_1.setBounds(230, 84, 75, 18);
		panel_1.add(label_5_1);
		
		electricity = new JTextField();
		electricity.setColumns(10);
		electricity.setBounds(103, 81, 86, 24);
		panel_1.add(electricity);
		
		JLabel lblNewLabel_1 = new JLabel("电费单价:");
		lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel_1.setBounds(14, 84, 75, 18);
		panel_1.add(lblNewLabel_1);
		
		JLabel lblNewLabel_2 = new JLabel("年份:");
		lblNewLabel_2.setBounds(25, 347, 52, 18);
		getContentPane().add(lblNewLabel_2);
		
		JComboBox years = new JComboBox();
		years.setBounds(77, 344, 72, 24);
		getContentPane().add(years);
		for (int i = 2016; i < 2026; i++) { 
   
			years.addItem(i + "年");
		}
		
		JLabel lblNewLabel_2_1 = new JLabel("月份:");
		lblNewLabel_2_1.setBounds(163, 346, 52, 18);
		getContentPane().add(lblNewLabel_2_1);
		
		JComboBox mouth = new JComboBox();
		mouth.setBounds(215, 343, 72, 24);
		getContentPane().add(mouth);
		for (int i = 1; i <= 12; i++) { 
   
			mouth.addItem(i + "月");
		}
		
		years.setSelectedItem("2021年");
		mouth.setSelectedItem("7月");
		
		JLabel label_6 = new JLabel("本月总价:");
		label_6.setFont(new Font("宋体", Font.PLAIN, 17));
		label_6.setForeground(Color.RED);
		label_6.setBounds(636, 350, 105, 18);
		getContentPane().add(label_6);
		
		cost = new JTextField();
		cost.setBounds(755, 347, 105, 24);
		getContentPane().add(cost);
		cost.setColumns(10);
		
		JLabel label_7 = new JLabel("备注:");
		label_7.setBounds(314, 350, 72, 18);
		getContentPane().add(label_7);
		
		node = new JTextField();
		node.setBounds(363, 347, 196, 24);
		getContentPane().add(node);
		node.setColumns(10);
		
		
		addBtn.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent arg0) { 
   
				String uid = userid.getText();
				
				String uwatertype = watertype.getText();
				String uwater = water.getText();
				String uwatersum = watersum.getText();
				String umonthwater = monthwater.getText();
				
				String uelectricitytype = electricitytype.getText();
				String uelectricity = electricity.getText();
				String uelectricitysum = electricitysum.getText();
				String umonthelectricity = monthelectricity.getText();
				
				String uyears = years.getItemAt(years.getSelectedIndex()).toString();
				String umouth = mouth.getItemAt(mouth.getSelectedIndex()).toString();
				
				String ucost = cost.getText();
				
				String costTime = getTime();
				
				String uadmin = admin.getText();
				
				String unode = node.getText();
				
				if (uid.equals("") && uadmin.equals("")) { 
   
					JOptionPane.showMessageDialog(null, "请填写完整信息!");
				} else { 
   
// String sql1= "INSERT INTO `feeinfo` VALUES (2, 1, '家庭用电', '20', '50', '200', '家庭用电', '20', '20', '20', '2021年', '5月', '300', '2000', 'mj', '背后')";
					String sql = "INSERT INTO feeinfo VALUES(null,'" + uid + "','"+uwatertype+"','" + uwater + "','" + uwatersum + "','" + umonthwater + "','" + uelectricitytype + "','" + uelectricity + "','" + uelectricitysum + "','" + umonthelectricity + "','" + uyears + "','" + umouth + "','" + ucost + "','" + costTime + "','" + uadmin + "','" + unode + "')";
					int reselt = updata.addData(sql);
					if (reselt > 0) { 
   
						JOptionPane.showMessageDialog(null, "水电费信息添加成功!");
						AdminView.getAdminFeeView().refresh();
						dispose();
					} else { 
   
						JOptionPane.showMessageDialog(null, "添加失败!");
					}
				}

			}
		});
		
	}
	
	private String getTime() { 
   
		Date d = new Date();
		SimpleDateFormat sbf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String format = sbf.format(d);
		System.out.println(sbf);
		System.out.println(sbf.format(d));
		System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
		return format;
	}
	
// public static void main(String[] args) { 
   
// new AdminFeeViewAdd().setVisible(true);
// }

}

③ AdminFeeViewUpd(水电费管理系统>用户水电费修改)

package com.ynavc.Vive;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.TitledBorder;

import com.ynavc.Bean.FeeinfoImp;
import com.ynavc.Controller.Updata;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.JComboBox;
import java.awt.Color;

public class AdminFeeViewUpd extends JFrame{ 
   
	
	private JTextField userid;
	private JTextField admin;
	private JTextField watertype;
	private JTextField watersum;
	private JTextField water;
	private JTextField monthwater;
	private JTextField electricitytype;
	private JTextField electricitysum;
	private JTextField monthelectricity;
	private JTextField electricity;
	private JTextField cost;
	private JTextField node;
	
	public AdminFeeViewUpd(FeeinfoImp f) { 
   
		super("水电费管理系统--用户水电费管理--收费信息添加");
		this.setBounds(0, 0, 900, 500);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);// 让窗口大小不可改变
		getContentPane().setLayout(null);
		
		Updata updata = new Updata();
		
		JLabel label = new JLabel("户主编号:");
		label.setBounds(25, 123, 83, 18);
		getContentPane().add(label);
		
		userid = new JTextField();
		userid.setBounds(117, 120, 196, 24);
		getContentPane().add(userid);
		userid.setColumns(10);
		
		JLabel label_1 = new JLabel("开票人:");
		label_1.setBounds(618, 120, 60, 18);
		getContentPane().add(label_1);
		
		admin = new JTextField();
		admin.setColumns(10);
		admin.setBounds(677, 117, 196, 24);
		getContentPane().add(admin);
		
		JLabel label_2 = new JLabel("水电费信息修改");
		label_2.setFont(new Font("宋体", Font.BOLD, 20));
		label_2.setBounds(363, 28, 196, 28);
		getContentPane().add(label_2);
		
		JButton addBtn = new JButton("确认修改");
		addBtn.setBounds(389, 425, 113, 27);
		addBtn.setIcon(new ImageIcon(AdminSysViewAdd.class.getResource("/images/modify.png")));
		getContentPane().add(addBtn);
		
		JPanel panel = new JPanel();
		panel.setBounds(17, 184, 419, 130);
		panel.setBorder(new TitledBorder(null, "水费信息", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		getContentPane().add(panel);
		panel.setLayout(null);
		
		JLabel label_3 = new JLabel("用水类型:");
		label_3.setBounds(14, 47, 75, 18);
		panel.add(label_3);
		
		watertype = new JTextField();
		watertype.setBounds(103, 44, 86, 24);
		panel.add(watertype);
		watertype.setColumns(10);
		
		JLabel label_4 = new JLabel("用水量:");
		label_4.setBounds(230, 47, 75, 18);
		panel.add(label_4);
		
		watersum = new JTextField();
		watersum.setBounds(319, 44, 86, 24);
		panel.add(watersum);
		watersum.setColumns(10);
		
		JLabel lblNewLabel = new JLabel("水费单价:");
		lblNewLabel.setBounds(14, 91, 75, 18);
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		panel.add(lblNewLabel);
		
		water = new JTextField();
		water.setBounds(103, 88, 86, 24);
		panel.add(water);
		water.setColumns(10);
		
		JLabel label_5 = new JLabel("本月水费:");
		label_5.setBounds(230, 91, 75, 18);
		panel.add(label_5);
		
		monthwater = new JTextField();
		monthwater.setBounds(319, 88, 86, 24);
		panel.add(monthwater);
		monthwater.setColumns(10);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new TitledBorder(null, "电费信息", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_1.setBounds(454, 184, 419, 130);
		getContentPane().add(panel_1);
		panel_1.setLayout(null);
		
		JLabel label_3_1 = new JLabel("用电类型:");
		label_3_1.setBounds(14, 40, 75, 18);
		panel_1.add(label_3_1);
		
		electricitytype = new JTextField();
		electricitytype.setColumns(10);
		electricitytype.setBounds(103, 37, 86, 24);
		panel_1.add(electricitytype);
		
		JLabel label_4_1 = new JLabel("用电量:");
		label_4_1.setBounds(230, 40, 75, 18);
		panel_1.add(label_4_1);
		
		electricitysum = new JTextField();
		electricitysum.setColumns(10);
		electricitysum.setBounds(319, 37, 86, 24);
		panel_1.add(electricitysum);
		
		monthelectricity = new JTextField();
		monthelectricity.setColumns(10);
		monthelectricity.setBounds(319, 81, 86, 24);
		panel_1.add(monthelectricity);
		
		JLabel label_5_1 = new JLabel("本月电费:");
		label_5_1.setBounds(230, 84, 75, 18);
		panel_1.add(label_5_1);
		
		electricity = new JTextField();
		electricity.setColumns(10);
		electricity.setBounds(103, 81, 86, 24);
		panel_1.add(electricity);
		
		JLabel lblNewLabel_1 = new JLabel("电费单价:");
		lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel_1.setBounds(14, 84, 75, 18);
		panel_1.add(lblNewLabel_1);
		
		JLabel lblNewLabel_2 = new JLabel("年份:");
		lblNewLabel_2.setBounds(25, 347, 52, 18);
		getContentPane().add(lblNewLabel_2);
		
		JComboBox years = new JComboBox();
		years.setBounds(77, 344, 74, 24);
		getContentPane().add(years);
		for (int i = 2016; i < 2026; i++) { 
   
			years.addItem(i + "年");
		}
		
		JLabel lblNewLabel_2_1 = new JLabel("月份:");
		lblNewLabel_2_1.setBounds(165, 347, 52, 18);
		getContentPane().add(lblNewLabel_2_1);
		
		JComboBox mouth = new JComboBox();
		mouth.setBounds(217, 344, 72, 24);
		getContentPane().add(mouth);
		for (int i = 1; i <= 12; i++) { 
   
			mouth.addItem(i + "月");
		}
		
		years.setSelectedItem("2021年");
		mouth.setSelectedItem("7月");
		
		JLabel label_6 = new JLabel("本月总价:");
		label_6.setFont(new Font("宋体", Font.PLAIN, 17));
		label_6.setForeground(Color.RED);
		label_6.setBounds(636, 350, 105, 18);
		getContentPane().add(label_6);
		
		cost = new JTextField();
		cost.setBounds(755, 347, 105, 24);
		getContentPane().add(cost);
		cost.setColumns(10);
		
		JLabel label_7 = new JLabel("备注:");
		label_7.setBounds(314, 350, 72, 18);
		getContentPane().add(label_7);
		
		node = new JTextField();
		node.setBounds(363, 347, 196, 24);
		getContentPane().add(node);
		node.setColumns(10);
		
		if (f!=null) { 
   
			userid.setText(f.getUserName().toString());
			admin.setText(f.getAdminid());
			water.setText(f.getWater());
			watertype.setText(f.getWatertype());
			watersum.setText(f.getWatersum());
			monthwater.setText(f.getMonthwater());
			electricity.setText(f.getElectricity());
			electricitysum.setText(f.getElectricitysum());
			electricitytype.setText(f.getElectricitytype());
			monthelectricity.setText(f.getMonthelectricity());
			node.setText(f.getNote());
			cost.setText(f.getCost());
			mouth.setSelectedItem(f.getMonth());
			years.setSelectedItem(f.getYears());
		}
		
		addBtn.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent arg0) { 
   
				String uid = userid.getText();
				
				String uwatertype = watertype.getText();
				String uwater = water.getText();
				String uwatersum = watersum.getText();
				String umonthwater = monthwater.getText();
				
				String uelectricitytype = electricitytype.getText();
				String uelectricity = electricity.getText();
				String uelectricitysum = electricitysum.getText();
				String umonthelectricity = monthelectricity.getText();
				
				String uyears = years.getItemAt(years.getSelectedIndex()).toString();
				String umouth = mouth.getItemAt(mouth.getSelectedIndex()).toString();
				
				String ucost = cost.getText();
				
				String costTime = getTime();
				
				String uadmin = admin.getText();
				
				String unode = node.getText();
				
				if (uid.equals("") && uadmin.equals("")) { 
   
					JOptionPane.showMessageDialog(null, "请填写完整信息!");
				} else { 
   
// String sql1= "INSERT INTO `feeinfo` VALUES (2, 1, '家庭用电', '20', '50', '200', '家庭用电', '20', '20', '20', '2021年', '5月', '300', '2000', 'mj', '背后')";
					String sql = "INSERT INTO feeinfo VALUES(null,'" + uid + "','"+uwatertype+"','" + uwater + "','" + uwatersum + "','" + umonthwater + "','" + uelectricitytype + "','" + uelectricity + "','" + uelectricitysum + "','" + umonthelectricity + "','" + uyears + "','" + umouth + "','" + ucost + "','" + costTime + "','" + uadmin + "','" + unode + "')";
					int reselt = updata.addData(sql);
					if (reselt > 0) { 
   
						JOptionPane.showMessageDialog(null, "水电费信息添加成功!");
						AdminView.getAdminFeeView().refresh();
						dispose();
					} else { 
   
						JOptionPane.showMessageDialog(null, "添加失败!");
					}
				}

			}
		});
		
	}
	
	private String getTime() { 
   
		Date d = new Date();
		SimpleDateFormat sbf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String format = sbf.format(d);
		System.out.println(sbf);
		System.out.println(sbf.format(d));
		System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
		return format;
	}
	
// public static void main(String[] args) { 
   
// new AdminFeeViewUpd().setVisible(true);
// }

}

④ AdminSysView(水电费管理系统>管理后台>管理员账户管理)

package com.ynavc.Vive;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;

import com.ynavc.Bean.Admin;
import com.ynavc.Controller.Select;
import com.ynavc.Controller.Updata;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Font;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import javax.swing.JPasswordField;

public class AdminSysView extends JFrame { 
   

	private JTextField textField;
	Select select = new Select();
	Updata updata = new Updata();
	Object[] header = { 
    "管理员编号", "管理员姓名", "管理员账户", "管理员密码" };
	Object[][] data = select.getAdminInfo();
	DefaultTableModel df = new DefaultTableModel(data, header);
	int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
	int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
	private JTextField textField_1;

	public AdminSysView() { 
   
		super("水电费管理系统--管理员后台---管理员账户管理");
		this.setBounds(0, 0, 748, 482);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);// 让窗口大小不可改变
		getContentPane().setLayout(null);

		JTable jTable = new JTable(df);
		JScrollPane jsp = new JScrollPane(jTable, v, h);
		jsp.setBounds(14, 114, 714, 320);
		getContentPane().add(jsp);

		JButton button_2 = new JButton("修改");
		button_2.setBounds(627, 27, 90, 30);
		button_2.setIcon(new ImageIcon(AdminSysViewAdd.class.getResource("/images/modify.png")));
		getContentPane().add(button_2);
		button_2.addActionListener(new ActionListener() { 
   
			@Override
			public void actionPerformed(ActionEvent e) { 
   
				if (jTable.getSelectedColumn() < 0) { 
   
					JOptionPane.showMessageDialog(null, "请选择要修改的数据!");
				} else { 
   
					Admin admin = new Admin();
					admin.setId(Integer.parseInt(jTable.getValueAt(jTable.getSelectedRow(), 0).toString()));
					admin.setName(jTable.getValueAt(jTable.getSelectedRow(), 1).toString());
					admin.setAccount(jTable.getValueAt(jTable.getSelectedRow(), 2).toString());
					admin.setPassword(jTable.getValueAt(jTable.getSelectedRow(), 3).toString());
					System.out.println(admin);
					AdminSysViewUpd adminSysViewUpd = new AdminSysViewUpd(admin);
					adminSysViewUpd.setVisible(true);
				}
			}
		});

		JButton button_3 = new JButton("删除");
		button_3.setBounds(522, 70, 90, 30);
		button_3.setIcon(new ImageIcon(AdminSysViewAdd.class.getResource("/images/delete.png")));
		getContentPane().add(button_3);
		button_3.addActionListener(new ActionListener() { 
   
			@Override
			public void actionPerformed(ActionEvent e) { 
   
				if (jTable.getSelectedColumn() < 0) { 
   
					JOptionPane.showMessageDialog(null, "请选中要删除的数据!");
				} else { 
   
					int userid = Integer.parseInt(jTable.getValueAt(jTable.getSelectedRow(), 0).toString());
					String dsql = "delete from admin where id=" + userid;
					int result = updata.addData(dsql);
					if (result > 0) { 
   
						JOptionPane.showMessageDialog(null, "删除成功!");
						Object[][] data = select.getAdminInfo();
						df.setDataVector(data, header);
					} else { 
   
						JOptionPane.showMessageDialog(null, "删除失败!");
					}
				}
			}
		});

		JButton button_4 = new JButton("添加");
		button_4.setBounds(627, 70, 90, 30);
		button_4.setIcon(new ImageIcon(AdminSysViewAdd.class.getResource("/images/add.png")));
		getContentPane().add(button_4);
		button_4.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent arg0) { 
   
				new AdminSysViewAdd().setVisible(true);
			}
		});
		
		JPanel panel = new JPanel();
		panel.setBounds(14, 13, 483, 81);
		panel.setBorder(new TitledBorder(null, "条件查询", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		getContentPane().add(panel);
				
				JLabel label_1 = new JLabel("编号:");
				panel.add(label_1);
				
				textField_1 = new JTextField();
				textField_1.setColumns(10);
				panel.add(textField_1);
		
				JLabel label = new JLabel("账户:");
				panel.add(label);
				
				textField = new JTextField();
				panel.add(textField);
				textField.setColumns(10);

				JButton button = new JButton("查询");
				button.setIcon(new ImageIcon(AdminSysViewAdd.class.getResource("/images/search.png")));
				panel.add(button);
				button.addActionListener(new ActionListener() { 
   
					public void actionPerformed(ActionEvent arg0) { 
   
						String id = textField_1.getText();
						String name = textField.getText();
						Object[][] data = select.getAdminInfoBykey(name, id);
						df.setDataVector(data, header);
					}
				});

		this.addWindowListener(new WindowAdapter() { 
   

			public void windowClosing(WindowEvent e) { 
   
				super.windowClosing(e);
				new AdminView().setVisible(true);
				// 加入动作
// GoodsManagement m = new GoodsManagement();
// m.setVisible(true);
			}
		});
	}
	
	
	public void refresh() { 
   
		Object[][] data = select.getAdminInfo();
		df.setDataVector(data, header);
	}

// public static void main(String[] args) { 
   
// AdminSysView t = new AdminSysView();
// t.setVisible(true);
// }
}

⑤ AdminSysViewAdd(水电费管理系统>管理后台>管理员账户添加)

package com.ynavc.Vive;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTextField;
import javax.swing.UnsupportedLookAndFeelException;

import com.ynavc.Controller.Updata;

import javax.swing.ImageIcon;
import javax.swing.JButton;

public class AdminSysViewAdd extends JFrame{ 
   
	
	private JTextField username;
	private JTextField account;
	private JTextField password;
	
	public AdminSysViewAdd() { 
   
		super("管理员账户管理");
		this.setBounds(0, 0, 450, 400);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);// 让窗口大小不可改变
		getContentPane().setLayout(null);
		
		Updata updata = new Updata();
		
		JLabel label = new JLabel("姓名:");
		label.setBounds(64, 95, 72, 18);
		getContentPane().add(label);
		
		username = new JTextField();
		username.setBounds(113, 92, 243, 24);
		getContentPane().add(username);
		username.setColumns(10);
		
		JLabel label_1 = new JLabel("账户:");
		label_1.setBounds(64, 149, 72, 18);
		getContentPane().add(label_1);
		
		account = new JTextField();
		account.setColumns(10);
		account.setBounds(113, 146, 243, 24);
		getContentPane().add(account);
		
		JLabel label_1_1 = new JLabel("密码:");
		label_1_1.setBounds(64, 203, 72, 18);
		getContentPane().add(label_1_1);
		
		password = new JTextField();
		password.setColumns(10);
		password.setBounds(113, 200, 243, 24);
		getContentPane().add(password);
		
		JLabel label_2 = new JLabel("管理员账户添加");
		label_2.setFont(new Font("宋体", Font.BOLD, 20));
		label_2.setBounds(144, 24, 173, 28);
		getContentPane().add(label_2);
		
		JButton addBtn = new JButton("确认添加");
		addBtn.setBounds(171, 288, 113, 27);
		addBtn.setIcon(new ImageIcon(AdminSysViewAdd.class.getResource("/images/add.png")));
		getContentPane().add(addBtn);
		addBtn.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent arg0) { 
   
				String uname = username.getText();
				String uaccount = account.getText();
				String pwd = password.getText();
				
				if (uname.equals("") && pwd.equals("") && uaccount.equals("")) { 
   
					JOptionPane.showMessageDialog(null, "请填写完整信息!");
				} else { 
   
					String sql = "INSERT INTO admin (name,account,`password`) VALUES('" + uname + "','"+uaccount+"','" + pwd + "')";
					int reselt = updata.addData(sql);
					if (reselt > 0) { 
   
						JOptionPane.showMessageDialog(null, "添加管理员账户成功!");
						AdminSysView adminSysView = AdminView.getAdminSysView();
						adminSysView.refresh();
						dispose();
					} else { 
   
						JOptionPane.showMessageDialog(null, "添加失败!");
					}
				}

			}
		});

	}
// public static void main(String[] args) { 
   
// new AdminSysViewAdd().setVisible(true);
// }
}

⑥ AdminSysViewUpd(水电费管理系统>管理后台>管理员账户修改)

package com.ynavc.Vive;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTextField;
import javax.swing.UnsupportedLookAndFeelException;

import com.ynavc.Bean.Admin;
import com.ynavc.Controller.Updata;

import javax.swing.ImageIcon;
import javax.swing.JButton;

public class AdminSysViewUpd extends JFrame{ 
   
	
	private JTextField username;
	private JTextField account;
	private JTextField password;
	private JTextField userid;
	
	public AdminSysViewUpd(Admin admin) { 
   
		super("管理员账户管理");
		this.setBounds(0, 0, 450, 400);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);// 让窗口大小不可改变
		getContentPane().setLayout(null);
		
		Updata updata = new Updata();
		
		JLabel label_2 = new JLabel("管理员账户修改");
		label_2.setFont(new Font("宋体", Font.BOLD, 20));
		label_2.setBounds(144, 24, 173, 28);
		getContentPane().add(label_2);
		
		JLabel label_3 = new JLabel("编号:");
		label_3.setBounds(65, 83, 72, 18);
		getContentPane().add(label_3);
		
		userid = new JTextField();
		userid.setEnabled(false);
		userid.setColumns(10);
		userid.setBounds(114, 80, 243, 24);
		getContentPane().add(userid);
		
		JLabel label = new JLabel("姓名:");
		label.setBounds(65, 132, 72, 18);
		getContentPane().add(label);
		
		username = new JTextField();
		username.setBounds(114, 129, 243, 24);
		getContentPane().add(username);
		username.setColumns(10);
		
		JLabel label_1 = new JLabel("账户:");
		label_1.setBounds(65, 186, 72, 18);
		getContentPane().add(label_1);
		
		account = new JTextField();
		account.setColumns(10);
		account.setBounds(114, 183, 243, 24);
		getContentPane().add(account);
		
		JLabel label_1_1 = new JLabel("密码:");
		label_1_1.setBounds(65, 240, 72, 18);
		getContentPane().add(label_1_1);
		
		password = new JTextField();
		password.setColumns(10);
		password.setBounds(114, 237, 243, 24);
		getContentPane().add(password);
		
		if (admin!=null) { 
   
			userid.setText(admin.getId().toString());
			username.setText(admin.getName());
			account.setText(admin.getAccount());
			password.setText(admin.getPassword());
		}
		
		JButton addBtn = new JButton("确认修改");
		addBtn.setBounds(171, 288, 113, 27);
		addBtn.setIcon(new ImageIcon(AdminSysViewUpd.class.getResource("/images/modify.png")));
		getContentPane().add(addBtn);
		addBtn.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent arg0) { 
   
				String uid = userid.getText();
				String uname = username.getText();
				String uaccount = account.getText();
				String pwd = password.getText();
				
				if (uname.equals("") && pwd.equals("") && uaccount.equals("")) { 
   
					JOptionPane.showMessageDialog(null, "请填写完整信息!");
				} else { 
   
					String sql = "UPDATE admin SET `name`='"+uname+"',account='"+uaccount+"',`password`='"+pwd+"' WHERE id='"+admin.getId()+"'";
					int reselt = updata.addData(sql);
					if (reselt > 0) { 
   
						JOptionPane.showMessageDialog(null, "添加管理员账户成功!");
						AdminSysView adminSysView = AdminView.getAdminSysView();
						adminSysView.refresh();
						dispose();
					} else { 
   
						JOptionPane.showMessageDialog(null, "添加失败!");
					}
				}

			}
		});

	}
// public static void main(String[] args) { 
   
// new AdminSysViewUpd(null).setVisible(true);
// }
}

⑦ AdminUserView(水电费管理系统>管理后台>平台用户信息管理)

package com.ynavc.Vive;

import javax.swing.JFrame;

import com.ynavc.Controller.Select;
import com.ynavc.Controller.Updata;

import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.xml.ws.soap.AddressingFeature;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import javax.swing.JTextArea;
import java.awt.FlowLayout;
import java.awt.BorderLayout;

public class AdminUserView extends JFrame{ 
   
	
	Select select = new Select();
	Updata updata = new Updata();
	
	private JTable table;
	DefaultTableModel df;
	
	Object[][] data = select.getUserInfo("");
	String[] header =  new String[] { 
    "户主编号", "户主姓名", "账户", "密码", "性别", "身份证号", "电话", "地址", "备注"};
	private JTextField userid;
	private JTextField username;
	private JTextField address;
	private JTextField idcard;
	private JTextField phone;
	private JTextField account;
	private JTextField password;
	private JTextField searchid;
	JTextArea usertime;
	ButtonGroup sex;
	JRadioButton male,female;
	

	public AdminUserView() { 
   
		super("水电费管理系统--管理员后台--平台用户信息管理");
		Updata updata = new Updata();
		this.setBounds(0, 0, 935, 700);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);
		getContentPane().setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(27, 321, 876, 331);
		getContentPane().add(scrollPane);
		
		table = new JTable();
		df = new DefaultTableModel(data,header);
		table.setModel(df);
		scrollPane.setViewportView(table);
		table.addMouseListener(new MouseListener() { 
   
			
			@Override
			public void mouseReleased(MouseEvent e) { 
   
				// 处理鼠标释放
			}
			
			@Override
			public void mousePressed(MouseEvent e) { 
   
				// 处理鼠标按下
			}
			
			@Override
			public void mouseExited(MouseEvent e) { 
   
				// 处理鼠标离开
			}
			
			@Override
			public void mouseEntered(MouseEvent e) { 
   
				// 处理鼠标移入
			}
			
			public void mouseClicked(MouseEvent e) { 
   
				// 处理鼠标点击
				userid.setText(table.getValueAt(table.getSelectedRow(), 0).toString());
				username.setText(table.getValueAt(table.getSelectedRow(), 1).toString());
				account.setText(table.getValueAt(table.getSelectedRow(), 2).toString());
				password.setText(table.getValueAt(table.getSelectedRow(), 3).toString());
				if ((table.getValueAt(table.getSelectedRow(), 4).toString()).equals("男")) { 
   
					male.setSelected(true);
				}else{ 
   
					female.setSelected(true);
				}
				idcard.setText(table.getValueAt(table.getSelectedRow(), 5).toString());
				phone.setText(table.getValueAt(table.getSelectedRow(), 6).toString());
				address.setText(table.getValueAt(table.getSelectedRow(), 7).toString());
				usertime.setText(table.getValueAt(table.getSelectedRow(), 8).toString());
			}
		});
		
		JPanel panel = new JPanel();
		panel.setBorder(new TitledBorder(null, "用户信息", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel.setBounds(27, 27, 876, 200);
		getContentPane().add(panel);
		panel.setLayout(null);
		
		JLabel label = new JLabel("户主编号:");
		label.setBounds(32, 30, 75, 18);
		panel.add(label);
		
		userid = new JTextField();
		userid.setEditable(false);
		userid.setBounds(112, 26, 119, 24);
		panel.add(userid);
		userid.setColumns(10);
		
		JLabel label_1 = new JLabel("户主姓名:");
		label_1.setBounds(257, 30, 75, 18);
		panel.add(label_1);
		
		username = new JTextField();
		username.setBounds(337, 26, 108, 24);
		panel.add(username);
		username.setColumns(10);
		
		JLabel label_2 = new JLabel("地址:");
		label_2.setBounds(505, 67, 54, 18);
		panel.add(label_2);
		
		address = new JTextField();
		address.setBounds(550, 64, 175, 24);
		panel.add(address);
		address.setColumns(10);
		
		JLabel label_3 = new JLabel("身份证号:");
		label_3.setBounds(32, 65, 75, 18);
		panel.add(label_3);
		
		idcard = new JTextField();
		idcard.setBounds(112, 61, 171, 24);
		panel.add(idcard);
		idcard.setColumns(10);
		
		JLabel label_2_1 = new JLabel("电话:");
		label_2_1.setBounds(308, 67, 45, 18);
		panel.add(label_2_1);
		
		
		phone = new JTextField();
		phone.setColumns(10);
		phone.setBounds(358, 63, 119, 24);
		panel.add(phone);
		
		JLabel label_1_1 = new JLabel("账户:");
		label_1_1.setBounds(459, 30, 45, 18);
		panel.add(label_1_1);
		
		account = new JTextField();
		account.setColumns(10);
		account.setBounds(511, 26, 120, 24);
		panel.add(account);
		
		JLabel label_1_1_1 = new JLabel("密码:");
		label_1_1_1.setBounds(651, 30, 45, 18);
		panel.add(label_1_1_1);
		
		password = new JTextField();
		password.setColumns(10);
		password.setBounds(703, 26, 127, 24);
		panel.add(password);
		
		JLabel label_4 = new JLabel("备注:");
		label_4.setBounds(35, 113, 72, 18);
		panel.add(label_4);
		
		usertime = new JTextArea();
		usertime.setBounds(91, 111, 741, 76);
		panel.add(usertime);
		
		JPanel panel_2 = new JPanel();
		panel_2.setBounds(739, 55, 91, 43);
		panel.add(panel_2);
		sex = new ButtonGroup ();
		panel_2.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		male = new JRadioButton ("男", true);
		female = new JRadioButton ("女", false);
		sex.add(male);
		sex.add(female);
		JPanel ButtonPanel=new JPanel();
        ButtonPanel.add(male);
        ButtonPanel.add(female);
        panel_2.add(ButtonPanel);
// panel_2.add(male,BorderLayout.WEST);
// panel_2.add(female,BorderLayout.EAST);
		
		
		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new TitledBorder(null, "条件查询", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		
		panel_1.setBounds(27, 240, 531, 68);
		getContentPane().add(panel_1);
		
		JLabel label_5 = new JLabel("编号:");
		panel_1.add(label_5);
		
		searchid = new JTextField();
		panel_1.add(searchid);
		searchid.setColumns(10);
		
		JButton searchBuut = new JButton("查询");
		panel_1.add(searchBuut);
		searchBuut.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				// 处理鼠标点击
				userid.setText("");
				username.setText("");
				account.setText("");
				password.setText("");
				male.setSelected(true);
				idcard.setText("");
				phone.setText("");
				address.setText("");
				usertime.setText("");
				String id = searchid.getText();
				Object[][] data = select.getUserInfo(id);
				df.setDataVector(data, header);
			}
		});
		searchBuut.setIcon(new ImageIcon(AdminUserView.class.getResource("/images/search.png")));
		
		JButton addButt = new JButton("新增用户");
		addButt.setBounds(790, 265, 113, 27);
		getContentPane().add(addButt);
		
		JButton updataButt = new JButton("修改信息");
		updataButt.setBounds(659, 265, 113, 27);
		getContentPane().add(updataButt);
		updataButt.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				String usex;
				if (male.isSelected()) { 
   
					usex = "男";
				} else { 
   
					usex = "女";
				}
				String sql = "UPDATE users SET username='"+username.getText()+"',account='"+account.getText()+"',`password`='"+password.getText()+"',sex='"+usex+"',idcard='"+idcard.getText()+"',phone='"+phone.getText()+"',address='"+address.getText()+"',usertime='"+usertime.getText()+"' WHERE id='"+userid.getText()+"'";
				int addData = updata.addData(sql);
				if (addData>0) { 
   
					JOptionPane.showMessageDialog(null, "修改成功!");
					Object[][] data = select.getUserInfo("");
					df.setDataVector(data, header);
				} else { 
   
					JOptionPane.showMessageDialog(null, "修改失败!");
				}
			}
		});
		
		this.addWindowListener(new WindowAdapter() { 
   

			public void windowClosing(WindowEvent e) { 
   
				super.windowClosing(e);
				new AdminView().setVisible(true);
			}
		});
	}
	
		
// public static void main(String[] args) { 
   
// new AdminUserView().setVisible(true);
// }
}

⑧ AdminUserViewAdd(水电费管理系统>管理后台>平台用户信息添加)

package com.ynavc.Vive;

import javax.swing.JFrame;

import com.ynavc.Controller.Updata;

public class AdminUserViewAdd extends JFrame{ 
   
	public AdminUserViewAdd() { 
   
		super("管理员账户管理");
		this.setBounds(0, 0, 450, 400);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);// 让窗口大小不可改变
		getContentPane().setLayout(null);
		
		Updata updata = new Updata();
		
	}
	
	public static void main(String[] args) { 
   
		
	}
}

⑨ AdminView(管理员后台主界面)

package com.ynavc.Vive;

import javax.swing.JFrame;

import com.ynavc.Controller.Updata;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import java.awt.Color;
import javax.swing.SwingConstants;

public class AdminView extends JFrame{ 
   
	
	static AdminUserView adminUserView = new AdminUserView();
	static AdminSysView adminSysView = new AdminSysView();
	static AdminFeeView adminFeeView = new AdminFeeView();
	public AdminView() { 
   
		super("水电费管理系统--管理员后台");
		getContentPane().setFont(new Font("宋体", Font.PLAIN, 35));
		Updata updata = new Updata();
		this.setBounds(0, 0, 760, 400);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);
		getContentPane().setLayout(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 用户单击窗口的关闭按钮时程序执行的操作
		
		JLabel lblxxx = new JLabel("你好,管理员 ,欢迎使用水电费管理系统");
		lblxxx.setFont(new Font("宋体", Font.PLAIN, 35));
		lblxxx.setBounds(44, 35, 726, 91);
		getContentPane().add(lblxxx);
		
		JButton button = new JButton("用户信息管理");
		button.setFont(new Font("宋体", Font.BOLD, 20));
		button.setBounds(80, 192, 166, 59);
		button.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent arg0) { 
   
				adminUserView.setVisible(true);
				dispose();
			}
		});
		getContentPane().add(button);
		
		JButton button_1 = new JButton("水电费管理");
		button_1.setFont(new Font("宋体", Font.BOLD, 20));
		button_1.setBounds(292, 192, 166, 59);
		button_1.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent arg0) { 
   
				adminFeeView.setVisible(true);
				dispose();
			}
		});
		getContentPane().add(button_1);
		
		JButton button_1_1 = new JButton("管理账户管理");
		button_1_1.setFont(new Font("宋体", Font.BOLD, 20));
		button_1_1.setBounds(515, 192, 166, 59);
		button_1_1.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent arg0) { 
   
				adminSysView.setVisible(true);
				dispose();
			}
		});
		getContentPane().add(button_1_1);
// String username = "系统管理员";
// if (UserLogin.getUsername()!=null) { 
   
// username = UserLogin.getUsername();
// }
 System.out.println("41534"+username);
// if (!username.equals("")) { 
   
// lblNewLabel.setText(username);
// }
	}
	
	public static AdminSysView getAdminSysView() { 
   
		return adminSysView;
	}
	public static AdminFeeView getAdminFeeView() { 
   
		return adminFeeView;
	}
	
// public static void main(String[] args) { 
   
// new AdminView().setVisible(true);
// }
}

⑩ Registered(用户注册界面)

package com.ynavc.Vive;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import com.ynavc.Controller.Updata;

public class Registered extends JFrame { 
   
	private JTextField username;
	private JTextField password;
	private JTextField textField;

	public Registered() { 
   
		super("用户注册");
		Updata updata = new Updata();
		this.setBounds(0, 0, 600, 350);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);// 让窗口大小不可改变
		getContentPane().setLayout(null);

		JLabel usernameText = new JLabel("账号:");
		usernameText.setBounds(142, 36, 72, 18);
		getContentPane().add(usernameText);

		username = new JTextField();
		username.setBounds(228, 33, 203, 24);
		getContentPane().add(username);
		username.setColumns(10);

		JLabel passwordText = new JLabel("密码:");
		passwordText.setBounds(142, 96, 72, 18);
		getContentPane().add(passwordText);

		password = new JPasswordField();
		password.setColumns(10);
		password.setBounds(228, 93, 203, 24);
		getContentPane().add(password);

		JButton regButton = new JButton("确认注册");
		regButton.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				String uname = username.getText();
				String pwd = password.getText();
				if (uname.equals("") && pwd.equals("")) { 
   
					JOptionPane.showMessageDialog(null, "账户名或密码未填写!");
				} else { 
   
					if (pwd.equals(textField.getText())) { 
   
						String sql = "INSERT INTO users (username,`password`) VALUES('" + uname + "','" + pwd + "')";
						int reselt = updata.addData(sql);
						if (reselt > 0) { 
   
							JOptionPane.showMessageDialog(null, "注册成功!请登录!");
							new UserLogin().setVisible(true);
							dispose();
						} else { 
   
							JOptionPane.showMessageDialog(null, "注册失败!");
						}
					} else { 
   
						JOptionPane.showMessageDialog(null, "两次密码不一致请重新输入!");
					}
				}

			}
		});
		regButton.setBounds(243, 222, 113, 27);
		getContentPane().add(regButton);

		ImageIcon icon = new ImageIcon("src/img/background.jpg");

		JLabel passwordText_1 = new JLabel("确认密码:");
		passwordText_1.setBounds(119, 148, 95, 18);
		getContentPane().add(passwordText_1);

		textField = new JPasswordField();
		textField.setColumns(10);
		textField.setBounds(228, 145, 203, 24);
		getContentPane().add(textField);

		this.addWindowListener(new WindowAdapter() { 
   

			public void windowClosing(WindowEvent e) { 
   
				super.windowClosing(e);
				// 加入动作
// UserLogin.getUserLoin().setVisible(true);
			}
		});

	}
}

⑪ UserFeeView(用户收费信息查询界面)

package com.ynavc.Vive;

import javax.swing.JFrame;
import javax.swing.JScrollPane;

import com.ynavc.Controller.Select;
import com.ynavc.Controller.Updata;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;

import java.awt.Color;
import java.awt.FileDialog;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.JButton;

public class UserFeeView extends JFrame { 
   
	
	JTable jtable;
	Select select = new Select();
	Updata updata = new Updata();
	Object[] header = { 
    "订单号", "户主", "用水分类", "水费单价", "水费总量", "本月水费", "用电类型", "电费单价", "电总量", "本月电费", "年份", "月份", "应缴纳费用",
			"收费时间", "开票人", "备注" };
	Object[][] data = null;
	DefaultTableModel df = null;
	int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
	int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;

	public UserFeeView(String id) { 
   
		super("水电费管理系统--用户水电费查询");
		Updata updata = new Updata();
		this.setBounds(0, 0, 1235, 500);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);
		getContentPane().setLayout(null);

		data = select.getFeeInfoByMonth(id, "", "");
		df = new DefaultTableModel(data, header);
		jtable = new JTable(df);// 创建表格
		jtable.getTableHeader().setFont(new Font(null, Font.BOLD, 14)); // 设置表头名称字体样式
		jtable.getTableHeader().setForeground(Color.black); // 设置表头名称字体颜色
		// jTable.getTableHeader().setResizingAllowed(false); // 设置不允许手动改变列宽
		jtable.getTableHeader().setReorderingAllowed(false);// 设置表头不允许拖动
		int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;// 水平滚动条
		int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;// 垂直滚动条
		JScrollPane jsp = new JScrollPane(jtable, v, h);
		jsp.setBounds(26, 105, 1178, 331);
		getContentPane().add(jsp);

		JPanel panel = new JPanel();
		panel.setBorder(new TitledBorder(null, "条件查询", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel.setBounds(26, 13, 340, 78);
		getContentPane().add(panel);

		JLabel label_1 = new JLabel("年份:");
		panel.add(label_1);

		JComboBox comboBox = new JComboBox();
		panel.add(comboBox);
		for (int i = 2016; i < 2026; i++) { 
   
			comboBox.addItem(i + "年");
		}

		JLabel label_2 = new JLabel("月份");
		panel.add(label_2);

		JComboBox comboBox_1 = new JComboBox();
		panel.add(comboBox_1);
		for (int i = 1; i <= 12; i++) { 
   
			comboBox_1.addItem(i + "月");
		}
		
		comboBox.setSelectedItem("2021年");
		comboBox_1.setSelectedItem("7月");

		JButton button = new JButton("查询");
		button.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				String years = comboBox.getItemAt(comboBox.getSelectedIndex()).toString();
				String mouth = comboBox_1.getItemAt(comboBox_1.getSelectedIndex()).toString();
				Object[][] data = select.getFeeInfoByMonth(id, years, mouth);
				df.setDataVector(data, header);
			}
		});
		panel.add(button);

// // 创建表模型
// df = new DefaultTableModel(data, header) { 
   
// // 设置表格内容不可被编辑
// public boolean isCellEditable(int row, int column) { 
   
// return false;// 返回true表示能编辑,false表示不能编辑
// }
// };

		JButton btnexcel = new JButton("导出数据导Excel");
		btnexcel.setBounds(1057, 47, 147, 27);
		getContentPane().add(btnexcel);

		JButton btnNewButton = new JButton("显示全部");
		btnNewButton.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				Object[][] data = select.getFeeInfo("");
				df.setDataVector(data, header);
			}
		});
		btnNewButton.setBounds(909, 47, 113, 27);
		getContentPane().add(btnNewButton);
		btnexcel.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				jButtonActionPerformed(e);
			}
		});
		// 设置单元格内容居中显示
		DefaultTableCellRenderer r = new DefaultTableCellRenderer();
		r.setHorizontalAlignment(JLabel.CENTER);
		jtable.setDefaultRenderer(Object.class, r);
		// Object[][] data = select.getAdminInfo();
		df.setDataVector(data, header);
		
		this.addWindowListener(new WindowAdapter() { 
   

			public void windowClosing(WindowEvent e) { 
   
				super.windowClosing(e);
				new UserLogin().setVisible(true);
				// 加入动作
// GoodsManagement m = new GoodsManagement();
// m.setVisible(true);
			}
		});
	}

	// 导出
	private void jButtonActionPerformed(java.awt.event.ActionEvent evt) { 
   
		FileDialog fd = new FileDialog(this, "将数据保存到", FileDialog.SAVE);
		fd.setLocation(1100, 600);
		fd.setVisible(true);
		String stringfile = fd.getDirectory() + fd.getFile() + ".xlsx";
		try { 
   
			this.exportTable(jtable, new File(stringfile));
		} catch (IOException ex) { 
   
			ex.printStackTrace();
		}
	}

	/** 导出JTable到excel */
	public void exportTable(JTable table, File file) throws IOException { 
   
		TableModel model = table.getModel();
		BufferedWriter bWriter = new BufferedWriter(new FileWriter(file));
		for (int i = 0; i < model.getColumnCount(); i++) { 
   
			bWriter.write(model.getColumnName(i));
			bWriter.write("\t");
		}
		bWriter.newLine();
		for (int i = 0; i < model.getRowCount(); i++) { 
   
			for (int j = 0; j < model.getColumnCount(); j++) { 
   
				bWriter.write(model.getValueAt(i, j).toString());
				bWriter.write("\t");
			}
			bWriter.newLine();
		}
		bWriter.close();
	}

// public static void main(String[] args) { 
   
// new UserFeeView("1").setVisible(true);
// }
}

⑫ UserLogin(登录界面)

package com.ynavc.Vive;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.UnsupportedLookAndFeelException;

import com.ynavc.Controller.Select;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Toolkit;

import javax.swing.JPasswordField;
import javax.swing.JCheckBox;

public class UserLogin extends JFrame { 
   
	Registered registered = new Registered();
	static { 
   
		try { 
   
			// 这里是皮肤包可以随意切换
			javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.mcwin.McWinLookAndFeel");
// javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel");
// javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.luna.LunaLookAndFeel");
// javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.aluminium.AluminiumLookAndFeel");
// javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.bernstein.BernsteinLookAndFeel");
// javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.hifi.HiFiLookAndFeel");
// javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.aero.AeroLookAndFeel");
// javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.mint.MintLookAndFeel");
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
				| UnsupportedLookAndFeelException e) { 
   
			e.printStackTrace();
		}
	}
	String uid;
	private static JTextField username;
	private JTextField password;
	JCheckBox chckbxNewCheckBox;

	public UserLogin() { 
   
		super("用户登录");
		Select select = new Select();
		this.setBounds(0, 0, 600, 350);
		this.setLocationRelativeTo(null);// 让窗口在屏幕中间显示
		this.setResizable(false);// 让窗口大小不可改变
		getContentPane().setLayout(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 用户单击窗口的关闭按钮时程序执行的操作
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(UserLogin.class.getResource("/images/logo.png")));

		JLabel usernameText = new JLabel("账号:");
		usernameText.setBounds(142, 70, 72, 18);
		usernameText.setIcon(new ImageIcon(UserLogin.class.getResource("/images/userName.png")));
		getContentPane().add(usernameText);

		username = new JTextField();
		username.setBounds(228, 67, 203, 24);
		getContentPane().add(username);
		username.setColumns(10);

		JLabel passwordText = new JLabel("密码:");
		passwordText.setIcon(new ImageIcon(UserLogin.class.getResource("/images/password.png")));
		passwordText.setBounds(142, 138, 72, 18);

		getContentPane().add(passwordText);

		password = new JPasswordField();
		password.setColumns(10);
		password.setBounds(228, 135, 203, 24);
		getContentPane().add(password);

		JButton logButton = new JButton("登录");
		logButton.setIcon(new ImageIcon(UserLogin.class.getResource("/images/login.png")));
		logButton.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				String uname = username.getText();
				String pwd = password.getText();
				if (chckbxNewCheckBox.isSelected()) { 
   
					if (uname.equals("") && pwd.equals("")) { 
   
						JOptionPane.showMessageDialog(null, "账户名或密码未填写!");
					} else { 
   
						String sql = "select COUNT(*) from admin where account='" + uname + "' and password='" + pwd
								+ "'";
						int reselt = select.userloginSelect(sql);
						if (reselt > 0) { 
   
							JOptionPane.showMessageDialog(null, "登录成功!欢迎使用!");
							new AdminView().setVisible(true);
							dispose();
						} else { 
   
							JOptionPane.showMessageDialog(null, "登录失败!账户名或密码不正确!请重新输入!");
						}
					}
				} else { 
   
					if (uname.equals("") && pwd.equals("")) { 
   
						JOptionPane.showMessageDialog(null, "账户名或密码未填写!");
					} else { 
   
						String sql = "select COUNT(*) from users where account='" + uname + "' and password='" + pwd
								+ "'";
						int reselt = select.userloginSelect(sql);
						if (reselt > 0) { 
   
							sql = "select id from users where account='" + uname + "' and password='" + pwd
									+ "'";
							uid = String.valueOf(select.userloginSelect(sql));
// String namesql = "select name from users where id="+uid;
// select.get
							JOptionPane.showMessageDialog(null, "登录成功!欢迎使用!");
							new UserFeeView(uid).setVisible(true);
							dispose();
						} else { 
   
							JOptionPane.showMessageDialog(null, "登录失败!账户名或密码不正确!请重新输入!");
						}
					}
				}
			}
		});
		logButton.setBounds(318, 228, 113, 27);
		getContentPane().add(logButton);

		JButton regButton = new JButton("重置");
		regButton.setIcon(new ImageIcon(UserLogin.class.getResource("/images/reset.png")));
		regButton.addActionListener(new ActionListener() { 
   
			public void actionPerformed(ActionEvent e) { 
   
				username.setText("");
				password.setText("");
			}
		});
		regButton.setBounds(142, 228, 113, 27);
		getContentPane().add(regButton);

		chckbxNewCheckBox = new JCheckBox("管理员登录");
		chckbxNewCheckBox.setBounds(331, 180, 118, 27);
		getContentPane().add(chckbxNewCheckBox);
	}

// public static String getUsername() { 
   
// if (username.getText().equals("")) { 
   
// return username.getText();
// }
// return "系统管理员";
// }

	public static void main(String[] args) { 
   
		new UserLogin().setVisible(true);
	}
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/149935.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • Java算法——判断素数[通俗易懂]

    Java算法——判断素数[通俗易懂]Java算法——判断素数,供自己学习方便和初学者参考! publicstaticbooleanisPrimeNumber(intnumber){if(number<2){returnfalse;}for(i

  • 软件版本号命名规范1.0.0.1什么意思_医疗器械软件版本号命名规范

    软件版本号命名规范1.0.0.1什么意思_医疗器械软件版本号命名规范软件版本号命名规范总原则标准的版本号必须采用XYZ的格式,并且X、Y和Z为非负的整数,禁止在数字前方补零版本是严格递增的,此处是:16.2.0->16.3.0->16.3.1在发布重要版本时,可以发布alpha,rc等先行版本alpha和rc等修饰版本的关键字后面可以带上次数和meta信息版本的优先层级指的是不同版本在排序时如何比较。判断优先层级时,必…

  • ❤️设计模式肝完了,还挺全!腾讯和阿里的offer已拿!❤️

    ❤️设计模式肝完了,还挺全!腾讯和阿里的offer已拿!❤️设计模式肝完了,还挺全!腾讯和阿里的offer已拿!金九银十已经来了,挺近大厂最好的机会已经来了!如果你是要找工作的,一定要抓住这个机会!前面已经整理了很多的面试资料:1,❤️爆肝!整理了一周的Spring面试大全【含答案】,吊打Java面试官【建议收藏】!❤️2,❤️肝完了,一天掌握数据结构和算法面试题,吊打面试官,建议收藏❤️3,❤️集合很简单?开什么玩笑?肝了一周,全是精华,万字讲解!面试再不怕集合问题了!!!❤️4,肝完了,总结了SpringBoot与缓存的知识点,快速掌

  • 史上最全 Java 多线程面试题及答案「建议收藏」

    史上最全 Java 多线程面试题及答案「建议收藏」这篇文章主要是对多线程的问题进行总结的,因此罗列了40个多线程的问题。这些多线程的问题,有些来源于各大网站、有些来源于自己的思考。可能有些问题网上有、可能有些问题对应的答案也有、也可能有些各位网友也都看过,但是本文写作的重心就是所有的问题都会按照自己的理解回答一遍,不会去看网上的答案,因此可能有些问题讲的不对,能指正的希望大家不吝指教。1、多线程有什么用? 一个可能在很多人…

  • linux(11)配置环境变量「建议收藏」

    linux(11)配置环境变量「建议收藏」前言在自定义安装软件的时候,经常需要配置环境变量,下面进行详细解析&nbsp;环境变量配置文件|用户|配置文件||:|:||系统环境|/ect/profil

  • The remote server returned an error (415) Cannot process the message

    The remote server returned an error (415) Cannot process the messageICreatedmyWCFServiceanditwasworkingproperlywheniwasmakingitsservicereferenceinmylocalmachine.AlsoitcanworkwellwithtoolWPFTestClient.ButtheproblemcamewhenIinvoked

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号