酒店管理系统代码c语言版

合集下载

酒店管理系统代码(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]。

酒店管理系统c语言程序设计

酒店管理系统c语言程序设计

酒店管理系统c语言程序设计以下是一个简单的酒店管理系统的 C 语言程序设计示例,包括了客户入住、退房和查询房间状态等基本功能。

请注意,这只是一个简化的示例,实际的酒店管理系统可能需要更多的功能和复杂的逻辑。

```c#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX_ROOMS 100#define MAX_CUSTOMERS 100// 房间结构体struct Room {int roomNumber;int isOccupied;int customerID;};// 客户结构体struct Customer {int customerID;char customerName[50];};// 房间列表struct Room rooms[MAX_ROOMS];// 客户列表struct Customer customers[MAX_CUSTOMERS];// 初始化房间列表void initRooms() {for (int i = 0; i < MAX_ROOMS; i++) {rooms[i].roomNumber = i + 1;rooms[i].isOccupied = 0;rooms[i].customerID = 0;}}// 初始化客户列表void initCustomers() {for (int i = 0; i < MAX_CUSTOMERS; i++) {customers[i].customerID = i + 1;strcpy(customers[i].customerName, "Customer");}}// 查找空闲房间int findFreeRoom() {for (int i = 0; i < MAX_ROOMS; i++) {if (rooms[i].isOccupied == 0) {return i;}}return -1;}// 客户入住void checkIn(int customerID, int roomNumber) {int freeRoom = findFreeRoom();if (freeRoom != -1) {rooms[freeRoom].isOccupied = 1;rooms[freeRoom].customerID = customerID;printf("Customer %d checked in to Room %d\n", customerID, roomNumber); } else {printf("No free rooms available\n");}}// 客户退房void checkOut(int roomNumber) {for (int i = 0; i < MAX_ROOMS; i++) {if (rooms[i].roomNumber == roomNumber && rooms[i].isOccupied == 1) { rooms[i].isOccupied = 0;rooms[i].customerID = 0;printf("Customer checked out of Room %d\n", roomNumber);return;}}printf("Room not found\n");}// 查询房间状态void viewRoomStatus(int roomNumber) {for (int i = 0; i < MAX_ROOMS; i++) {if (rooms[i].roomNumber == roomNumber) {if (rooms[i].isOccupied == 1) {printf("Room %d is occupied by Customer %d\n", roomNumber, rooms[i].customerID);} else {printf("Room %d is vacant\n", roomNumber);}return;}}printf("Room not found\n");}// 主函数int main() {initRooms();initCustomers();int choice;while (1) {printf("1. Check In\n2. Check Out\n3. View Room Status\n4. Exit\n"); scanf("%d", &choice);switch (choice) {case 1:int customerID, roomNumber;printf("Enter customer ID: ");scanf("%d", &customerID);printf("Enter room number: ");scanf("%d", &roomNumber);checkIn(customerID, roomNumber);break;case 2:printf("Enter room number: ");scanf("%d", &roomNumber);checkOut(roomNumber);break;case 3:printf("Enter room number: ");scanf("%d", &roomNumber);viewRoomStatus(roomNumber);break;case 4:exit(0);break;default:printf("Invalid choice\n");}}return 0;}```上述代码实现了一个简单的酒店管理系统,包括客户入住、退房和查询房间状态等功能。

(完整版)C语言酒店管理系统

(完整版)C语言酒店管理系统
}
for(y=0;y<5;y++)
{
if(room[x][y]==0)
{
printf("空%d-%d |",x+1,y+1);
}else
{
printf("住%d-%d |",x+1,y+1);
}
if(y+1==5)
{
if(x+1==1||x+1==2)
printf("该层标间均50元");
else
printf("该层标间均100元");
printf("\t2.查询房间的入住情况\n");
printf("\t3.查询当前费用\n");
printf("\t4.结账退房\n");
printf("\t5.退出程序\n");
}
void hotel_execute();
void hotel_select();
void hotel_outhotel();
{
printf("|-------|--------|--------|--------|--------|--------|\n|第%d层|",x+|-------|--------|--------|--------|--------|--------|\n|第%d层|",x+1);
}
}
}
printf("\n|-------|--------|--------|--------|--------|--------|\n");

酒店管理系统C语言版

酒店管理系统C语言版

