服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - Java教程 - java实现客房管理系统

java实现客房管理系统

2021-07-16 16:13Break丶It Java教程

这篇文章主要为大家详细介绍了java实现客房管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了java实现客房管理系统的具体代码,供大家参考,具体内容如下

addclient.java

?
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
import java.awt.borderlayout;
import java.awt.color;
import java.awt.container;
import java.awt.flowlayout;
import java.awt.gridlayout;
import java.awt.event.actionevent;
import java.awt.event.actionlistener;
import java.sql.connection;
import java.sql.drivermanager;
import java.sql.resultset;
import java.sql.statement;
import java.util.calendar;
 
import javax.naming.spi.dirstatefactory.result;
import javax.swing.borderfactory;
import javax.swing.box;
import javax.swing.buttongroup;
import javax.swing.jbutton;
import javax.swing.jdialog;
import javax.swing.jframe;
import javax.swing.jlabel;
import javax.swing.joptionpane;
import javax.swing.jpanel;
import javax.swing.jradiobutton;
import javax.swing.jtextfield;
import javax.swing.uimanager;
import javax.swing.uimanager.lookandfeelinfo;
 
 
 public class addclient extends jframe implements actionlistener{
 jtextfield sname,id,age,home_addr,employer,phone,cno,rno,intime,outtime,days,cashpledge;
 jbutton save,cancel,save1;
 jpanel pl,pl1,pl2,pl3,pl4,pl5,pl6,pl7,pl8,pl9,pl10,pl11,pl12,pl13,pl14,pl15,pl16;
 jradiobutton man,wuman,yes,no;
 buttongroup group,group1;
 string sex,vip;
 int k,k1,k2;
 public addclient(){
 pl=new jpanel();
 pl1=new jpanel();
 pl2=new jpanel();
 pl3=new jpanel();
 pl4=new jpanel();
 pl5=new jpanel();
 pl6=new jpanel();
 pl7=new jpanel();
 pl8=new jpanel();
 pl9=new jpanel();
 pl10=new jpanel();
 pl11=new jpanel();
 pl12=new jpanel();
 pl13=new jpanel();
 pl14=new jpanel();
 pl15=new jpanel();
 pl16=new jpanel(new flowlayout(flowlayout.center,20,20));
 
 sname=new jtextfield(15);
 id=new jtextfield(15);
 age=new jtextfield(15);
 home_addr=new jtextfield(15);
 employer=new jtextfield(15);
 phone=new jtextfield(15);
 cno=new jtextfield(15);
 rno=new jtextfield(15);
 intime=new jtextfield(15);
 outtime=new jtextfield(15);
 days=new jtextfield(15);
 cashpledge=new jtextfield(15);
 
 
 group=new buttongroup();
 group1=new buttongroup();
 man=new jradiobutton("男",true);
 wuman=new jradiobutton("女",false);
 yes=new jradiobutton("是",true);
 no=new jradiobutton("否",false);
 group.add(man);
 group.add(wuman);
 group1.add(yes);
 group1.add(no);
 
 
 pl1.add(new jlabel("姓名:  ",jlabel.right));
 pl1.add(sname);
 pl2.add(new jlabel("身份证号:",jlabel.right));
 pl2.add(id);
 pl3.add(new jlabel("性别:  ",jlabel.right));
 pl3.add(man);
 pl3.add(wuman);
 pl4.add(new jlabel("vip客户:"));
 pl4.add(yes);
 pl4.add(no);
 pl5.add(new jlabel("年龄:  ",jlabel.right));
 pl5.add(age);
 pl6.add(new jlabel("家庭地址:",jlabel.right));
 pl6.add(home_addr);
 pl7.add(new jlabel("工作单位:",jlabel.right));
 pl7.add(employer);
 pl8.add(new jlabel("手机号: ",jlabel.right));
 pl8.add(phone);
 
 
 pl.setborder(borderfactory.createtitledborder("客户 信息"));
 pl.setlayout(new gridlayout(4,2,10,10));
 pl.add(pl1);
 pl.add(pl2);
 pl.add(pl3);
 pl.add(pl4);
 pl.add(pl5);
 pl.add(pl8);
 pl.add(pl7);
 pl.add(pl6);
 
 
 pl9.add(new jlabel("房号:   ",jlabel.right));
 pl9.add(rno);
 pl10.add(new jlabel("入住时间:",jlabel.right));
 pl10.add(intime);
 pl11.add(new jlabel("预离店时间",jlabel.right));
 pl11.add(outtime);
 pl12.add(new jlabel("入住天数:",jlabel.right));
 pl12.add(days);
 pl13.add(new jlabel("预交押金:",jlabel.right));
 pl13.add(cashpledge);
 pl14.add(new jlabel("入住序号:",jlabel.right));
 pl14.add(cno);
 
 pl15.setborder(borderfactory.createtitledborder("客户入住 信息"));
 pl15.setlayout(new gridlayout(3,2,15,15));
 pl15.add(pl14);
 pl15.add(pl9);
 pl15.add(pl10);
 pl15.add(pl11);
 pl15.add(pl12);
 pl15.add(pl13);
 
 
 save=new jbutton("登记入住");
 cancel=new jbutton("取消");
 save1=new jbutton("添加家属");
 save.addactionlistener(this);
 cancel.addactionlistener(this);
 save1.addactionlistener(this);
 pl16.add(save);
 pl16.add(save1);
 pl16.add(cancel);
 
 add(pl,borderlayout.north);
 add(pl15,borderlayout.center);
 add(pl16,borderlayout.south);
 
 setbounds(600,300,600,600);
 settitle("客户入住信息");
 setvisible(true);
 }
 @override
 public void actionperformed(actionevent e) {
 if(e.getsource()==save){
 int result=joptionpane.showconfirmdialog(null, "确认提交吗", "温馨提示", joptionpane.yes_no_option);
 if (result==0) {
 if(man.isselected()){
  sex="男";
  }
 else{
  sex="女";
  }
 if(yes.isselected()){
  vip="是";
  }
 else{
  vip="否";
  }
 try
  {
  class.forname(url.driver);
  connection con=drivermanager.getconnection(url.url,url.username,url.userpwd);
  statement sql=con.createstatement(resultset.type_scroll_sensitive,resultset.concur_read_only);
  k=sql.executeupdate("insert into client values('"+sname.gettext()+"','"+id.gettext()+"','"+sex+"','"+age.gettext()+"','"+home_addr.gettext()+"','"+employer.gettext()+"','"+vip+"','"+phone.gettext()+"')");
  k1=sql.executeupdate("insert into check_in(cno,rno,intime,outtime,dayss,cashpledge) values('"+cno.gettext()+"','"+rno.gettext()+"','"+intime.gettext()+"','"+outtime.gettext()+"','"+days.gettext()+"','"+cashpledge.gettext()+"')");
  k2=sql.executeupdate("insert into type_in values('"+cno.gettext()+"','"+id.gettext()+"')");
  if (k==1&&k1==1&&k2==1) {
  int result1=joptionpane.showconfirmdialog(null, "入住成功!是否添加家属信息?", "温馨提示", joptionpane.yes_no_option);
  if(result1==0){
  id.settext("");
  sname.settext("");
  age.settext("");
  home_addr.settext("");
  phone.settext("");
  employer.settext("");
  }
  else {
  dispose();
  }
 }
  }catch(exception e1){
  joptionpane.showmessagedialog(this, "入住失败");
  }
 }
 }
 if(e.getsource()==cancel){
 dispose();
 }
 
 if(e.getsource()==save1){
 int result=joptionpane.showconfirmdialog(null, "确认提交吗", "温馨提示", joptionpane.yes_no_option);
 if (result==0) {
 if(man.isselected()){
  sex="男";
  }
 else{
  sex="女";
  }
 if(yes.isselected()){
  vip="是";
  }
 else{
  vip="否";
  }
 try
  {
  class.forname(url.driver);
  connection con=drivermanager.getconnection(url.url,url.username,url.userpwd);
  statement sql=con.createstatement();
  k=sql.executeupdate("insert into client values('"+sname.gettext()+"','"+id.gettext()+"','"+sex+"','"+age.gettext()+"','"+home_addr.gettext()+"','"+employer.gettext()+"','"+vip+"','"+phone.gettext()+"')");
  k2=sql.executeupdate("insert into type_in values('"+cno.gettext()+"','"+id.gettext()+"')");
  if (k==1&&k2==1) {
  int result1=joptionpane.showconfirmdialog(null, "入住成功!是否继续添加家人信息?", "温馨提示", joptionpane.yes_no_option);
  if(result1==0){
  id.settext("");
  sname.settext("");
  age.settext("");
  home_addr.settext("");
  phone.settext("");
  employer.settext("");
  }
  else {
  dispose();
  }
 }
  }catch(exception e1){
  joptionpane.showmessagedialog(this, "添加失败");
  }
 }
 }
 
 
 }
}

