当前位置: 移动技术网 > IT编程>软件设计>架构 > 宾馆客房管理系统的设计与实现

宾馆客房管理系统的设计与实现

2019年07月08日  | 移动技术网IT编程  | 我要评论

 

课程设计(论文)任务书

 

     软件      学院  软件工程 专业 2016 -07  

一、课程设计(论文)题目 综合课程设计2 

二、课程设计(论文)工作自 2018 1 1 日起至 2018 1 12 日止。

三、课程设计(论文) 地点:软件工程实训中心一部                      

四、课程设计(论文)内容要求:

1.本课程设计的目的

(1)使学生熟练掌握数据库基本原理;

(2)使学生熟练掌握数据库的分析和设计能力;

(3)培养学生熟练使用常见的数据库管理系统;

(4)培养学生使用java语言进行面向对象设计的能力;

(5)培养学生熟练使用java语言进行数据库应用程序设计的能力;

(6)提高学生的科技论文写作能力。

2.基本要求:

课程设计题目:

设计主要内容:

 

 

 

 

 

 

 

3.课程设计论文编写要求

(1)要按照书稿的规格打印誊写课设报告;

(2)报告分为封面、任务书(本文档)、正文、课程设计体会和参考文献四部分;

学生签名:              

2018年1月 1日

 

 

 

 

 

 

 

 

 

 

 

 

课程设计(论文)评审意见

(1)题目分析     (20分):优( )、良( )、中( )、一般( )、差( );

(2)流程分析   (30分):优( )、良( )、中( )、一般( )、差( );

(3)数据定义   (30分):优( )、良( )、中( )、一般( )、差( );

(4)代码编写   (10分):优( )、良( )、中( )、一般( )、差( );

(5)创新能力   (10分):优( )、良( )、中( )、一般( )、差( );

(6)格式规范性、设计态度及考勤是否降等级:是( )、否( )

 

评阅人:         职称:

2018年 1 月 12 日

 

标题:宾馆客房管理系统的设计与实现

 

一、 数据设计

1.     实体

宾馆客房管理系统设计中用到的实体如下:

1)  实体1:用户信息

—   属性1:用户编号

—   属性2:用户姓名

—   属性3:密码

—   属性4:性别(0-男,1-女)

—   属性5:email地址

—   属性6:通讯地址

—   属性7:联系电话

—   属性8:所在部门

—   属性9:用户类型(1-酒店管理员,2-前台服务员)

2)  实体2:客户信息

l  属性1: 身份证号

l  属性2: 客户姓名

l  属性3: 联系电话

3)    实体3:客房类型

l  属性1:客房类型编号

l  属性2:类型名称

l  属性3:客房面积

l  属性4:配置床位

l  属性5:客房价格

l  属性6:配置空调(0-是,1-否)

l  属性7:配置电视(0-是,1-否)

4)   实体4:客房信息

l  属性1: 客房号

l  属性2:客房类型编号

l  属性3:客房位置

l  属性4:描述

5)  实体5:客房状态

l   属性1:客房编号

l   属性2:状态(1-空房,2-入住)

6)  实体6:客房业务

l   属性1:客房编号

l   属性2:入住时间

l   属性3:客户身份证号

l   属性4:备注

7)  实体7:业务记录

l  属性1:入住时间

l  属性2:退房时间

l  属性3:客房编号

l  属性4:金额

l  属性5:客户身份证号

l  属性6:客户姓名

l  属性7:客户电话

l  属性8:备注

 

2.     联系

宾馆客房管理系统设计中实体之间的联系如下(e-r图):

 

 

 

 

 

 

 

二、 数据库设计

1.     关系模式

宾馆客房管理设计中的关系模式如下:

客户(客户编号,姓名,电话,e-mail)。关系的主键:客户编号;外键:无

