Popular Posts

6/25/2012

Restaurant Management System in C Programming


Restaurant Management System - C implementation

Royal University of Phnom Penh
Computer Science Campus
College of Computer Management and Information Technology

A Partial Fulfillment of the Subject C Programming
Download Here
This is the source codes of Restaurant Management in C Programming :

============================================


#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<process.h>

struct menurec{ char number[30];
char name[30];
float price;
int customer;
}menu;

struct orderbill{ char bid[30];
 char bnumber[30];
 char bname[30];
 float bprice;
 float btotal;} ord[30];


void printxy(int x,int y,char string[])
{gotoxy(x,y); printf("%s",string);}

void center(int y,char string[])
{int x=(80-strlen(string)+1)/2;
gotoxy(x,y);printf("%s",string);}

void twolinebox(int x1,int y1,int x2,int y2)
{int x,y;
 gotoxy(x1,y1); printf("É"); //alt-201
 gotoxy(x2,y1); printf("»"); //alt-187
  for(y=y1+1;y<y2;y++){
    gotoxy(x1,y); printf("º"); //alt-186
    gotoxy(x2,y); printf("º"); //alt-186
  }
 gotoxy(x1,y2); printf("È"); //alt-200
 gotoxy(x2,y2); printf("¼"); //alt-188
  for(x=x1+1;x<x2;x++){
    gotoxy(x,y1); printf("Í"); //alt-205
    gotoxy(x,y2); printf("Í"); //alt-205
  }
 gotoxy(x1+1,y1+1);
}

void createmenu(void)
{ FILE *fp;
  char opt;
  center(21,"WARNING!!!");
  center(22,"You are about to create a new Menu Record");
  center(23,"This will erase all records in the Record...");
  center(24,"Are you sure you want to proceed?[Y/N] ");
  opt=getche(); opt=toupper(opt);
  if(opt=='Y'){
   fp=fopen("Group3.txt","w");
   center(24,"                                             ");
   center(24,"File successfully created!");
  }
   getch();
 fclose(fp);
}

void addmenu(void)
{    char opt; int i,n;FILE *fp;
   fp=fopen("Group3.txt","a");
 //  clrscr();
 //  printf("How many foods or drinks you want to add?"); scanf("%d",&n);
  clrscr();
   twolinebox(2,6,79,20);
   twolinebox(2,20,79,24);
   twolinebox(2,2,79,24);
   center(4,"ADD MENU RECORD");
   printxy(6,8,"Number: "); gotoxy(19,8); fflush(stdin);gets(menu.number);
   printxy(6,10,"Name: ");gotoxy(19,10); fflush(stdin);gets(menu.name);
   printxy(6,12, "Price: "); gotoxy(19,12);fflush(stdin); scanf("%f",&menu.price);
   gotoxy(5,22); clreol(); printxy(79,22,"º");
   fprintf(fp," %s %s %f ",menu.number,menu.name,menu.price);
   gotoxy(5,21); clreol(); center(21,"Record successfully added!");
   printxy(79,21,"º");  gotoxy(53,22); delay(1000);


   center(22,"Press Esc to go to main menu..."); getch();
   fclose(fp);

}

void listmenu(void)
{int count=0,i,x=0,page=1;
FILE *fp;
fp=fopen("Group3.txt","r");


 clrscr();
 center(2,"Kingdom of Wander, Cambodia");
 center(3,"Ly Meng Restaurant");
 center(5,"The most popular Restaurant in the World");
 printxy(10,7,"Number Name Price");
 for(i=1;i<80;i++){ gotoxy(i,8); puts("Í"); /*Alt-205*/ }
 i=0;
 while(fscanf(fp," %s %s %f ",&menu.number,&menu.name,&menu.price)!=EOF)
{
    if(count!=0&&count%5==0){ printxy(5,23,"Press any key to continue..."); getch(); x=0;
  for(i=10;i<=24;i++){gotoxy(1,i); clreol();}
    page++;
    }
    gotoxy(70,4); printf("Page %d",page);
    gotoxy(19,10+x); printf("%s",menu.number);
    gotoxy(37,10+x); printf("%s",menu.name);
    gotoxy(62,10+x); printf("%f",menu.price);
    x++;
  count++;
}
 printxy(5,23,"Press any key to go to main menu...");
 getch();

 fclose(fp);
}

