基于java的Swing+MySQL物业收费系统(java+gui)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

130123062403

130123062402

140123062402

150123062402

160123062402

基于java的Swing+MySQL物业收费系统(java+gui)

功能介绍:

用户登陆、用户注册、收费记录、生成业单、用户管理、查询缴费、历史账单、资料设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
		String pwdString2 = new String (passwordField2.getPassword());
String phoneString = phoneField.getText();
String keyString=keyField.getText();
if(userNameString.length()*pwdString1.length()*pwdString2.length()*phoneString.length()*keyString.length()==0) {
JOptionPane.showMessageDialog(null, "请将所有信息完善", "找回失败", JOptionPane.ERROR_MESSAGE);
}else {
if(pwdString1.equals(pwdString2)) {
// if(codeString.length()!=0) {
// if(codeString.equals(keyString)) {
List<User> selectOne = new UserDAOImp().selectOne(userNameString, phoneString);
if(selectOne.size()>0) {
int flag = new UserDAOImp().updateForForget(userNameString, phoneString, pwdString2);
if(flag<=0) {
JOptionPane.showMessageDialog(null, "数据库异常", "找回失败", JOptionPane.ERROR_MESSAGE);
}else {
JOptionPane.showMessageDialog(null, "密码找回成功,请尝试重新登录", "成功找回", JOptionPane.PLAIN_MESSAGE);
ForgetUI.dispose();
}
}else {
JOptionPane.showMessageDialog(null, "用户不存在或者此用户预留手机号码不正确", "找回失败", JOptionPane.ERROR_MESSAGE);
}
// }else {
// JOptionPane.showMessageDialog(null, "验证码错误或者无效", "找回失败", JOptionPane.ERROR_MESSAGE);
// }
// }else {
// JOptionPane.showMessageDialog(null, "请先获取验证码", "警告", JOptionPane.WARNING_MESSAGE);
// }
}else {
JOptionPane.showMessageDialog(null, "两次输入密码不一致", "找回失败", JOptionPane.ERROR_MESSAGE);
}
}
}

@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==sendBtn) {
codeCheck();
}
if(e.getSource()==submitBtn) {
checkRight();
}
}

private void codeCheck() {
if(phoneField.getText().matches(regexCh)) {
timer.schedule(new TimerTask() {
int i = 60;
@Override
public void run() {
sendBtn.setForeground(Color.white);
sendBtn.setBackground(Color.DARK_GRAY);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
	}
public JComboBox<String> getWillPayBox() {
return willPayBox;
}
public void setWillPayBox(JComboBox<String> willPayBox) {
this.willPayBox = willPayBox;
}
public List<Payment> getpList() {
return pList;
}
public void setpList(List<Payment> pList) {
this.pList = pList;
}
public JButton getPayBtn() {
return payBtn;
}
public void setPayBtn(JButton payBtn) {
this.payBtn = payBtn;
}
public JButton getCodeBtn() {
return codeBtn;
}
public void setCodeBtn(JButton codeBtn) {
this.codeBtn = codeBtn;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}

}
package com.program.userUI;



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
       closeBtn.setBackground(null);

miniBtn.setIcon(new ImageIcon("mstUI_img/mini2.png"));
miniBtn.setRolloverIcon(new ImageIcon("mstUI_img/mini1.png"));
miniBtn.setPressedIcon(new ImageIcon("mstUI_img/mini3.png"));
closeBtn.setIcon(new ImageIcon("mstUI_img/close2.png"));
closeBtn.setRolloverIcon(new ImageIcon("mstUI_img/close1.png"));
closeBtn.setPressedIcon(new ImageIcon("mstUI_img/close3.png"));

headPanel.add(miniBtn);
headPanel.add(closeBtn);

JLabel showWhoJLabel=new JLabel();
showWhoJLabel.setBounds(20, 0, 600, 60);
showWhoJLabel.setFont(new Font("微软雅黑",Font.BOLD,20));
String textString="物业收费系统-居民模式 Hi! "+user.getName()+" ,今天是"+getDateStr();
//String textString="物业收费系统-居民模式 Hi! "+" ,今天是"+getDateStr();
showWhoJLabel.setText(textString);
headPanel.add(showWhoJLabel);

add(headPanel);
}
private static String getDateStr() {
Calendar c=Calendar.getInstance();
Date d=new Date();
c.setTime(d);//设置指定时间
int year=c.get(Calendar.YEAR);
int month=c.get(Calendar.MONTH)+1; //默认是0-11,我国是1-12
int day=c.get(Calendar.DAY_OF_MONTH);
return year+"/"+month+"/"+day;
}
public JTabbedPane initJTabbedPane() {
uTabbedPane=new JTabbedPane();
jPanel01=new JPanel(null);
jPanel02=new JPanel(null);
jPanel03=new JPanel(null);

jPanel01.setBackground(color);
jPanel02.setBackground(color);
jPanel03.setBackground(color);

uTabbedPane.addTab("jPanel01", jPanel01); //添加选项卡容器,并且设置其中每个选项卡的标签以及其是否可启用
uTabbedPane.setEnabledAt(0, true);
uTabbedPane.setTitleAt(0, "查询缴费");
uTabbedPane.addTab("jPanel02", jPanel02); //添加选项卡容器,并且设置其中每个选项卡的标签以及其是否可启用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
					int insertNum = new PaymentDAOImp().insertObj(insertList);
JOptionPane.showMessageDialog(null, "业单生成成功:"+insertNum+"条", "添加成功",JOptionPane.PLAIN_MESSAGE);
} catch (SQLException e1) {
System.out.println("MasterListener中账单生成的SQL语句错误");
}
}
}

}
if(e.getSource()==masterPaneSon1.getClearButton()) {
masterPaneSon1.getPayBox().setSelectedIndex(0);
masterPaneSon1.getField02().setText("");
masterPaneSon1.getField03().setText("");
masterPaneSon1.getField04().setText("");
}
if(e.getSource()==masterPaneSon2.getDelButton()) {
delRows(masterPaneSon2.getDtm(), masterPaneSon2.getUserTable(), new UserDAOImp());
}
}

