酒店管理系统源代码

合集下载

酒店管理系统源代码

酒店管理系统源代码

酒店管理系统源代码#include<string.h>#include<stdlib.h>#include<stdio.h>#include<conio.h>typedef struct tagCustomer{char m_ID[19]; /*身份证号码*/ char m_name[10]; /*顾客姓名*/ int m_age; /*顾客年龄*/ char m_sex[6]; /*顾客性别*/ int num;}Customer;/*顾客结构*/typedef struct tagRoom{int m_num; /*房间号*/int m_floor; /*楼层*/int m_price; /*价格*/int m_use; /*是否已入住*/}Room;/*房间结构*/int i,j=0,age,num,floor,price,use,n;int reg =0;Customer cus[5];Room r[5];int count=5;char ID[18],name[10],sex[6];FILE *fproom;FILE *fpcustomer;void Customer_Input(){if(count<=5){printf("请输入身份证号(18位数字):");scanf("%s",&cus[j].m_ID);printf("请输入姓名(10位字符)");scanf("%s",&cus[j].m_name);printf("请输入年龄(数字型)");scanf("%d",&cus[j].m_age);printf("请输入性别(男或女):");scanf("%s",&cus[j].m_sex);}else{printf("\n 存储空间已满!");}printf("\n\r顾客可以住在:");printf("\n\r房间号楼层价格是否空闲(1:空闲0:已使用)");for(i=0;i<count;i++){if(r[i].m_use==1){printf("\n\r%d %d %d %d ",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);}}printf("\n\r请你输入房间号:");scanf("%d",&num);reg = 0;for(i=0;i<count;i++){if(r[i].m_use==1&&r[i].m_num==num){r[i].m_use = 0;printf("\n 登记成功!\n");cus[j].num=r[i].m_num ;j=j+1;reg=1;}}if(reg==0){printf("\n 登记失败!\n");}}void Customer_ListOut(){if(count<=5){printf("请输入身份证号(18位数字):");scanf("%s",&ID);for(i=0;i<count;i++)if(strcmp(cus[i].m_ID,ID)==0){printf("\n\r顾客身份证号:%s 姓名:%s 年龄:%d 性别:%s \n",cus[i].m_ID,cus[i].m_name,cus[i].m_age,cus[i].m_sex);}}}else{printf("\n \n");}}void Room_ListOut(){printf("\n\r房间号楼层价格是否空闲(1:空闲0:已使用)");for(i=0;i<count;i++){if(r[i].m_use==1){printf("\n\r%d %d %d %d ",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);}}}void PerCustomer_Search(){if(count<=5){printf("请输入身份证号(18位数字):");scanf("%s",&cus[j].m_ID);printf("请输入姓名(10位字符)");scanf("%s",&cus[j].m_name);printf("请输入年龄(数字型)");scanf("%d",&cus[j].m_age);printf("请输入性别(男或女):");scanf("%s",&cus[j].m_sex);}else{printf("\n 住房已满!");}printf("\n\r顾客可以预订:");printf("\n\r房间号楼层价格是否空闲(1:空闲0:已使用)");for(i=0;i<count;i++){if(r[i].m_use==1){printf("\n\r%d %d %d %d ",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);}}printf("\n 请你输入要预订的房间号:");scanf("%d",&num);reg = 0;for(i=0;i<count;i++){if(r[i].m_use==1&&r[i].m_num==num){r[i].m_use = 0;printf("\n 预订成功!\n");cus[j].num=r[i].m_num ;j=j+1;reg=1;}}if(reg==0){printf("\n 预订失败!\n");}}void UnCustomer_Out(){int k;printf("\n 请输入要退房顾客身份证:");scanf("%s",&ID);for(i=0;i<count;i++){if(strcmp(cus[i].m_ID,ID)==0){printf("\n\r顾客身份证号:%s 姓名:%s 年龄:%d 性别:%s \n\r已经成功退房!",cus[i].m_ID,cus[i].m_name,cus[i].m_age,cus[i].m_sex);for(k=0;k<count;k++)if(r[k].m_num==cus[i].num)r[k].m_use=1;memset(&cus[i],0,sizeof(Customer));}}}void Customer_Goaway(){fproom=fopen("room","wb+");fwrite((void *)&r,sizeof(Room),count,fproom);fclose(fproom);fpcustomer=fopen("customer","wb+");fwrite((void*)&r,sizeof(Room),count,fpcustomer);fclose(fpcustomer);exit(0);}main(){fproom=fopen("room","wb");if(fproom!=NULL){for(i=0;i<count;i++){int id=100;r[i].m_num=i+100;r[i].m_floor=1;r[i].m_price=100;r[i].m_use=1;}fwrite((void *)&r,sizeof(Room),count,fproom);fclose(fproom);}else{printf("\n---文件打开失败--");}for(;;){printf("\n");printf("/******************************************\\\n ");printf("**\n");printf("* 酒店管理系统*\n");printf("* 主菜单*\n");printf("**\n");printf("* 1.顾客登记*\n");printf("* 2.查询顾客信息*\n");printf("* 3.查询空房间*\n");printf("* 4.预订房间*\n");printf("* 5.退订房间*\n");printf("* 6.保存并退出系统*\n");printf("**\n");printf("\\******************************************/\n\ n");printf("请输入选择项(1-6):");scanf("%d",&n);printf("\n\n\n\n");if(n>0&&n<=6){switch(n){case 1:Customer_Input();break;case 2:Customer_ListOut();break;/*查询顾客信息*/case 3:Room_ListOut();break;/*查询空房间*/case 4:PerCustomer_Search();break;/*预订房间*/case 5:UnCustomer_Out();break;/*退订房间*/case 6:Customer_Goaway(); /*保存退出*/}}else{printf("********************************************* **************************\n");printf("**\n");printf("*输入错误! *\n");printf("*请退出! *\n");printf("**\n");printf("********************************************* **************************\n");break;}} }。

酒店管理系统代码(C语言版)

酒店管理系统代码(C语言版)

#include <stdio.h〉#include 〈stdlib。

h>#include <string。

h>//房间信息结构体struct Node{int Count; //指示该房间有多少个房客char nameOne[20]; //房客1的名字char nameTwo[20]; //房客2的名字int sexOne;//房客1的性别—1代表女,0代表没有,1代表男int sexTwo; //房客2的性别int roomNumber;//房间号}roomArray[5];//初始化房间数组void InitArray(){int i;for(i=0;i<5;i++){roomArray[i].roomNumber = 301+i;memset(roomArray[i]。

nameOne,0,20);memset(roomArray[i]。

nameTwo,0,20);roomArray[i].sexOne = 0;roomArray[i].sexTwo = 0;roomArray[i].Count = 0;}}void fun1() //旅客入住的操作{char name[20];int sex;int i;printf(”\n输入入住旅客姓名和性别(空格隔开,1为男,—1为女):”);scanf(”%s %d",name,&sex);for(i=0;i<5;i++){if(roomArray[i]。