用户(用户编号,用户姓名,密码,性别(0-男,1-女),email地址,通讯地址,联系电话,所在部门,用户类型(1-酒店管理员,2-前台服务员)。

关系主键:用户编号;外键:无

客户信息(身份证号,客户姓名,联系电话)

关系主键:身份证号;外键:客户姓名

客房类型(客房类型编号,类型名称,客房面积,配置床位,客房价格,配置空调 (0-是,1-否),配置电视(0-是,1-否))

关系主键:客房类型编号;外键:类型名称

客房信息(客房号,客房类型编号,客房位置,描述)

关系主键:客房号;外键:客房类型编号

客房状态(客房编号,状态(1-空房,2-入住))

关系主键:客房编号;外键:无。

客房业务(客房编号,入住时间客户身份证号,备注)

关系主键:客房编号;外键:入住身份证号

业务记录(入住时间,退房时间,客房编号,金额,客户身份证号,客,姓名,客户电话,备注)

关系主键:入住时间;外键:客房编号,客户身份证,姓名,电话。

2.     数据表

本设计中创建的数据库名为:

数据表分别为(将数据库中设计的数据表表截图至此)。

 

                            表1:用户信息

 

 

表2:客户信息

 

表3:客房信息类型表

 

   表4:客房信息表

 

       表5:客房状态表

 

表6:客房业绩表

             

 

    

 

表7:业务记录表

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

数据库关系图为:

            

 
   

 


    

 

 

 

三、 数据库实现

设计中实现数据库操作的sql 语句如下:

新建数据表:

 

1)用户信息数据建表

 create table [dbo].weiwei( userid int 用户编号
name varchar(50) 用户姓名
password varchar(50) 密码
gender int 性别(0-男,1-女)
email varchar(50) email地址
address varchar(50) 通讯地址
telephone varchar(50) 联系电话
department varchar(50) 所在部门

type
int 用户类型(1-酒店管理员,2-前台服务员



2)客户信息数据建表

create table [dbo]. customersinfo (  cidentityid nvarchar(50) 身份证号
cname nvarchar(50) 客户姓名
cphone nvarchar(50) 联系电话)


3)客户类型数据建表   
create table [dbo]. roomcategory ( rcategoryid int 客房类型编号
name nvarchar(50) 类型名称history
area float 客房面积
bednum int 配置床位
price money 客房价格
aircondition int 配置空调(0-是,1-否)
tv int 配置电视(0-是,1-否)

)

4)业务记录数据建表

 create table [dbo]. history ( begintime datetime 入住时间
endtime datetime 退房时间
roomid int 客房编号
totalprice money 金额
cidentityid nvarchar(50) 客户身份证号
cname nvarchar(50) 客户姓名
cphone nvarchar(50) 客户电话
remarks nvarchar(50) 备注

 

5)客房信息表

create table [dbo].romsinfo (room int 客房号
rcategoryld int 客房编号
rpostition nvarchar(50) 客房位置

description nvarchar(50)  描述

 

6)客房状态

create table [dbo].roomstatus (roomld int 客房编号

status int 状态)

 

7)客房业务表

create table [dbo].roomoperation (roomld int 客房编号

begintime datetime 入住时间

cidentityid nvarchar(50) 客户身份证号

 

 

 

 

 

 

二、查询

1)业务记录增加,删除修改操作

插入:insert

into history(roomld,cname)

values(‘223456’,’345’)

删除:delete

from history

where roomld=’57’

修改:update history

set cname=’456’

where roomld=’5678’

2)用户编号查询:select userid

from usersinfo

where gender=’女’

 

3)客房类型查询

select *

from view_1 where 客房类型 in";

where rcategoryld=‘123’)

4)客房信息查询

select *

from view_1 where 客房信息 in";

where roomld=‘063’)

5)客房状态查询

select *

from view_1 where 客房状态 in";

where roomld=‘723’)

6)客房业务表查询

select *

from view_1 where 客房业务 in";

where roomld=‘793’)

7)客户信息查询

select *

from customersinfo

 

 

 

 

 

 

四、 程序设计

1.     类

设计中定义的java类如下:

1)  weiwei类,表示设计中所有的客户信息类,连接数据库。

 

2)  load类,表示设计中的客房管理,是weiwei的子类。

 

3)  addrooms类,表示设计中的客房管理,是weiwei的子类。

 

4)  useofrooms类,表示设计中的客户,是weiwei的子类。

 

5)  customerinformation类,表示设计中的员工信息,是weiwei的子类。

 

6)  checkstaff类,表示设计中的客户,是weiwei的子类。

 

 

2.     类设计

1)weiwei类

public class weiwei

{

     private tadmindao admindao;

     private trenyuandao renyuandao;

     public tadmindao getadmindao()

     {

            return admindao;

     }

     public void setadmindao(tadmindao admindao)

     {

            this.admindao = admindao;

     }

    

     public trenyuandao getrenyuandao()

     {

            return renyuandao;

     }

     public void setrenyuandao(trenyuandao renyuandao)

     {

            this.renyuandao = renyuandao;

     }

     public string login(string username,string userpw,int usertype)