#i n c l u d e<s t d i o.h>#include<stdlib.h>struct peopledata{char name[11];char sex[3];int age;int idcard[2];};struct datefflush(stdin);printf("房间类型:");scanf("%c",&room.kind);printf("住宿人员信息:\n");printf("\t\t姓名:");fflush(stdin);scanf("%s",);fflush(stdin);printf("\t\t性别:");gets(room.people.sex);printf("\t\t年龄:");scanf("%d",&room.people.age);printf("\t\t请输入身份证号码:");for(i=0;i<2;i++)scanf("%d",&room.people.idcard[i]); printf("入住时间:\n");printf("\t\t年:");scanf("%d",&room.time.year);printf("\t\t月:");scanf("%d",&room.time.month);printf("\t\t日:");scanf("%c",&tag);fflush(stdin);}else{printf("要继续添加吗?(y/n)\n");scanf("%c",&tag);fflush(stdin);}}fclose(fp);} while(tag=='y');}void updata(){FILE *fp;rooms room;int number,i;printf("请输入要更新的信息的房间编号:\n");scanf("%d",&number);printf("\t\t姓名\t性别\t年龄");printf("\t\t%s\t%s\t%d\n",,room.people.sex,room.people.age);printf("身份证号:");for(i=0;i<2;i++)printf("%d",room.people.idcard[i]);putchar('\n');printf("入住时间:\n");printf("%d年%d月%d日\n",room.time.year,room.time.month,room.time.day);printf("入住时长:\n");printf("%d天\n",room.time.time);printf("\t————————————————\n");printf("*******************************************************\n");printf("请输入更新信息:\n");printf("房间编号:");scanf("%d",&room.number);fflush(stdin);printf("房间类型:");scanf("%c",&room.kind);printf("住宿人员信息:\n");printf("\t\t姓名:");fflush(stdin);void searchdata(){FILE *fp;rooms room;int number,i;printf("请输入要查询的信息的房间编号:\n");scanf("%d",&number);if((fp=fopen("d:\\酒店住宿登记表.txt","r+"))==NULL){printf("打开文件”酒店住宿登记表“失败,按任意键退出。

酒店管理系统代码

酒店管理系统代码