Count == 2){continue;}else if(roomArray[i].Count == 1){if(roomArray[i]。

sexOne != sex){continue;}strcpy(roomArray[i].nameTwo,name);roomArray[i].sexTwo = sex;roomArray[i]。

Count++;system("cls”);printf("客人已经成功入住,在房间%d”,roomArray[i].roomNumber);return;;}else{strcpy(roomArray[i]。

酒店管理系统实现代码

酒店管理系统实现代码

//入住import java。

awt。

*;import java。

awt.event.*;import javax.swing.*;import javax.swing.border。

Border;import javax。

swing。

text。

*;public class A1 extends JFrame implements WindowListener {//定义各个组件JFrame frame = new JFrame ("入住系统”);JLabel nameLabel = new JLabel(”客户姓名”);JLabel idtifyLabel = new JLabel(”身份证号”);JLabel roomLabel = new JLabel("入住房号");JLabel moneyLabel = new JLabel("应付金额");JTextField nameField = new JTextField();JTextField idtifyField= new JTextField();JTextField roomField= new JTextField();JTextField moneyField= new JTextField();JButton button1,button2;/*public static void main(String args[]){A1 a1 = new A1();a1.go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField。

setDocument(ucDocument);nameField.setForeground(Color。

black);//frame.addWindowListener(this);nameField.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){String username = nameField.getText();}});JComboBox jcb1;//组合框String[]itemList = { "现金",”刷卡”};jcb1 = new JComboBox(itemList);jcb1.setSelectedIndex(0);button1=new JButton("确认支付”);button2=new JButton(”取消支付”);final JPanel p1 = new JPanel();p1。

酒店管理系统实现代码

酒店管理系统实现代码

//入住import java.awt.*;import java。

awt。

event.*;import javax。

swing。

*;import javax.swing。

border.Border;import javax.swing。

text.*;public class A1 extends JFrame implements WindowListener {//定义各个组件JFrame frame = new JFrame ("入住系统”);JLabel nameLabel = new JLabel(”客户姓名");JLabel idtifyLabel = new JLabel(”身份证号”);JLabel roomLabel = new JLabel("入住房号”);JLabel moneyLabel = new JLabel("应付金额”);JTextField nameField = new JTextField();JTextField idtifyField= new JTextField();JTextField roomField= new JTextField();JTextField moneyField= new JTextField();JButton button1,button2;/*public static void main(String args[]){A1 a1 = new A1();a1。

go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField.setDocument(ucDocument);nameField.setForeground(Color.black);//frame.addWindowListener(this);nameField。

C语言宾馆管理系统源代码

C语言宾馆管理系统源代码
}
else
{
printf("要删除的话就按1:");
scanf("%d",&i);
if(i==1)
{
q=head;
while(q!=NULL&&q->next!=p)
q=q->next;
q->next=p->next;
}
while(b--)
{
p=(listnode *)malloc(sizeof(listnode));
printf("姓名 性别 证件 入住 天数 房号 标准 价格 预收 押金 离开 备注\n");
printf("**********************************************************************\n");
printf("*******************************************\n");
printf("姓名查找,按1表示查找:");
p=head->next;
scanf("%d",&i);
if(i==1)
{
printf("请输入要查询的姓名:");
scanf("%s",&come);
while(p&&strcmp(p->e,come)<0)
p=p->next;
if(p==NULL||strcmp(p->e,come)>0)

酒店管理系统源代码

酒店管理系统源代码

西彼科技有限责任公司参考源码酒店管理系统彼岸2011-03-31本段源代码,参考与阳光酒店管理系统编写的系统包Sunsdk包1)System包CsHashtable.java/** @(#)CsHashtable.java 1.24 03/12/19** public class** Copyright 2006 CazoSoft, Inc. All rights reserved.*/package sunsdk.system;import java.util.*;/*** <code> CsHashtable </code>* <p>* 该类的作用是封装哈希表* <p>* <strong>注意: </strong> 本类使用的哈希表方法put, 可能存在不安全因素* <p>* 相关类:Hashtable** @author 鲜强* @version 2006.3.28 22:18* @see java.util.Hashtable* @since CAZOSOFT 1.0*/public class CsHashtable {/*** 静态变量功能: 构造一个hashtable 供其他函数使用*/private static Hashtable hTable = new Hashtable();/*** 构造函数功能: 构造函数为静态的不能创建对象*/private CsHashtable() {}/*** 放入对象函数功能: 把对象放入哈希表,对象为Object类型** @param key :* 键值, Object 对象* @param value :* 对象, Object 对象*/public static void put(Object key, Object value) {hTable.put(key, value);}/*** 返回对象函数功能: 从哈希表中取出对象,返回为Object类型** @param key :* 键值* @return : 一个Object 对象*/public static Object get(Object key) {return hTable.get(key);}/*** 返回大小函数功能: 返回哈希表的大小** @return : 一个int 哈希表长度值*/public static int size() {return hTable.size();}/*** 移除一个对象** @param key : 接受一个要移除的键值*/public static Object remove(Object key) {return hTable.remove(key);}}/**Sunini.java*############################################################################## ** [ 项目名] :* [ 公司名] : SunshineSOFT* [ 模块名] : 对于INI文件的相关操作* [ 文件名] : sunini.java* [ 相关文件] : config.ini* [ 文件实现功能] : 读取和保存INI文件* [ 作者] : 顾俊* [ 版本] : 1.1* ----------------------------------------------------------------------------* [ 备注] :* ----------------------------------------------------------------------------* [ 修改记录] :** [ 日期] [版本] [修改人] [修改内容]* 2006/03/31 1.0 顾俊创建* 2006/04/06 1.1 顾俊修改读取函数* ##--------------------------------------------------------------------------* 版权所有(c) 2006-2007, SunshineSOFT Corporation* --------------------------------------------------------------------------##** [ 函数说明] :** [## private sunini() {} ]:* 功能: 构造函数** [## public static String getIniKey (String k) {} ]:* 功能: 获得INI文件中的指定键的键值** [## public static void setIniKey (String k, String v) {} ]:* 功能: 设置k键的键值为v对象** [## public static void saveIni (String k[]) {} ]:* 功能: 将k字符数组中所有键所对应的键值保存到INI文件中** [ 遗留问题] : setIniKey ()方法不能处理键值中的转义字符**############################################################################## */package com.sunshine.sunsdk.system;import java.util.*;import java.io.*;public class sunini {private static Properties ini = null;static {try {ini = new Properties ();ini.load (new FileInputStream ("config.ini"));}catch (Exception ex) {System.out.println ("Load CONFIG.INI is false!!");}//End try}/**=======================================================================* ** [## private sunini() {} ]: 构造函数* 参数:无* 返回值:无* 修饰符:private* 功能:防止实例化sunini对象**=======================================================================** */private sunini() {}/**=======================================================================* ** [## public static String getIniKey (String k) {} ]:* 参数:String对象表示键* 返回值:String对象表示k键所对应的键值,如果失败则返回空串* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:获得INI文件中的指定键的键值**=======================================================================** */public static String getIniKey (String k) {if(!ini.containsKey (k)) { //是否有k 这个键System.out.println ("The [ " + k + " ] Key is not exist!!");return "";}//End if(!ini.containsKey (k))return ini.get (k).toString ();}/**=======================================================================* ** [## public static void setIniKey (String k, String v) {} ]:* 参数:String k对象表示键,String v对象表示键值* 返回值:无* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:设置k键的键值为v对象**=======================================================================** */public static void setIniKey (String k, String v) {if(!ini.containsKey (k)) { //是否有k 这个键System.out.println ("The [ " + k + " ] Key is not exist!!");return;}//End if(!ini.containsKey (k))ini.put (k, v);}/**=======================================================================* ** [## public static void saveIni (String k[]) {} ]:* 参数:String k[]字符串数组表示要保存的所有键* 返回值:无* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:将k字符数组中所有键所对应的键值保存到INI文件中**=======================================================================** */public static void saveIni (String k[]) {try {FileWriter fw = new FileWriter ("config.ini");BufferedWriter bw = new BufferedWriter ( fw );//循环变量i是k字符串数组的下标for (int i = 0; i < k.length; i++) {bw.write (k[i] + "=" + getIniKey (k[i]));bw.newLine ();}//End forbw.close ();fw.close ();}catch (Exception ex) {System.out.println ("Save CONFIG.INI is false.");}//End try}}Suntools.java/***############################################################################## ** [ 项目名] :* [ 公司名] : SunshineSOFT* [ 模块名] : 工具函数* [ 文件名] : suntools.java* [ 相关文件] :* [ 文件实现功能] : 测试数据是否合法及流水号自动分配* [ 作者] : 顾俊* [ 版本] : 1.2* ----------------------------------------------------------------------------* [ 备注] :* ----------------------------------------------------------------------------* [ 修改记录] :** [ 日期] [版本] [修改人] [修改内容]* 2006/04/07 1.0 顾俊建立isDate()函数* 2006/04/08 1.1 顾俊添加函数#A, #B, #C, #D* 2006/04/08 1.2 顾俊添加函数#E, #F, #G* ##--------------------------------------------------------------------------* 版权所有(c) 2006-2007, SunshineSOFT Corporation* --------------------------------------------------------------------------##** [ 函数说明] :** [## private suntools () {} ] :* 功能: 防止实例化suntools对象** [## public static boolean isDate (String date) {} ]:* 功能: 判断日期字符串是否合法函数** [## public static boolean isNum (String in) {} ]: #A* 功能: 测试字符串是否由数字(0-9)组成** [## public static boolean isNum (String in, int length, double min, double max) {} ]: #B* 功能: 测试字符串表示的数值及范围,且字符串只能是数字组成** [## public static String getNumber (int type) {} ]: #C* 功能: 自动分配单据编号, 自动递增** [## public static void savNumber (String num, int type) {} ]: #D* 功能: 将已用编号保存到INI文件** [## public static double getConsumeFactor(String sDate, String eDate) {} ]: #E* 功能: 计算酒店计费天数按INI文件中设置的** [## public static double getClockFactor(String sDate, String eDate) {} ]: #F* 功能: 计算酒店钟点房计费系数按INI文件中设置的** [## public static String getConsumeHour(String sDate, String eDate) {} ]: #G* 功能: 计算两个时间之间有几小时几分*** [ 遗留问题] :***############################################################################## */package com.sunshine.sunsdk.system;import java.util.*;import java.text.*;import java.sql.*;import com.sunshine.sunsdk.sql.*;public class suntools {public static final int Number_RZ = 0; //表示销售单号public static final int Number_YD = 1; //表示进货单号public static final int Number_JS = 1; //表示进货单号/**=======================================================================* ** [## private suntools () {} ]: 构造函数* 参数:无* 返回值:无* 修饰符:private* 功能:防止实例化suntools对象**=======================================================================** */private suntools () {}/**=======================================================================* ** [## public static boolean isDate (String date) {} ]:* 参数:String对象表示日期的字符串* 返回值:boolean 合法返回true* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:判断日期字符串是否合法函数**=======================================================================** */public static boolean isDate (String date) {SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss");String isdate = date;if(date.length() == 10) //如果只有日期,函数自动加上00:00:00 isdate = date + " 00:00:00";try {sdf.parse (isdate);return true;}catch (Exception ex) {System.out.println ("feetools.isDate(): The DATE format is error .");return false;}}/**=======================================================================* ** [## public static boolean isNum (String in) {} ]:* 参数:String对象表示被测字符串* 返回值:boolean 合法返回true* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:测试字符串是否由数字(0-9)组成**=======================================================================** */public static boolean isNum (String in) {return isNum (in, 0, 0, 0);}/**=======================================================================* ** [## public static boolean isNum (String in, int length, double min, double max) {} ]:* 参数:String对象表示被测字符串* length变量表示字符串最大长度,取值0,表示没有长度限定* min,max变量限定了String对象表示的数值范围,当(length > 0)时* 返回值:boolean 合法返回true* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:测试字符串表示的数值及范围,且字符串只能是数字组成**=======================================================================** */public static boolean isNum (String in, int length, double min, double max) {String num = in;int point = 0; //'.'的个数int len = num.length ();if(length > 0) {if(len > length || len == 0) { //判断字符串长度,不合法空返回falseSystem.out.println ("suntools.isNum(): Length error.");return false;}//Endif}//End if(length > 0)elseif(len == 0) { //判断字符串是否为空,空返回falseSystem.out.println ("suntools.isNum(): String is NULL");return false;}//End if(len == 0)for (int i = len - 1; i >=0; i--) { //判断字符串只能是数字char ac = num.charAt (i);if(ac == '.' && point == 0 && i!= 0) { //如果是'.'字符,且是第一次出现,且不是只有一个点if(i > len - 4) { //判断小数位只能是两位point++;continue;}//Endif}//Endifif(ac < '0' || ac > '9' ) {System.out.println ("suntools.isNum(): Character isn't ( '0' - '9' )");return false;}//Endif}//Endforif(length !=0) {double s = Double.parseDouble (num); //现在len为字符串表示的数值if(s < min || s >max) { //限制范围min-max之间System.out.println ("suntools.isNum(): Amount limit error. ");return false;}//Endif}//End if(length != 0)return true;}/**=======================================================================* ** [## public static String getNumber (int type) {} ]:* 参数:int变量表示要获得什么类型的单号(见类头常量)* 返回值:String对象: 单号;* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:自动分配单据编号, 自动递增**=======================================================================** */public static String getNumber (int type) {GregorianCalendar gc = new GregorianCalendar();String tp, number, month, day; //单号标头, 单号记数位, 为月份, 为天int numLen = 0; //单号的默认位数if(type == Number_RZ) { //要获取销售单号tp = sunini.getIniKey ("LodgName");number = sunini.getIniKey ("LodgNumber");}else if(type == Number_YD){ //要获取进货单号tp = sunini.getIniKey ("EngaName");number = sunini.getIniKey ("EngaNumber");}else {tp = sunini.getIniKey ("ChouName");number = sunini.getIniKey ("ChouNumber");}numLen = number.length (); //得到单号的默认位数number = Integer.parseInt (number) + 1 + ""; //将单号增1,再转成字符串//判断记数号是否超位(超出要求长度)if(number.equals ((int)Math.pow (10, numLen - 1) + "") && number.length() > 1)number = number.substring(1); //单号记数位清零//for循环,用'0'为number补位(i = 当前号码位数, i < numLen)for (int i = number.length (); i < numLen; i++) {number = "0" + number;}//Endfor//为月份补'0'month = gc.get (GregorianCalendar.MONTH) + 1 + "";if( month.length() == 1)month = "0" + month;//为天补'0'day = gc.get (GregorianCalendar.DAY_OF_MONTH) + "";if( day.length () == 1)day = "0" + day;//连接单号标头,日期,记数位;组成单据号码tp = tp + gc.get (GregorianCalendar.YEAR) + month + day + number;return tp; //返回单号}/**=======================================================================* ** [## public static void savNumber (String num, int type) {} ]:* 参数:String对象表示要保存的单号* int变量表示要保存什么类型的单号(见类头常量)* 返回值:无* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:将已用编号保存到INI文件**=======================================================================** */public static void savNumber (String num, int type) {//INI文件中的键名String ini[] = { "[SOFTINFO]", "UserName", "CompName", "[CONFIG]", "Soft_First","Default_Link" , "Default_Page", "Sys_style", "[NUMBER]","LodgName", "LodgNumber", "EngaName", "EngaNumber", "ChouName","ChouNumber", "[HABITUS]", "Ck_Habitus", "Ck_Minute", "[PARTTIME]","In_Room", "Out_Room1", "Out_Room2", "InsuDay", "ClockRoom1","ClockRoom2", "InsuHour1", "InsuHour2", "[JDBC]", "DBFname","UserID", "Password", "IP", "Access", "[ODBC]", "LinkName" };String bt;if(type == Number_RZ) {bt = sunini.getIniKey ("LodgName");sunini.setIniKey ("LodgNumber", num.substring (bt.length () + 8));}else if(type == Number_YD){bt = sunini.getIniKey ("EngaName");sunini.setIniKey ("EngaNumber", num.substring (bt.length () + 8));} else{bt = sunini.getIniKey ("ChouName");sunini.setIniKey ("ChouNumber", num.substring (bt.length () + 8));}//保存到INI文件sunini.saveIni (ini);}/**=======================================================================* ** [## public static double getConsumeFactor(String sDate, String eDate) {} ]:* 参数:String sDate对象表示开始时间* String eDate变量表示结束时间* 返回值:double* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:计算酒店计费天数按INI文件中设置的**=======================================================================** *///获得消费系数public static double getConsumeFactor(String sDate, String eDate) {//获得开始日期时间的--年--月--日--时--分--秒String syh [] = sDate.trim ().split(" ");String symd[] = syh[0].trim().split("-");String shms[] = syh[1].trim().split(":");int sy = Integer.parseInt(symd[0]);int sM = Integer.parseInt(symd[1]);int sd = Integer.parseInt(symd[2]);int sh = Integer.parseInt(shms[0]);int sm = Integer.parseInt(shms[1]);int ss = Integer.parseInt(shms[2]);//获得结束日期时间的--年--月--日--时--分--秒String eyh [] = eDate.trim ().split(" ");String eymd[] = eyh[0].trim().split("-");String ehms[] = eyh[1].trim().split(":");int ey = Integer.parseInt(eymd[0]);int eM = Integer.parseInt(eymd[1]);int ed = Integer.parseInt(eymd[2]);int eh = Integer.parseInt(ehms[0]);int em = Integer.parseInt(ehms[1]);int es = Integer.parseInt(ehms[2]);//获得sDate的long值long sdt = new Timestamp(sy, sM, sd, sh, sm, ss, 0).getTime();//获得eDate的long值long edt = new Timestamp(ey, eM, ed, eh, em, es, 0).getTime();double db = 0;if(sdt > edt) { //不合法开始日期一定要小于结束日期db = -1;return db;}//Endifif(sdt == edt) { //无时间差db = 0;return db;}//Endifint insuDay = (int)(edt - sdt)/3600000;if(insuDay < 24) { //入住不到一天if(Integer.parseInt(sunini.getIniKey("InsuDay")) == 1)db = 1; //按全天计费else {if(insuDay > 1 && insuDay < 12)db = 0.5; //如果不按全天计费,则大于1小时按半天计费elsedb = 1; //如果不按全天计费,则大于12小时按全天计费}//Endifreturn db;}//Endif//几点之后按新的一天计费int inRoom = Integer.parseInt(sunini.getIniKey("In_Room"));if(sh < inRoom) {db = 0.5;}//Endifsh = inRoom; //多的时间已经加了系数,去掉多余的//几点之后按半天计费int outRoom1 = Integer.parseInt(sunini.getIniKey("Out_Room1"));int outRoom2 = Integer.parseInt(sunini.getIniKey("Out_Room2"));if(eh > outRoom1 && eh < outRoom2) {db = db + 0.5;eh = outRoom1; //多的时间已经加了系数,去掉多余的}else if(eh >= outRoom2) {db = db + 1;eh = outRoom2;}//Endif//计算入住时间sdt = new Timestamp(sy, sM, sd, sh, sm, ss, 0).getTime();edt = new Timestamp(ey, eM, ed, eh, em, es, 0).getTime();db = db + (edt - sdt)/86400000;return db;}/**=======================================================================* ** [## public static double getClockFactor(String sDate, String eDate) {} ]:* 参数:String sDate对象表示开始时间* String eDate变量表示结束时间* 返回值:double* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:计算酒店钟点房计费系数按INI文件中设置的**=======================================================================** */public static double getClockFactor(String sDate, String eDate) {//获得开始日期时间的--年--月--日--时--分--秒String syh [] = sDate.trim ().split(" ");String symd[] = syh[0].trim().split("-");String shms[] = syh[1].trim().split(":");int sy = Integer.parseInt(symd[0]);int sM = Integer.parseInt(symd[1]);int sd = Integer.parseInt(symd[2]);int sh = Integer.parseInt(shms[0]);int sm = Integer.parseInt(shms[1]);int ss = Integer.parseInt(shms[2]);//获得结束日期时间的--年--月--日--时--分--秒String eyh [] = eDate.trim ().split(" ");String eymd[] = eyh[0].trim().split("-");String ehms[] = eyh[1].trim().split(":");int ey = Integer.parseInt(eymd[0]);int eM = Integer.parseInt(eymd[1]);int ed = Integer.parseInt(eymd[2]);int eh = Integer.parseInt(ehms[0]);int em = Integer.parseInt(ehms[1]);int es = Integer.parseInt(ehms[2]);//获得sDate的long值long sdt = new Timestamp(sy, sM, sd, sh, sm, ss, 0).getTime();//获得eDate的long值long edt = new Timestamp(ey, eM, ed, eh, em, es, 0).getTime();//获得时间差double db = 0;if(sdt > edt) { //不合法开始日期一定要小于结束日期db = -1;return db;}//Endif//获得两个时间之间有多少秒edt = (edt - sdt) / 1000;//--------------------------------------------------------------------//if(edt <= 60 * Integer.parseInt(sunini.getIniKey("ClockRoom1"))) { db = 0; //开房后几分钟开始计费,读INI文件设置return db;}//Endif//--------------------------------------------------------------------//if(edt / 60 < 60 * Integer.parseInt(sunini.getIniKey("ClockRoom2"))) { db = 1; //不足几小时按一个单位计费return db;}//Endif//--------------------------------------------------------------------////除以上可能的正常计费公式如下db = edt / 3600; //获得过去的小时数edt = edt % 3600 / 60; //获得多余的分钟数if(edt > Integer.parseInt(sunini.getIniKey("InsuHour2")) && edt <= Integer.parseInt(sunini.getIniKey("InsuHour1"))) {db = db + 0.5; //超过多少分,但小于多少分部分,收半价}else if(edt > Integer.parseInt(sunini.getIniKey("InsuHour2"))) {db = db + 1; //超过多少分的,收全价}//Endif//--------------------------------------------------------------------//return db;}/**=======================================================================* ** [## public static String getConsumeHour(String sDate, String eDate) {} ]:* 参数:String sDate对象表示开始时间* String eDate变量表示结束时间* 返回值:String* 修饰符:public static 可以不实例化对象而直接调用方法* 功能:计算两个时间之间有几小时几分**=======================================================================** */public static String getConsumeHour(String sDate, String eDate) {//获得开始日期时间的--年--月--日--时--分--秒String syh [] = sDate.trim ().split(" ");String symd[] = syh[0].trim().split("-");String shms[] = syh[1].trim().split(":");int sy = Integer.parseInt(symd[0]);int sM = Integer.parseInt(symd[1]);int sd = Integer.parseInt(symd[2]);int sh = Integer.parseInt(shms[0]);int sm = Integer.parseInt(shms[1]);int ss = Integer.parseInt(shms[2]);//获得结束日期时间的--年--月--日--时--分--秒String eyh [] = eDate.trim ().split(" ");String eymd[] = eyh[0].trim().split("-");String ehms[] = eyh[1].trim().split(":");int ey = Integer.parseInt(eymd[0]);int eM = Integer.parseInt(eymd[1]);int ed = Integer.parseInt(eymd[2]);int eh = Integer.parseInt(ehms[0]);int em = Integer.parseInt(ehms[1]);int es = Integer.parseInt(ehms[2]);//获得sDate的long值long sdt = new Timestamp(sy, sM, sd, sh, sm, ss, 0).getTime();//获得eDate的long值long edt = new Timestamp(ey, eM, ed, eh, em, es, 0).getTime();//获得时间差sdt = edt - sdt;//生成过去多少时间的字符串String t = sdt / 3600000 + "小时" + sdt % 3600000 / 60000 + "分";return t;}}ToCap.java/** @(#)ToCap.java 1.24 03/12/19** Copyright 2006 CazoSoft, Inc. All rights reserved.*/package sunsdk.system;/*** <code> ToCap </code>* <p>* 本类用于转化中文大写人民币** @author 鲜强* @version 22.14, 04/05/06* @since CAZOSOFT 1.0*/public class ToCap {/*** 用户设置大写钱数(100,000,000 (一亿)以内).** @param money :* String 接收用户的正实数.* @return : String 包括圆整或角分的中文大写人民币,如果不合法,将返回空(null) */public String setMoney(String money) {String re = null;double num;//测试数据是否合法try {num = Double.parseDouble(money.trim());if (num < 100000000 && num >= 0) {//合法, 使用字符串开始转换re = this.mySetMoney(money);}//end if} catch (Exception ex) {}//end try//返回值return re;}/*** 大写转换函数. 功能: 转换数字为中文大写** @param num :* int 接受整数* @return : String 大写数字零到玖.*/private String setDaXie(int num) {String re = null;switch (num) {case 0:re = "零";break;case 1:re = "壹";break;case 2:re = "贰";break;case 3:re = "叁";break;case 4:re = "肆";break;case 5:re = "伍";break;case 6:re = "陆";break;case 7:re = "柒";break;case 8:re = "捌";break;case 9:re = "玖";break;default:break;}return re;}/*** 处理大写人民币** @param num :* String 接收处理过的字符串(实为数字). * @return : 返回处理过的大写人民币.*/private String mySetMoney(String num) throws Exception {//要返回的字符串String re = "";//转换过程String setNum = null;int index = num.indexOf(".");//处理整数if (index == -1) {setNum = num;} else {setNum = num.substring(0, index);}int weiShu = setNum.length();if (weiShu > 0) {int leng = setNum.length();int numYuan = Integer.parseInt("" + setNum.charAt(weiShu - 1));String zhuanYuan = setDaXie(numYuan);re = zhuanYuan;//个位if (weiShu > 1) {int numShi = Integer.parseInt("" + setNum.charAt(weiShu - 2));String zhuanShi = setDaXie(numShi);//十位re = zhuanShi + "拾" + re;if (weiShu > 2) {int numBai = Integer.parseInt(""+ setNum.charAt(weiShu - 3));String zhuanBai = setDaXie(numBai);//百位re = zhuanBai + "佰" + re;if (weiShu > 3) {int numQian = Integer.parseInt(""+ setNum.charAt(weiShu - 4));String zhuanQian = setDaXie(numQian);//千位re = zhuanQian + "仟" + re;if (weiShu > 4) {int numWan = Integer.parseInt(""+ setNum.charAt(weiShu - 5));String zhuanWan = setDaXie(numWan);//万位re = zhuanWan + "万" + re;if (weiShu > 5) {int numShiWan = Integer.parseInt(""+ setNum.charAt(weiShu - 6));String zhuanShiWan = setDaXie(numShiWan);//十万位re = zhuanShiWan + "拾" + re;if (weiShu > 6) {int numBaiWan = Integer.parseInt(""+ setNum.charAt(weiShu - 7));String zhuanBaiWan = setDaXie(numBaiWan);//百万位re = zhuanBaiWan + "佰" + re;if (weiShu > 7) {int numQianWan = Integer.parseInt(""+ setNum.charAt(weiShu - 8));String zhuanQianWan = setDaXie(numQianWan);//千万位re = zhuanQianWan + "仟" + re;}//end qianwan}//end baiwan}//end shiwan}//end wan}//end qian}//end bai}//end shi}//end yuan//处理小数if (index != -1) {String xiaoShu = num.substring(index + 1, num.length());int leng = xiaoShu.length();int numJiao = Integer.parseInt("" + xiaoShu.charAt(0));String zhuanJiao = setDaXie(numJiao);int numFen;if (leng == 1) {numFen = 0;}//end ifnumFen = Integer.parseInt("" + xiaoShu.charAt(1));String zhuanFen = setDaXie(numFen);//十分位+百分位if (numJiao == 0 && numFen != 0 || numJiao != 0 && numFen != 0) {re = re + "圆" + zhuanJiao + "角" + zhuanFen + "分";} else {re = re + "圆整";}//end if} else {re = re + "圆整";}//end indexreturn re;}}2)swing包CsUIManager.java/** @(#)CsUIManager.java 2006-4-13** public class** Copyright 2006 CazoSoft, Inc. All rights reserved.*/package sunsdk.swing;import java.awt.*;import javax.swing.*;import javax.swing.plaf.metal.*;/*** <code> CsUIManager </code>* <p>* 说明:本类为外观管理器* <p>* <strong>警告:</strong>* 使用金属(BOLD)外观时,输入中文会有异常,但不影响系统运行* <p>* 相关库文件:o.jar** @author 鲜强* @version 2006-4-13 23:05:39* @since CAZOSOFT 1.0*/public class CsUIManager {//Windows 外观public static final int WINDOWS = 0;//Java 默认外观public static final int METAL = 1;//Linux 外观public static final int MOTIF = 2;//WindowsClassic 外观public static final int WINDOWSCLASSIC = 3;//Alloy 外观public static final int ALLOY = 4;//Alloy 玻璃外观public static final int GLASSTHEMEALLOY = 5;//Alloy 迷幻外观public static final int ACIDTHEMEALLOY = 6;//Alloy 贝多因外观public static final int BEDOUIDTHEMEALLOY = 7;//Alloy 默认外观public static final int DEAFULTTHEMEALLOY = 8;//Bold 外观public static final int BOLD = 9;/*** 界面风格选择器** @param cp* 接受要改变的控件* @param style* 接受界面下标* @return 返回成功设置与否*/public static boolean setUI(Component cp, int style) {try {switch (style) {case 0:UIManager.setLookAndFeel("com.sun.java.swing.plaf."+ "windows.WindowsLookAndFeel");break;case 1:UIManager.setLookAndFeel("javax.swing.plaf."+ "metal.MetalLookAndFeel");break;case 2:UIManager.setLookAndFeel("com.sun.java.swing.plaf."+ "motif.MotifLookAndFeel");break;case 3:UIManager.setLookAndFeel("com.sun.java.swing.plaf."+"windows.WindowsClassicLookAndFeel");break;case 4:UIManager.setLookAndFeel("com.incors.plaf."+ "alloy.AlloyLookAndFeel");break;case 5:UIManager.setLookAndFeel("soft.wes.feels."+ "GlassThemeAlloyLookAndFeel");break;case 6:UIManager.setLookAndFeel("soft.wes.feels."+ "AcidThemeAlloyLookAndFeel");break;case 7:UIManager.setLookAndFeel("soft.wes.feels."+ "BedouinThemeAlloyLookAndFeel");break;case 8:UIManager.setLookAndFeel("soft.wes.feels."+ "DefaultThemeAlloyLookAndFeel");break;case 9:UIManager.put("swing.boldMetal", Boolean.FALSE);//可设置对话框外观JDialog.setDefaultLookAndFeelDecorated(true);//可设置设置窗口外观JFrame.setDefaultLookAndFeelDecorated(true);Toolkit.getDefaultToolkit().setDynamicLayout(true);System.setProperty("sun.awt.noerasebackground","true");UIManager.setLookAndFeel(new MetalLookAndFeel());break;}} catch (Exception ex) {JOptionPane.showMessageDialog(null, "更换风格失败,以原风格显。

酒店管理系统实现代码

酒店管理系统实现代码

//入住import java.awt.*;import java。

awt.event。

*;import javax。

swing.*;import javax。

swing.border.Border;import javax。

swing.text.*;public class A1 extends JFrame implements WindowListener {//定义各个组件JFrame frame = new JFrame ("入住系统”);JLabel nameLabel = new JLabel(”客户姓名");JLabel idtifyLabel = new JLabel("身份证号”);JLabel roomLabel = new JLabel(”入住房号");JLabel moneyLabel = new JLabel(”应付金额");JTextField nameField = new JTextField();JTextField idtifyField= new JTextField();JTextField roomField= new JTextField();JTextField moneyField= new JTextField();JButton button1,button2;/*public static void main(String args[]){A1 a1 = new A1();a1。

go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField。

setDocument(ucDocument);nameField.setForeground(Color.black);//frame。

酒店管理系统实现代码

酒店管理系统实现代码

//入住import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A1 extends JFrame implements WindowListener {//定义各个组件JFrame frame = new JFrame ("入住系统");JLabel nameLabel = new JLabel("客户姓名");JLabel idtifyLabel = new JLabel("身份证号");JLabel roomLabel = new JLabel("入住房号");JLabel moneyLabel = new JLabel("应付金额");JTextField nameField = new JTextField();JTextField idtifyField= new JTextField();JTextField roomField= new JTextField();JTextField moneyField= new JTextField();JButton button1,button2;/*public static void main(String args[]){A1 a1 = new A1();a1.go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField.setDocument(ucDocument);nameField.setForeground(Color.black);//frame.addWindowListener(this);nameField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String username = nameField.getText();}});JComboBox jcb1;//组合框String[] itemList = { "现金", "刷卡" };jcb1 = new JComboBox(itemList);jcb1.setSelectedIndex(0);button1=new JButton("确认支付");button2=new JButton("取消支付");final JPanel p1 = new JPanel();p1.add(jcb1);p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(3,1));Border etched = BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, "付款方式");p1.setBorder(border);button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="确认支付"){ JOptionPane.showMessageDialog(p1,"支付成功","success",RMA TION_MESSAGE);}}});button2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="取消支付"){ JOptionPane.showMessageDialog(p1,"支付失败","failure",RMA TION_MESSAGE);}}});idtifyField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String idtify= idtifyField.getText();String idtifyword= new String(idtify);}});roomField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String room= roomField.getText();String roomword= new String(room);}});moneyField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String money= moneyField.getText();String idtifyword= new String(money);}});//面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(4,1));labelPanel.add(nameLabel);labelPanel.add(idtifyLabel);labelPanel.add(roomLabel);labelPanel.add(moneyLabel);//面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(4,1));fieldPanel.add(nameField);fieldPanel.add(idtifyField);fieldPanel.add(roomField);fieldPanel.add( moneyField);//面板northPanel放面板lanelPanel和面板fieldPanelJPanel northPanel = new JPanel();northPanel.setLayout(new GridLayout(1,2));northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);//northPanel放在northcp.add(p1,BorderLayout.SOUTH);frame.setSize(200,250);frame.setVisible(true);}public void windowClosing(WindowEvent e1){System.exit(0);}public void windowOpened(WindowEvent e2){}public void windowIconified(WindowEvent e3){}public void windowDeiconified(WindowEvent e4){}public void windowClosed(WindowEvent e5){}public void windowActivated(WindowEvent e6){}public void windowDeactivated(WindowEvent e7){ }}class UpperCaseDocument extends PlainDocument { public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException{ string = string.toUpperCase();super.insertString(offset,string, attributeSet);}}第二个://退房import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A2 extends JFrame {//定义各个组件JFrame frame = new JFrame ("退房系统");JLabel nameLabel = new JLabel("客户姓名");JLabel idtifyLabel = new JLabel("身份证号");JLabel roomLabel = new JLabel("退房号");JLabel timeLabel = new JLabel("退房时间");JTextField nameField = new JTextField();JTextField idtifyField= new JTextField();JTextField roomField= new JTextField();JTextField timeField= new JTextField();JButton button1,button2;//JTextArea ta = new JTextArea(5,20);/*public static void main(String args[]){A2 a2 = new A2();a2.go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField.setDocument(ucDocument);nameField.setForeground(Color.black);nameField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String username = nameField.getText();}});button1=new JButton("是");button2=new JButton("否");final JPanel p1 = new JPanel();p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(2,1));Border etched = BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, "是否结清消费账单");p1.setBorder(border);button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="是"){ JOptionPane.showMessageDialog(p1,"谢谢您的大力支持!","success",RMA TION_MESSAGE);}}});button2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="否"){ JOptionPane.showMessageDialog(p1,"请结清消费账单","failure",RMA TION_MESSAGE);}}});idtifyField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String idtify= idtifyField.getText();String idtifyword= new String(idtify);}});roomField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ String room= roomField.getText();String roomword= new String(room);}});timeField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ String time= timeField.getText();String timeword= new String(time);}});//面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(4,1)); labelPanel.add(nameLabel);labelPanel.add(idtifyLabel);labelPanel.add(roomLabel);labelPanel.add(timeLabel);//面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(4,1)); fieldPanel.add(nameField);fieldPanel.add(idtifyField);fieldPanel.add(roomField);fieldPanel.add( timeField);//面板northPanel放面板lanelPanel和面板fieldPanel JPanel northPanel = new JPanel();northPanel.setLayout(new GridLayout(1,2)); northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);//northPanel放在northcp.add(p1,BorderLayout.SOUTH);// frame.pack();frame.setSize(200,230);frame.setVisible(true);}}class UpperCaseDocument extends PlainDocument{ public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException{ string = string.toUpperCase();super.insertString(offset,string, attributeSet);}}第三个://客房预订import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A3 extends JFrame {//定义各个组件JFrame frame = new JFrame ("客房预订");JLabel nameLabel = new JLabel("预订人姓名");JLabel numberLabel = new JLabel("手机号");JTextField nameField = new JTextField();JTextField numberField= new JTextField();JRadioButton rb1 = new JRadioButton("来电预订");JRadioButton rb2 = new JRadioButton("电话预订");JRadioButton rb3 = new JRadioButton("电传预订");JRadioButton rb4 = new JRadioButton("传真预订");JRadioButton rb5 = new JRadioButton("信函预订");JButton button1,button2;/** public static void main(String args[]){A3 a3 = new A3();a3.go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField.setDocument(ucDocument);nameField.setForeground(Color.black);nameField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String username = nameField.getText();}});JComboBox jcb1;//组合框String[] itemList = { "总统套房", "双人间","单人间" };jcb1 = new JComboBox(itemList);jcb1.setSelectedIndex(0);button1=new JButton("是");button2=new JButton("否");final JPanel p1 = new JPanel();p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(3,1));Border etched = BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, "预订房类型"); p1.setBorder(border);button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="是"){ JOptionPane.showMessageDialog(p1,"客人预订成功","success",RMA TION_MESSAGE);}}});button2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="否"){ JOptionPane.showMessageDialog(p1,"客人预订失败","failure",RMA TION_MESSAGE);}}});JPanel p2 = new JPanel();p2.add(rb1);p2.add(rb3);p2.add(rb4);p2.add(rb5);p2.setLayout(new FlowLayout());border = BorderFactory.createTitledBorder(etched, "预订方式"); p2.setBorder(border);//创建ButtonGroup按钮组,并在组中添加按钮ButtonGroup group1 = new ButtonGroup();group1.add(rb1);group1.add(rb2);group1.add(rb3);group1.add(rb4);group1.add(rb5);numberField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String number= numberField.getText();String numberword= new String(number);}});//面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(2,1));labelPanel.add(nameLabel);labelPanel.add(numberLabel);//面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(2,1));fieldPanel.add(nameField);fieldPanel.add(numberField);//面板northPanel放面板lanelPanel和面板fieldPanelJPanel northPanel = new JPanel();northPanel.setLayout(new GridLayout(1,2));northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);//northPanel放在northcp.add(p2,BorderLayout.CENTER);cp.add(p1,BorderLayout.SOUTH);frame.setSize(200,330);frame.setVisible(true);}}class UpperCaseDocument extends PlainDocument{ public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException{ string = string.toUpperCase();super.insertString(offset,string, attributeSet);}}第四个//餐饮预订import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A4 extends JFrame {//定义各个组件JFrame frame = new JFrame ("餐饮预订");JLabel nameLabel = new JLabel("预订人姓名");JLabel timeLabel = new JLabel("预订消费时间");JTextField nameField = new JTextField();JTextField timeField= new JTextField();JCheckBox cb1 = new JCheckBox("中餐");JCheckBox cb2 = new JCheckBox("西餐");JCheckBox cb3 = new JCheckBox("红酒");JCheckBox cb4 = new JCheckBox("饮料");JCheckBox cb5 = new JCheckBox("甜点");JCheckBox cb6 = new JCheckBox("水果");JButton button1,button2;/*public static void main(String args[]){A4 a4 = new A4();a4.go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField.setDocument(ucDocument);nameField.setForeground(Color.black);nameField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String username = nameField.getText();//ta.append("\nUser Name : "+username);}});button1=new JButton("是");button2=new JButton("否");final JPanel p1 = new JPanel();p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(3,1));Border etched = BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, "确认订餐"); p1.setBorder(border);button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="是"){ JOptionPane.showMessageDialog(p1,"订餐成功","success",RMA TION_MESSAGE);}}});button2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="否"){ JOptionPane.showMessageDialog(p1,"订餐失败","failure",RMA TION_MESSAGE);}}});timeField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String time= timeField.getText();String timeword= new String(time);}});JPanel p2 = new JPanel();p2.add(cb1);p2.add(cb2);p2.add(cb3);p2.add(cb4);p2.add(cb5);p2.add(cb6);Border etched1 = BorderFactory.createEtchedBorder();Border border1 = BorderFactory.createTitledBorder(etched1, "预订内容"); p2.setBorder(border1);//面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(4,1));labelPanel.add(nameLabel);labelPanel.add(timeLabel);//面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(4,1));fieldPanel.add(nameField);fieldPanel.add(timeField);//面板northPanel放面板lanelPanel和面板fieldPanelJPanel northPanel = new JPanel();northPanel.setLayout(new GridLayout(1,2));northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);//northPanel放在northcp.add(p2,BorderLayout.CENTER);cp.add(p1,BorderLayout.SOUTH);frame.setSize(200,350);frame.setVisible(true);}}class UpperCaseDocument extends PlainDocument{ public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException{ string = string.toUpperCase();super.insertString(offset,string, attributeSet);}}第五个:import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A5 extends JFrame {//定义各个组件JFrame frame = new JFrame ("订单管理");JLabel a1 = new JLabel("订单号");JLabel a2 = new JLabel("订货名称");JLabel a3 = new JLabel("收货地址");JLabel a4 = new JLabel("应收金额");JLabel a5 = new JLabel("客户名称");JLabel a6 = new JLabel("结算方式");JLabel a7 = new JLabel("经办人");JTextField b1 = new JTextField();JTextField b2= new JTextField();JTextField b3= new JTextField();JTextField b4= new JTextField();JTextField b5 = new JTextField();JTextField b6 = new JTextField();JTextField b7 = new JTextField();JButton button1,button2;public static void main(String args[]){A5 a1 = new A5();a1.go();}public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();b1.setDocument(ucDocument);b1.setForeground(Color.black);b1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String username = b1.getText();}});JComboBox jcb1;//组合框String[] itemList = { "现金", "刷卡" };jcb1 = new JComboBox(itemList);jcb1.setSelectedIndex(0);button1=new JButton("确认收款");button2=new JButton("取消收款");final JPanel p1 = new JPanel();p1.add(jcb1);p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(3,1));Border etched = BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, "收款方式"); p1.setBorder(border);button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="确认收款"){ JOptionPane.showMessageDialog(p1,"收款成功","success",RMA TION_MESSAGE);}}});button2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="取消收款"){ JOptionPane.showMessageDialog(p1,"收款失败","failure",RMA TION_MESSAGE);}}});b1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String idtify= a1.getText();String idtifyword= new String(idtify);}});b2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String room= a2.getText();String roomword= new String(room);}});b3.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String money= a3.getText();String idtifyword= new String(money);}});b4.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String money= a4.getText();String idtifyword= new String(money);}});b5.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String money= a5.getText();String idtifyword= new String(money);}});//面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(7,1));labelPanel.add(a1);labelPanel.add(a2);labelPanel.add(a3);labelPanel.add(a4);labelPanel.add(a5);labelPanel.add(a6);labelPanel.add(a7);//面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(7,1));fieldPanel.add(b1);fieldPanel.add(b2);fieldPanel.add(b3);fieldPanel.add( b4);fieldPanel.add( b5);fieldPanel.add( b6);fieldPanel.add( b7);//面板northPanel放面板lanelPanel和面板fieldPanel JPanel northPanel = new JPanel();northPanel.setLayout(new GridLayout(1,2));northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);//northPanel放在northcp.add(p1,BorderLayout.SOUTH);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setSize(200,250);frame.setVisible(true);}}class UpperCaseDocument extends PlainDocument{ public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException{ string = string.toUpperCase();super.insertString(offset,string, attributeSet);}}第六个:import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.text.*;import javax.swing.border.*;public class F{private JFrame frame;private JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13;JTextArea ta = new JTextArea(20,20);JTextArea tb = new JTextArea(20,20);public static void main(String args[]){F that=new F();that.go();}void go(){frame=new JFrame("客房检查");Container contentPane=frame.getContentPane();JPanel P1=new JPanel();P1.setLayout(new GridLayout());b1=new JButton("101 \n单人间");b2=new JButton("102 \n单人间");b3=new JButton("103 \n单人间");b4=new JButton("104 \n单人间");b5=new JButton("105 \n单人间");b6=new JButton("201 \n双人间");b7=new JButton("202 \n双人间");b8=new JButton("203 \n双人间");b9=new JButton("204 \n双人间");b10=new JButton("205 \n双人间");b11=new JButton("301 \n总统套房");b12=new JButton("302 \n总统套房");b13=new JButton("303 \n总统套房");b1.setBackground(Color.cyan);b2.setBackground(Color.cyan);b3.setBackground(Color.cyan);b4.setBackground(Color.cyan);b5.setBackground(Color.cyan);b6.setBackground(Color.magenta);b7.setBackground(Color.magenta);b8.setBackground(Color.magenta);b9.setBackground(Color.magenta);b10.setBackground(Color.magenta);b11.setBackground(Color.pink);b12.setBackground(Color.pink);b13.setBackground(Color.pink);P1.add(b1);P1.add(b2);P1.add(b3);P1.add(b4);P1.add(b5);P1.add(b6);P1.add(b7);P1.add(b8);P1.add(b9);P1.add(b10);P1.add(b11);P1.add(b12);P1.add(b13);tb.append("房间总数:13");tb.append("\n当前占用:");tb.append("\n当前可供:");P1.add(tb);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="101 \n单人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n101房间是否打扫:");ta.append("\n101房间里是否有家具损坏:");ta.append("\n101房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.yellow);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="102 \n单人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n102房间是否打扫:");ta.append("\n102房间里是否有家具损坏:");ta.append("\n102房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.yellow);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="103 \n单人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n103房间是否打扫:");ta.append("\n103房间里是否有家具损坏:");ta.append("\n103房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.yellow);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="104 \n单人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n104房间是否打扫:");ta.append("\n104房间里是否有家具损坏:");ta.append("\n104房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.yellow);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="105 \n单人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n105房间是否打扫:");ta.append("\n105房间里是否有家具损坏:");ta.append("\n105房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.yellow);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="201 \n双人间"){ta.setText("");JFrame frame1=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n201房间是否打扫:");ta.append("\n201房间里是否有家具损坏:");ta.append("\n201房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.cyan);frame1.setContentPane(p2);frame1.pack();frame1.setVisible(true);}else if(e.getActionCommand()=="202 \n双人间"){ta.setText("");JFrame frame2=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n202房间是否打扫:");ta.append("\n202房间里是否有家具损坏:");ta.append("\n202房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.cyan);frame2.setContentPane(p2);frame2.pack();frame2.setVisible(true);}else if(e.getActionCommand()=="203 \n双人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n203房间是否打扫:");ta.append("\n203房间里是否有家具损坏:");ta.append("\n203房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.cyan);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="204 \n双人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n204房间是否打扫:");ta.append("\n204房间里是否有家具损坏:");。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

{ if(r[i].m_use==1&&r[i].m_num==num) { r[i].m_use = 0; printf("\n 预订成功!\n"); cus[j].num=r[i].m_num ; j=j+1; reg=1; } } if(reg==0) { printf("\n 预订失败!\n"); } } void UnCustomer_Out() { int k; printf("\n 请输入要退房顾客身份证:"); scanf("%s",&ID); for(i=0;i<count;i++) { if(strcmp(cus[i].m_ID,ID)==0) { printf("\n\r顾客身份证号:%s 姓名:%s 年龄:%d 性别:%s \n\r已经成功退 房!",cus[i].m_ID,cus[i].m_name,cus[i].m_age,cus[i].m_sex); for(k=0;k<count;k++) if(r[k].m_num==cus[i].num) r[k].m_use=1; memset(&cus[i],0,sizeof(Customer)); } } } void Customer_Goaway()
{ fproom=fopen("room","wb+"); fwrite((void *)&r,sizeof(Room),count,fproom); fclose(fproom); fpcustomer=fopen("customer","wb+"); fwrite((void *)&r,sizeof(Room),count,fpcustomer); fclose(fpcustomer); exit(0); } main() { fproom=fopen("room","wb"); if(fproom!=NULL) { for(i=0;i<count;i++) { int id=100; r[i].m_num=i+100; r[i].m_floor=1; r[i].m_price=100; r[i].m_use=1; } fwrite((void *)&r,sizeof(Room),count,fproom); fclose(fproom); } else { printf("\n---文件打开失败--"); } for(;;) { printf("\n");
} if(reg==0) { printf("\n 登记失败!\n"); } } void Customer_ListOut() { if(count<=5) { printf("请输入身份证号(18位数字):"); scanf("%s",&ID); for(i=0;i<count;i++) { if(strcmp(cus[i].m_ID,ID)==0) { printf("\n\r顾客身份证号:%s 姓名:%s 年龄:%d 性 别:%s \n",cus[i].m_ID,cus[i].m_name,cus[i].m_age,cus[i].m_sex); } } } else { printf("\n \n"); } } void Room_ListOut() { printf("\n\r房间号 楼层 价格 是否空闲(lt;count;i++) { if(r[i].m_use==1) { printf("\n\r%d %d %d %d
酒店管理系统源代码 #include<string.h> #include<stdlib.h> #include<stdio.h> #include<conio.h> typedef struct tagCustomer { char m_ID[19]; /*身份证号码*/ char m_name[10]; /*顾客姓名*/ int m_age; /*顾客年龄*/ char m_sex[6]; /*顾客性别*/ int num; }Customer;/*顾客结构*/ typedef struct tagRoom { int m_num; /*房间号*/ int m_floor; /*楼层*/ int m_price; /*价格*/ int m_use; /*是否已入住*/ }Room;/*房间结构*/ int i,j=0,age,num,floor,price,use,n; int reg =0; Customer cus[5]; Room r[5]; int count=5; char ID[18],name[10],sex[6]; FILE *fproom; FILE *fpcustomer; void Customer_Input() { if(count<=5) { printf("请输入身份证号(18位数字):");
printf("****************************************************************** printf("* *\n"); printf("* 输入错误! *\n");
printf("* printf("*
请退出!
*\n"); *\n");
scanf("%s",&cus[j].m_ID); printf("请输入姓名(10位字符)"); scanf("%s",&cus[j].m_name); printf("请输入年龄(数字型)"); scanf("%d",&cus[j].m_age); printf("请输入性别(男或女):"); scanf("%s",&cus[j].m_sex); } else { printf("\n 存储空间已满!"); } printf("\n\r顾客可以住在:"); printf("\n\r房间号 楼层 价格 是否空闲(1:空闲0:已使 用)"); for(i=0;i<count;i++) { if(r[i].m_use==1) { printf("\n\r%d %d %d %d ",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use); } } printf("\n\r请你输入房间号:"); scanf("%d",&num); reg = 0; for(i=0;i<count;i++) { if(r[i].m_use==1&&r[i].m_num==num) { r[i].m_use = 0; printf("\n 登记成功!\n"); cus[j].num=r[i].m_num ; j=j+1; reg=1; }
",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use); } } } void PerCustomer_Search() { if(count<=5) { printf("请输入身份证号(18位数字):"); scanf("%s",&cus[j].m_ID); printf("请输入姓名(10位字符)"); scanf("%s",&cus[j].m_name); printf("请输入年龄(数字型)"); scanf("%d",&cus[j].m_age); printf("请输入性别(男或女):"); scanf("%s",&cus[j].m_sex); } else { printf("\n 住房已满!"); } printf("\n\r顾客可以预订:"); printf("\n\r房间号 楼层 价格 是否空闲(1:空闲0:已使 用)"); for(i=0;i<count;i++) { if(r[i].m_use==1) { printf("\n\r%d %d %d %d ",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use); } } printf("\n 请你输入要预订的房间号:"); scanf("%d",&num); reg = 0; for(i=0;i<count;i++)
printf("****************************************************************** break; } } }
printf("/******************************************\\\n"); printf("* *\n"); printf("* 酒店管理系统 *\n"); printf("* 主菜单 *\n"); printf("* *\n"); printf("* 1.顾客登记 *\n"); printf("* 2.查询顾客信息 *\n"); printf("* 3.查询空房间 *\n"); printf("* 4.预订房间 *\n"); printf("* 5.退订房间 *\n"); printf("* 6.保存并退出系统 *\n"); printf("* *\n"); printf("\\******************************************/\n\n"); printf("请输入选择项(1-6):"); scanf("%d",&n); printf("\n\n\n\n"); if(n>0&&n<=6) { switch(n) { case 1:Customer_Input();break; case 2:Customer_ListOut();break;/*查询顾客信息*/ case 3:Room_ListOut();break;/*查询空房间*/ case 4:PerCustomer_Search();break;/*预订房间*/ case 5:UnCustomer_Out();break;/*退订房间*/ case 6:Customer_Goaway(); /*保存退出*/ } } else {
相关文档
最新文档