




已阅读5页,还剩15页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
自选题目设计一:酒店管理系统程序代码1.数据库的实现创建系统用户表格 Roomtypecreate database hotelgouse hotelgoCREATE TABLE Roomtype (Typeid Varchar (10)primary key,Typename Varchar (16) ,Bednum SMALLINT,Price INT,) insert into Roomtype values(LX0001,标准单人间,1,100)insert into Roomtype values(LX0002,标准双人间,2,160)insert into Roomtype values(LX0003,豪华单人间,1,200)insert into Roomtype values(LX0004,豪华双人间,2,360)insert into Roomtype values(LX0005,商务套房,1,1000)insert into Roomtype values(LX0006,总统套房,2,2000)创建客房信息表格RoomsCREATE TABLE Rooms (RoomNOVarchar(10) primary key,Typeid Varchar (10) NOT NULL,RoompositionVarchar(5)NULL,PutupVarchar(5)NOT NULL,FOREIGN KEY(Typeid) REFERENCES Roomtype(Typeid) 2. 登录功能实现该模块只要是为了方便酒店管理员的操作,界面友好,简单易操作。需要有一定的美观性和可操作性。同时为了保证安全性,我们设定了权限功能,管理员可以使用全部功能,而普通用户不能使用系统管理功能,所以普通用户不能增减客房信息,同时,也不能增减系统的用户。图4 主界面主代码如下package UI;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import UI.*;public class mainFrame extends JFrameprivate JButton bt1,bt2,bt3,bt4,bt5;private JTextField tf1,tf2;private int wholepart;public mainFrame() super ( 金翎酒店欢迎您!);JPanel panelMain,panelCent,panelNort,panelBottom;panelMain = new JPanel(new BorderLayout();panelNort = buildNorth();panelCent = buildDTM();panelMain.add(panelNort,BorderLayout.NORTH);panelMain.add(panelCent);setContentPane(panelMain);setSize (780,620);setVisible(true);private JPanel buildNorth() JPanel panelNort1 = new JPanel();Icon bug1= new ImageIcon(pic/m01.gif);Icon bug2= new ImageIcon(pic/m04.gif);Icon bug3= new ImageIcon(pic/m05.gif);Icon bug4= new ImageIcon(pic/m06.gif);Icon bug5= new ImageIcon(pic/m07.gif);bt1 = new JButton ( 客户预定, bug3);bt2 = new JButton ( 入住登记, bug2);bt3 = new JButton ( 客户结账, bug1);bt4 = new JButton ( 营业查询, bug4);bt5 = new JButton ( 系统管理, bug5);panelNort1.add(bt1);panelNort1.add(bt2);panelNort1.add(bt3);panelNort1.add(bt4);panelNort1.add(bt5);Buttonhandler handler = new Buttonhandler();bt1.addActionListener(handler);bt2.addActionListener(handler);bt3.addActionListener(handler);bt4.addActionListener(handler);bt5.addActionListener(handler);return panelNort1;private JPanel buildDTM () JPanel panelCent1 = new JPanel(new BorderLayout();tf1 = new JTextField(20);tf1.setForeground(Color.yellow);tf1.setBackground(Color.red);tf1.setText(金翎酒店欢迎您!);tf1.setFont( new Font(楷体,Font.BOLD,20);tf1.setHorizontalAlignment (JTextField.CENTER);tf1.setBorder(new LineBorder(new Color(87,87,47);tf1.setEditable(false);panelCent1.add(North,tf1);JPanel panelBottom1 = new JPanel(new BorderLayout();final ImageIcon imageIcon = new ImageIcon(pic/jiudian.jpg); JPanel p = new JPanel() / 获取图片 Image image = imageIcon.getImage(); public void paint(Graphics g) / 绘制图片 g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(),this); JScrollPane scrollPane = new JScrollPane(p); panelBottom1.add(panelCent1,BorderLayout.NORTH); panelBottom1.add(scrollPane,BorderLayout.CENTER);return panelBottom1;public void setwholepart(int a) wholepart = a; private class Buttonhandler implements ActionListener public void actionPerformed( ActionEvent event ) Object o = event.getSource(); if(o=bt1) new Engage(); /客户预定 else if(o=bt2) new Customer(); /入住登记 else if(o=bt3) new account(); /客户结账 else if(o=bt4) new quarryBussiness(); /营业查询 else if(o=bt5) if (wholepart = 0)JOptionPane.showMessageDialog(null,金翎酒店提示您n非管理员无此权限!);elsenew systemManager(); /系统管理 public static void main( String args ) mainFrame application = new mainFrame(); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); 3. 预定功能实现 此模块主要实现客户的预定功能,包括查询、增加、删除预订信息,并能查询剩余的客房,以便于实现预定功能。图8 客户预定主界面主代码:package UI;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import UI.*;public class Engage extends JFrame private JButton bt1,bt2,bt3,bt4;private JTextField tf1;public Engage() super ( 金翎酒店客户预订);JPanel panelMain,panelCent,panelNort;panelMain = new JPanel(new BorderLayout();panelNort = buildNorth();panelCent = buildDTM();panelMain.add(North,panelNort);panelMain.add(panelCent);setContentPane(panelMain);setSize (500,130);setResizable(false);/不允许改变窗口大小setVisible(true);private JPanel buildNorth() JPanel panelCent1 = new JPanel(new BorderLayout();tf1 = new JTextField(宾客预定信息);tf1.setFont( new Font(楷体,Font.BOLD,15);tf1.setHorizontalAlignment (JTextField.CENTER);tf1.setForeground(Color.yellow);tf1.setBackground(Color.red);tf1.setBorder(new LineBorder(new Color(87,87,47);tf1.setEditable(false);panelCent1.add(North,tf1);panelCent1.setBorder(BorderFactory.createTitledBorder();return panelCent1;private JPanel buildDTM () JPanel panelNort1 = new JPanel();Icon bug1= new ImageIcon(pic/new.gif);Icon bug2= new ImageIcon(pic/del.gif);Icon bug3= new ImageIcon(pic/find.gif);bt1 = new JButton ( 增加, bug1);bt3 = new JButton ( 删除, bug2);bt2 = new JButton ( 查询预定信息, bug3);bt4 = new JButton ( 查询客房信息, bug3);panelNort1.add(bt1);panelNort1.add(bt3);panelNort1.add(bt2);panelNort1.add(bt4);Buttonhandler handler = new Buttonhandler();bt1.addActionListener(handler);bt2.addActionListener(handler);bt3.addActionListener(handler);bt4.addActionListener(handler);return panelNort1;private class Buttonhandler implements ActionListener public void actionPerformed( ActionEvent event ) Object o = event.getSource(); if(o=bt1) addEngage add = new addEngage(); else if(o=bt3) deleteEngage delete= new deleteEngage(); else if(o=bt2) quaryEngage quary = new quaryEngage(); else if(o=bt4) quaryLeft quary = new quaryLeft(); public static void main( String args ) Engage application = new Engage(); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); 增加预定信息图9 增加客户预订信息主代码如下:/addEngage.javapackage UI;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;import UI.HotelUI;import UI.ConnectionSql;class addEngage extends JFrame private HotelUI userInterface; private JButton clearButton, writeButton; String sqlString ; String names = 订房编号,姓 名,身份证号,客房编号,联系电话,入住时间; public addEngage() super( 客房预订 ); userInterface = new HotelUI( names ); getContentPane().add( userInterface, BorderLayout.CENTER ); writeButton = userInterface.getDoTask1Button(); writeButton.setText( 保存 ); writeButton.addActionListener( new ActionListener() public void actionPerformed( ActionEvent event ) addRecord(); ); clearButton = userInterface.getDoTask2Button(); clearButton.setText( 清除 ); clearButton.addActionListener( new ActionListener() public void actionPerformed( ActionEvent event ) userInterface.clearFields(); ); setSize( 300, 200 ); setBackground(new Color(199,183,143); setVisible( true ); public void addRecord() ConnectionSql tempdb = new ConnectionSql(); String fieldValues = userInterface.getFieldValues(); if ( ! fieldValues HotelUI.Bookno .equals( ) ) try String sqlInsert1 = INSERT INTO Bookin + VALUES ( + fieldValues0+, +fieldValues1+, +fieldValues2+, +fieldValues3+, +fieldValues4+, +fieldValues5+ );String sqlInsert2 = Update Rooms SET +Putup=1+ WHERE RoomNo=+fieldValues3+; int result1 = tempdb.statement.executeUpdate(sqlInsert1); int result2 = tempdb.statement.executeUpdate(sqlInsert2); if (result1!=0 & result2!=0) userInterface.clearFields(); JOptionPane.showMessageDialog( this, 插入成功, Insert Result, JOptionPane.INFORMATION_MESSAGE ); catch (SQLException ee) System.out.println(ee); else JOptionPane.showMessageDialog( this, 错误的编号, Invalid Number Format, JOptionPane.ERROR_MESSAGE ); tempdb.terminate() ; / end method addRecord public static void main( String args ) new addEngage(); 删除预订信息:图5 删除客户预订信息主代码如下:/deleteEngage.javapackage UI;import java.awt.*;import java.sql.*;import java.util.*;import javax.swing.*;import UI.*;class deleteEngage extends JFrame private HotelUI userInterface1,userInterface2; private JButton firstButton1,secondButton1, firstButton2,secondButton2; String BooknoUpdate; String sqlString ; public deleteEngage() super( 删除预定信息 ); String names1 = 请输入要删除的预定编号:; userInterface1= new HotelUI( names1 ); / four textfields String names2 = 订房编号,姓 名,身份证号,客房编号,联系电话,入住日期; userInterface2 = new HotelUI(names2 ); Container c= getContentPane(); Box box = Box.createVerticalBox(); box.add(userInterface1 ); box.add(userInterface2 ); c.add(box); firstButton1 = userInterface1.getDoTask1Button(); firstButton1.setText( 确认 ); firstButton1.addActionListener( new ActionListener() public void actionPerformed( ActionEvent event ) /initialize(); DisplayRecord(); ); secondButton1 = userInterface1.getDoTask2Button(); secondButton1.setText( 清除 ); secondButton1.addActionListener( new ActionListener() public void actionPerformed( ActionEvent event ) userInterface1.clearFields(); ); firstButton2 = userInterface2.getDoTask1Button(); firstButton2.setText( 确认删除 ); firstButton2.addActionListener( new ActionListener() public void actionPerformed( ActionEvent event ) UpdateRecord(); ); secondButton2 = userInterface2.getDoTask2Button(); secondButton2.setText( 放弃 ); secondButton2.addActionListener( new ActionListener() public void actionPerformed( ActionEvent event ) userInterface2.clearFields(); ); setSize( 400, 300 ); setVisible( true ); public void DisplayRecord() String fieldValues1 = userInterface1.getFieldValues(); ConnectionSql tempdb = new ConnectionSql(); String fieldValues2 =new String6 ; if ( ! fieldValues1 HotelUI.Bookno .equals( ) ) BooknoUpdate=fieldValues10; try String sqlString = select * from Bookin + where Bookno=+fieldValues10 + ; ResultSet resultSet =tempdb.statement.executeQuery( sqlString) ; ResultSetMetaData metaData = resultSet.getMetaData(); int numberOfColumns = metaData.getColumnCount(); if ( resultSet.next() ) 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); else userInterface2.clearFields(); JOptionPane.showMessageDialog( this, Not fund this record!, Find Result, JOptionPane.INFORMATION_MESSAGE ); catch ( NumberFormatException formatException ) JOptionPane.showMessageDialog( this, Bad age number , Invalid Number Format, JOptionPane.ERROR_MESSAGE ); catch (SQLException ee) System.out.println(ee); else JOptionPane.showMessageDialog( this, 错误的预定编号, Invalid Number Format, JOptionPane.ERROR_MESSAGE ); tempdb.terminate() ; public void UpdateRecord() ConnectionSql tempdb = new ConnectionSql(); String fieldValues = userInterface2.getFieldValues(); if ( ! fieldValues HotelUI.Bookno .equals( ) ) try /the string sql statement String sqlString1 = delete from Bookin + where Bookno=+BooknoUpdate + ; String sqlString2 = Update Rooms SET +Putup=0+ WHERE RoomNo=+fieldValues3+; int result1 = tempdb.statement.executeUpdate(sqlString1); int result2 = tempdb.statement.executeUpdate(sqlString2); if (result1!=0 & result2!=0) JOptionPane.showMessageDialog( this, Deleted sucess!, Delete Result, JOptionPane.INFORMATION_MESSAGE ); catch ( NumberFormatException formatException ) JOptionPane.showMessageDialog( this, Bad age number , Invalid Number Format, JOptionPane.ERROR_MESSAGE ); catch (SQLException ee) System.out.println(ee); /end of if sno field value is not emptyelse JOptionPane.showMessageDialog( this, 错误的预定编号, Invalid Number Format, JOptionPane.ERROR_MESSAGE );tempdb.terminate() ; public static void main( String args ) new deleteEngage(); / end class 查询客房预订信息图6 客房预订状态查询主代码如下:package UI;import java.awt.*;import java.sql.*;import java.util.*;import javax.swing.*;public class quaryEngage extends JFrame public quaryEngage() super( 客房预订信息 ); ConnectionSql tempdb = new ConnectionSql(); try String sqlString=new String(select Bookno as 订房编号,Customname as 顾客姓名,CustomID as 顾客身份证号,RoomNO as 预定客房编号,Phoneno as 联系方式, Bookdate as 预定日期, 预定 as 房态 from Bookin); ResultSet resultSet = tempdb.statement.executeQuery( sqlString) ; StringBuffer results = new StringBuffer(); ResultSetMetaData metaData = resultSet.getMetaData(); int numberOfColumns = metaData.getColumnCount(); for ( int i = 1; i = numberOfColumns; i+ ) results.append( metaData.getColumnName( i ) + t ); results.append( n ); while ( resultSet.next() ) for ( int i = 1; i = numberOfColumns; i+ ) results.append( resultSet.getObject( i ) + t ); results.append( n ); JTextArea textArea = new JTextArea( results.toString() ); Container container = getContentPane(); container.add( new JScrollPane( textArea ) ); setSize( 600, 400 ); / set window size setVisible( true ); / display window catch ( SQLException sqlException ) JOptionPane.showMessageDialog( null, sqlException.getMessage(), Database Error, JOptionPane.ERROR_MESSAGE ); System.exit( 1 ); tempdb.terminate() ;/close db / end DisplayStudents constructor public static void main( String args ) quaryEngage window = new quaryEngage(); window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); 剩余客房查询图7 剩余客房查询主代码如下:package UI;import java.awt.*;import java.sql.*;import java.util.*;import javax.swing.*;public class quaryLeft extends JFrame public quaryLeft() super( 剩余客房查询 ); ConnectionSql tempdb = new ConnectionSql(); try String sqlString=new String(select RoomNO as 客房编号,Typename as 标准,Roomposition as 客房位置,Bednum as 床位数量, Price as 单价, 空闲 as 房态 from Roomsview+ where Putup = 0); ResultSet resultSet = tempdb.statement.executeQuery( sqlString) ; StringBuffer results = new StringBuffer(); ResultSetMetaData metaData = resultSet.getMetaData(); int numberOfColumns = metaData.getColumnCount(); for ( int i = 1; i = numberOfColumns; i+ ) results.append( metaData.getColumnName( i
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 幼儿园各类防护应急预案(3篇)
- 呼吸骤停的应急预案(3篇)
- 幼儿园六T应急预案(3篇)
- 直播电商中商品展示的艺术化设计对GMV增长的促进研究
- 检察业务工作应急预案(3篇)
- 医院环境应急预案备案制度(3篇)
- 平安保险疫情应急预案流程(3篇)
- 学校区域封控应急预案(3篇)
- 司法技术岗面试题及答案
- 陕西师范大学《化工机械设备》2024-2025学年第一学期期末试卷
- 2025年中国邮政集团工作人员招聘考试笔试试题(含答案)
- 云计算环境下的数据安全与隐私保护研究
- 规范大件运输管理制度
- 药学处方审核培训
- T-MSC 005-2024 灵芝孢子油生产加工技术规范
- 职业院校班主任辅导员培训
- 贸易意向合作协议书范本
- 校园活动讲安全
- DB37T 5230-2022 岩棉复合板外墙外保温系统应用技术规程
- 外科腹腔镜手术护理
- 浅析立体心何模块在新高考中的命题方向研究课件高三数学一轮复习
评论
0/150
提交评论