     {

            system.out.println("usertype"+usertype);

            try

            {

                   thread.sleep(700);

            } catch (interruptedexception e)

            {

                   // todo auto-generated catch block

                   e.printstacktrace();

            }

           

            string result="no";

           

            if(usertype==0)//系统管理员登陆

            {

                   string sql="from tadmin where username=? and userpw=?";

                   object[] con={username,userpw};

                   list adminlist=admindao.gethibernatetemplate().find(sql,con);

                   if(adminlist.size()==0)

                   {

                           result="no";

                   }

                   else

                   {

                           webcontext ctx = webcontextfactory.get();

                           httpsession session=ctx.getsession();

                           tadmin admin=(tadmin)adminlist.get(0);

                           session.setattribute("usertype", 0);

                  session.setattribute("admin", admin);

                  result="yes";

                   }

            }

            if(usertype==1)

            {

                   string sql="from trenyuan where gonghao=? and loginpw=? and del='no'";

                   object[] con={username.trim(),userpw.trim()};

                   list renyuanlist=renyuandao.gethibernatetemplate().find(sql,con);

                   if(renyuanlist.size()==0)

                   {

                           result="no";

                   }

                   else

                   {

                           webcontext ctx = webcontextfactory.get();

                           httpsession session=ctx.getsession();

                           trenyuan renyuan=(trenyuan)renyuanlist.get(0);

                           session.setattribute("usertype", 1);

                  session.setattribute("renyuan", renyuan);

                  result="yes";

                   }

            }

            if(usertype==2)

            {

                  

            }

            return result;

     }

 

    public string adminpwedit(string userpwnew)

    {

            system.out.println("dddd");

        try

            {

                   thread.sleep(700);

            }

            catch (interruptedexception e)

            {

                   // todo auto-generated catch block

                   e.printstacktrace();

            }

            webcontext ctx = webcontextfactory.get();

            httpsession session=ctx.getsession();

             

            tadmin admin=(tadmin)session.getattribute("admin");

            admin.setuserpw(userpwnew);

           

            admindao.gethibernatetemplate().update(admin);

            session.setattribute("admin", admin);

           

            return "yes";

    }

   

}

 

2)  load 类

public class load extends jframe implements actionlistener {

      private  boolean boo1=false,boo2=false;

    int type=0;

      public jtextfield []t ={new jtextfield("用户名:",8),new jtextfield(27),

                   new jtextfield("密码:",8),new jpasswordfield(27),

new jtextfield("宾馆客房管理系统登陆界面--(设计人员:陈其巍)",36),

new jtextfield("后台技术:应用数据库加密技术--安全保护你的信息!请放心使用!",36),

new jtextfield("功能:管理宾馆客房!",36)};

     public jbutton []b={new jbutton("登陆"),new jbutton("退出")};

 imageicon ic=new imageicon(hoteland.class.getresource("/百吉星级酒店.jpg"));

     jframe app;

    statement statement;

       //构造方法

     public weiwei(){

                 app= new jframe("--宾馆客房管理系统登陆界面--");

                         app.setdefaultcloseoperation(jframe.exit_on_close);

                         app.setsize(438,583);

                         app.setresizable(false);

                         container c=app.getcontentpane();

                         c.setlayout(new flowlayout());

                         jlabel alabel=new jlabel(ic,jlabel.left);

                         t[0].setfont(new font("timesroman",font.bold,13));

                t[0].setforeground(color.red);

                         t[0].seteditable(false);

                         t[2].setfont(new font("timesroman",font.bold,13));

                 t[2].setforeground(color.red);

                         t[2].seteditable(false);

                         for(int i=0;i<4;i++)

                           c.add(t[i]);

                           c.add(b[0]);

                           c.add(b[1]);

                           for(int j=4;j<7;j++)

                           {

                              c.add(t[j]);

                           t[j].setfont(new font("timesroman",font.bold,13));

                   t[j].setforeground(color.blue);

                           t[j].seteditable(false);

                          }

                           c.add(alabel);

                    t[0].addactionlistener(this);

                    t[2].addactionlistener(this);

                    b[0].addactionlistener(this);

                    b[1].addactionlistener(this);

                app.setvisible(true);

     }

         //消息响应方法