public void delRows(DefaultTableModel tableModel,JTable table,AdapterDAO adapterDAO) {
List<Integer> idList=new ArrayList<Integer>();
int selectRows=table.getSelectedRows().length;// 取得用户所选行的行数
int[] selectedRows = table.getSelectedRows();
if(selectRows<=0) {
JOptionPane.showMessageDialog(null, "删除前要选中行", "警告", JOptionPane.WARNING_MESSAGE);
}else {
// 确认是否删除
int get = JOptionPane.showOptionDialog(null, "请确认是否删除?", "友情询问", JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE, null, new Object[]{"是","否"}, "否");
if(get!=1) {
// 视觉上:倒着删避免数组下标越界
for(int i=selectRows-1;i>=0;i--) {
idList.add((Integer.parseInt(tableModel.getValueAt(selectedRows[i], 0)+"")));
tableModel.removeRow(selectedRows[i]);
}
// 数据库中:先获取选中行的第0列 -> 编号列,通过编号删除数据库中的数据
// 调用删除方法
if(adapterDAO instanceof PaymentDAOImp) {
PaymentDAOImp p=(PaymentDAOImp)adapterDAO;
p.delete(idList);
}else if(adapterDAO instanceof UserDAOImp){
UserDAOImp u=(UserDAOImp)adapterDAO;
u.delete(idList);
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
jPanel01.setBackground(color);
JLabel jLabel01=new JLabel("用户名");
jLabel01.setBounds(100, 20, 60, 40);
jLabel01.setFont(font);
field=new JTextField(20);
field.setBounds(170, 20, 200, 40);
field.setFont(fontField);
field.setBorder(null);
jPanel01.add(jLabel01);
jPanel01.add(field);
jPanel01.setBounds(0, 50, this.getWidth(), 50);
this.add(jPanel01);

// 密码+密码框
jPanel02=new JPanel();
jPanel02.setLayout(null);
jPanel02.setBackground(color);
JLabel jLabel02=new JLabel("密码");
jLabel02.setBounds(100, 20, 60, 40);
jLabel02.setFont(font);
passwordField=new JPasswordField(20);
passwordField.setBounds(170, 20, 200, 40);
passwordField.setFont(fontField);
passwordField.setBorder(null);
jPanel02.add(jLabel02);
jPanel02.add(passwordField);
jPanel02.setBounds(0, 100, this.getWidth(), 50);
this.add(jPanel02);

// 手机号+文本框
jPanel03=new JPanel();
jPanel03.setLayout(null);
jPanel03.setBackground(color);
JLabel jLabel03=new JLabel("手机号");
jLabel03.setBounds(100, 20, 60, 30);
jLabel03.setFont(font);
phoneField=new JTextField();
phoneField.setBounds(170, 20, 200, 40);
phoneField.setFont(fontField);
phoneField.setBorder(null);

jPanel03.add(jLabel03);
jPanel03.add(phoneField);
jPanel03.setBounds(0, 150, this.getWidth(), 50);
this.add(jPanel03);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
field01.setForeground(new Color(211,82,48));
this.payBox=initBox();
payBox.setBounds(400, 100, 180, 36);
payBox.setFont(font2);
payBox.setBackground(Color.white);
payBox.setBorder(null);
payBox.addItemListener(getItemListener());
add(payBox);
add(field01);

field02=new JTextField();
field03=new JTextField();
field04=new JTextField();
field02.setBounds(400, 150, 180, 36);
field03.setBounds(400, 200, 180, 36);
field04.setBounds(400, 250, 180, 36);
field02.setFont(font2);
field03.setFont(font2);
field04.setFont(font2);

infoField01=new JTextField();
infoField02=new JTextField();
infoField03=new JTextField();
infoField01.setBounds(600, 150, 200, 36);
infoField02.setBounds(600, 200, 200, 36);
infoField03.setBounds(600, 250, 200, 36);
infoField01.setFont(font2);
infoField01.setEditable(false);
infoField01.setBorder(null);
infoField01.setBackground(null);
infoField01.setForeground(new Color(211,82,48));
infoField02.setFont(font2);
infoField02.setEditable(false);
infoField02.setBorder(null);
infoField02.setBackground(null);
infoField02.setForeground(new Color(211,82,48));
infoField03.setFont(font2);
infoField03.setEditable(false);
infoField03.setBorder(null);
infoField03.setBackground(null);
infoField03.setForeground(new Color(211,82,48));

add(field02);


项目链接:
https://javayms.github.io?id=151222062008200wo
https://javayms.pages.dev?id=151222062008200wo