void addorder(void){
   int i=0,n,count=1;
   ord[i].btotal=0;   FILE *fp1; FILE *co;
   fp1=fopen("Group3order.txt","w");
   if(fp1==NULL)
   { puts("Can't Open File");
getch();
exit(1);
   }
   printf("Please Remember Your Number of food or drink choice to put in the order!");
   listmenu(); delay(1000);
   printf("Now press any key to enter your choice!");
   char opt1=getch();clrscr();
   printf("Customers Number %d",i+1);
   printf("\nHow Many Items You want to order?"); scanf("%d",&n);

   clrscr();
   twolinebox(2,6,79,20);
   twolinebox(2,20,79,24);
   twolinebox(2,2,79,24);
   center(4,"ADD ORDER");
   gotoxy(6,8);printf("Customer Number %d",count);   count++;
   for(i=0;i<n;i++){
   printxy(6,i+9,"Number= ");gotoxy(i+18,i+15);fflush(stdin); gets(ord[i].bnumber);
   printxy(6,i+10,"Price= "); gotoxy(i+18,i+16); fflush(stdin);scanf("%f",&ord[i].bprice); }
   for(i=0;i<n;i++)
   ord[i].btotal=ord[i].btotal+ord[i].bprice;
   gotoxy(6,i+3);printf("Total: %f",ord[i].btotal);
   gotoxy(5,22); clreol(); printxy(79,22,"º");
   fprintf(fp1," %s %f %f ",ord[i].bnumber,ord[i].bprice,ord[i].btotal);
   gotoxy(5,21); clreol(); center(21,"Order successfully added!");
   printxy(79,21,"º");  gotoxy(53,22); delay(1000);


   for(i=0;i<n;i++)
   fprintf(fp1," %s %s %f %f ",ord[i].bnumber,ord[i].bname,ord[i].bprice,ord[i].btotal);
   fclose(fp1);     co=fopen("Count.txt","w");
   fprintf(co," %d ",count); fclose(co);
   center(22,"Press Esc to go to main menu..."); getch();

}

void listorder(void){
int count=0,i,x=0,page=1;
FILE *fp;
fp=fopen("Group3.txt","r");


 clrscr();
 center(2,"Kingdom of Wander, Cambodia");
 center(3,"Ly Meng Restaurant");
 center(5,"Reciept");
 printxy(10,7,"Number Name Price");
 for(i=1;i<80;i++){ gotoxy(i,8); puts("Í"); /*Alt-205*/ }
 i=0;
 while(fscanf(fp," %s %s %f %f ",&ord[i].bnumber,&ord[i].bname,&ord[i].bprice,&ord[i].btotal)!=EOF)
{
    if(count!=0&&count%5==0){ printxy(5,23,"Press any key to continue..."); getch(); x=0;
  for(i=10;i<=24;i++){gotoxy(1,i); clreol();}
    page++;
    }
    gotoxy(70,4); printf("Page %d",page);
    gotoxy(13,10+x); printf("%d",count+1);
    gotoxy(19,10+x); printf("%s",ord[i].bnumber);
    gotoxy(37,10+x); printf("%s",ord[i].bname);
    gotoxy(62,10+x); printf("%f",ord[i].bprice);
    x++;
  count++;
 }
 printxy(5,23,"Press any key to go to main menu...");
 getch();

 fclose(fp);
}
void sale(void){
int count=0,i,x=0,page=1;
FILE *fp1;
fp1=fopen("Group3order.txt","r");


 clrscr();
 center(2,"Kingdom of Wander, Cambodia");
 center(3,"Ly Meng Restaurant");
 center(5,"Reciept");
 printxy(10,7,"Number Name Price");
 for(i=1;i<80;i++){ gotoxy(i,8); puts("Í"); }
 i=0;
 while(fscanf(fp1," %s %s %f %f ",ord[i].bnumber,ord[i].bname,&ord[i].bprice,&ord[i].btotal)!=EOF)
{
    if(count!=0&&count%5==0){ printxy(5,23,"Press any key to continue..."); getch(); x=0;
  for(i=10;i<=24;i++){gotoxy(1,i); clreol();}
    page++;
    }
    gotoxy(70,4); printf("Page %d",page);
    gotoxy(13,10+x); printf("%d",count+1);
    gotoxy(19,10+x); printf("%s",ord[i].bnumber);
    gotoxy(37,10+x); printf("%s",ord[i].bname);
    gotoxy(62,10+x); printf("%f",ord[i].bprice);
    x++;
  count++;
 }
 printxy(5,23,"Press any key to go to main menu...");
 getch();

 fclose(fp1);
}

void Quit(void)
{clrscr();
 twolinebox(2,2,79,24);
 center(8,"PROGRAMMED");
 center(9,"BY");
 center(11,"Group 3");
 center(13,"Ly Meng, Nheb Chhat Chhaya");
 center(14,"Oum Serey Chan, Pann Malinet");
 center(15,"Oeng Kean Hourt, Meng Sophea");
 center(16,"On Chetra, Oum Makara");
 delay(5000);
 exit(1);
}

void Err_mess(void){
sound(1000);
center(22,"Invalid Input!");
delay(1000);
nosound();
}


void main()
{char choice;
    do{
     clrscr();
     twolinebox(2,20,79,25);
     twolinebox(2,2,79,25);

     center(4,"MAIN MENU");
     printxy(30,6,"Press:");
     printxy(30,8,"[1]-Create Menu");
     printxy(30,9,"[2]-Add Menu");
     printxy(30,10,"[3]-List Menu");
     printxy(30,11,"[4]-Add Order");
     printxy(30,12,"[5]-List Order");
     printxy(30,13,"[6]-Sale");
     printxy(30,14,"[7]-Exit");
     printxy(30,15,"Enter your choice..."); gotoxy(50,13);
     choice=getch(); choice=toupper(choice);
       switch(choice){
 case '1': createmenu(); break;
 case '2': addmenu(); break;
 case '3': listmenu(); break;
 case '4': addorder(); break;
 case '5': listorder(); break;
 case '6': sale(); break;
 case '7': Quit(); break;
 default: Err_mess(); break;
       }
     }while(choice!='7');
}

//Leave us a command and share it to your friends ..!

1 comments:

  1. There are a lots of error while running this code...

    ReplyDelete