     public void actionperformed(actionevent e){

                    jbutton source=(jbutton)e.getsource();

  //如果单击"登陆"按键,执行studentmanager程序,该部分应用到数据库加密技术

if(source==b[0]){

 

 try{

//基于sql server 2000 的 jdbc-odbc 桥数据库连接(先要创建一个数据源lib)

                                                       class.forname("sun.jdbc.odbc.jdbcodbcdriver");

                     //使用网络登录id的windows nt 验证(w)

connection conn=drivermanager.getconnection("jdbc:odbc:宾馆客户数据库");                         statement=conn.createstatement(resultset.type_scroll_insensitive,resultset.concur_read_only);

                                         string s1=t[1].gettext();

                            string s2=t[3].gettext();

resultset resultset=statement.executequery("select * from usersinfo where name='"+s1+"'and password='"+s2+"'");

                             resultset.next();

                             type=resultset.getint("type");                       

                           if(resultset!=null){

                                            boo1=boo2=true;

                                            resultset.close();

                                         }

                                         }

                                        catch(exception e1){

joptionpane.showmessagedialog(this,"用户名和密码不正确!","警告",joptionpane.warning_message);      

                                           }   

                               //如果输入的用户名和密码都正确,则登陆

                             if(boo1&&boo2&&type==1){

                                    type=0;

                                        boo1=boo2=true;

                             new hotemen(statement,"普通员工--"+t[1].gettext());

                                     app.setvisible(false);

                             }

                            if(boo1&&boo2&&type==2){

                                   type=0;

                                                  boo1=boo2=true;

                     new hotelmanagermen(statement,"管理员--"+t[1].gettext());

                                                   //new studentmanager();

                                                   app.setvisible(false);

                             }

                       }

                  //如果单击"退出"按键,则退出登陆界面

                       if(source==b[1]){

                                 system.exit(0);

                          }

     }

     public static void main(string args[]){

        new weiwei();

      }

}

}

3)addrooms类

public class addrooms extends weiwei implements actionlistener

{

hashtable 基本信息表=null;

jtextfield 房间号,房间位置;

jtextarea 描述;

jbutton 录入,重置;

choice 房间类型;

statement  statement=null;

jlabel 添加客房信息=null;

public addrooms(statement statement)

{

this.statement=statement;

房间号=new jtextfield(10);

房间位置=new jtextfield(10);

描述 =new jtextarea(7,10);

录入=new jbutton("录入");

重置=new jbutton("重置");

录入.addactionlistener(this);

重置.addactionlistener(this);

box box0=box.createhorizontalbox();

添加客房信息=new jlabel("--添加客房信息--",jlabel.center);

添加客房信息.setfont(new font("timesroman",font.bold,25));

添加客房信息.setforeground(color.red);

box0.add(添加客房信息);

box box1=box.createhorizontalbox();

box1.add(new jlabel("房间号:",jlabel.center));

box1.add(房间号);

  房间类型=new choice();

         房间类型.add("普通单人间");

         房间类型.add("普通双人间");

         房间类型.add("vip单人间");

         房间类型.add("vip双人间");

         房间类型.add("豪华贵宾间");

         房间类型.add("总统套间");

box box2=box.createhorizontalbox();

box2.add(new jlabel("房间类型:",jlabel.center));

box2.add(房间类型);

box box3=box.createhorizontalbox();

box3.add(new jlabel("房间位置:",jlabel.center));

box3.add(房间位置);

box box4=box.createhorizontalbox();

box4.add(new jlabel("单价 :",jlabel.center));

box4.add(new jscrollpane(描述),borderlayout.center);

box boxh=box.createverticalbox();

boxh.add(box0);

boxh.add(box1);

boxh.add(box2);

boxh.add(box3);

boxh.add(box4);

boxh.add(box.createverticalglue());

jpanel pcenter=new jpanel();

pcenter.add(boxh);

setlayout(new borderlayout());

add(pcenter,borderlayout.center);

jpanel psouth=new jpanel();

psouth.add(录入);

psouth.add(重置);

add(psouth,borderlayout.south);

validate();

}

public void actionperformed(actionevent e)

{

resultset resultset=null;

boolean boo=false;

if(e.getsource()==录入)

{

int number=0;

  try{

     number=integer.parseint(房间号.gettext().tostring());

     boo=true;

  }

 catch(exception e1){

      boo=false;

 }

if(boo&&(number>0))

{

try{

resultset=statement.executequery("use 宾馆客户数据库;select * from roomsinfo where roomid='"+number+"'");

 try{

 resultset.next();

 resultset.getint("roomid");

 string warning="该客房信息已存在,请到修改页面修改!";

joptionpane.showmessagedialog(this,warning,"警告",joptionpane.warning_message);

 }

 catch(exception e1){

      int roomid=integer.parseint(房间号.gettext().tostring());

      string rcategory=房间类型.getselecteditem().tostring();

      string rpostion=房间位置.gettext().tostring();

      string description=描述.gettext().tostring();

      string str="use 宾馆客户数据库;insert into roomsinfo values("+roomid+",'"+rcategory+"','"+rpostion+"','"+description+"')";

     try{

      statement.executeupdate(str);

      statement.executeupdate("use 宾馆客户数据库;insert into roomstatus values("+roomid+","+1+")");

      joptionpane.showmessagedialog(this,"成功录入客房信息!","提示",joptionpane.warning_message);

     }

       catch(exception e2){

 

          string  warning="输入格式有误,请重新输入!";

          joptionpane.showmessagedialog(this,warning,"警告",joptionpane.warning_message);

           e2.printstacktrace();

       }

       房间号.settext(null);

      房间类型.select("普通单人间");

      房间位置.settext(null);

      描述.settext(null);

}

 

}

catch(exception e1){

    string warning="输入格式有误,请重新输入!";

    joptionpane.showmessagedialog(this,warning,"警告",joptionpane.warning_message);

}

 

}

  else {

     string warning="必须要输入房间号!";

     joptionpane.showmessagedialog(this,warning,"警告",joptionpane.warning_message);

  }

}

if(e.getsource()==重置)

{

房间号.settext(null);

房间类型.select("普通单人间");

房间位置.settext(null);

描述.settext(null);

}

}

}