附录Base.Dlg.cpp程序:#include "stdafx.h"#include "MyPos.h"#include "BaseDlg.h"#include "MaterielDlg.h"#include "ClassDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CBaseDlg dialogCBaseDlg::CBaseDlg(CWnd* pParent /*=NULL*/): CDialog(CBaseDlg::IDD, pParent){//{{AFX_DATA_INIT(CBaseDlg)// NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT}void CBaseDlg::DoDataExchange(CDataExchange* pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CBaseDlg)DDX_Control(pDX, IDC_TAB_BASE, m_oTabBase);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CBaseDlg, CDialog)//{{AFX_MSG_MAP(CBaseDlg)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CBaseDlg message handlersBOOL CBaseDlg::OnInitDialog(){CDialog::OnInitDialog();// TODO: Add extra initialization herem_oTabBase.AddPage("商品类别", &m_oClassdlg, IDD_DIALOG_CLASS);m_oTabBase.AddPage("商品资料", &m_oMaterieldlg, IDD_DIALOG_MA TERIEL);m_oTabBase.AddPage("付款方式", &m_oPaymodedlg, IDD_DIALOG_PAYMODE);m_oTabBase.Show();return TRUE; // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE}CallDlg.cpp程序:#include "stdafx.h"#include "MyPos.h"#include "CallDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CCallDlg dialogextern CMyPosApp theApp;CCallDlg::CCallDlg(CWnd* pParent /*=NULL*/): CDialog(CCallDlg::IDD, pParent){//{{AFX_DATA_INIT(CCallDlg)// NOTE: the ClassWizard will add member initialization here//}}AFX_DATA_INIT}void CCallDlg::DoDataExchange(CDataExchange* pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CCallDlg)DDX_Control(pDX, IDC_STATIC_CALL, m_oCallstatic);DDX_Control(pDX, IDC_EDIT_CALLBILLID, m_oCallbillid);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CCallDlg, CDialog)//{{AFX_MSG_MAP(CCallDlg)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CCallDlg message handlersvoid CCallDlg::OnOK(){if(dowhat=="imhappy"){theApp.scallid="";m_oCallbillid.GetWindowText(theApp.scallid);}if(dowhat=="pleased")m_oCallbillid.GetWindowText(dowhat);CDialog::OnOK();}BOOL CCallDlg::OnInitDialog(){CDialog::OnInitDialog();if(dowhat=="pleased")m_oCallstatic.SetWindowText("请输入桌号:");return TRUE; // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE }CheckDlg.cpp程序:#include "stdafx.h"#include "MyPos.h"#include "CheckDlg.h"#include "PosDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CCheckDlg dialogextern CMyPosApp theApp;CCheckDlg::CCheckDlg(CWnd* pParent /*=NULL*/): CDialog(CCheckDlg::IDD, pParent){//{{AFX_DATA_INIT(CCheckDlg)//}}AFX_DATA_INIT}void CCheckDlg::DoDataExchange(CDataExchange* pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CCheckDlg)DDX_Control(pDX, IDC_EDIT_CONSUME, m_oConsume);DDX_Control(pDX, IDC_EDIT_CDISCOUNT, m_oCdiscount);DDX_Control(pDX, IDC_EDIT_RECEIVE, m_oReceive);DDX_Control(pDX, IDC_EDIT_CHANGE, m_oChange);DDX_Control(pDX, IDC_EDIT_TOTALM, m_oTotalm);DDX_Control(pDX, IDC_COMBO_PAYMODE, m_oCombopay);DDX_Control(pDX, IDC_LIST_CHECKLIST, m_oChecklist);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CCheckDlg, CDialog)//{{AFX_MSG_MAP(CCheckDlg)ON_BN_CLICKED(IDC_BUTTON_CHECKOK, OnButtonCheckok)ON_EN_CHANGE(IDC_EDIT_RECEIVE, OnChangeEditReceive)ON_NOTIFY(NM_CLICK, IDC_LIST_CHECKLIST, OnClickListChecklist) ON_EN_CHANGE(IDC_EDIT_CDISCOUNT, OnChangeEditCdiscount)ON_BN_CLICKED(IDC_BUTTON_RF, OnButtonRf)ON_BN_CLICKED(IDC_BUTTON_HANG, OnButtonHang)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CCheckDlg message handlersBOOL CCheckDlg::OnInitDialog(){CDialog::OnInitDialog();//设置list控件的文字和背景颜色m_oChecklist.SetBkColor(RGB(255,255,255));m_oChecklist.SetTextBkColor(RGB(161,223,212));//清空list控件的数据for(int delcolumn=100;delcolumn>=0;delcolumn--)m_oChecklist.DeleteColumn(delcolumn);//设置list对话框的列DWORD dwStyle;RECT rect;LV_COLUMN lvc;dwStyle = m_oChecklist.GetStyle();dwStyle |= LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT|LVS_SHOWSELALWAYS ;m_oChecklist.SetExtendedStyle(dwStyle);m_oChecklist.GetClientRect(&rect);lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH |LVCF_FMT;lvc.fmt=LVCFMT_LEFT;lvc.iSubItem = 0;lvc.pszText = _T("商品类别");lvc.cx = 110;m_oChecklist.InsertColumn(1,&lvc);lvc.iSubItem = 1;lvc.pszText = _T("消费金额");lvc.cx = 90;m_oChecklist.InsertColumn(2,&lvc);lvc.iSubItem = 2;lvc.pszText = _T("可折扣金额");lvc.cx = 90;m_oChecklist.InsertColumn(3,&lvc);lvc.iSubItem = 3;lvc.pszText = _T("折扣%");lvc.cx = 60;m_oChecklist.InsertColumn(4,&lvc);lvc.iSubItem = 4;lvc.pszText = _T("结帐金额");lvc.cx = 90;m_oChecklist.InsertColumn(5,&lvc);//Add paymode to combobox._RecordsetPtr m_pRecordset;CString sql="select * from PAYMODE";try{m_pRecordset.CreateInstance("ADODB.Recordset");m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),a dOpenStatic,adLockOptimistic,adCmdText);while(!m_pRecordset->adoEOF){m_oCombopay.AddString((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("NAME"));m_pRecordset->MoveNext();}m_pRecordset->Close();m_oCombopay.SetCurSel(0);//Select the 1st string of combobox.}catch(_com_error e)///捕捉异常{CString temp;temp.Format("[结帐]读取付款方式到组合框出错:%s",e.ErrorMessage());AfxMessageBox(temp);}//Read class consume to list.ReadtoList(theApp.scallid);//Sum bill Items money from database.CString stotal;float ftotal=0;sql="Select SUM(ITEMTOTAL) as SSS from SALEDETAIL where BILLID='"+theApp.scallid+"'";try{m_pRecordset.CreateInstance("ADODB.Recordset");m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),a dOpenStatic,adLockOptimistic,adCmdText);_variant_t vtemp = m_pRecordset->GetCollect("SSS");if(vtemp.dblVal>0)ftotal=(float)m_pRecordset->GetCollect("SSS");elseftotal=0;stotal.Format("%.2f",ftotal);m_oTotalm.SetWindowText(stotal);m_oConsume.SetWindowText(stotal);}catch(_com_error e)///捕捉异常{CString temp;temp.Format("[结帐]计算单据商品金额出错:%s",e.ErrorMessage());AfxMessageBox(temp);}return TRUE; // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE}void CCheckDlg::OnButtonCheckok(){CString stotal,sbilltotal,spayID,sql,spaymode,snowtime;long lpayID;_RecordsetPtr m_pRecordset;m_oConsume.GetWindowText(stotal);m_oTotalm.GetWindowText(sbilltotal);int nselect=m_oCombopay.GetCurSel();m_oCombopay.GetLBText(nselect,spaymode);lpayID=GetPaymodeID(spaymode);spayID.Format("%d",lpayID);if(fchange<0)return;//得到系统时间CTime now=CTime::GetCurrentTime();snowtime=now.Format(_T("%Y-%m-%d %H:%M:%S"));sql="Update SALEBILL set ENDDATE='"+snowtime+"',SALES='"++"',TOTAL="+stotal+",ACTTOTAL="+sbilltotal+",STATUS='已结帐',PAYMODE="+spayID+" where ID='"+theApp.scallid+"'";try{_variant_t RecordsAffected;theApp.m_pConnection->Execute((_bstr_t)sql,&RecordsAffected,adCmdText);}catch(_com_error e)///捕捉异常{CString temp;temp.Format("[结帐]单据头更新数据库出错:%s",e.ErrorMessage());AfxMessageBox(temp);return;}//output the checkout time and paymode to the print.theApp.snowtimep=snowtime;theApp.spaymodep=spaymode;theApp.sconsume=stotal;theApp.sactsum=sbilltotal;//Insert data into PAYDETAIL.CString sclass,scontotal,sdiscount,sacttotal,svaltotal;int nItemCount=m_oChecklist.GetItemCount();//表项总数for(int i=0;i<nItemCount;i++){sclass=m_oChecklist.GetItemText(i,0);scontotal=m_oChecklist.GetItemText(i,1);sdiscount=m_oChecklist.GetItemText(i,3);sacttotal=m_oChecklist.GetItemText(i,4);float fvaltotal=atof(scontotal)-atof(sacttotal);svaltotal.Format("%.2f",fvaltotal);sql="Insert into PAYDETAIL(BILLID,CLASS,TOTAL,DISCOUNT,ACTTOTAL,VALTOTAL)values('"+theApp.scallid+"','"+sclass+"',"+scontotal+",'"+sdiscount+"',"+sacttotal+","+svaltotal+")";try{_variant_t RecordsAffected;theApp.m_pConnection->Execute((_bstr_t)sql,&RecordsAffected,adCmdText);}catch(_com_error e)///捕捉异常{CString temp;temp.Format("[结帐]付款明细(PAYDETAIL)插入数据出错:%s",e.ErrorMessage());AfxMessageBox(temp);return;}}//When the check button is click down,send a message(WM_CHECKOUT) to the CPosDlg.LRESULT Res=::SendMessage(theApp.pWnd, WM_CHECKOUT, 0, 0);CDialog::OnOK();}long CCheckDlg::GetPaymodeID(CString payname){long paymodeID;_RecordsetPtr m_pRecordset;CString sql="Select * from PAYMODE where NAME='"+payname+"'";try{m_pRecordset.CreateInstance("ADODB.Recordset");m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),a dOpenStatic,adLockOptimistic,adCmdText);paymodeID=(long)m_pRecordset->GetCollect("ID");}catch(_com_error e)///捕捉异常{CString temp;temp.Format("[结帐]获取付款方式ID出错:%s",e.ErrorMessage());AfxMessageBox(temp);}return paymodeID;}void CCheckDlg::OnChangeEditReceive(){// TODO: If this is a RICHEDIT control, the control will not// send this notification unless you override the CDialog::OnInitDialog()// function and call CRichEditCtrl().SetEventMask()// with the ENM_CHANGE flag ORed into the mask.CString sreceive,schange,stotal;m_oChange.SetWindowText("");m_oReceive.GetWindowText(sreceive);m_oTotalm.GetWindowText(stotal);fchange=atof(sreceive)-atof(stotal);if(fchange>=0){schange.Format("%.2f",fchange);m_oChange.SetWindowText(schange);}}void CCheckDlg::ReadtoList(CString sbillid){_RecordsetPtr m_pRecordset; //Must define it in functionCString sql,sclassname,sclassname1,sctotal;long lclassid;float fctotal=0;sql="Select Sum(ITEMTOTAL) as XXX,CLASSID from SALEDETAIL where BILLID='"+sbillid+"' group by CLASSID ";//删除所有list中的数据。

