checkin.bak

来自「Hotel Management System in c++」· BAK 代码 · 共 115 行

BAK
115
字号
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<string.h>
#include<ctype.h>

typedef struct CUST
{
 char cid[10],name[20],ph[15],rtype[3],bgroup[4],addr[20];
 int rno;
 date cin,cout,dob;
 float adv;
 };
CUST cust;
ROOM r;
void  chkin()
{
 FILE *chkin,*rm;
 int f=0,rec=0;
 fpos_t pos;
 chkin=fopen("c:\\hotel\\database\\Checkin.dat","ab+");
 rm=fopen("c:\\hotel\\database\\roomdet.dat","rb+");
 clrscr();
 panel();
 statusbar("Enter Detail For Customer ");
 getdate(&cust.cin);
 gotoxy(6,6);
 printf("Enter the Customer ID  :");
 gotoxy(6,8);
 printf("Enter the Customer Name:");
 gotoxy(6,10);
 printf("Enter the Phone Number :");
 gotoxy(6,12);
 printf("Enter the Address      :");
 gotoxy(6,14);
 printf("Enter the Room No.:");
 gotoxy(35,14);
 printf("Room Type :");
 gotoxy(6,16);
 printf("Check In Date %d/%d/%d :",cust.cin.da_day,cust.cin.da_mon,cust.cin.da_year);
 gotoxy(35,16);
 printf("Check out Date (dd/mm/yy) :");
 gotoxy(6,18);
 printf("Enter the Blood Group :");
 gotoxy(35,18);
 printf("Enter the Advance Amount :");
 gotoxy(6,20);
 printf("Enter the Date of Birth(dd/mm/yy) :");
 gotoxy(35,6);
 scanf(" %[^\n]",cust.cid);
 gotoxy(35,8);
 scanf(" %[^\n]",cust.name);
 gotoxy(35,10);
 scanf(" %[^\n]",cust.ph);
 gotoxy(35,12);
 fflush(stdin);
 scanf("%[^\n]",cust.addr);
 fflush(stdin);

 while(f==0)
 {
 gotoxy(28,14);
 scanf(" %d",&cust.rno);
 rec=0;
 while((fread(&r,sizeof(r),1,rm))==1)
 {
  if(r.no==cust.rno)
  {
   rec=1;
   printf("\a");
   if(r.status>0)
    {
     statusbar(" Already Reserved Room                ");
     gotoxy(28,14);
     printf("     ");
     }
     else
    {
    r.status=1;
   f=1;
   fgetpos(rm,&pos);
   pos=pos-sizeof(r);
   fsetpos(rm,&pos);
   fwrite(&r,sizeof(r),1,rm);
   break;
     }
  }
 }
if(rec==0)
  {
   statusbar(" RECORD FOR ROOM NO. NOT FOUND . . . ")
   getch();
   return;
  }
}
 strcpy(cust.rtype,r.type);
 gotoxy(60,14);
 printf("%s ",cust.rtype);
 gotoxy(62,16);
 scanf(" %d/%d/%d",&cust.cout.da_day,&cust.cout.da_mon,&cust.cout.da_year);
 gotoxy(30,18);
 fflush(stdin);
 scanf(" %[^\n]",&cust.bgroup);
 gotoxy(62,18);
 fflush(stdin);
 scanf("%f",&cust.adv);
 gotoxy(62,18);
 printf("%.2f      ",cust.adv);
 gotoxy(42,20);
 fflush(stdin);
 scanf(" %d/%d/%d",&cust.dob.da_day,&cust.dob.da_mon,&cust.dob.da_year);
 fwrite(&cust,sizeof(cust),1,chkin);
 fclose(rm);
 fclose(chkin);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?