4)useofrooms类

public class useofrooms extends weiwei implements actionlistener

{

jbutton 查询;

choice 房间类型,状态;

statement statement=null;

jtextarea 房间使用情况;

jlabel 客房使用情况=null;

public useofrooms(statement statement)

{

this.statement=statement;

查询=new jbutton("查询");

查询.addactionlistener(this);

房间类型=new choice();

         房间类型.add("普通单人间");

         房间类型.add("普通双人间");

         房间类型.add("vip单人间");

         房间类型.add("vip双人间");

         房间类型.add("豪华贵宾间");

         房间类型.add("总统套间");

状态=new choice();

状态.add("有");

状态.add("否");

box box0=box.createhorizontalbox();

客房使用情况=new jlabel("--客房使用情况--",jlabel.center);

客房使用情况.setfont(new font("timesroman",font.bold,25));

客房使用情况.setforeground(color.red);

box0.add(客房使用情况);

box box1=box.createhorizontalbox();

box1.add(new jlabel("按房间类型:",jlabel.center));

box1.add(房间类型);

box box2=box.createhorizontalbox();

box2.add(new jlabel("状态:",jlabel.center));

box2.add(状态);

box2.add(查询);

box box3=box.createhorizontalbox();

box3.add(new jlabel("房间使用情况:",jlabel.center));

box box4=box.createhorizontalbox();

box4.add(new jlabel("-客房号:"));

box4.add(new jlabel("-客房类型:"));

box4.add(new jlabel("-是否空房:"));

box box5=box.createhorizontalbox();

房间使用情况=new jtextarea(8,12);

房间使用情况.setfont(new font("timesroman",font.bold,15));

房间使用情况.setforeground(color.red);

房间使用情况.seteditable(false);

box5.add(new jscrollpane(房间使用情况),borderlayout.center);

box boxh=box.createverticalbox();

boxh.add(box0);

boxh.add(box1);

boxh.add(box2);

boxh.add(box3);

boxh.add(box4);

boxh.add(box5);

boxh.add(box.createverticalglue());

jpanel pcenter=new jpanel();

pcenter.add(boxh);

setlayout(new borderlayout());

add(pcenter,borderlayout.center);

validate();

}

public void actionperformed(actionevent e)

{    int i=1;

     resultset resultset=null;

     string string="";

       if(e.getsource()==查询){

        string str=房间类型.getselecteditem().tostring();

         string str1=状态.getselecteditem();

        if(str1.equals("有")){

          i=2;

        }

        else i=1;

  string str2="use 宾馆客户数据库;select roomsinfo.roomid,rcategory,roomstatus.status from roomsinfo,roomstatus where roomsinfo.roomid=roomstatus.roomid and status="+i+" and rcategory='"+str+"'";

         try{

         resultset=statement.executequery(str2);

           while(resultset.next()){

               string+=resultset.getint(1)+", "+resultset.getstring(2)+", "+str1+"\n";

       }

              if(string==""){

                     房间使用情况.settext("没有要找的客房!");

              }

              else

              房间使用情况.settext(string);

         }

         catch(exception e1){

         e1.printstacktrace();

         }

  }

}

}

 

5)customerinformation类

public class customerinformation extends weiwei implements actionlistener