adminframe.java

?
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import java.awt.borderlayout;
import java.awt.container;
import java.awt.event.actionevent;
import java.awt.event.actionlistener;
 
import javax.swing.imageicon;
import javax.swing.jdialog;
import javax.swing.jframe;
import javax.swing.jlabel;
import javax.swing.jmenu;
import javax.swing.jmenubar;
import javax.swing.jmenuitem;
import javax.swing.jpanel;
 
class adminframe extends jdialog implements actionlistener{
 jlabel label = new jlabel();
 jmenubar mbar= new jmenubar();
 private jmenu quarto,message,clinet;
 private jmenuitem item1,item2,item3,item4,item5,item6,item7,item8,item9;
 jpanel pl1;
 container con;
 adminframe(){
 pl1=new jpanel();
 setjmenubar(mbar);
 imageicon icon = new imageicon("src/picture/1.jpg");
 label.seticon(icon);
 label.setbounds(0,0, 600, 500);
 pl1.add(label);
 add(pl1);
 setbounds(600,300,600,500);
 
 quarto=new jmenu("客房操作");
 message=new jmenu("信息查询");
 clinet=new jmenu("统计客房相关信息");
 mbar.add(quarto);
 mbar.add(message);
 mbar.add(clinet);
 item3=new jmenuitem("查询客房");
 item1=new jmenuitem("入住登记");
 item2=new jmenuitem("退房操作");
 quarto.add(item1);
 quarto.addseparator();
 quarto.add(item2);
 quarto.addseparator();
 quarto.add(item3);
 item4=new jmenuitem("客人信息查询");
 item5=new jmenuitem("客房时间查询");
 item6=new jmenuitem("客人费用查询");
 message.add(item4);
 message.addseparator();
 message.add(item5);
 message.addseparator();
 message.add(item6);
 item7=new jmenuitem("各类房型入住情况");
 item8=new jmenuitem("各月份客房收入");
 clinet.add(item7);
 clinet.addseparator();
 clinet.add(item8);
 item1.addactionlistener(this);
 item2.addactionlistener(this);
 item3.addactionlistener(this);
 item4.addactionlistener(this);
 item5.addactionlistener(this);
 item6.addactionlistener(this);
 item7.addactionlistener(this);
 item8.addactionlistener(this);
 setvisible(false);
 settitle("客房管理系统");
 validate();
 }
 @override
 public void actionperformed(actionevent e) {
 if(e.getsource()==item1){
 addclient stu=new addclient();
 stu.setvisible(true);
 }
 
 if(e.getsource()==item2){
 left left=new left();
 left.setvisible(true);
 }
 
 if (e.getsource()==item3) {
 queryroom qr=new queryroom();
 qr.setvisible(true);
 }
 if (e.getsource()==item4) {
 queryclient qc=new queryclient();
 qc.setvisible(true);
 }
 
 if(e.getsource()==item5){
 querytime qt=new querytime();
 qt.setvisible(true);
 }
 
 if(e.getsource()==item6){
 querycost qc=new querycost();
 qc.setvisible(true);
 }
 
 if(e.getsource()==item7){
 statisticsinformation si=new statisticsinformation();
 si.setvisible(true);
 }
 
 if(e.getsource()==item8){
 income income=new income();
 income.setvisible(true);
 }
}
}

完整代码:java实现客房管理系统

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

延伸 · 阅读

精彩推荐