酒店管理系统代码

酒店管理系统代码

#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. 查询入住情况 \t\t\t*\n");printf("*\t\t\t\t3. 查询当前费用 \t\t\t*\n");printf("*\t\t\t\t4. 结账退房 \t\t\t\t*\n");printf("*\t\t\t\t5. 退出程序 \t\t\t\t*\n\n\n");printf("\n\n==========================酒店房间登记与计费管理管理系统=======================\t\n\n\n");printf("请输入相应编号进入菜单\t");//接受输入scanf("%d",&chooseNum);switch(chooseNum){case 1:GUI = HotelInfoUI;break;case 2:GUI = HotelInfoUI;break;case 3:GUI = OrderUI;break;case 4:GUI = OrderUI;break;case 5:Sleep(3000);GUI = Exit;break;default:break;}}void showHotelInfoUI(){int chooseNum;system("cls");printf("\n\n=========================酒店入住情况查询菜单=======================\t\n\n\n\n");printf("*\t\t\t入住房间数: %d\t\t\t\t*\n", hotelInfo->checkinAmount);printf("*\t\t\t剩余房间数: \t");printf("单人房:%d\t\t*\n",hotelInfo->singleRemainAmount);printf("*\t\t\t\t\t双人房:%d\t\t*\n",hotelInfo->doubleRemainAmount);printf("*\t\t\t\t\t大床房:%d\t\t*\n\n",hotelInfo->bigRemainAmount);printf("\n\n=========================酒店入住情况查询菜单=======================\t\n\n\n");printf("按 0 :返回 \n");printf("按 1 : 登记入住\n");scanf("%d",&chooseNum);switch(chooseNum){case 0:GUI = MainUI;break;case 1:GUI = CheckinUI;break;default:GUI = HotelInfoUI;break;}}void showCheckinUI(){Order * newOrder;Room* newRoom = NULL;//填写一个新的入住信息CheckinInfo * newCheckinInfo = NULL;int roomTypeNum;int countTypeNum;time_t timep;system("cls");printf("\n\n===========================酒店入住登记菜单=========================\t\n\n\n");newCheckinInfo = ( CheckinInfo * )malloc(sizeof(CheckinInfo));printf("*\t\t请输入姓名:");scanf("%s", &(newCheckinInfo->name) );printf("*\t\t请输入证件号:");scanf("%d", &(newCheckinInfo->id) );printf("*\t\t请选择入住房型:\n");printf("\t\t\t1.单人房\n\t\t\t2.双人房\n\t\t\t3.大床房\n");scanf("%d",&(roomTypeNum));switch(roomTypeNum) //通过输入的数字对应房型{case 1:newCheckinInfo->roomType = Single;break;case 2:newCheckinInfo->roomType = Double;break;case 3:newCheckinInfo->roomType = Big;break;default:newCheckinInfo->roomType = Single;break;}printf("*\t\t请选择计费方式:\n");printf("\t\t\t1.按小时计费; \n\t\t\t2.按天数计费\n"); //通过输入的数字对应计费方式scanf("%d",&countTypeNum);switch(countTypeNum){case 1:newCheckinInfo->countType = Hour;break;case 2:newCheckinInfo->countType = Day;break;}printf("\n\n===========================酒店入住登记菜单=========================\t\n\n\n");//生成一个新的订单newOrder = ( Order* )malloc(sizeof(Order));newOrder -> checkinInfo = newCheckinInfo;newOrder -> date = time(0);switch(newCheckinInfo->roomType) //通过房型获取房间{case Single:newRoom = getRoomByType(Single);break;case Double:newRoom=getRoomByType(Double);break;case Big :newRoom=getRoomByType(Big);break;}newOrder->room = newRoom;insertToOrderList(newOrder);printf("房间号为:%d\n",newOrder->room->roomNum);GUI = CheckinResultUI;}void showCheckinResultUI(){int chooseNum;printf("\n\n=========================酒店入住登记确认菜单=======================\t\n\n\n");printf("\t\t\t************\t\t\t\t\n");printf("\t\t\t* 登记成功 *\t\t\t\t\n");printf("\t\t\t************\t\t\t\t\n\n");printf("\n\n=========================酒店入住登记确认菜单=======================\t\n\n\n");printf("按 0 :返回 \n");scanf("%d",&chooseNum);switch(chooseNum){case 0:GUI = MainUI;break;default:GUI = CheckinResultUI;break;}}void showOrderUI(){int roomNum;int chooseNum;int amount;Order * theOrder = NULL;system("cls");printf("\n\n=========================酒店房间信息查询菜单=======================\t\n\n\n");printf("请输入房间号:");scanf("%d",&roomNum);if (roomNum<0 || roomNum>100){printf("\n 输入有误请重新输入") ;GUI = OrderUI;}else{theOrder = getOrderByRoomNum(roomNum);printf("房型:");switch(theOrder->room->roomType){case Single:printf("单人房\n");break;case Double:printf("双人房\n");break;case Big:printf("大床房\n");break;}printf("计费方式:");switch(theOrder->checkinInfo->countType ){case Hour:printf("小时计费\n");amount = (time(0) - theOrder->date) / 3600 +1;printf("已入住时间:%d小时\n",amount);break;case Day:printf("天计费\n");amount = (time(0) - theOrder->date) / (3600*24) +1;printf("已入住时间:%d天\n",amount);break;}printf("房价:%d\n",theOrder->room->price);printf("应支付:%d\n\n",amount * theOrder->room->price);printf("\n\n=========================酒店房间信息查询菜单=======================\t\n\n\n");printf("按0:返回\n");printf("按1:结账退房\n");scanf("%d",&chooseNum);switch(chooseNum){case 0:GUI = MainUI;break;case 1:GUI = CheckOutUI;break;default:break;}}}void showCheckOutUI(){int chooseNum;printf("\n\n=========================酒店结账退房确认菜单=======================\t\n\n\n");printf("\t\t\t\t************\t\t\t\t\n");printf("\t\t\t\t* 结账成功 *\t\t\t\t\n");printf("\t\t\t\t************\t\t\t\t\n\n");printf("\n\n=========================酒店结账退房确认菜单=======================\t\n\n\n");printf("按0:返回");scanf("%d",&chooseNum);switch(chooseNum){case 0:GUI = MainUI;break;default:GUI = CheckOutUI;break;}}-----精心整理,希望对您有所帮助!。

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)