{

jtextfield 姓名;

jtextarea 查询结果;

jbutton 查询,查询所有;

statement statement=null;

jlabel 客户信息查询;

public customerinformation(statement statement)

{

this.statement=statement;

姓名=new jtextfield(10);

查询=new jbutton("查询");

查询所有=new jbutton("查询所有");

姓名.addactionlistener(this);

查询.addactionlistener(this);

查询所有.addactionlistener(this);

查询结果=new jtextarea(8,10);

查询结果.seteditable(false);

查询结果.setfont(new font("timesroman",font.bold,15));

查询结果.setforeground(color.blue);

box box0=box.createhorizontalbox();

客户信息查询=new jlabel("--客户信息查询--",jlabel.center);

客户信息查询.setfont(new font("timesroman",font.bold,25));

客户信息查询.setforeground(color.red);

box0.add(客户信息查询);

box box1=box.createhorizontalbox();

box1.add(new jlabel("输入要查询的姓名:",jlabel.center));

box1.add(姓名);

box1.add(查询);

box box2=box.createhorizontalbox();

box2.add(new jlabel("查询结果:",jlabel.center));

box2.add(new jscrollpane(查询结果),borderlayout.center);

box box3=box.createhorizontalbox();

box3.add(查询所有);

box boxh=box.createverticalbox();

boxh.add(box0);

boxh.add(box1);

boxh.add(box2);

boxh.add(box3);

boxh.add(box.createverticalglue());

jpanel pcenter=new jpanel();

pcenter.add(boxh);

setlayout(new borderlayout());

add(pcenter,borderlayout.center);

validate();

}

public void actionperformed(actionevent e)

{

resultset resultset=null;

boolean boo=false;

string cname="",cidentityid="",cphone="",croom,begintime,remarks;

string str="",chk;

if(e.getsource()==查询)

{ cname=姓名.gettext().tostring();

if(!cname.equals(""))

{

try{

 chk="use 宾馆客户数据库;select * from customersinfo,roomoperation where customersinfo.cidentityid=roomoperation.cidentityid and cname='"+cname+"'";

resultset=statement.executequery(chk);

 resultset.next();

        cidentityid=resultset.getstring("cidentityid");

        cphone=resultset.getstring("cphone");

        croom=resultset.getstring("roomid");

        begintime=resultset.getstring("begintime");

        remarks=resultset.getstring("remarks");

        str="客房号:"+croom+"\n身份证号码:"+cidentityid+"\n客户姓名:"+cname+"\n电话:"+cphone+"\n订房时间:"+begintime+"\n备注:"+remarks+"\n";

       查询结果.settext(str);

 }

 catch(exception e1){

     string warning="该客房信息不存在!";

     查询结果.settext(warning);

joptionpane.showmessagedialog(this,warning,

"警告",joptionpane.warning_message);

 }

}

else{

       string warning="必须要输入客户姓名!";

     joptionpane.showmessagedialog(this,warning,

"警告",joptionpane.warning_message);

}

}

if(e.getsource()==查询所有){

        str="";

   try{

        chk="use 宾馆客户数据库;select * from customersinfo,roomoperation where customersinfo.cidentityid=roomoperation.cidentityid";

   resultset=statement.executequery(chk);

    while(resultset.next()){

cidentityid=resultset.getstring("cidentityid");

        cname=resultset.getstring("cname");

        cphone=resultset.getstring("cphone");

        croom=resultset.getstring("roomid");

        begintime=resultset.getstring("begintime");

        remarks=resultset.getstring("remarks");

        str="客房号:"+croom+"\n身份证号码:"+cidentityid+"\n客户姓名:"+cname+"\n电话:"+cphone+"\n订房时间:"+begintime+"\n备注:"+remarks+"\n";

         }

         if(str.equals("")){

                姓名.settext("");

                查询结果.settext("客户信息不存在!");

         }

        else  {

                     姓名.settext("");

                     查询结果.settext(str);

              }

    }

    catch(exception e1){

              //e1.printstacktrace();

              姓名.settext("");

           查询结果.settext("客房信息不存在!");

        string warning="客房信息不存在!";

       joptionpane.showmessagedialog(this,warning,

"警告",joptionpane.warning_message);

 }

}

}

}

 

6) checkstaff类

public class checkstaff extends weiwei implements actionlistener

