java实现客房管理系统
这篇文章主要为大家详细介绍了java实现客房管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下本文实例为大家分享了java实现客房管理系统的具体代码,供大家参考,具体内容如下
addclient.java
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
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实现客房管理系统
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持CodeAE代码之家。
http://www.zzvips.com/article/176846.html
页:
[1]