酒店系统c语言课程设计

酒店系统c语言课程设计

酒店管理系统是一个非常实用的项目,它可以帮助酒店提高效率,优化客户体验。

以下是一个简单的酒店管理系统的C语言课程设计示例:c复制代码#include<stdio.h>#include<string.h>// 定义酒店房间结构体struct HotelRoom {int room_number;char type[20];int occupancy;};// 定义酒店房间数组struct HotelRoom rooms[100];int num_rooms = 0;// 添加房间函数void add_room(int room_number, char* type, int occupancy) {struct HotelRoom new_room;new_room.room_number = room_number;strcpy(new_room.type, type);new_room.occupancy = occupancy;rooms[num_rooms++] = new_room;}// 查找房间函数struct HotelRoom* find_room(int room_number) {for (int i = 0; i < num_rooms; i++) {if (rooms[i].room_number == room_number) {return &rooms[i];}}return NULL;}// 打印所有房间函数void print_rooms() {printf("Room Number\tType\tOccupancy\n");for (int i = 0; i < num_rooms; i++) {printf("%d\t%s\t%d\n", rooms[i].room_number, rooms[i].type,rooms[i].occupancy);}}int main() {add_room(101, "Single", 0);add_room(102, "Double", 0);add_room(103, "Family", 0);print_rooms(); // 输出: Room Number Type Occupancy 101 Single 0 102 Double 0 103 Family 0struct HotelRoom* room = find_room(102);if (room != NULL) {printf("Found room %d: %s, occupancy: %d\n", room->room_number, room->type, room->occupancy); // 输出: Found room 102: Double,occupancy: 0} else {printf("Room not found\n");}return0;}这个示例中,我们定义了一个HotelRoom结构体来表示酒店房间,然后使用一个数组来存储所有的房间。

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