{

jtextfield 姓名;

jtextarea 查询结果;

jbutton 查询,查询所有;

statement statement=null;

jlabel 客户信息查询;

public checkstaff(statement statement)

{

this.statement=statement;

姓名=new jtextfield(10);

查询=new jbutton("查询");

查询所有=new jbutton("查询所有");

姓名.addactionlistener(this);

查询.addactionlistener(this);

查询所有.addactionlistener(this);

查询结果=new jtextarea(7,10);

查询结果.seteditable(false);

查询结果.setfont(new font("timesroman",font.bold,15));

查询结果.setforeground(color.blue);

box box0=box.createhorizontalbox();

客户信息查询=new jlabel("--员工信息查询--",jlabel.center);

客户信息查询.setfont(new font("timesroman",font.bold,25));

客户信息查询.setforeground(color.red);

box0.add(客户信息查询);

box box1=box.createhorizontalbox();

box1.add(new jlabel("输入要查询的姓名:",jlabel.center));

box1.add(姓名);

box1.add(查询);

box box2=box.createhorizontalbox();

box2.add(new jlabel("查询结果:",jlabel.center));

box2.add(new jscrollpane(查询结果),borderlayout.center);

box box3=box.createhorizontalbox();

box3.add(查询所有);

box boxh=box.createverticalbox();

boxh.add(box0);

boxh.add(box1);

boxh.add(box2);

boxh.add(box3);

boxh.add(box.createverticalglue());

jpanel pcenter=new jpanel();

pcenter.add(boxh);

setlayout(new borderlayout());

add(pcenter,borderlayout.center);

validate();

}

public void actionperformed(actionevent e)

{

resultset resultset=null;

boolean boo=false;

string name,password,sex,email,address,telephone,department,type;

int userid=-1,gender=0;

string str="";

if(e.getsource()==查询)

{

    name=姓名.gettext().tostring();

if(!name.equals(""))

{

try{

resultset=statement.executequery("use 宾馆客户数据库;select * from usersinfo where name='"+name+"'");

 resultset.next();

         userid=resultset.getint("userid");

         name=resultset.getstring("name");

               password=resultset.getstring("password");

               gender=resultset.getint("gender");

               if(gender==1){

                          sex="男";

                    }

                    else sex="女";

                email=resultset.getstring("email");

                address=resultset.getstring("address");                   telephone=resultset.getstring("telephone");

                 department=resultset.getstring("department");

            type=resultset.getint("type")==1?"普通员工":"宾馆管理员";    str=userid+","+name+","+password+","+sex+","+email+","+address+","+telephone+","+department+","+type+"\n";

       查询结果.settext(str);

 }

 catch(exception e1){

     string warning="该客房信息不存在!";

     查询结果.settext(warning);

joptionpane.showmessagedialog(this,warning

,"警告",joptionpane.warning_message);

 }

}

else{

       string warning="必须要输入客户姓名!";

     joptionpane.showmessagedialog(this,warning,

"警告",joptionpane.warning_message);

}

}

if(e.getsource()==查询所有){

       str="";

   try{

   resultset=statement.executequery("use 宾馆客户数据库;select * from usersinfo");

    while(resultset.next()){

      userid=resultset.getint("userid");

         name=resultset.getstring("name");

               password=resultset.getstring("password");

               gender=resultset.getint("gender");

               if(gender==1){

                          sex="男";

                    }

                    else sex="女";

                email=resultset.getstring("email");

                address=resultset.getstring("address");

                 telephone=resultset.getstring("telephone");

                 department=resultset.getstring("department");

            type=resultset.getint("type")==1?"普通员工":"宾馆管理员";

        str+=userid+","+name+","+password+","+sex+","+email+","+address+","+telephone+","+department+","+type+"\n";

        }

        if(str.equals("")){

               姓名.settext("");

               查询结果.settext("客户信息不存在!");

        }

        else  {

                    姓名.settext("");

                    查询结果.settext(str);

             }

    }

    catch(exception e1){

             姓名.settext("");

          查询结果.settext("客房信息不存在!");

        string warning="客房信息不存在!";

       joptionpane.showmessagedialog(this,warning,

"警告",joptionpane.warning_message);

 }}}}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

五、 java源代码

package com.util;

 

import java.text.parseexception;

import java.util.date;

import java.util.gregoriancalendar;

import java.net.url.*;

import javax.swing.*;

import javax.swing.imageicon;

import javax.swing.jlabel;

import java.sql.*;

import java.awt.container;

import java.awt.gridlayout;

import java.awt.flowlayout;

import javax.swing.jbutton;

import javax.swing.jframe;

import javax.swing.jtextfield;

import javax.swing.jpasswordfield;

import java.awt.event.actionevent;

import java.awt.event.actionlistener;

import java.awt.*;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.io.*;

import java.util.*;

import java.sql.*;

 

 

public class util {

       public static date newdate(string s) throws parseexception {

              java.text.simpledateformat sdf = new java.text.simpledateformat(

                            "yyyy-mm-dd");

              date date = new date();

              date = sdf.parse(s);

              return date;

       }

 

       public static date newdate1(string s) throws parseexception {

              java.text.simpledateformat sdf = new java.text.simpledateformat(

                            "yyyy-mm-dd hh:mm");

              date date = new date();

              date = sdf.parse(s);

              return date;

       }

 

       public static date formatfulldate(string s) throws parseexception {

              java.text.simpledateformat sdf = new java.text.simpledateformat(

                            "yyyy-mm-dd hh:mm:ss");

              date date = new date();

              date = sdf.parse(s);

              return date;

 

       }

 

