软件工程课程设计——物业管理系统_软件工程课程设计系统
软件工程课程设计——物业管理系统由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“软件工程课程设计系统”。
软件工程
——物业管理系统的开发
学生姓名: 武鹏艳 乔海亮
学生班级: 软件工程122002班
学生学号: 201220040220 201220040213 指导老师: 潘理虎 日 期: 2014.6.20
目录
一.背景分析...............................................................................................1 二.系统设计问题定义..............................................................................1 三.系统分析.............................................................................................11、现行系统分析................................................................................12、系统可行性分析............................................................................1 四.系统描述.............................................................................................21、系统需求具体描述........................................................................22、系统功能具体描述........................................................................3 五.系统流程图设计................................................................................3 六.系统功能模块图设计........................................................................41、系统性能需求分析......................................................................42、系统功能需求分析......................................................................5 七.系统功能模型设计............................................................................5 八.系统所涉及的实体联系设计............................................................5 九. 系统状态图设计..............................................................................6 十. 系统数据流图设计..........................................................................7 十一.系统人机交互界面的设计............................................................9 十二. 系统设计的实现........................................................................11 十三. 系统设计的代码附录................................................................20
一.背景分析
随着市场经济的发展和人们生活水平的提高,小区物业方面缴费方面越来越多,但缴费难的问题继续困扰着我们,需要有一个系统来实现银行卡交水电费,实现小区管理而且小区用户可以更好的维护小区各项物业管理业务,处理工作,实现缴费方便功能,就可以避免应缴费不及时而造成停电停水的情况发生。二.系统设计问题定义
1、实现对住户水电使用信息管理。
2、实现住户的信息查询与更新。三.系统分析(1)现行系统分析
以往住户的更替使水电费管理有些混乱,不能顺利收取费用。现在的系统会对小区水电管理存在的不完善之处做相应的改进,及时提醒住户缴费,而且对每户人员及时更新并做详细记录,为操作人员做权限设置。
(2)系统可行性分析 A系统成本效益分析
1、货币的时间价值
假设生命周期为t年,编写程序需m元,应用程序后,每年可节省n元,年利率为p。
2、纯收入
工程的纯收入是:r=n/(1+p)+n/(1+p)²+„„+n/(1+p)^n-m
3、投资回收率
m=F1/(1+j)+F2/(1+j)²+„„+Fn/(1+j)^n(Fi是第i年底效益,j是投资回收率。)B系统可行性综述
1、经济可行性:获益是当初投资总额的三倍或三倍以上,可以进行投资。
2、技术可行性:该系统简单、使用,且以现有的技术可以实现系统中的功能。
3、社会可行性:该系统面向全社会小区居民的物业管理,没有负面影响,并且可以为社会带来很高的效益。四.系统描述
(1)系统需求具体描述
所设计的物业管理系统,它是由住户信息管理,缴费管理,投诉管理,楼房管理组成的网络系统。a住户信息管理
由住户注册,注册姓名,联系方式,住址,邮箱,入住时间。注册成功后,由系统管理员统一管理,管理员可以进行查询,修改信息。住户注册成功可以进行登录系统进行查询,但是不可以修改。进行信息的修改需要投诉给管理员,管理员进行修改。b缴费管理
由住户执行,住户可以查询水电费使用情况,余额不足进行缴费,进入银行缴费界面,输入账号密码,进行缴费。
c投诉管理
由管理员进行查询,用户可以对小区物业管理水电费物业部门投诉建议。管理员可以根据客户要求,能对住户水电费信息、修改、查询和删除等操作,并且还要实现包括水、电、煤气费在内的各项物业管理费用的统计、查询和报表生成。d住户和管理员
住户可以管理自己的信息,可以提交投诉信息,可以浏览收费信息和缴费信息。管理员可以对纪录进行增加、删除、修改,管理投诉等更新操作。用户进入系统必须先输入用户名和密码,按“确认”按钮后,系统辨别用户身份,对合法用户根据用户的权限赋予相应的使用功能。
(2)系统功能具体描述
小区物业管理系统具体实现以下功能:
1.对小区所有房屋资料的录入和增,删,改,查询等功能的实现。
2.对本小区内住户的详细资料的管理,包括增,删,改,查询等功能的实现。
3.实现物业设备管理,仪表包括水,电数据管理,收费管理。仪表数据管理模块管理每个住户的水,电的资料,统计住户每月的用量以及需要交纳的费用,收费管理记录物业公司对住户的每一笔收费,包括水,电等使用费用和物业管理费用,余额不足进行银行卡充值。五.系统流程图设计
六.系统功能模块图设计
1、系统性能需求分析
所设计的系统主要涉及到四大部分:系统管理,基本信息管理,水电管理,费用查询。
(1)系统管理:管理系统操作人员,设置操作人员口令和权限。在满足不同系统用户的操作需求的基础上,提高系统的安全性。(2)基本信息管理:维护小区基本信息。
住户信息管理:入住登记,信息修改,迁出注销,查询。房屋信息管理:房屋信息添加,修改,删除,查询。户型信息管理:小区户型登记。(3)水电服务管理:完成小区各种服务,例如物业费用缴费管理功能。
(4)查询统计管理:本系统中各种数据的统计与查询功能。
2、系统功能需求分析
小区物业管理水电费物业部门用来对住宅小区内水费,电费,缴费情况信息管理系统。根据客户要求,系统要能对住户水电费信息、修改、查询和删除等操作,并且还要实现包括水、电、煤气费在内的各项物业管理费用的统计、查询和报表生成。因此,实现该物业管理系统功能模块图如下
七.系统功能模型设计
八.系统所涉及的实体联系设计
九.系统状态图设计(1)总状态图设计
(2)系统银行卡模块状态设计
十.系统数据流图设计
(1)系统数据流程图
(2)系统数据字典(1)
名字:用水信息记录表 别名:用水信息
描述:水量剩余小于临界值时报告住户
定义:用水信息记录表=户主信息+水量使用费+收费日期
位置:输出打印机(2)
名字:用电信息表 别名:电量信息
描述:剩余电量小于临界值时报告住户
定义:用电信息表=户主信息+电量使用费+收费日期 位置:输出打印机(3)
名字:住户信息表 描述:每户人员的详细信息
定义:住户信息表=住户姓名+性别+年龄+联系方式+证件号码 位置:输出打印机,显示在屏幕 十一.系统人机交互界面的设计 ①登陆界面的设计
②住户界面的设计
③管理员界面的设计
十二.系统设计的实现(1)数据库载入
(2).住户登陆成功界面
(3)住户界面
(4)住户修改信息
(5)住户查询物业信息
(6)住户反馈
(7)住户缴费
(8)银行卡登陆
(9)银行卡登陆成功
(10)银行卡缴费界面
(11)银行卡修改密码界面
(12)管理员登陆
(13)管理员界面
(14)管理员查询住户信息界面
(15)管理员修改住户信息
(16)管理员更新物业信息
(17)管理员添加管理员信息
(18)管理员接收反馈
(19)管理员接收反馈界面
十三.系统设计的代码附录
package xuesheng;
import javax.swing.*;import java.awt.event.*;import java.sql.*;
public cla systems extends JFrame implements ActionListener { static systems;
JPanel panel = new JPanel();JLabel label1 = new JLabel(“输入姓名:”);JTextField name = new JTextField();JLabel label2 = new JLabel(“密 码:”);JPawordField pwd = new JPawordField();JButton Enter = new JButton(“登录”);JButton Exit = new JButton(“退出”);String url = “F:JAVA背景图片4.jpg”;ButtonGroup bgp = new ButtonGroup();JRadioButton ihb = new JRadioButton(“住户”);JRadioButton mg = new JRadioButton(“管理员”);
public systems(){
super(“物业系统登录”);
this.setResizable(false);JLabel img = new JLabel(new ImageIcon(url));
img.setBounds(0,0,500,100);
panel.add(img);
ihb.setBounds(165,210,70,20);
mg.setBounds(265,210,70,20);
bgp.add(ihb);
bgp.add(mg);
panel.add(ihb);
panel.add(mg);
Enter.setBounds(150,250,80,20);
Exit.setBounds(270,250,80,20);
Enter.addActionListener(this);
Exit.addActionListener(this);
panel.add(Enter);
panel.add(Exit);panel.setLayout(null);
this.add(panel);20
label1.setBounds(135,130,100,25);
panel.add(label1);name.setBounds(265,130,100,25);
panel.add(name);
label2.setBounds(135,165,100,25);
panel.add(label2);pwd.setBounds(265,165,100,25);
panel.add(pwd);
this.setBounds(100,100,500,350);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}
public void actionPerformed(ActionEvent e){
if(e.getSource()==Enter)
{
String username , paword;
username = name.getText();
paword = pwd.getText();
try
{
Cla.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);
}
catch(ClaNotFoundException ce)
{
JOptionPane.showMeageDialog(,ce.getMeage());
}
if(ihb.isSelected())
{
try
{
//
Connection con = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;DatabaseName=物业管理系统”,“sa”,“11111111”);
String sql = “select * from inhabitant where 姓名=? and 密码=?”;
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, username);
pstmt.setString(2, paword);
ResultSet rs = pstmt.executeQuery();
if(rs!=null)
{
JOptionPane.showMeageDialog(,“登陆成功”);
new inhabitants();
}
else
{
JOptionPane.showMeageDialog(,“登录失败”);
}
rs.close();
pstmt.close();
}
catch(SQLException se)
{
JOptionPane.showMeageDialog(,se.getMeage());
}
}
else if(mg.isSelected())
{
try
{
Connection con = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;DatabaseName=物业管理系统”,“sa”,“11111111”);
String sql = “select * from manager where 姓名=? and 密码=?”;
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, username);
pstmt.setString(2, paword);
ResultSet rs = pstmt.executeQuery();
if(rs!=null)
{
JOptionPane.showMeageDialog(,“登陆成功”);
new managers();
}
else
{
JOptionPane.showMeageDialog(,“登录失败”);
}
rs.close();
pstmt.close();22
}
catch(SQLException se)
{
JOptionPane.showMeageDialog(,se.getMeage());
}
}
}
else
{
System.exit(0);
} }
public static void main(String[] args){
new systems();} }
package xuesheng;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public cla inhabitants extends JFrame implements ActionListener { JPanel panel=new JPanel();JMenuBar jmb = new JMenuBar();JMenu Meage = new JMenu(“信息”);JMenu Payment = new JMenu(“缴费”);JMenu back = new JMenu(“反馈”);JMenuItem Item1 = new JMenuItem(“修改住户信息”);JMenuItem Item2 = new JMenuItem(“查询物业信息”);JMenuItem Item3 = new JMenuItem(“发送反馈”);JMenuItem Item4 = new JMenuItem(“交电费”);JMenuItem Item5 = new JMenuItem(“交水费”);String url = “F:JAVA背景图片36.jpg”;public inhabitants(){ 23
super(“住户界面”);
this.setSize(500,400);
this.setVisible(true);JLabel img = new JLabel(new ImageIcon(url));
img.setBounds(0,0,500,600);
panel.add(img);
panel.setLayout(null);
this.add(panel);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setJMenuBar(jmb);
jmb.add(Meage);
jmb.add(back);
jmb.add(Payment);
Meage.add(Item1);
Meage.add(Item2);
back.add(Item3);
Payment.add(Item4);
Payment.add(Item5);
Item1.addActionListener(this);
Item2.addActionListener(this);
Item3.addActionListener(this);
Item4.addActionListener(this);
Item5.addActionListener(this);}
public void actionPerformed(ActionEvent e){
if(e.getSource()==Item1)
{
AlterInhabitantInformation ai = new AlterInhabitantInformation();
}
else if(e.getSource()==Item2)
{
Serch ser = new Serch();
}
else if(e.getSource()==Item3)
{
tickling ib=new tickling();
}
else if(e.getSource()==Item4)24
{
ATM atm=new ATM();
}
else if(e.getSource()==Item5)
{
ATM atm=new ATM();
} }
public static void main(String[] args){
inhabitants stu = new inhabitants();} }
package xuesheng;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public cla managers extends JFrame implements ActionListener { JMenuBar bar = new JMenuBar();JMenu menu1 = new JMenu(“信息”);JMenu menu2 = new JMenu(“反馈”);JMenuItem item1 = new JMenuItem(“查询住户信息”);JMenuItem item2 = new JMenuItem(“修改住户信息”);JMenuItem item3 = new JMenuItem(“更新物业信息”);JMenuItem item4 = new JMenuItem(“接收反馈”);JMenuItem item5 = new JMenuItem(“添加管理员信息”);String url = “F:JAVA背景图片36.jpg”;JPanel jpl = new JPanel();
public managers(){
super(“管理员界面”);
this.setSize(500,300);
this.setResizable(false);25
} this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setJMenuBar(bar);this.add(jpl);jpl.setLayout(null);bar.add(menu1);bar.add(menu2);menu1.add(item1);menu1.add(item2);menu1.add(item3);menu1.add(item5);menu2.add(item4);item1.addActionListener(this);item2.addActionListener(this);item3.addActionListener(this);item4.addActionListener(this);item5.addActionListener(this);public void actionPerformed(ActionEvent e){ if(e.getSource()==item1){
ReferMsg rm = new ReferMsg();} if(e.getSource()==item2){
AlterInhabitantInformations ai = new AlterInhabitantInformations();} else if(e.getSource()==item3){
AddMsg sc = new AddMsg();} else if(e.getSource()==item4){
tickling tl=new tickling();} else if(e.getSource()==item5){
managerinformation mf=new managerinformation();} } 26
public static void main(String[] args){
managers mng = new managers();} }
package xuesheng;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;import java.awt.font.*;import java.sql.*;
public cla ReferMsg extends JFrame implements ActionListener { static ReferMsg s;JLabel title = new JLabel(“查询住户信息”,JLabel.CENTER);Font f = new Font(“楷体”,Font.BOLD+Font.ITALIC,16);JPanel jpl = new JPanel();JLabel label1 = new JLabel(“请输入门牌号:”,JLabel.CENTER);JTextField num = new JTextField();JButton serch = new JButton(“查询”);JButton fangqi = new JButton(“返回”);JLabel label2 = new JLabel(“门牌号:”,JLabel.LEFT);JLabel label3 = new JLabel(“姓名:”,JLabel.LEFT);JLabel label4 = new JLabel(“性别:”,JLabel.LEFT);JLabel label5 = new JLabel(“年龄:”,JLabel.LEFT);JLabel label6 = new JLabel(“籍贯:”,JLabel.LEFT);JLabel label7 = new JLabel(“身份证号:”,JLabel.LEFT);JLabel label8 = new JLabel(“电话:”,JLabel.LEFT);JLabel label9 = new JLabel(“职业:”,JLabel.LEFT);
JTextField[] txt ={ new JTextField(), new JTextField(), new JTextField(), new JTextField(), new JTextField(),new JTextField(), new JTextField(),new JTextField()};static int p = 140;
public ReferMsg()27
{ super(“查询住户信息”);this.setResizable(false);this.setSize(500,550);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);title.setFont(f);this.add(jpl);jpl.setLayout(null);title.setBounds(80,20,300,20);jpl.add(title);label1.setBounds(100,60,90,20);jpl.add(label1);num.setBounds(200,60,140,20);jpl.add(num);serch.setBounds(130,100,90,20);fangqi.setBounds(240,100,90,20);jpl.add(serch);jpl.add(fangqi);serch.addActionListener(this);fangqi.addActionListener(this);label2.setBounds(100,140,140,20);label3.setBounds(100,180,140,20);label4.setBounds(100,220,140,20);label5.setBounds(100,260,140,20);label6.setBounds(100,300,140,20);label7.setBounds(100,340,140,20);label8.setBounds(100,380,140,20);label9.setBounds(100,420,140,20);jpl.add(label2);jpl.add(label3);jpl.add(label4);jpl.add(label5);jpl.add(label6);jpl.add(label7);jpl.add(label8);jpl.add(label9);
for(int i = 0;i
txt[i].setBounds(200,p,140,20);
jpl.add(txt[i]);
p=p+40;} 28
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==fangqi)
{
this.setVisible(false);
new managers();
}
if(e.getSource()==serch)
{
String mp = num.getText();
try
{
Cla.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);
}
catch(ClaNotFoundException ce)
{
JOptionPane.showMeageDialog(s,ce.getMeage());
}
try
{
Connection con = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;DatabaseName=物业管理系统”,“sa”,“11111111”);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(“select * from inhabitant where inhabitant.门牌号 ='” + mp + “' AND inhabitant.门牌号 = inhabitant.门牌号”);
while(rs.next())
{
for(int i = 0;i
{
txt[i].setText(rs.getString(i+1));
}
}
}
catch(SQLException se)
{
JOptionPane.showMeageDialog(s,se.getMeage());
}
}
else
{
for(int i = 0;i
{
txt[i].setText(“”);
}
num.setText(“”);
} }
public static void main(String[] args){
ReferMsg s = new ReferMsg();} }
package xuesheng;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;import java.sql.*;
public cla Serch extends JFrame implements ActionListener { /*查询学生信息控件*/ static Serch s;JPanel jpl = new JPanel();JLabel SCH = new JLabel(“物业信息”,JLabel.CENTER);JLabel label1 = new JLabel(“请输入门牌号:”,JLabel.CENTER);JButton serch = new JButton(“查询”);JLabel label2 = new JLabel(“姓名:”,JLabel.CENTER);JLabel label3 = new JLabel(“电量:”,JLabel.CENTER);JLabel label4 = new JLabel(“水量:”,JLabel.CENTER);JLabel label5 = new JLabel(“性别:”,JLabel.CENTER);ButtonGroup bgp = new ButtonGroup();JRadioButton man = new JRadioButton(“男”);JRadioButton women = new JRadioButton(“女”);JTextField num = new JTextField();JTextField nam = new JTextField();JTextField ele = new JTextField();30
JTextField wat = new JTextField();JButton fangqi = new JButton(“返回”);public Serch(){ this.setSize(500,400);this.setVisible(true);this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.add(jpl);jpl.setLayout(null);serch.addActionListener(this);fangqi.addActionListener(this);/*查询面板*/ SCH.setBounds(100,20,300,20);jpl.add(SCH);label1.setBounds(100,60,100,20);jpl.add(label1);num.setBounds(220,60,140,20);jpl.add(num);serch.setBounds(120,100,90,20);fangqi.setBounds(260,100,90,20);jpl.add(serch);jpl.add(fangqi);label2.setBounds(100,140,70,20);jpl.add(label2);nam.setBounds(190,140,140,20);jpl.add(nam);label5.setBounds(100,180,70,20);jpl.add(label5);man.setBounds(205,180,60,20);women.setBounds(285,180,60,20);bgp.add(man);bgp.add(women);jpl.add(man);jpl.add(women);label3.setBounds(100,220,70,20);jpl.add(label3);ele.setBounds(190,220,140,20);jpl.add(ele);label4.setBounds(100,260,70,20);jpl.add(label4);wat.setBounds(190,260,140,20);jpl.add(wat);31
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==fangqi)
{
this.setVisible(false);
new inhabitants();
}
String mp = num.getText();
if(e.getSource()==serch)
{
try
{
Cla.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);
}
catch(ClaNotFoundException ce)
{
JOptionPane.showMeageDialog(s,ce.getMeage());
}
try
{
Connection con = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;DatabaseName=物业管理系统”,“sa”,“11111111”);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(“select * from PropertyInformation where 门牌号 = '” + mp + “'”);
while(rs.next())
{
nam.setText(rs.getString(“姓名”));
if(rs.getString(“性别”).equals(“男”))
{
man.setSelected(true);
}
else
{
women.setSelected(true);
}
ele.setText(rs.getString(“电量”));
wat.setText(rs.getString(“水量”));
}
}
catch(SQLException se)32
{
JOptionPane.showMeageDialog(s,se.getMeage());
}
} }
public static void main(String[] args){
Serch sch = new Serch();} }
package xuesheng;import java.awt.*;import java.awt.event.*;cla Selection extends Frame implements ActionListener{ Button button1,button2,button3,button4,button5;Panel p1 = new Panel();Panel p2 = new Panel();Panel p3 = new Panel();Panel p4 = new Panel();Panel p5 = new Panel();Panel p = new Panel();Account act;
public Selection(){} Selection(String s,Account act){
super(s);
this.act=act;
this.setLayout(null);
this.setLayout(new GridLayout(6,1));
p.add(new Label(“请选择你要的服务”));
this.add(p);/*各种服务功能*/
button1 = new Button(“缴水费”);
p1.add(button1);
this.add(p1);
button2 = new Button(“交电费”);
p2.add(button2);
this.add(p2);
button3 = new Button(“查询”);33
p3.add(button3);this.add(p3);button4 = new Button(“退出”);p4.add(button4);this.add(p4);button5 = new Button(“修改密码”);p5.add(button5);this.add(p5);this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});button1.addActionListener(this);button2.addActionListener(this);button3.addActionListener(this);button4.addActionListener(this);button5.addActionListener(this);setBounds(150,150,225,275);setVisible(true);validate();} public void actionPerformed(ActionEvent e){ if(e.getSource()==button1){//取款
GetWater gw = new GetWater(“交水费”,act);
} if(e.getSource()==button2){//取款
GetBalance gb = new GetBalance(“交电费”,act);
} if(e.getSource()==button3){//查询余额
Query q =new Query(“查询余额”,act);} else if(e.getSource()==button4){//退出
System.exit(0);
dispose();} else if(e.getSource()==button5){//修改密码
Account 修改密码;
ChangePaword cp = new ChangePaword(“修改密码”,act);34
dispose();
} } }
package xuesheng;import java.awt.Color;import java.awt.Font;
import javax.swing.*;public cla tickling { public tickling(){ //创建JFrame对象
JFrame f=new JFrame(“反馈”);//创建具有指定文本的JLbabel对象 JLabel Label=new JLabel(“反馈:”);Font ft = new Font(“黑体” , Font.BOLD , 24);
Label.setFont(ft);
Label.setForeground(Color.black);//创建列数为20的JTextField对象 JTextField t=new JTextField(20);JPanel panel=new JPanel();
panel.add(Label);t.setBounds(70,100,300,120);panel.add(t);Font fo = new Font(“黑体” , Font.BOLD , 24);t.setFont(fo);Label.add(t);f.setVisible(true);
//将JLabel组件添加到JFrame窗体上 f.getContentPane().add(Label);f.getContentPane().add(Label);f.setSize(400,350);f.setVisible(true);} public static void main(String[] args){ 35
tickling tl = new tickling();}
}
package xuesheng;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;import java.sql.*;
public cla AlterInhabitantInformation extends JFrame implements ActionListener { static AlterInhabitantInformation;JLabel[] label = {new JLabel(“门牌号:”), new JLabel(“姓名:”), new JLabel(“性别:”), new JLabel(“年龄:”), new JLabel(“籍贯:”), new JLabel(“身份证号:”), new JLabel(“电话:”), new JLabel(“职业:”)};JTextField[] txt = {new JTextField(), new JTextField(), new JTextField(), new JTextField(), new JTextField(),new JTextField(), new JTextField(),new JTextField()};JButton add = new JButton(“确认”);JButton fangqi = new JButton(“返回”);JPanel jpl = new JPanel();JLabel title = new JLabel(“修改住户信息” , JLabel.CENTER);Font f = new Font(“黑体” , Font.BOLD , 16);int s = 100;
public AlterInhabitantInformation(){
super(“修改住户信息”);
this.setResizable(false);
this.setSize(500,600);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
this.add(jpl);
add.addActionListener(this);
fangqi.addActionListener(this);
jpl.setLayout(null);36
title.setBounds(150,40,200,20);
title.setFont(f);
title.setForeground(Color.red);
jpl.setBackground(Color.LIGHT_GRAY);
jpl.add(title);
for(int i = 0;i
{
label[i].setBounds(100,s,140,20);
jpl.add(label[i]);
txt[i].setBounds(260,s,140,20);
jpl.add(txt[i]);
s=s+40;
}
add.setBounds(150,s,80,20);
fangqi.setBounds(250,s,80,20);
jpl.add(add);
jpl.add(fangqi);}
public void actionPerformed(ActionEvent e){
if(e.getSource()==fangqi)
{
this.setVisible(false);
new inhabitants();
}
if(e.getSource()==add)
{
try
{
Cla.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);
}
catch(ClaNotFoundException ce)
{
JOptionPane.showMeageDialog(,ce.getMeage());
}
try
{
Connection con = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;DatabaseName=物业管理系统”,“sa”,“11111111”);
Statement stmt = con.createStatement();
int a = stmt.executeUpdate(“insert into inhabitant(门牌号,姓名,性别,年龄,籍贯,身份证号,电话,职 37
业)values('”+txt[0].getText()+“','”+txt[1].getText()+“','”+txt[2].getText()+“','”+txt[3].getText()+“','”+txt[4].getText()+“','”+txt[5].getText()+“','”+txt[6].getText()+“','”+txt[7].getText()+“')”);
if(a==1)
{
JOptionPane.showMeageDialog(,“添加成功”);
}
else
{
JOptionPane.showMeageDialog(,“添加失败”);
}
}
catch(SQLException se)
{
JOptionPane.showMeageDialog(,se.getMeage());
}
}
else
{
for(int i = 0;i
{
txt[i].setText(“”);
txt[0].requestFocus();
}
} }
public static void main(String[] args){
AlterInhabitantInformation as = new AlterInhabitantInformation();} }
package xuesheng;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;import java.sql.*;38
public cla AlterInhabitantInformations extends JFrame implements ActionListener { static AlterInhabitantInformation;JLabel[] label = {new JLabel(“门牌号:”), new JLabel(“姓名:”), new JLabel(“性别:”), new JLabel(“年龄:”), new JLabel(“籍贯:”), new JLabel(“身份证号:”), new JLabel(“电话:”), new JLabel(“职业:”)};JTextField[] txt = {new JTextField(), new JTextField(), new JTextField(), new JTextField(), new JTextField(),new JTextField(), new JTextField(),new JTextField()};JButton add = new JButton(“确认”);JButton fangqi = new JButton(“返回”);JPanel jpl = new JPanel();JLabel title = new JLabel(“修改住户信息” , JLabel.CENTER);Font f = new Font(“黑体” , Font.BOLD , 16);int s = 100;
public AlterInhabitantInformations(){
super(“修改住户信息”);
this.setResizable(false);
this.setSize(500,600);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
this.add(jpl);
add.addActionListener(this);
fangqi.addActionListener(this);
jpl.setLayout(null);
title.setBounds(150,40,200,20);
title.setFont(f);
title.setForeground(Color.red);
jpl.setBackground(Color.LIGHT_GRAY);
jpl.add(title);
for(int i = 0;i
{
label[i].setBounds(100,s,140,20);
jpl.add(label[i]);
txt[i].setBounds(260,s,140,20);
jpl.add(txt[i]);
s=s+40;
}
add.setBounds(150,s,80,20);
fangqi.setBounds(250,s,80,20);
jpl.add(add);39
jpl.add(fangqi);}
public void actionPerformed(ActionEvent e){
if(e.getSource()==fangqi)
{
this.setVisible(false);
new managers();
}
if(e.getSource()==add)
{
try
{
Cla.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);
}
catch(ClaNotFoundException ce)
{
JOptionPane.showMeageDialog(,ce.getMeage());
}
try
{
Connection con = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;DatabaseName=物业管理系统”,“sa”,“11111111”);
Statement stmt = con.createStatement();
int a = stmt.executeUpdate(“insert into inhabitant(门牌号,姓名,性别,年龄,籍贯,身份证号,电话,职业)values('”+txt[0].getText()+“','”+txt[1].getText()+“','”+txt[2].getText()+“','”+txt[3].getText()+“','”+txt[4].getText()+“','”+txt[5].getText()+“','”+txt[6].getText()+“','”+txt[7].getText()+“')”);
if(a==1)
{
JOptionPane.showMeageDialog(,“添加成功”);
}
else
{
JOptionPane.showMeageDialog(,“添加失败”);
}
}
catch(SQLException se)
{
JOptionPane.showMeageDialog(,se.getMeage());
} 40
}
else
{
for(int i = 0;i
{
txt[i].setText(“”);
txt[0].requestFocus();
}
} } }
package xuesheng;
import javax.swing.*;
import java.awt.event.*;import java.sql.*;
public cla AddMsg extends JFrame implements ActionListener { static AddMsg s;/*添加住户信息控件*/ JPanel jpl = new JPanel();JLabel label1 = new JLabel(“更新物业信息”,JLabel.CENTER);JLabel label2 = new JLabel(“门牌号:”,JLabel.CENTER);JLabel label3 = new JLabel(“姓名:”,JLabel.CENTER);JLabel label4 = new JLabel(“性别:”,JLabel.CENTER);JLabel label5 = new JLabel(“电量:”,JLabel.CENTER);JLabel label6 = new JLabel(“水量:”,JLabel.CENTER);JTextField num = new JTextField(2);JTextField nam = new JTextField(4);ButtonGroup bgp = new ButtonGroup();JRadioButton man = new JRadioButton(“男”);JRadioButton women = new JRadioButton(“女”);JTextField ele = new JTextField();JTextField wat = new JTextField();JButton fangqi = new JButton(“返回”);JButton addmsg = new JButton(“添加”);
public AddMsg()41
{
} super(“更新物业信息”);this.setResizable(false);this.setSize(500,400);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.add(jpl);jpl.setLayout(null);addmsg.addActionListener(this);fangqi.addActionListener(this);/*插入面板*/ label2.setBounds(100,50,70,20);jpl.add(label2);num.setBounds(190,50,140,20);jpl.add(num);
label3.setBounds(100,90,70,20);jpl.add(label3);nam.setBounds(190,90,140,20);jpl.add(nam);
label4.setBounds(100,130,70,20);jpl.add(label4);man.setBounds(190,130,60,20);women.setBounds(270,130,60,20);jpl.add(man);jpl.add(women);bgp.add(man);bgp.add(women);label5.setBounds(100,170,70,20);jpl.add(label5);ele.setBounds(190,170,140,20);jpl.add(ele);label6.setBounds(100,210,70,20);jpl.add(label6);wat.setBounds(190,210,140,20);jpl.add(wat);fangqi.setBounds(120,250,90,20);addmsg.setBounds(240,250,90,20);jpl.add(fangqi);jpl.add(addmsg);42
public void actionPerformed(ActionEvent e){
if(e.getSource()==fangqi)
{
this.setVisible(false);
new managers();
}
if(e.getSource()==addmsg)
{
String sex;
if(man.isSelected())
{
sex=“男”;
}
else
{
sex=“女”;
}
try
{
Cla.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);
}
catch(ClaNotFoundException ce)
{
JOptionPane.showMeageDialog(s,ce.getMeage());
}
try
{
String number = num.getText();
String name = nam.getText();
String electyic = ele.getText();
String water = wat.getText();
//1注册驱动
Connection con = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;DatabaseName=物业管理系统”,“sa”,“11111111”);
String sql = “insert into PropertyInformation(门牌号 ,姓名, 性别 , 电量 , 水量)values(?,?,?,?,?)”;
//2预处理
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, number);
pstmt.setString(2, name);
pstmt.setString(3, sex);
pstmt.setString(4, electyic);43
pstmt.setString(5, water);
//3执行
int a = pstmt.executeUpdate();
if(a==1)
{
JOptionPane.showMeageDialog(s,“已成功添加”);
}
else
{
JOptionPane.showMeageDialog(s,“添加失败”);
}
pstmt.close();
}
catch(SQLException se)
{
System.out.println(1);
JOptionPane.showMeageDialog(s,se.getMeage());
}
}
else
{
num.setText(“”);
nam.setText(“”);
ele.setText(“”);
wat.setText(“”);
num.requestFocus();
} }
public static void main(String[] args){
new AddMsg();} }
package xuesheng;public cla ATM{ public ATM(){
new WindowBox(“登录页面”);} public static void main(String [] args){ ATM atm=new ATM();} 44
}
package xuesheng;import javax.swing.*;import java.awt.*;import javax.swing.border.*;import java.awt.event.*;import java.io.*;/*登陆页面首窗口*/ cla WindowBox extends Frame implements ActionListener{ Box baseBox,box1,box2;TextField tf1,tf2;Button button1;Button button2;WindowBox(String s){//构造方法
super(s);tf1 = new TextField(6);tf2 = new TextField(6);
box1= Box.createVerticalBox();
box1.add(new Label(“请输入你的卡号”));//输入卡号
box1.add(Box.createVerticalStrut(8));
box1.add(new Label(“请输入你的支付密码”));//输入密码
box2=Box.createVerticalBox();
box2.add(tf1);
//box2.add(new TextField(16));
box2.add(Box.createVerticalStrut(8));
box2.add(tf2);
//box2.add(new TextField(16));
baseBox=Box.createHorizontalBox();
baseBox.add(box1);
baseBox.add(Box.createHorizontalStrut(10));
baseBox.add(box2);
add(baseBox);
button1= new Button(“确定”);//加入按钮
button1.addActionListener(this);
add(button1);
button2 = new Button(“退卡”);//退卡按钮
button2.addActionListener(this);
add(button2);
setLayout(new FlowLayout());
/*监听器*/ 45
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
setBounds(220,225,225,275);
setVisible(true);} public void actionPerformed(ActionEvent e){
Account act;
String card;String pwd;
act=new Account(“12”,“Devil”,“12”,50000);//初始化
/*选择各种服务*/
if(e.getSource()== button1){
String number1,number2;//输入的两个卡号和密码的变量
number1=tf1.getText();
number2=tf2.getText();
/*判断两次输入的卡号和密码是否正确*/
if((“123”.equals(number1))&&(“123”.equals(number2)))
{
Selection s = new Selection(“选择服务”,act);
}else{
dispose();
ErrorWarn ew = new ErrorWarn();//报输入密码或卡号不正确
}
} if(e.getSource()==button2){
System.exit(0);
dispose();//退出
} } }
package xuesheng;import javax.swing.*;import java.awt.*;import javax.swing.border.*;import java.awt.event.*;cla Query extends Frame implements ActionListener{ 46
//Account act;Button button;Account act;Query(String s,Account act){//构造函数
super(s);
this.act = act;
button=new Button(“确定”);
//TextField tf = new TextField(6);
Panel panel1 = new Panel();
Panel panel = new Panel();
panel1.add(new Label(“你的余额为: ” + act.get_Money()));//查询余额的方法
//panel1.add(tf);
button.addActionListener(this);
panel.add(button);
this.add(panel);
this.add(panel1);
this.setLayout(new GridLayout(2,1));
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
setBounds(200,200,150,150);
setVisible(true);} public void actionPerformed(ActionEvent e){
if(e.getSource()==button){
dispose();
Selection s = new Selection(“选择服务”,act);//返回选择服务
}
} }
package xuesheng;import javax.swing.*;import java.awt.*;import javax.swing.border.*;import java.awt.event.*;47
cla GetBalance extends Frame implements ActionListener{ Box baseBox, box1,box2;Button button;TextField tf;Account act;GetBalance(String s,Account act){//构造函数
super(s);
this.act=act;
button=new Button(“确定”);
Panel panel = new Panel();
Panel panel1 = new Panel();
tf = new TextField(6);
this.setLayout(new GridLayout(2,1));
panel1.add(new Label(“请输入你想交电费的数目”));
panel1.add(tf);
panel.add(button);
this.add(panel1);
this.add(panel);
button.addActionListener(this);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
setBounds(200,200,150,150);
this.setVisible(true);}
public void actionPerformed(ActionEvent e){
//System.out.println(e.getActionCommand());
double money;
money = Double.parseDouble(tf.getText().trim());
if(e.getSource()==button){
if(act.get_Money()
dispose();
ErrorWarn4 ew4 = new ErrorWarn4();
}
else if(money
if((money%100!=0)||(money>=5000)){
dispose();
ErrorWarn6 ew6 = new ErrorWarn6();
} 48