oomNumber = 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() ount == 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].nameOne,name);
roomArray[i].sexOne = sex;
roomArray[i].Count++;
system("cls");
printf("客人已经成功入住,在房间%d",roomArray[i].roomNumber);
return;;
}
}
printf("无法入住,房间已经住满或者是没有适合的房间");
}
void fun2() ameOne,name) == 0)
{
memset(roomArray[i].nameOne,0,20);
roomArray[i].sexOne = 0;
roomArray[i].Count--;
system("cls");
printf("%s客人已经成功退房\n",name);
return;
}
if(strcmp(roomArray[i].nameTwo,name) == 0)
{
memset(roomArray[i].nameTwo,0,20);
roomArray[i].sexTwo = 0;
roomArray[i].Count--;
system("cls");
printf("%s客人已经成功退房\n",name);
return;
}
}
system("cls");
printf("没有名为%s的客人,请检查输入的正确性!\n",name); }
void fun3() 有房间入住信息显示\n");
printf(" 2.按照姓名查询\n"); printf(" 3.按照房号查询\n"); scanf("%d",&index);
if(index == 1)
{
for( i=0;i<5;i++)
{
printf("房间%d:",roomArray[i].roomNumber);
if(roomArray[i].Count == 0)
{
printf("没有客人入住\n");
}
else if(roomArray[i].Count == 1)
{
if(roomArray[i].sexTwo == 0)
{
printf("当前有1位客人-> 姓名%s,",roomArray[i].nameOne);
if(roomArray[i].sexOne == 1)
printf("性别:男");
else if(roomArray[i].sexOne == -1)
printf("性别:女");
printf("\n");
}
else if(roomArray[i].sexOne == 0)
{
printf("当前有1位客人-> 姓名%s,",roomArray[i].nameTwo);
if(roomArray[i].sexTwo == 1)
printf("性别:男");
else if(roomArray[i].sexTwo == -1)
printf("性别:女");
printf("\n");
}
}
else
{
ameOne,roomArray[i].sexOne,roomArray[i].nameTwo,roomArray[i].sexTwo);
printf("当前有2位客人-> 姓名%s,",roomArray[i].nameOne);
if(roomArray[i].sexOne == 1)
printf("性别:男,");
else if(roomArray[i].sexOne == -1)
printf("性别:女,");
printf("姓名:%s,",roomArray[i].nameTwo);
if(roomArray[i].sexTwo == 1)
printf("性别:男,");
else if(roomArray[i].sexOne == -1)
printf("性别:女,");
printf("\n");
}
}
}
else if(index == 2)
{
printf("请输入你要查询房客的姓名:");
scanf("%s",name);
for(i=0;i<5;i++)
{
if(strcmp(roomArray[i].nameOne,name) == 0 || strcmp(roomArray[i].nameTwo,name) == 0)
{
printf("%s房客入住在房间%d!\n",name,roomArray[i].roomNumber);
return;
}
}
printf("没有找到该旅客的信息!");
}
else if(index == 3)
{
printf("请输入你要查询的房间号:");
scanf("%d",&number);
j = number - 301;
if(roomArray[j].Count == 0)
{
printf("没有客人入住\n");
}
else if(roomArray[j].Count == 1)
{
printf("当前有1位客人-> 姓名%s,性别%d!",roomArray[j].nameOne,roomArray[j].sexOne);
}
else
{
printf("当前有两个客人入住姓名%s,性别%d 姓名%s,性别%d \n",roomArray[j].nameOne,roomArray[j].sexOne,roomArray[j].nameTwo,roomArray[j].sexTwo);
}
}
}
void show()
{
system("color 9f");
printf("*******************请选择操作************************\n");
printf(" 1.旅客入住\n");
printf(" 2.旅客退房\n");
printf(" 3.信息查询\n");
printf(" 4.退出exit\n");
printf("请输入你要选择的操作:");
}
int main()
{
int i= 100;
InitArray();
printf("*******************宾馆信息管理软件*******************\n");
while(i != 4)
{
printf("\n");
show();
scanf("%d",&i);
switch(i)
{
case 1:
fun1();
break;
case 2:
fun2();
break;
case 3:
fun3();
break;
}
}
system("pause");
return 0;
}。

相关文档
最新文档