       public static string splitdate(date d) {

              java.text.simpledateformat sdf = new java.text.simpledateformat(

                            "yyyy-mm-dd");

              return sdf.format(d);

       }

 

       public static string splitdate1(date d) {

              java.text.simpledateformat sdf = new java.text.simpledateformat(

                            "yyyy年mm月dd日");

              return sdf.format(d);

       }

 

       public static string chop(string orignalstring, double length,

                     string chopedstring) {

              if (orignalstring == null || orignalstring.length() == 0) {

                     return orignalstring;

              }

              orignalstring = orignalstring.replaceall(" ", " ");

              if (orignalstring.length() < length) {

                     return orignalstring;

              }

              stringbuffer buffer = new stringbuffer((int) length);

              length = length * 2;

              int count = 0;

              int stringlength = orignalstring.length();

              int i = 0;

              for (; count < length && i < stringlength; i++) {

                     char c = orignalstring.charat(i);

                     if (c < '\u00ff') {

                            count++;

                     } else {

                            count += 2;

                     }

                     buffer.append(c);

              }

              if (i < stringlength) {

                     buffer.append(chopedstring);

              }

              return buffer.tostring();

       }

 

       public static long getprimekey() {

              gregoriancalendar calendar = new gregoriancalendar();

              return calendar.gettimeinmillis();

       }

 

       public static long stringtolong(string source) {

              return long.parselong(source);

       }

       /*

        * public static void main(string[] args){ for(int i=0;i<10;i++){

        * system.out.println(util.getprimekey()); } }

        */

}

六、 实验结果

 

 

 

图:1-1客房管理管理页面的设计

 

 

 

 

 

  2-2客房经营管理页面

 

 

 

3-3 客户信息查询页面

 

 

 

 

 

 

4-4 员工信息管理页面

 

 

 

 

 

 

 

 

 

 

七、 实验小结

1.     数据库设计小结

当时对于数据库的选择,却走了一点弯路。因为平时对于数据库接触不多,所以一开始建表找工具花费时间作为数据库。这在初期是没啥问题的,但后来随着项目推进,产品经理不断地增加需求,慢慢对建表,查询和数据类型熟练。

2.     java应用小结

我是用这个学期刚开的java语言进行编写。这样不仅可以学习数据库,而且还可以对java的知识进行巩固。知识是相互联系的,没有哪一门是单独而存在的。对java大项目应用程序,要灵活应用类的定义以及类当中的方法,在定义类时,善于用接口。面对对象中,多个实现功能,最好用类和类继承。

3.     需完善之处

数据库建表和java的可连接部分需要熟练,需要自己掌握。对sql语句建表的变量需要记住,以后不需要查询书本。当我把这个数据库完整地设计出时,我心情是多么的激动,多么的自豪。这次实验主要是数据库设计,而应用程序是次要的。所以,在这次实验中,由于时间问题,我只是做了一部分功能,但也足已蔚我心了。这个宾馆客房管理系统完完全全是我自己做的,没有一点参照成分。做完这个实验后,尽管这个系统有不足之处,但我感觉自己的编程能力已经有了质的提升。我真的很高兴!很自豪!

 

课程设计体会

 

 

本次实验是对我进行一次全面的综合训练,这次实验不仅仅是把这个学期的数据库的知识总结,更是自入学以来一次知识大检查。自己学了什么,都会心里有底。这个不单要掌握数据库原理,还要熟练掌握一门编程语言。在这次实验中,我是用这个学期刚开的java语言进行编写。这样不仅可以学习数据库,而且还可以对java的知识进行巩固。知识是相互联系的,没有哪一门是单独而存在的。所以,要学好一门课,就是应该横向思考,多联系,这样会学得更深刻。这次实验,首先是要纵观全局,从大处着眼,先是需求分析,这是设计过程的基础,是最困难,最耗时的一步。作为“地基”的分析是否做得充分与准确,决定了在其上构建数据库大厦的速度与质量。需求分析做得不好,甚至会导致整个数据库设计返工重做。接着就是概念结构设计,这也是整个数据库设计的关键,它通过对用户需求进行综合,归纳与抽象,形成一个独立具体dbms的概念模型。再接着就是逻辑结构设计了,最后就是编程工作了。

 

参考文献

 

1.数据库系统概论(第5版)王珊 萨师煊编著 高等教育出版社 2014年9月

2.java语言程序设计(第2版)丁振凡 编著 清华大学出版社2014年9月

3.求是科技编著sqlsever 2000数据库开发技术与工程实践 人民邮电出版社2004年6月

4.数据库系统实验指导 单建魁 赵启升 编著 清华大学出版社          

5.互联网资源

 

公众号回复--“宾馆”--获取文档

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网