第五组酒店客房预订管理系统的设计与实现源代码(可编辑修改word版)
- 格式:docx
- 大小:15.49 KB
- 文档页数:13
//入住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。
酒店客房管理系统设计系统源代码酒店客房管理系统代码清单:frmAddlb窗体代码:Private Sub Command1_Click()Dim sql As StringDim conn As New adodb.ConnectionDim rs_fjstyle As New adodb.RecordsetIf Trim(Text1.Text) = "" ThenMsgBox "请输入房间类型", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd IfIf Trim(Text2.Text) = "" ThenMsgBox "请输入类型代号", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd IfIf Trim(Text3.Text) = "" ThenMsgBox "请输入房间数量", vbOKOnly + vbExclamation, ""Text3.SetFocusExit SubEnd Ifconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select * from 客房类别where 房间类型='" & Text1.Text & "'"rs_fjstyle.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_fjstyle.EOF Thenrs_fjstyle.AddNewrs_fjstyle.Fields(1) = Trim(Text1.Text)rs_fjstyle.Fields(2) = Trim(Text2.Text)rs_fjstyle.Fields(3) = Trim(Text3.Text)rs_fjstyle.UpdateMsgBox "添加成功", vbOKOnly + vbExclamation, ""Text1.Text = ""Text2.Text = ""Text3.Text = ""Text1.SetFocusrs_fjstyle.CloseElseMsgBox "你添加的类别已存在,请输入新类别", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""Text2.Text = ""rs_fjstyle.CloseExit SubEnd IfEnd SubPrivate Sub Command2_Click()Unload Mefrmlbinfo.ShowEnd SubfrmAdduser窗体代码:Private Sub Command1_Click()Dim sql As StringDim rs_add As New adodb.RecordsetDim conn As New adodb.Connectionconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"If Trim(Text1.Text) = "" ThenMsgBox "用户名不能为空,请输入!", vbOKOnly + vbExclamation, ""Text1.SetFocusElsesql = "select * from 用户信息"rs_add.Open sql, conn, adOpenKeyset, adLockPessimisticWhile (rs_add.EOF = False)If Trim(rs_add.Fields(1)) = Trim(Text1.Text) ThenMsgBox "已有这个用户", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""Text2.Text = ""Text3.Text = ""Exit SubElsers_add.MoveNextEnd IfWendIf Trim(Text2.Text) <> Trim(Text3.Text) ThenMsgBox "两次密码不一致", vbOKOnly + vbExclamation, ""Text2.SetFocusText2.Text = ""Text3.Text = ""Exit SubElsers_add.AddNewrs_add.Fields(1) = Text1.Textrs_add.Fields(2) = Text2.Textrs_add.UpdateMsgBox "添加用户成功!", vbOKOnly + vbExclamation, ""'Me.HideEnd IfEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubfrmdfAdd窗体代码:Private Sub Command1_Click()Dim sql As StringDim conn As New adodb.ConnectionDim rs_fjstyle As New adodb.RecordsetIf Trim(Text1.Text) = "" ThenMsgBox "请输入姓名!", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd If'If Trim(Text2.Text) = "" Then'MsgBox "日期不能为空!", vbOKOnly + vbExclamation, ""'Text2.SetFocus'Exit Sub'Else'If Not IsDate(Text2.Text) Then' MsgBox "请按照2006-12-30格式输入登记日期!", vbOKOnly + vbExclamation, "" ' Text2.Text = ""' Text2.SetFocus'Exit Sub'End If'End IfIf Trim(Text3.Text) = "" ThenMsgBox "请输入房间编号!", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd IfIf Trim(Text4.Text) = "" ThenMsgBox "请选择房间类型!", vbOKOnly + vbExclamation, ""Text4.SetFocusExit SubEnd IfIf Trim(Text5.Text) = "" ThenMsgBox "请交定金!", vbOKOnly + vbExclamation, ""Text5.SetFocusExit SubEnd Ifconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select * from 预订客房"rs_fjstyle.Open sql, conn, adOpenKeyset, adLockPessimistic'rs_fjstyle.EOFrs_fjstyle.AddNewrs_fjstyle.Fields(1) = Trim(Text1.Text)rs_fjstyle.Fields(4) = Trim(DTPicker1.Value)rs_fjstyle.Fields(5) = Trim(DTPicker2.Value)rs_fjstyle.Fields(2) = Trim(Text3.Text)rs_fjstyle.Fields(3) = Trim(Text4.Text)rs_fjstyle.Fields(6) = Val(Text5.Text)rs_fjstyle.UpdateMsgBox "添加成功", vbOKOnly + vbExclamation, ""rs_fjstyle.CloseCommand3.Enabled = TrueExit SubEnd SubPrivate Sub Command2_Click()Text1.Text = ""'Text2.Text = ""'Text3.Text = ""Text4.Text = ""Text5.Text = ""Text1.SetFocusEnd SubPrivate Sub Command3_Click()Dim conn As New adodb.ConnectionDim rs_fjstyle As New adodb.Recordsetconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select 客人姓名,房间编号,房间类型,订房日期,订房时间,预交订金from 预订客房" rs_fjstyle.CursorLocation = adUseClientrs_fjstyle.Open sql, conn, adOpenKeyset, adLockPessimisticDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_fjstyleMsgBox "数据已更新!", vbOKOnly + vbExclamation, ""Exit SubEnd SubPrivate Sub Command4_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim sql As StringDim conn As New adodb.ConnectionDim rs_fjstyle As New adodb.Recordsetconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select 客人姓名,房间编号,房间类型,订房日期,订房时间,预交订金from 预订客房" rs_fjstyle.CursorLocation = adUseClientrs_fjstyle.Open sql, conn, adOpenKeyset, adLockPessimisticDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_fjstyleExit SubSet DTPicker2.Value = TimeEnd SubfrmDfdy窗体代码:Private Sub Command1_Click()Dim conn As New adodb.ConnectionDim rs_dfdybb As New adodb.Recordsetconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select 房间编号,房间类别,日住宿费,周住宿费,月住宿费,预订,空房from 客房信息"rs_dfdybb.Open sql, conn, adOpenKeyset, adLockPessimisticSet DataReport1.DataSource = rs_dfdybb.DataSourceDataReport1.DataMember = rs_dfdybb.DataMemberDataReport1.Show' Unload MeEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim sql As StringDim rs_dfdy As New RecordsetDim conn As New adodb.ConnectionOn Error GoTo loaderrorconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select 房间编号,房间类别,日住宿费,周住宿费,月住宿费,预订,空房from 客房信息" rs_dfdy.CursorLocation = adUseClientrs_dfdy.Open sql, conn, adOpenKeyset, adLockPessimisticDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_dfdyExit Subloaderror:MsgBox Err.DescriptionEnd SubfrmdfEdit窗体代码:Option ExplicitDim rs_xgkfinfo As New adodb.RecordsetPrivate Sub cmddel_Click()Dim answer As Stringanswer = MsgBox("确定要删除吗?", vbYesNo, "")If answer = vbYes ThenDataGrid1.AllowDelete = TrueDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = Falsers_xgkfinfo.Deleters_xgkfinfo.UpdateDataGrid1.RefreshElseExit SubEnd IfEnd SubPrivate Sub cmdEdit_Click()Dim answer As StringOn Error GoTo cmdEditcmddel.Enabled = FalsecmdEdit.Enabled = Falsecmdupdate.Enabled = TrueCommand4.Enabled = FalseDataGrid1.AllowUpdate = TrueExit SubcmdEdit:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd Sub'-------------------------------------------------------Private Sub DataGrid1_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)If ColIndex = 3 ThenIf Not IsDate(DataGrid1.Columns(3).Value) ThenCancel = TrueMsgBox "请输入一个日期型数据。
#include <iostream>#include <iomanip>#include <string>#include <fstream>#include"conio.h" //输入/输出文件流类using namespace std;const int Maxr=100; //最多的客户const int Maxb=100; //最多的客房const int Maxbor=10; //每位客户最多预订十间客房//person类class person{public:char name[20];char ID[18];char *getname() {return name;}//获取姓名char *getID() {return ID;} //获取身份证号void setID(char I[]) //设置身份证号{strcpy(ID,I);}void setname(char na[]) //设置姓名{strcpy(name,na);}};//客户类公有继承了person类,实现对客户的信息的描述class customer:public person{private:int num; //客户编号int tag; //删除标记1:已删0:未删int borbook[Maxbor]; //所订房间public:customer() {}int gettag() {return tag;} //获取删除标记void delbook(){ tag=1; } //设置删除标记1:已删0:未删int getnum() {return num;} //获取客户编号void addcustomer(int n,char *na,char *I) //增加客户{tag=0;num=n;strcpy(name,na);strcpy(ID,I);for(int i=0;i<Maxbor;i++)borbook[i]=0;}void borrowbook(int bookid) //预订操作{for(int i=0;i<Maxbor;i++){if (borbook[i]==0){borbook[i]=bookid;return;}}}int retbook(int bookid) //退订操作{for(int i=0;i<Maxbor;i++){if(borbook[i]==bookid){borbook[i]=0;return 1;}}return 0;}void display() //读出客户信息{cout <<"客户编号:" << num <<setw(15)<< "姓名:" << name <<setw(15)<< "身份证号:" << ID<<setw(15)<<"客房编号:[";for(int i=0;i<Maxbor;i++)if(borbook[i]!=0)cout <<"#"<< borbook[i]<<" ";cout << "]"<<endl;}};//客户库类,实现建立客户的个人资料class RDatabase{private:int top; //客户记录指针customer read[Maxr]; //客户记录public:RDatabase() //构造函数,将customer.txt读到read[]中{customer s;top=-1;fstream file("customer.txt",ios::in); //打开一个输入文件while (1){file.read((char *)&s,sizeof(s));if (!file)break;top++;read[top]=s;}file.close(); //关闭customer.txt}void clear() //删除所有客户信息{top=-1;}int addcustomer(int n,char *na,char *I) //添加客户时先查找是否存在{customer *p=query(n);if (p==NULL){top++;read[top].addcustomer(n,na,I);return 1;}return 0;}customer *query(int customerid) //按编号查找{for (int i=0;i<=top;i++)if (read[i].getnum()==customerid&&read[i].gettag()==0){return &read[i];}return NULL;}customer *query(string name) //按name查找{for (int i=0;i<=top;i++)if (read[i].getname()==name&&read[i].gettag()==0){return &read[i];}return NULL;}void display() //输出所有客户信息{for (int i=0;i<=top;i++)if(read[i].gettag()==0)read[i].display();}void customerdata(); //客户库维护~RDatabase() //析构函数,将read[]写到customer.txt文件中{fstream file("customer.txt",ios::out);for (int i=0;i<=top;i++)if (read[i].gettag()==0)file.write((char *)&read[i],sizeof(read[i]));file.close();}};void RDatabase::customerdata(){char choice;char rsex[10];char rname[20];int customerid;char rID[18];customer *r;system("cls");while (choice!='0'){cout<<endl<<setw(40)<<"客户信息"<<endl;cout<<endl<<setw(28)<<"1 "<<"新增"<<endl;cout<<endl<<setw(28)<<"2 "<<"更改"<<endl;cout<<endl<<setw(28)<<"3 "<<"删除"<<endl;cout<<endl<<setw(28)<<"4 "<<"查找"<<endl;cout<<endl<<setw(28)<<"5 "<<"显示"<<endl;cout<<endl<<setw(28)<<"6 "<<"全删"<<endl;cout<<endl<<setw(28)<<"0 "<<"返回"<<endl;cin>>choice;system("cls");switch (choice){case '1':cout <<"请输入客户信息:"<<endl;cout << "输入客户编号:";cin >> customerid;cout << "输入客户姓名:";cin >> rname;cout << "输入客户身份证号:";cin >> rID;addcustomer (customerid,rname,rID);break;case '2':cout << "输入客户编号:";cin >> customerid;r=query(customerid);if (r==NULL){cout << " 该客户不存在"<<endl;break;}cout << "输入新的客户姓名:";cin >> rname;r->setname(rname);cout<<"输入新的身份证号码:";cin>>rID;r->setID (rID);break;case '3':cout << "输入客户编号:";cin >> customerid;r=query(customerid);if (r==NULL){cout <<" 该客户不存在" << endl;break;}r->delbook();cout<<"删除成功!"<<endl;break;case '4':char cho;cout<<"请选择查找方式:"<<endl;cout<<"1.按客户编号查找,2.按客户姓名查找";cin>>cho;system("cls");switch (cho){case '1':cout << "输入客户编号:";cin >> customerid;r=query(customerid);if (r==NULL){cout <<" 该客户不存在"<< endl;break;}break;case'2':cout<<"输入客户名字:";cin >> rname;r=query(rname);if (r==NULL){cout<<"该客户不存在"<<endl;break;}}r->display();break;case '5':display();break;case '6':clear();cout<<"删除成功!"<<endl;break;default:cout<<"正在返回主界面...";system("cls");break;}}}//客房类,实现对客房的描述class Book{private:int tag; //删除标记1:已删0:未删int no; //客房编号char name[20]; //客房描述int onshelf; //是否预订1:空房2:已预订public:Book(){}char *getname() { return name; } //获取姓名int getno(){ return no; } //获取客房编号int gettag(){ return tag; } //获取删除标记void setname(char na[]) //设置客房描述{strcpy(name,na);}void delbook(){ tag=1;} //删除客房void addbook(int n,char *na) //增加客房{tag=0;no=n;strcpy(name,na);onshelf=1;}int borrowbook() //预订操作{if (onshelf==1){onshelf=0;return 1;}return 0;}void retbook() //退订操作{onshelf=1;}void disp() //输出客房{cout <<"客房编号:"<< no <<setw(15)<< "客房描述:"<< name <<setw(15)<<(onshelf==1? "空房":"已预订") <<endl;}};//客房库类,实现对客房的管理,如查找、删除等class BDatabase{private:int top; //客房记录指针Book book[Maxb]; //客房记录public:BDatabase() //构造函数,将book.txt读到book[]中{Book b;top=-1;fstream file("book.txt",ios::in);while (1){file.read((char *)&b,sizeof(b));if (!file) break;top++;book[top]=b;}file.close();}void clear() //全删{top=-1;}int addbook(int n,char *na) //增加客房{Book *p=query(n);if (NULL==p){top++;book[top].addbook(n,na);return 1;}return 0;}Book *query(int bookid) //查找客房{for (int i=0;i<=top;i++)if (book[i].getno()==bookid &&book[i].gettag()==0){return &book[i];}return NULL;}Book *query(string bname){for (int i=0;i<=top;i++)if (book[i].getname()==bname&&book[i].gettag()==0){return &book[i];}return NULL;}void bookdata(); //客房库维护void disp(){for (int i=0;i<=top;i++)if (book[i].gettag()==0)book[i].disp();}~BDatabase() //析构函数,将book[]写到book.txt文件中{fstream file("book.txt",ios::out);for (int i=0;i<=top;i++)if (book[i].gettag()==0)file.write((char *)&book[i],sizeof(book[i]));file.close();}};void BDatabase::bookdata(){char choice;char bname[40];int bookid;Book *b;system("cls");while (choice!='0'){cout<<endl<<setw(40)<<"客房信息"<<endl;cout<<endl<<setw(28)<<"1 "<<"新增"<<endl;cout<<endl<<setw(28)<<"2 "<<"更改"<<endl;cout<<endl<<setw(28)<<"3 "<<"删除"<<endl;cout<<endl<<setw(28)<<"4 "<<"查找"<<endl;cout<<endl<<setw(28)<<"5 "<<"显示"<<endl;cout<<endl<<setw(28)<<"6 "<<"全删"<<endl;cout<<endl<<setw(28)<<"0 "<<"返回"<<endl;cin >> choice;system("cls");switch (choice){case '1':cout <<"请输入客房信息:"<<endl;cout << "输入客房编号:";cin >> bookid;cout << "输入客房描述:";cin >> bname;addbook(bookid,bname);break;case '2':cout << "输入客房编号:";cin >> bookid;b=query(bookid);if (b==NULL){cout <<" 该客房不存在"<<endl;break;}cout << "输入新的客房描述:";cin >> bname;b->setname(bname);break;case '3':cout <<"输入客房编号:";cin >> bookid;b=query(bookid);if (b==NULL){cout <<" 该客房不存在" << endl;break;}b->delbook();cout<<"删除成功!"<<endl;break;case '4':char bb;cout << "请选择查找方式:1.按客房编号查找2.按客房描述查找";cin >> bb;switch(bb){case'1':cout<<"请输入客房编号:";cin>>bookid;b=query(bookid);if (b==NULL){cout <<" 该客房不存在"<< endl;break;}break;case'2':cout<<"请输入客房描述:";cin>>bname;b=query(bname);if (b==NULL){cout <<" 该客房不存在"<< endl;break;}}b->disp();break;case '5':disp();break;case '6':clear();cout<<"删除成功!"<<endl;break;default:cout<<"正在返回主界面...";system("cls");}}}int main(){char choice;int bookid,customerid;RDatabase customerDB;customer *r;BDatabase BookDB;Book *b;while(choice!='0'){cout <<setw(39)<<"欢迎使用"<<endl;cout <<endl<<setw(55)<<"酒店客房预订管理系统"<<endl<<endl;cout <<"のののののののののののののののののののののののののののののののののののの"<<endl;cout <<"I"<<setw(71)<<"I";cout <<endl<<"I"<<setw(25)<<"1"<<setw(15)<<"客户信息"<<setw(31)<<"I"<<endl;cout <<"I"<<setw(71)<<"I";cout <<endl<<"I"<<setw(25)<<"2"<<setw(15)<<"客房信息"<<setw(31)<<"I"<<endl;cout <<"I"<<setw(71)<<"I";cout <<endl<<"I"<<setw(25)<<"3"<<setw(15)<<"订房"<<setw(31)<<"I"<<endl;cout <<"I"<<setw(71)<<"I";cout <<endl<<"I"<<setw(25)<<"4"<<setw(15)<<"退房"<<setw(31)<<"I"<<endl;cout <<"I"<<setw(71)<<"I";cout <<endl<<"I"<<setw(25)<<"0"<<setw(15)<<"退出"<<setw(31)<<"I"<<endl;cout <<"のののののののののののののののののののののののののののののののののののの"<<endl;cin >> choice;switch (choice){case '1':customerDB.customerdata();break;case '2':BookDB.bookdata();break;case '3':cout <<"输入客户编号:";cin >>customerid;cout <<"输入客房编号:";cin >>bookid;r=customerDB.query(customerid);//按编号查找if (r==NULL){cout <<" 不存在的客户,不能预订"<< endl;break;}b=BookDB.query(bookid);if (b==NULL){cout <<" 不存在的客房,不能预订"<< endl;break;}if (b->borrowbook()==0){cout << " 该客房已预订,不能预订"<< endl;break;}r->borrowbook(b->getno());cout<<"预订成功!"<<endl;break;case '4':cout<<"输入客户编号:";cin >>customerid;cout << "输入客房编号:";cin >>bookid;r=customerDB.query(customerid);if (r==NULL){cout <<" 不存在的客户,不能退订" << endl;break;}b=BookDB.query(bookid);if (b==NULL){cout <<" 不存在的客房,不能退订" <<endl;break;}b->retbook();r->retbook(b->getno());cout<<"退订成功!"<<endl;break;default:cout<<"正在写入数据库......谢谢使用!";}}return 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, "更换风格失败,以原风格显。
#include 〈windows.h>#include <dos。
h〉#include〈stdio。
h〉#include〈stdlib.h〉#include<time.h〉//—-------—-—-—-——-———-——--—-—-—-——-———--—-—-—-----—结构定义———--—--—-——---———--—-———-——--——————--——-—typedef struct CheckinInformation{char name[10]; //姓名int id; //证件号int roomType; //房型int countType; //计费方式}CheckinInfo;typedef struct HotelRoom{int roomType;//房型int roomNum; //房号int checked; //入住情况int price;//房价}Room;typedef struct RoomOrder{CheckinInfo *checkinInfo; //入住信息long date;//入住时间Room * room;//房间信息}Order;typedef struct HotelInfomation{int checkinAmount;//已入住房数int singleRemainAmount;//单人房剩余房数int doubleRemainAmount;//双人房剩余房数int bigRemainAmount; //大床房剩余房数}HotelInfo;//--—--——--——-—--—--—---—-———--—-—枚举类型—--—--—-—--————-—-------—--enum {MainUI,HotelInfoUI,CheckinUI,CheckinResultUI,OrderUI,CheckOutUI,Exit};//GUI enum {Single,Double,Big};//Room Typeenum {Hour,Day};//countType//——--—---—--——-—---—---——-----—-—全局变量--——————————-—-—-——-———--—int GUI = MainUI;Order*orderList[100]; //订单数组Room*roomList[100]; //房间数组HotelInfo * hotelInfo = NULL;//酒店房间信息//—-—-—————-----—-———-—-———---———函数声明--—---—--------—-——---——-——-void initiallizeRoomList();void insertToOrderList(Order *order);Room*getRoomByType(int roomType);Order* getOrderByRoomNum(int roomNum);void showMainUI();void showHotelInfoUI();void showCheckinUI();void showCheckinResultUI();void showOrderUI();void showCheckOutUI();//—--——--———--——-—-—---——-————--—Main函数----—-————--—----———-————---void main() //主函数{//初始化酒店房间信息hotelInfo = (HotelInfo *)malloc(sizeof(HotelInfo));hotelInfo -> singleRemainAmount = 20;hotelInfo -〉doubleRemainAmount=40;hotelInfo —〉bigRemainAmount=40;hotelInfo —〉checkinAmount=0;//初始化房间列表initiallizeRoomList();//界面显示while(GUI != Exit){switch(GUI){case MainUI:showMainUI();break;case HotelInfoUI:showHotelInfoUI();break;case CheckinUI:showCheckinUI();break;case CheckinResultUI:showCheckinResultUI();break;case OrderUI:showOrderUI();break;case CheckOutUI:showCheckOutUI();break;default:break;}}}//----————-——-————---------—-——--函数定义—-----———-——————--—---——————void initiallizeRoomList(){//房间数组初始化,初始化的结果是让roomList的数组有100个room指针,而且设置了相应的值int i;Room*newRoom=NULL;for(i=0;i〈20;i++)//单人房房间信息初始化{newRoom = (Room* )malloc(sizeof(Room));roomList[i]= newRoom;roomList[i]->checked=0;roomList[i]—〉price=110;roomList[i]-〉roomNum=i+1;roomList[i]—〉roomType=Single;}for(i=20;i<60;i++)//双人房房间信息初始化{newRoom = ( Room*)malloc(sizeof(Room));roomList[i]= newRoom;roomList[i]—>checked=0;roomList[i]—>price=180;roomList[i]—〉roomNum=i+1;roomList[i]—>roomType=Double;}for(i=60;i〈100;i++) //大床房房间信息初始化{newRoom = ( Room*)malloc(sizeof(Room));roomList[i]= newRoom;roomList[i]—〉checked=0;roomList[i]—>price=180;roomList[i]—〉roomNum=i+1;roomList[i]->roomType=Big;}}//通过所选择的房型获取空房间,获取房间后将房间信息改为已入住,并减少相应房型的剩余房间数Room* getRoomByType(int roomType){int i;switch(roomType){case Single:for(i=0;i<20;i++){if( roomList[i]->checked == 0){roomList[i]->checked=1;hotelInfo-〉singleRemainAmount -- ;hotelInfo—〉checkinAmount++;return roomList[i];}}break;case Double:for(i=20;i<60;i++){if(roomList[i]-〉checked == 0){roomList[i]—>checked=1;hotelInfo—>doubleRemainAmount —— ;hotelInfo-〉checkinAmount++;return roomList[i];}}break;case Big:for(i=60;i<100;i++){if( roomList[i]->checked == 0){roomList[i]—〉checked=1;hotelInfo—〉bigRemainAmount -—;hotelInfo—>checkinAmount++;return roomList[i];}}break;}}//将订单放入订单列表void insertToOrderList(Order * order){int i;for( i = 0;i<100;i++){if( orderList[i]==NULL ){orderList[i]= order;break;}}}//通过房号查询订单Order*getOrderByRoomNum(int roomNum){int i;for(i=0;i〈100;i++){if( orderList[i]—>room-〉roomNum == roomNum){return orderList[i];}}}void showMainUI(){//显示主界面,并接受输入int chooseNum;system("cls");printf(”\n\n==========================酒店房间登记与计费管理管理系统=======================\t\n\n\n");printf(”*\t\t\t\t1. 入住登记\t\t\t\t*\n");printf("*\t\t\t\t2。
#include<iostream>#include<string>#include<fstream>using namespace std;/*问题描述:该系统能简单实现对客栈的住宿情况进行管理。
至少包括以下信息:房号、房型、单价(每床)、已住人数;住客姓名、性别、年龄、身份、身份证号码,房号,床号,入住日期、入住时间、离店日期、离店时间。
这些信息应存放在两个文件中,分别是客房信息文件、住客信息文件。
"房型"可取值1-3,分别表示单人间、双人间、通铺(可以住很多人的房间)功能要求:1.具有建立数据文件(客房信息文件、住客信息文件)功能;2.具有数据输入功能;3.具有数据修改功能;4.具有数据删除功能;5.能查询(查找)一些基本信息(如按房号查询、按姓名查询、空余客房查询等);6.具有多种统计功能(要求有一定的实用性)(如某客房当前有那些空床、某住客应付多少费用、某天住店总人数和总收入等)说明:(1)功能各方面越完善越好(2)自定义的数据结构可以使用数组,链表,树等,可以使用多种数据结构来存放数据,然后在其上使用不同的排序算法。
(3)若用数组,必须动态分配空间(文本文件中最好有一行来表示数组应该有多大,这样便于动态分配空间)*///*************************************************类定义class Customer //住客信息类{public:string name; //姓名string id; //身份证号string sex;//性别int age; //年龄int roomnum; //入住房号string ruzhum; //入住日期string ruzhut;//入住时间string lidianm;//离店日期string lidiant;//离店时间int staytime; //入住天数Customer(){name="无";id="0";sex="0";age= -1;roomnum=0;ruzhum="0";ruzhut="0";lidianm="0";lidiant="0";staytime=0;};~Customer(){};};class Room //客房类{public:int num;//房号int price; //价格string type; //类型int renshu; //入住人数int yajin; //客房押金Room(){num=0;price=0;type=50;renshu=0;yajin=0;};~Room(){};};//******************************************************************** ******************客房信息录入功能void room_luru(Room *room);void room_luru2(Room *room);void room_luru(Room *room)//无房,添房函数{if(room[0].num==0){int size;static int Number=300;cout<<"目前暂无房间信息,请添加!"<<endl<<endl;cout<<"请输入要添加的房间数:";cin>>size;for(int i=0;i<size;i++){room[i].num=Number++;cout<<"房间号码:"<<room[i].num;cout<<endl;cout<<"房间类型:";cin>>room[i].type;cout<<"房间价格:";cin>>room[i].price;cout<<endl<<endl;};cout<<"客房信息录入成功!"<<endl<<endl;}else{string P;cout<<"客房信息已有,是否还要添加房间?(Y/N)";cin>>P;if(P=="Y")room_luru2(room);else if(P=="N")cout<<"已取消房间添加."<<endl<<endl;else cout<<"此操作非法!"<<endl<<endl;};system("pause");system("cls");};//******************************************************************** ********void room_luru2(Room *room)//有房,添加房间函数{static int Number=300;string P;do{// int Number=300;for(int i=0;i<30;i++){if(room[i].num==0){room[i].num=Number++;cout<<"房间号码:"<<room[i].num;cout<<endl;cout<<"房间类型:";cin>>room[i].type;cout<<endl;cout<<"房间价格:";cin>>room[i].price;cout<<endl<<endl;cout<<"房间添加成功,是否继续添加?(Y/N):";cin>>P;break;}else Number++;};}while(P=="Y");if(P=="N")cout<<"已取消添加。
酒店管理系统的设计与实现(正文+部分源代码)目录摘要........................................................ I II Abstract ...................................................... I V 引言. (1)第一章绪论 (2)1.1 系统开发背景 (2)1.2 课题研究目的及意义 (2)1.3 国内外现状及发展动态 (3)1.4 系统开发工具及相关技术 (4)1.4.1 系统开发工具 (4)1.4.2 数据库开发工具 (4)1.4.3 C#开发语言介绍 (5)第二章系统分析 (8)2.1 需求分析 (8)2.1.1 系统的主要功能 (8)2.1.2 系统的实现目标 (8)2.1.3 系统的性能需求 (9)2.1.4 运行环境 (10)2.2 可行性分析 (11)2.3 数据需求分析 (12)2.4 数据字典 (14)2.5 数据流图 (15)第三章系统设计 (16)3.1 系统功能结构设计 (16)3.2 数据库设计 (17)3.3 系统流程图 (20)第四章系统详细设计与实现 (22)4.1 用户登录 (22)4.3客房管理 (25)4.3.1客房信息修改 (25)4.3.2 入住管理 (29)4.3.3 退租管理 (33)4.3.4 客房类型管理 (35)4.4 员工管理 (38)4.5财务管理 (44)4.6 酒店初始化 (46)4.7用户密码更改 (48)第五章系统测试 (52)5.1测试的作用和意义 (52)5.2测试方法 (52)5.3系统测试 (53)结束语 (57)参考文献 (58)致谢 (59)附录 (60)摘要该软件采用应用开发技术,具有一些客房查询、入住、退房等功能,尤其依靠的优点来为酒店更好的进行管理,稳定性,可扩展性,安全性,健壮性,都是该酒店管理的优势所在。
目录引言 (1)1.1开发项目的目的 (1)2.项目开发计划 (2)2.1项目概述 (2)2.2实施计划 (2)2.3项目开发进程 (3)3.需求分析 (3)3.1系统需求和功能分析 (3)3.2数据字典 (4)4.模块设计 (7)4.1系统功能模块划分 (7)4.2系统功能模块图 (8)5.概念结构设计 (8)5.1概念结构E-R图 (8)6.逻辑设计 (10)6.1逻辑设计 (10)6.2设计优化 (12)6.3模块设计 (12)7.物理设计 (12)7.1建立索引 (12)7.2数据存放位置 (12)7.3系统配置 (12)8.数据库实施和维护 (13)8.1创建数据库 (13)8.2数据库备份和恢复 (15)9.应用程序的设计 (18)9.1登陆界面设计 (18)9.2开房界面设计 (19)9.3 退房界面设计 (19)9.4 换房界面设计 (20)9.5预订信息界面设计 (20)9.6预订入住界面设计 (21)10.测试报告 (21)10.1白盒测试 (21)10.2黑盒测试 (21)11总结体会 (27)1.引言酒店客房管理系统在正常运营中需要对客房资源、客人信息、结算信息等进行管理,利用酒店客房管理信息系统对客房的各个操作进行管理,能够及时了解各个环节中信息的变更,有利于提高管理的效率。
1.1开发项目的目的本项目要设计和实现一个能对酒店客房租住信息,客人信息,结算信息的管理,实现前台操作流程较方便,清晰,高效的信息管理系统1.2开发背景项目名称:酒店客房管理系统项目任务提出者:李代平老师项目开发者:巫凯平,吴师伟,刘礼浩,周挺项目用户:项目开发者,项目测试员,验收老师1.3开发环境计算机及操作系统:PC机,WindowsXP;开发工具:VC++运行环境: 装有SQL SERVER 2000 的系统语言: VC++ 与 SQL查询语言1.4参考资料[1].求是科技.Visual C++数据库通用模块及典型系统开发实例导航.—北京:人民邮电出版社,2006.3[2].李代平.软件工程.第二版.北京:冶金工业出版社,2006.11[3].王珊/萨师煊.数据库系统概论.第四版.-北京:高等教育出版社,2006.5[4].郑阿奇.Visual C++教程-北京:机械工业出版社,2004.91.5可行性分析目前酒店客房管理系统在宾馆中已普遍使用,使用该项目的开发研究有很好发展前景。
create database hotelmanager /*创建数据库hotelmanager*/ gouse hotelmanagergocreate table cusinfo /*创建数据表cusinfo*/ (dingname varchar(10) not null,cname varchar(10),cid char(18),vip char(2))gocreate table ordform /*创建数据表ordform*/(ono varchar(36) not null,cname varchar(10) not null,csex char(2),cid char(18),rid char(6) not null,rstyle varchar(10),arrivetime datetime,cno char(10) not null,dingname varchar(10),livetime char(10),dingph char(15) not null,ozt char(4))gocreate table roominfo /*创建数据表roominfo*/(rid char(6) not null,rstyle varchar(10),kfzt char(2) not null)gocreate table liveorder /*创建数据表liveorder*/(lno varchar(36) not null,rid char(6) not null,rstyle varchar(10),btime datetime not null,cno char(10),cname varchar(10) not null,etime datetime,ono varchar(36),lzt char(4) )gocreate table bill /*创建数据表bill*/(bno varchar(36) not null,rid char(6) not null,cname varchar(10),cust money,btime datetime,etime datetime,remarks varchar(40))gocreate table roomsp /*创建数据表roomsp*/(rstyle varchar(10) not null,rprice money)gocreate table hordform /*创建数据表hordform*/(ono varchar(36) not null,cname varchar(10) not null,csex char(2),cid char(18),rid char(6) not null,rstyle varchar(10),arrivetime datetime,cno char(10) not null,dingname varchar(10),livetime char(10),dingph char(15) not null,ozt char(4))gocreate table hliveorder /*创建数据表hliveorder*/(lno varchar(36) not null,rid char(6) not null,rstyle varchar(10),btime datetime not null,cno char(10),cname varchar(10) not null,etime datetime,ono varchar(36),lzt char(4) )goinsert into cusinfo values('mao','zcl','330227************','n') insert into cusinfo values('qxb','zyy','330227************','n') goinsert into roominfo values('2010','s','n')insert into roominfo values('2201','s','n')insert into roominfo values('2301','s','n')insert into roominfo values('3010','s','y')insert into roominfo values('3012','s','n')insert into roominfo values('3015','s','n')insert into roominfo values('4210','d','n')insert into roominfo values('4110','d','n')insert into roominfo values('4010','d','n')insert into roominfo values('5220','d','n')insert into roominfo values('5210','d','n')insert into roominfo values('5201','d','n')goinsert into roomsp values('s',200)insert into roomsp values('d',300)goinsert into ordform values('o0201001','zcl','f','330227************','2301','s','2010-01-02','1','mao','1','883060089','n')goinsert into liveorder values('l2010001','2301','s','2010-01-02','1','zcl','2010-01-03','o0201001','n') insert into liveorder values('l2010002','3010','s','2010-01-03','1','qxb','2010-01-04','o0201002','y') insert into liveorder(lno,rid,rstyle,btime,cno,cname,ono,lzt)values('l2010003','5220','d','2010-01-09','1','myy','o0201003','y')insert into liveorder(lno,rid,rstyle,btime,cno,cname,ono,lzt)values('l2010004','5201','d','2010-01-02','2','zxx',null,'y')goinsert into bill(bno,rid,cname,cust,btime) values('b2010003','5220','myy',0,'2010-01-10')insert into bill(bno,rid,cname,cust,btime) values('b2010004','5201','zxx',0,'2010-01-02')goalter table cusinfo add primary key(dingname)alter table ordform add primary key(ono)alter table roominfo add primary key(rid)alter table liveorder add primary key(lno)alter table bill add primary key(bno)alter table roomsp add primary key(rstyle)gocreate proc ordformproc @lno varchar(36) /*保存入住单*/asbegin tranupdate roominfo set kfzt='y' from roominfo,liveorder where liveorder.rid=roominfo.rid and liveorder.lno=@lno /*修改客房信息*/update ordform set ozt='y' from ordform,liveorder where liveorder.ono=ordform.ono and liveorder.lno=@lno /*修改预订单信息*/insert into hordform select * from ordform where ozt='y' /*将已入住的预订单放入历史*/ delete from ordform where ozt='y' /*清除已入住预订单*/commitgoselect * from roominfoselect * from ordformgoexec ordformproc 'l2010001'exec ordformproc 'l2010004'select * from roominfoselect * from ordformgocreate proc liveorderproc @lno varchar(36) /*收银退房*/asbegin tranupdate liveorder set etime=getdate(),lzt='n' where lno=@lnoupdate roominfo set kfzt='n' from roominfo,liveorder where roominfo.rid=liveorder.rid and liveorder.lno=@lno /*修改客房状态*/insert into hliveorder select * from liveorder where lno=@lno /*导入历史*/delete from liveorder where lno=@lno /*清除入住单*/commitgoselect * from liveorderselect * from hliveordergoexec liveorderproc 'l2010004'goselect * from liveorderselect * from hliveorderselect *from roominfo where rid='5201'gocreate proc billproc @lno varchar(36) /*计算应收款*/asbegin trandeclare @total moneydeclare @datecount intupdate liveorder set etime=getdate() where lno=@lno /*设置离店时间*/select @datecount=datediff(dd,btime,getdate()) from liveorder where lno=@lno /*计算住店天数*/ select @total=0select @total=@datecount*(isnull(rprice,0)) from liveorder,bill,roomspwhere bill.rid=liveorder.rid and liveorder.rstyle=roomsp.rstyle and lno=@lno /*计算住店金额*/ update bill set etime=getdate(),cust=@total from bill,liveorder where bill.rid=liveorder.rid and lno=@lno /*修改账单*/commitgoselect * from liveorderselect * from billgoexec billproc 'l2010004'goselect * from liveorderselect * from bill。
//入住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语言程序设计客房管理系统源码和报告公司内部编号:(GOOD-TMMT-MMUT-UUPTY-UUYY-DTTI-《C语言程序设计》综合实验报告一、需求分析编写一个客房管理系统,提供键盘式菜单实现功能选择,功能包括:用户登记、统计、查询和用户信息修改。
软件平台:CODEBLOCKS二、整体设计整个客房管理系统被设计为用户登记模块、统计模块、查询模块和修改模块。
数据以TXT格式存储,支持保存信息。
三、详细设计(1通过函数添加信息到txt。
是(2)统计模块读取txt信息到结构体数组room,提示用户选择统计方式,设置计数器,顺序遍历Room数组,1、计数器记录数组数,即总客房数2、判断每一个数组中的结构体的时间是否和需要查询的日期相同,若相同,计数器加一(3)查询模块调用readfile 函数,将信息读入room结构体数组中,提示用户选择查询方式,通过基本查找算法查找Room 数组。
可以按房间号、价格、房间标记、用户姓名、居民身份证查询。
(4)修改模块调用readfile 函数,读取信息到room 结构体数组,提示用户输入需要修改的房间号,采用基本查找算法在数组中找到要修改的数据,提示用户重新更改房间信息,最后将结构体数组重新写入文件保存。
四、源代码#include <stdio.h>#include <stdlib.h>#include <string.h>选择统计方式 2、按时间统计 1、统计总客房数 遍历每一个结构判断是否和要调用打印函数,是 遍历每一个结构调用readfile (读取文件函判断是否是用户输入需要查询的房修改结构体j 调用saveall 函调用readfile 函数,读读取信息#define M 80//客户结构体typedef struct client{char name[12]; //姓名int sex; //性别int age; //年龄char id[20]; //身份证号int year; //入住时间int month;int date;}CLIENT;//客房结构体struct Hotel{int roomid;int tel; //用户的话int price; //价格int sign; //默认标记为空房间 CLIENT client_list; //客户信息}room[M];void Menu(); //目录界面void dengji(struct Hotel room[]);void savefile(struct Hotel room[],int i);int readfile(struct Hotel room[]);void tongji(struct Hotel room[]);void chaxun(struct Hotel room[]);void printmessage(struct Hotel room[],int n); void xiugai(struct Hotel room[]);//主函数int main(){int n;char reply;Menu();do{printf("请输入选项对应的数字:\n");scanf("%d",&n);while(n!=1&&n!=2&&n!=3&&n!=4){printf("请输入各选项对应的数字!\n"); scanf("%d",&n);}switch (n){case 1:dengji(room);break;case 2:tongji(room);break;case 3:chaxun(room);break;case 4:xiugai(room);break;}printf("是否还要进入其它选项(回复Y或y继续)\n"); scanf(" %c",&reply);}while (reply=='y'||reply=='Y');return 0;}//系统目录void Menu(){printf("************************客房管理系统***************************\n");printf( "\t\t\t 1————登记\n" );printf( "\t\t\t 2————统计\n" );printf( "\t\t\t 3————查询\n" );printf( "\t\t\t 4————修改\n" );printf("******************************************************* ********\n");}//登记客户信息void dengji(struct Hotel room[]){int x,j,i,flag;char answer;do{i=readfile(room);do{flag=0;printf("输入您想入住的房间号:(三位数)\n"); scanf("%3d",&x);for(j=0;j<i;j++){if(room[j].roomid==x){printf("该房间已经被占用!\n");flag=1;}}}while(flag>0);room[i+1].roomid=x;printf("请输入您的电话:(仅支持六位数号码~)\n"); scanf("%d",&room[i+1].tel);printf("入住价格\n");scanf("%d",&room[i+1].price);printf("请输入您的名字\n");scanf("%s",room[i+1].client_);printf("性别:(1表示女,0表示男)\n");scanf("%d",&room[i+1].client_list.sex);printf("您的年龄:\n");scanf("%d",&room[i+1].client_list.age);printf("您的id:\n");scanf("%s",room[i+1].client_list.id);printf( "请输入入住年月日(格式:2015 11 11)\n");scanf("%4d%2d%2d",&room[i+1].client_list.year,&room[i+1].client _list.month,&room[i+1].client_list.date);savefile(room,i+1);printf("是否还要继续登记(回复Y或y继续)\n");scanf(" %c",&answer);}while(answer=='Y'||answer=='y');}//读取txt中的信息int readfile(struct Hotel room[]){FILE *fp;int i;if((fp=fopen("room.txt","r"))==NULL){printf("Failure to open score.txt!\n");exit(0);}for (i=0;!feof(fp);i++){fscanf(fp,"%5d",&room[i].roomid);fscanf(fp,"%6d",&room[i].price);fscanf(fp,"%15d",&room[i].tel);fscanf(fp,"%12s",room[i].client_); fscanf(fp,"%4d",&room[i].client_list.sex); fscanf(fp,"%6d",&room[i].client_list.age); fscanf(fp,"%20s",room[i].client_list.id);fscanf(fp,"%7d",&room[i].client_list.year); fscanf(fp,"%5d",&room[i].client_list.month); fscanf(fp,"%5d",&room[i].client_list.date); }fclose(fp);return i;}//保存结构体数组信息到文件void savefile(struct Hotel room[],int i){FILE *fp;if((fp = fopen("room.txt","a"))==NULL){printf("Failure to open score.txt!\n");exit(0);}fprintf(fp,"%5d%6d%15d%12s%4d%6d%20s%7d%5d%5d",room[i].roomid,room[i].price,room[i].tel,room[i].client_,room[i].client_list.sex,room[i].client_list.age,room[i].client_list.id,room[i].client_list.year,room[i].client_list.month,room[i].client_list.date);fclose(fp);}//统计模块void tongji(struct Hotel room[]){int n,x;int year,month,day,j,count=0;x=readfile(room);printf("请选择统计方式:1>统计房客数,2>统计某一天的房客数\n");scanf("%d",&n);switch (n){case 1:printf("客房总数为:%d\n",x);break;case 2:printf("请输入具体时间:\n");scanf("%d%d%d",&year,&month,&day);for(j=0;j<x;j++){if(room[j].client_list.year==year&&room[j].client_list.month==m onth&&room[j].client_list.date==day){count++;}}printf("%d年%d月%d号的房客数为%d",year,month,day,count);}}//查询模块void chaxun(struct Hotel room[]){int n,x,roomid,price,j;char name[12],id[20];x=readfile(room);printf("按房间号查询请按1;按价格查询请按2;按用户姓名查询请按3;按身份证号码查询请按4\n");scanf("%d",&n);switch(n){case 1:printf("请输入房间号:\n");scanf("%d",&roomid);for(j=0;j<x;j++){if(room[j].roomid==roomid){print(room,j);}}break;case 2:printf("请输入价格:\n");scanf("%d",&price);for(j=0;j<x;j++){if(room[j].price==price){print(room,j);}}break;case 3:printf("请输入客户姓名:\n");scanf("%s",name);for(j=0;j<x;j++){if(strcmp(room[j].client_,name)==0) {print(room,j);}}break;case 4:printf("请输入身份证号码:\n");scanf("%s",id);for(j=0;j<x;j++){if(strcmp(room[j].client_list.id,id)==0) {print(room,j);}}}}//打印void print(struct Hotel room[],int j){printf("%5d%6d%15d%12s%4d%6d%20s%7d%5d%5d\n",room[j].roomid,room[j].price,room[j].tel,room[j].client_,room[j].client_list.sex,room[j].client_list.age,room[j].client_list.id,room[j].client_list.year,room[j].client_list.month,room[j].client_list.date);}void printmessage(struct Hotel room[],int n){int j;for(j=0;j<n;j++){printf("%5d%6d%15d%12s%4d%6d%20s%7d%5d%5d\n", room[j].roomid,room[j].price,room[j].tel,room[j].client_,room[j].client_list.sex,room[j].client_list.age,room[j].client_list.id,room[j].client_list.year,room[j].client_list.month,room[j].client_list.date);}}//修改模块void xiugai(struct Hotel room[]){int i, m, roomid;m = readfile(room);printf("请选择房间号:\n");scanf("%d",&roomid);for(i=0;i<m;i++){if(room[i].roomid==roomid){printf("请输入您的电话:\n");scanf("%d",&room[i].tel);printf("入住价格\n");scanf("%d",&room[i].price);printf("请输入您的名字\n");scanf("%s",room[i].client_);printf("性别:\n");scanf("%d",&room[i].client_list.sex);printf("您的年龄:\n");scanf("%d",&room[i].client_list.age);printf("您的id:\n");scanf("%s",room[i].client_list.id);scanf("%4d%2d%2d",&room[i].client_list.year,&room[i].client_lis t.month,&room[i].client_list.date);}}saveall(room,m);}//保存所有信息到txt文件void saveall(struct Hotel room[],int m){int j;FILE *fp;if((fp = fopen("room.txt","w"))==NULL){printf("Failure to open score.txt!\n");exit(0);}for(j=0;j<m;j++){fprintf(fp,"%5d%6d%15d%12s%4d%6d%20s%7d%5d%5d",room[j].roomid,room[j].price,room[j].tel,room[j].client_,Room[j].client_list.sex,room[j].client_list.age,room[j].client_list.id,room[j].client_list.year,room[j].client_list.month,room[j].client_list.date);}fclose(fp);}五、调试与测试主界面:1、登记功能测试:情况1:客户需要入住的房间号被占用,提示已经被占用,重新选择情况2:选择的房间没有被占用,提示用户输入登记信息,登记完成后系统后台执行保存,弹出窗口询问是否继续登记下一个顾客2、统计功能测试:情况1:选择统计客房总数,系统返回总客房数情况2:选择按日期统计,系统返回具体某天的客房总数3、查询功能测试:情况1:按房间号查询情况2:按价格查询情况3:按用户名查询情况4:按身份证号查询4、修改功能测试:输入需要修改的房间后,系统提示用户重新写入房间信息六、总结本程序可通过键盘选择目录对应的功能,提供登记、查询、统计、修改四大功能。
酒店预订系统代码简介本文档描述了一个简单的酒店预订系统的代码实现。
该系统允许用户查询酒店的房间信息并进行预订。
功能1. 查询房间信息用户可以通过输入日期、地点和其他条件来查询可预订的酒店房间信息。
2. 预订房间用户可以选择一个可用的房间并进行预订。
预订时需要提供用户的个人信息和支付方式。
3. 取消预订用户可以取消已经预订的房间。
取消预订时需要提供预订的唯一标识。
数据模型房间(Room)每个房间有以下属性:- 房间号(room_number)- 房间类型(room_type)- 房间价格(price)- 可预订日期列表(available_dates)预订(Reservation)每个预订有以下属性:- 预订唯一标识(reservation_id)- 用户姓名(user_name)- 预订日期(reservation_date)- 房间号(room_number)- 付款方式(payment_method)代码结构hotel_reservation_system├── main.py├── models.py└── utils.py- `main.py`:系统的入口,包含了用户界面和主要的业务逻辑。
- `models.py`:定义了房间和预订的数据模型。
- `utils.py`:包含了一些实用函数,如日期处理和支付验证。
技术栈后端- 语言:Python- 框架:Flask- 数据库:SQLite前端- CSS- JavaScript部署该系统可以部署在本地或云服务器上,具体步骤如下:1. 安装Python和Flask。
2. 创建数据库并导入初始数据。
3. 运行`main.py`启动服务器。
4. 在浏览器中打开系统的网址。
总结本文档介绍了一个简单的酒店预订系统的代码实现。
该系统具备房间查询、预订和取消预订的功能,并使用了Python和Flask框架进行开发。
部署该系统需要安装相关依赖并运行服务器。
如有需要,可根据实际情况进行定制和扩展。
//入住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。
酒店管理系统源代码#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;}}}。