酒店管理系统4_第1页
酒店管理系统4_第2页
酒店管理系统4_第3页
酒店管理系统4_第4页
酒店管理系统4_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、自选题目设计一:酒店管理系统程序代码.数据库的实现创建系统用户表格RoomtypecreatedatabasehotelgousehotelgoCREATETABLERoomtype(TypeidVarchar(10)primarykey,TypenameVarchar(16),BednumSMALLINT,PriceINT,)insertintoRoomtypevalues(LX0001,标准单人问,1,100)insertintoRoomtypevalues(LX0002,标准双人问,2,160)insertintoRoomtypevalues(LX0003,豪华单人问,1,200)ins

2、ertintoRoomtypevalues(LX0004,豪华双人问,2,360)insertintoRoomtypevalues(LX0005,商务套房,1,1000)insertintoRoomtypevalues(LX0006,总统套房,2,2000)创建客房信息表格RoomsCREATETABLERooms(RoomNOVarchar(10)primarykey,TypeidVarchar(10)NOTNULL,RoompositionVarchar(5)NULL,PutupVarchar(5)NOTNULL,FOREIGNKEY(Typeid)REFERENCESRoomtype(T

3、ypeid).登录功能实现该模块只要是为了方便酒店管理员的操作,界面友好,简单易操作。需要有一定的美观性和可操作性。同时为了保证安全性,我们设定了权限功能,管理员可以使用全部功能,而普通用户不能使用系统管理功能,所以普通用户不能增减客房信息,同时,也不能增减系统的用户。图4主界面主代码如下packageUI;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjava.util.*;importUI.*;publicclassmainFrameextendsJFrameprivateJButtonbt1,bt2,bt3,

4、bt4,bt5;privateJTextFieldtf1,tf2;privateintwholepart;publicmainFrame()super(金翎酒店欢迎您!);JPanelpanelMain,panelCent,panelNort,panelBottom;panelMain=newJPanel(newBorderLayout();panelNort=buildNorth();panelCent=buildDTM();panelMain.add(panelNort,BorderLayout.NORTH);panelMain.add(panelCent);setContentPane(

5、panelMain);setSize(780,620);setVisible(true);privateJPanelbuildNorth()JPanelpanelNort1=newJPanel();Iconbug1=newImageIcon(pic/m01.gif);Iconbug2=newImageIcon(pic/m04.gif);Iconbug3=newImageIcon(pic/m05.gif);Iconbug4=newImageIcon(pic/m06.gif);Iconbug5=newImageIcon(pic/m07.gif);bt1=newJButton(客户预定,bug3);

6、bt2=newJButton(入住登记,bug2);bt3=newJButton(客户结账,bug1);bt4=newJButton(营业查询,bug4);bt5=newJButton(系统管理,bug5);panelNort1.add(bt1);panelNort1.add(bt2);panelNort1.add(bt3);panelNort1.add(bt4);panelNort1.add(bt5);Buttonhandlerhandler=newButtonhandler();bt1.addActionListener(handler);bt2.addActionListener(han

7、dler);bt3.addActionListener(handler);bt4.addActionListener(handler);bt5.addActionListener(handler);returnpanelNort1;privateJPanelbuildDTM()JPanelpanelCent1=newJPanel(newBorderLayout();tf1=newJTextField(20);tf1.setForeground(Color.yellow);tf1.setBackground(Color.red);tfl.setText(金翎酒店欢迎您!);tf1.setFont

8、(newFont(t皆体,Font.BOLD,20);tf1.setHorizontalAlignment(JTextField.CENTER);tf1.setBorder(newLineBorder(newColor(87,87,47);tf1.setEditable(false);panelCent1.add(North,tf1);JPanelpanelBottom1=newJPanel(newBorderLayout();finalImageIconimageIcon=newImageIcon(pic/jiudian.jpg);JPanelp=newJPanel()/获取图片Imagei

9、mage=imageIcon.getImage();publicvoidpaint(Graphicsg)/绘制图片g.drawImage(image,0,0,this.getWidth(),this.getHeight(),this);JScrollPanescrollPane=newJScrollPane(p);panelBottom1.add(panelCent1,BorderLayout.NORTH);panelBottom1.add(scrollPane,BorderLayout.CENTER);returnpanelBottom1;publicvoidsetwholepart(int

10、a)wholepart=a;privateclassButtonhandlerimplementsActionListenerpublicvoidactionPerformed(ActionEventevent)Objecto=event.getSource();if(o=bt1)newEngage();/客户预定elseif(o=bt2)newCustomer();/入住登记elseif(o=bt3)newaccount();/客户结账elseif(o=bt4)newquarryBussiness();营业查询elseif(o=bt5)if(wholepart=0)JOptionPane.s

11、howMessageDialog(null,金翎酒店提示您n非管理员无此权限!);elsenewsystemManager();/系统管理publicstaticvoidmain(Stringargs)mainFrameapplication=newmainFrame();application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);一一.预定功能实现此模块主要实现客户的预定功能,包括查询、增加、删除预订信息,并能查询剩余的客房,以便于实现预定功能。因金翎酒店需尸预订口雷空噌加.删除查询预定信息查遍客房信息图8客户预定主界面主代码:pac

12、kageUI;importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjava.util.*;importUI.*;publicclassEngageextendsJFrameprivateJButtonbt1,bt2,bt3,bt4;privateJTextFieldtf1;publicEngage()super(金翎酒店客户预订);JPanelpanelMain,panelCent,panelNort;panelMain=newJPanel(newBorderLayout();pa

13、nelNort=buildNorth();panelCent=buildDTM();panelMain.add(North,panelNort);panelMain.add(panelCent);setContentPane(panelMain);setSize(500,130);setResizable(false);/不允许改变窗口大小setVisible(true);privateJPanelbuildNorth()JPanelpanelCent1=newJPanel(newBorderLayout();tf1=newJTextField(宾客预定信息)tf1.setFont(newFo

14、nt(t皆体,Font.BOLD,15);tf1.setHorizontalAlignment(JTextField.CENTER);tf1.setForeground(Color.yellow);tf1.setBackground(Color.red);tf1.setBorder(newLineBorder(newColor(87,87,47);tf1.setEditable(false);panelCent1.add(North,tf1);panelCent1.setBorder(BorderFactory.createTitledBorder();returnpanelCent1;pri

15、vateJPanelbuildDTM()JPanelpanelNort1=newJPanel();Iconbug1=newImageIcon(pic/new.gif);Iconbug2=newImageIcon(pic/del.gif);Iconbug3=newImageIcon(pic/find.gif);bt1=newJButton(增加,bug1);bt3=newJButton(删除,bug2);bt2=newJButton(查询预定信息,bug3);bt4=newJButton(查询客房信息,bug3);panelNort1.add(bt1);panelNort1.add(bt3);p

16、anelNort1.add(bt2);panelNort1.add(bt4);Buttonhandlerhandler=newButtonhandler();bt1.addActionListener(handler);bt2.addActionListener(handler);bt3.addActionListener(handler);bt4.addActionListener(handler);returnpanelNort1;privateclassButtonhandlerimplementsActionListenerpublicvoidactionPerformed(Actio

17、nEventevent)Objecto=event.getSource();if(o=bt1)addEngageadd=newaddEngage();elseif(o=bt3)deleteEngagedelete=newdeleteEngage();elseif(o=bt2)quaryEngagequary=newquaryEngage();elseif(o=bt4)quaryLeftquary=newquaryLeft();publicstaticvoidmain(Stringargs)Engageapplication=newEngage();application.setDefaultC

18、loseOperation(JFrame.EXIT_ON_CLOSE);一一增加预定信息图9增加客户预订信息主代码如下:/addEngage.javapackageUI;importjava.awt.event.*;importjava.sql.*;importjava.util.*;importjavax.swing.*;importUI.HotelUI;importUI.ConnectionSql;classaddEngageextendsJFrameprivateHotelUIuserInterface;privateJButtonclearButton,writeButton;Stri

19、ngsqlString;Stringnames=订房编号,姓名,身份证号,客房编号,联系电话,入住时间;publicaddEngage()super(客房预订);userInterface=newHotelUI(names);getContentPane().add(userInterface,BorderLayout.CENTER);writeButton=userInterface.getDoTask1Button();writeButton.setText(保存);writeButton.addActionListener(newActionListener()publicvoidact

20、ionPerformed(ActionEventevent)addRecord(););clearButton=userInterface.getDoTask2Button();clearButton.setText(清除);clearButton.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevent)userInterface.clearFields(););setSize(300,200);setBackground(newColor(199,183,143);setVisible(t

21、rue);publicvoidaddRecord()ConnectionSqltempdb=newConnectionSql();StringfieldValues=userInterface.getFieldValues();if(!fieldValuesHotelUI.Bookno.equals()tryStringsqlInsert1=INSERTINTOBookin+VALUES(+fieldValues0+,+fieldValues1+,+fieldValues2+,+fieldValues3+,+fieldValues4+”,+WHEREfieldValues5+);Strings

22、qlInsert2=UpdateRoomsSET+Putup=1+RoomNo=+fieldValues3+”;intresult1=tempdb.statement.executeUpdate(sqlInsert1);intresult2=tempdb.statement.executeUpdate(sqlInsert2);if(result1!=0&result2!=0)userInterface.clearFields();JOptionPane.showMessageDialog(this,插入成功,InsertResult,JOptionPane.INFORMATION_MESSAG

23、E);catch(SQLExceptionee)System.out.println(ee);elseJOptionPane.showMessageDialog(this,”错误的编号,InvalidNumberFormat,JOptionPane.ERROR_MESSAGE);tempdb.terminate();/endmethodaddRecordpublicstaticvoidmain(Stringargs口)newaddEngage();删除预订信息:图5删除客户预订信息主代码如下:/deleteEngage.javapackageUI;importjava.awt.*;import

24、java.sql.*;importjava.util.*;importjavax.swing.*;importUI.*;classdeleteEngageextendsJFrameprivateHotelUIuserInterface1,userInterface2;privateJButtonfirstButton1,secondButton1,firstButton2,secondButton2;StringBooknoUpdate;StringsqlString;publicdeleteEngage()super(删除预定信息);Stringnames1=请输入要删除的预定编号:;use

25、rInterface1=newHotelUI(names1);/fourtextfieldsStringnames2=订房编号,姓名,身份证号,客房编号,联系电话,入住日期;userInterface2=newHotelUI(names2);Containerc=getContentPane();Boxbox=Box.createVerticalBox();box.add(userInterface1);box.add(userInterface2);c.add(box);firstButton1=userInterface1.getDoTask1Button();firstButton1.s

26、etText(确认);firstButton1.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevent)/initialize();DisplayRecord(););secondButton1=userInterface1.getDoTask2Button();secondButton1.setText(清除);secondButton1.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventev

27、ent)userInterface1.clearFields(););firstButton2=userInterface2.getDoTask1Button();firstButton2.setText(确认删除);firstButton2.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevent)UpdateRecord(););secondButton2=userInterface2.getDoTask2Button();secondButton2.setText(放弃);secondB

28、utton2.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevent)userInterface2.clearFields(););setSize(400,300);setVisible(true);publicvoidDisplayRecord()StringfieldValues1=userInterface1.getFieldValues();ConnectionSqltempdb=newConnectionSql();StringfieldValues2=newString6;if(

29、!fieldValues1HotelUI.Bookno.equals()BooknoUpdate=fieldValues10;wheretryStringsqlString=select*fromBookin+Bookno=+fieldValues10+;ResultSetresultSet=tempdb.statement.executeQuery(sqlString);ResultSetMetaDatametaData=resultSet.getMetaData();intnumberOfColumns=metaData.getColumnCount();if(resultSet.next

30、()fieldValues20=resultSet.getString(1);fieldValues21=resultSet.getString(2);fieldValues22=resultSet.getString(3);fieldValues23=resultSet.getString(4);fieldValues24=resultSet.getString(5);fieldValues25=resultSet.getString(6);userInterface2.setFieldValues(fieldValues2);elseuserInterface2.clearFields()

31、;JOptionPane.showMessageDialog(this,Notfundthisrecord!,FindResult,JOptionPane.INFORMATION_MESSAGE);catch(NumberFormatExceptionformatException)JOptionPane.showMessageDialog(this,Badagenumber,InvalidNumberFormat,JOptionPane.ERROR_MESSAGE);catch(SQLExceptionee)System.out.println(ee);elseJOptionPane.sho

32、wMessageDialog(this,错误的预定编号,InvalidNumberFormat,JOptionPane.ERROR_MESSAGE);tempdb.terminate();publicvoidUpdateRecord()ConnectionSqltempdb=newConnectionSql();StringfieldValues=userInterface2.getFieldValues();if(!fieldValuesHotelUI.Bookno.equals()try/thestringsqlstatementStringsqlString1=deletefromBoo

33、kin+WHEREwhereBookno=+BooknoUpdate+StringsqlString2=UpdateRoomsSET+Putup=0+RoomNo=+fieldValues3+;intresult1=tempdb.statement.executeUpdate(sqlString1);intresult2=tempdb.statement.executeUpdate(sqlString2);if(result1!=0&result2!=0)JOptionPane.showMessageDialog(this,Deletedsucess!,DeleteResult,JOption

34、Pane.INFORMATION_MESSAGE);catch(NumberFormatExceptionformatException)JOptionPane.showMessageDialog(this,Badagenumber,InvalidNumberFormat,JOptionPane.ERROR_MESSAGE);catch(SQLExceptionee)System.out.println(ee);/endofifsnofieldvalueisnotemptyelseJOptionPane.showMessageDialog(this,”错误的预定编号,InvalidNumber

35、Format,JOptionPane.ERROR_MESSAGE);tempdb.terminate();publicstaticvoidmain(Stringargs口)newdeleteEngage();/endclass查询客房预订信息,客房预讨信息-1X订房编号顾客姓名顾客身份证号顼定客房编号联系方式技定日期房分0001吴海佳124354110031333333333320091111预定0002吴佳佳134534510041313243333420091112秋定0003于金铭1244354200323423432420091112预定0004张恺6463sB310041333333

36、333420091112制定0005张却翻635787630041332433233420091113我定OOOB明明12346678100212323213220100101凿定.TI图6客房预订状态查询主代码如下:packageUI;importjava.awt.*;importjava.sql.*;importjava.util.*;importjavax.swing.*;publicclassquaryEngageextendsJFramepublicquaryEngage()super(客房预iT信息);ConnectionSqltempdb=newConnectionSql();t

37、ryStringsqlString=newString(selectBooknoas订房编号,Customnameas顾客姓名,CustomIDas顾客身份证号,RoomNOas预定客房编号,Phonenoas联系方式,Bookdateas预定日期,预定as房态fromBookin);ResultSetresultSet=tempdb.statement.executeQuery(sqlString);StringBufferresults=newStringBuffer();ResultSetMetaDatametaData=resultSet.getMetaData();intnumber

38、OfColumns=metaData.getColumnCount();for(inti=1;i=numberOfColumns;i+)results.append(metaData.getColumnName(i)+t);results.append(n);while(resultSet.next()for(inti=1;i=numberOfColumns;i+)results.append(resultSet.getObject(i)+t);results.append(n);JTextAreatextArea=newJTextArea(results.toString();Contain

39、ercontainer=getContentPane();container.add(newJScrollPane(textArea);setSize(600,400);/setwindowsizesetVisible(true);/displaywindowcatch(SQLExceptionsqlException)JOptionPane.showMessageDialog(null,sqlException.getMessage(),DatabaseError,JOptionPane.ERROR_MESSAGE);System.exit(1);tempdb.terminate();/cl

40、osedb/endDisplayStudentsconstructorpublicstaticvoidmain(Stringargs)quaryEngagewindow=newquaryEngage();window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);一一剩余客房查询rB剩余客房查询一嚼_o1客房编号标准客房位置床位数量单价房意A1001标难单人间一褶1100空闲1002标推单人间一楼1100空闲2001标推双人间二楼2160空闲2002标准双人间二楼2160空闹3001奈华双人间三楼2360空闲3302商务套房三楂11000空闹30

41、03豪华双A间三楼2360楚.*111图7剩余客房查询主代码如下:packageUI;importjava.awt.*;importjava.sql.*;importjava.util.*;importjavax.swing.*;publicclassquaryLeftextendsJFramepublicquaryLeft()super(剩余客房查询);ConnectionSqltempdb=newConnectionSql();tryStringsqlString=newString(selectRoomNOas客房编号,Typenameas标准,Roompositionas客房位置,Be

42、dnumas床位数量,Priceas单价,空闲as房态fromRoomsview+wherePutup=0);ResultSetresultSet=tempdb.statement.executeQuery(sqlString);StringBufferresults=newStringBuffer();ResultSetMetaDatametaData=resultSet.getMetaData();intnumberOfColumns=metaData.getColumnCount();for(inti=1;i=numberOfColumns;i+)results.append(metaD

43、ata.getColumnName(i)+t);results.append(n);while(resultSet.next()for(inti=1;i=numberOfColumns;i+)results.append(resultSet.getObject(i)+t);results.append(n);JTextAreatextArea=newJTextArea(results.toString();Containercontainer=getContentPane();container.add(newJScrollPane(textArea);setSize(510,280);/se

44、twindowsizesetVisible(true);/displaywindow/endtrycatch(SQLExceptionsqlException)JOptionPane.showMessageDialog(null,sqlException.getMessage(),DatabaseError,JOptionPane.ERROR_MESSAGE);System.exit(1);tempdb.terminate();/closedb/endDisplayStudentsconstructorpublicstaticvoidmain(Stringargs)quaryLeftwindo

45、w=newquaryLeft();window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);.入住登记功能实现此模块主要实现客户入住登记、查询、删除以及剩余客房的查询,因此功能与客户预定功能很相近,故代码不再列出。图8客户入住信息5.结算功能实现此模块主要实现客户的退宿结算功能图9客户结算信息主代码如下:deleteEngage.javapackageUI;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjava.util.*;importjavax.swing.*;

46、importUI.*;classaccountextendsJFrameprivateHotelUIuserInterface1,userInterface2,userInterface3,userInterface4;privateJButtonfirstButton1,secondButton1,firstButton2,secondButton2;StringBooknoUpdate;StringsqlString;publicaccount。super(结账信息);Stringnames1口=请输入客户编号:;Stringnames2=请输入结账日期:;Stringnames3=您的总

47、消费额为:;userInterface1=newHotelUI(names1);/fourtextfieldsuserInterface2=newHotelUI(names2);userInterface3=newHotelUI(names3);Stringnames4=客户编号,姓名,客房编号,客房类型,客房位置,入住日期,客房单价;userInterface4=newHotelUI(names4);Containerc=getContentPane();Boxbox=Box.createVerticalBox();box.add(userInterface1);box.add(userIn

48、terface2);box.add(userInterface3);box.add(userInterface4);c.add(box);firstButton1=userInterface1.getDoTask1Button();firstButton1.setText(确认);firstButton1.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevent)DisplayRecord(););secondButton1=userInterface1.getDoTask2Button();

49、secondButton1.setText(清除);secondButton1.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevent)userInterface1.clearFields(););firstButton2=userInterface4.getDoTask1Button();firstButton2.setText(结算);firstButton2.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevent)accountRecord(););

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论