Home » » Restaurant Management System in C Programming

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 :
============================================
  1. #include
  2. #include
  3. #include
  4. #include
  5. #include
  6. #include
  7. #include
  8. #include
  9.  
  10. struct menurec{ char number[30];
  11. char name[30];
  12. float price;
  13. int customer;
  14. }menu;
  15.  
  16. struct orderbill{ char bid[30];
  17. char bnumber[30];
  18. char bname[30];
  19. float bprice;
  20. float btotal;} ord[30];
  21.  
  22.  
  23. void printxy(int x,int y,char string[])
  24. {gotoxy(x,y); printf("%s",string);}
  25.  
  26. void center(int y,char string[])
  27. {int x=(80-strlen(string)+1)/2;
  28. gotoxy(x,y);printf("%s",string);}
  29.  
  30. void twolinebox(int x1,int y1,int x2,int y2)
  31. {int x,y;
  32. gotoxy(x1,y1); printf("É"); //alt-201
  33. gotoxy(x2,y1); printf("»"); //alt-187
  34. for(y=y1+1;y<y2;y++){
  35. gotoxy(x1,y); printf("º"); //alt-186
  36. gotoxy(x2,y); printf("º"); //alt-186
  37. }
  38. gotoxy(x1,y2); printf("È"); //alt-200
  39. gotoxy(x2,y2); printf("¼"); //alt-188
  40. for(x=x1+1;x<x2;x++){
  41. gotoxy(x,y1); printf("Í"); //alt-205
  42. gotoxy(x,y2); printf("Í"); //alt-205
  43. }
  44. gotoxy(x1+1,y1+1);
  45. }
  46.  
  47. void createmenu(void)
  48. { FILE *fp;
  49. char opt;
  50. center(21,"WARNING!!!");
  51. center(22,"You are about to create a new Menu Record");
  52. center(23,"This will erase all records in the Record...");
  53. center(24,"Are you sure you want to proceed?[Y/N] ");
  54. opt=getche(); opt=toupper(opt);
  55. if(opt=='Y'){
  56. fp=fopen("Group3.txt","w");
  57. center(24," ");
  58. center(24,"File successfully created!");
  59. }
  60. getch();
  61. fclose(fp);
  62. }
  63.  
  64. void addmenu(void)
  65. { char opt; int i,n;FILE *fp;
  66. fp=fopen("Group3.txt","a");
  67. // clrscr();
  68. // printf("How many foods or drinks you want to add?"); scanf("%d",&n);
  69. clrscr();
  70. twolinebox(2,6,79,20);
  71. twolinebox(2,20,79,24);
  72. twolinebox(2,2,79,24);
  73. center(4,"ADD MENU RECORD");
  74. printxy(6,8,"Number: "); gotoxy(19,8); fflush(stdin);gets(menu.number);
  75. printxy(6,10,"Name: ");gotoxy(19,10); fflush(stdin);gets(menu.name);
  76. printxy(6,12, "Price: "); gotoxy(19,12);fflush(stdin); scanf("%f",&menu.price);
  77. gotoxy(5,22); clreol(); printxy(79,22,"º");
  78. fprintf(fp," %s %s %f ",menu.number,menu.name,menu.price);
  79. gotoxy(5,21); clreol(); center(21,"Record successfully added!");
  80. printxy(79,21,"º"); gotoxy(53,22); delay(1000);
  81.  
  82.  
  83. center(22,"Press Esc to go to main menu..."); getch();
  84. fclose(fp);
  85.  
  86. }
  87.  
  88. void listmenu(void)
  89. {int count=0,i,x=0,page=1;
  90. FILE *fp;
  91. fp=fopen("Group3.txt","r");
  92.  
  93.  
  94. clrscr();
  95. center(2,"Kingdom of Wander, Cambodia");
  96. center(3,"Ly Meng Restaurant");
  97. center(5,"The most popular Restaurant in the World");
  98. printxy(10,7,"Number Name Price");
  99. for(i=1;i<80;i++){ gotoxy(i,8); puts("Í"); /*Alt-205*/ }
  100. i=0;
  101. while(fscanf(fp," %s %s %f ",&menu.number,&menu.name,&menu.price)!=EOF)
  102. {
  103. if(count!=0&&count%5==0){ printxy(5,23,"Press any key to continue..."); getch(); x=0;
  104. for(i=10;i<=24;i++){gotoxy(1,i); clreol();}
  105. page++;
  106. }
  107. gotoxy(70,4); printf("Page %d",page);
  108. gotoxy(19,10+x); printf("%s",menu.number);
  109. gotoxy(37,10+x); printf("%s",menu.name);
  110. gotoxy(62,10+x); printf("%f",menu.price);
  111. x++;
  112. count++;
  113. }
  114. printxy(5,23,"Press any key to go to main menu...");
  115. getch();
  116.  
  117. fclose(fp);
  118. }
  119.  
  120. void addorder(void){
  121. int i=0,n,count=1;
  122. ord[i].btotal=0; FILE *fp1; FILE *co;
  123. fp1=fopen("Group3order.txt","w");
  124. if(fp1==NULL)
  125. { puts("Can't Open File");
  126. getch();
  127. exit(1);
  128. }
  129. printf("Please Remember Your Number of food or drink choice to put in the order!");
  130. listmenu(); delay(1000);
  131. printf("Now press any key to enter your choice!");
  132. char opt1=getch();clrscr();
  133. printf("Customers Number %d",i+1);
  134. printf("\nHow Many Items You want to order?"); scanf("%d",&n);
  135.  
  136. clrscr();
  137. twolinebox(2,6,79,20);
  138. twolinebox(2,20,79,24);
  139. twolinebox(2,2,79,24);
  140. center(4,"ADD ORDER");
  141. gotoxy(6,8);printf("Customer Number %d",count); count++;
  142. for(i=0;i<n;i++){
  143. printxy(6,i+9,"Number= ");gotoxy(i+18,i+15);fflush(stdin); gets(ord[i].bnumber);
  144. printxy(6,i+10,"Price= "); gotoxy(i+18,i+16); fflush(stdin);scanf("%f",&ord[i].bprice); }
  145. for(i=0;i<n;i++)
  146. ord[i].btotal=ord[i].btotal+ord[i].bprice;
  147. gotoxy(6,i+3);printf("Total: %f",ord[i].btotal);
  148. gotoxy(5,22); clreol(); printxy(79,22,"º");
  149. fprintf(fp1," %s %f %f ",ord[i].bnumber,ord[i].bprice,ord[i].btotal);
  150. gotoxy(5,21); clreol(); center(21,"Order successfully added!");
  151. printxy(79,21,"º"); gotoxy(53,22); delay(1000);
  152.  
  153.  
  154. for(i=0;i<n;i++)
  155. fprintf(fp1," %s %s %f %f ",ord[i].bnumber,ord[i].bname,ord[i].bprice,ord[i].btotal);
  156. fclose(fp1); co=fopen("Count.txt","w");
  157. fprintf(co," %d ",count); fclose(co);
  158. center(22,"Press Esc to go to main menu..."); getch();
  159.  
  160. }
  161.  
  162. void listorder(void){
  163. int count=0,i,x=0,page=1;
  164. FILE *fp;
  165. fp=fopen("Group3.txt","r");
  166.  
  167.  
  168. clrscr();
  169. center(2,"Kingdom of Wander, Cambodia");
  170. center(3,"Ly Meng Restaurant");
  171. center(5,"Reciept");
  172. printxy(10,7,"Number Name Price");
  173. for(i=1;i<80;i++){ gotoxy(i,8); puts("Í"); /*Alt-205*/ }
  174. i=0;
  175. while(fscanf(fp," %s %s %f %f ",&ord[i].bnumber,&ord[i].bname,&ord[i].bprice,&ord[i].btotal)!=EOF)
  176. {
  177. if(count!=0&&count%5==0){ printxy(5,23,"Press any key to continue..."); getch(); x=0;
  178. for(i=10;i<=24;i++){gotoxy(1,i); clreol();}
  179. page++;
  180. }
  181. gotoxy(70,4); printf("Page %d",page);
  182. gotoxy(13,10+x); printf("%d",count+1);
  183. gotoxy(19,10+x); printf("%s",ord[i].bnumber);
  184. gotoxy(37,10+x); printf("%s",ord[i].bname);
  185. gotoxy(62,10+x); printf("%f",ord[i].bprice);
  186. x++;
  187. count++;
  188. }
  189. printxy(5,23,"Press any key to go to main menu...");
  190. getch();
  191.  
  192. fclose(fp);
  193. }
  194. void sale(void){
  195. int count=0,i,x=0,page=1;
  196. FILE *fp1;
  197. fp1=fopen("Group3order.txt","r");
  198.  
  199.  
  200. clrscr();
  201. center(2,"Kingdom of Wander, Cambodia");
  202. center(3,"Ly Meng Restaurant");
  203. center(5,"Reciept");
  204. printxy(10,7,"Number Name Price");
  205. for(i=1;i<80;i++){ gotoxy(i,8); puts("Í"); }
  206. i=0;
  207. while(fscanf(fp1," %s %s %f %f ",ord[i].bnumber,ord[i].bname,&ord[i].bprice,&ord[i].btotal)!=EOF)
  208. {
  209. if(count!=0&&count%5==0){ printxy(5,23,"Press any key to continue..."); getch(); x=0;
  210. for(i=10;i<=24;i++){gotoxy(1,i); clreol();}
  211. page++;
  212. }
  213. gotoxy(70,4); printf("Page %d",page);
  214. gotoxy(13,10+x); printf("%d",count+1);
  215. gotoxy(19,10+x); printf("%s",ord[i].bnumber);
  216. gotoxy(37,10+x); printf("%s",ord[i].bname);
  217. gotoxy(62,10+x); printf("%f",ord[i].bprice);
  218. x++;
  219. count++;
  220. }
  221. printxy(5,23,"Press any key to go to main menu...");
  222. getch();
  223.  
  224. fclose(fp1);
  225. }
  226.  
  227. void Quit(void)
  228. {clrscr();
  229. twolinebox(2,2,79,24);
  230. center(8,"PROGRAMMED");
  231. center(9,"BY");
  232. center(11,"Group 3");
  233. center(13,"Ly Meng, Nheb Chhat Chhaya");
  234. center(14,"Oum Serey Chan, Pann Malinet");
  235. center(15,"Oeng Kean Hourt, Meng Sophea");
  236. center(16,"On Chetra, Oum Makara");
  237. delay(5000);
  238. exit(1);
  239. }
  240.  
  241. void Err_mess(void){
  242. sound(1000);
  243. center(22,"Invalid Input!");
  244. delay(1000);
  245. nosound();
  246. }
  247.  
  248.  
  249. void main()
  250. {char choice;
  251. do{
  252. clrscr();
  253. twolinebox(2,20,79,25);
  254. twolinebox(2,2,79,25);
  255.  
  256. center(4,"MAIN MENU");
  257. printxy(30,6,"Press:");
  258. printxy(30,8,"[1]-Create Menu");
  259. printxy(30,9,"[2]-Add Menu");
  260. printxy(30,10,"[3]-List Menu");
  261. printxy(30,11,"[4]-Add Order");
  262. printxy(30,12,"[5]-List Order");
  263. printxy(30,13,"[6]-Sale");
  264. printxy(30,14,"[7]-Exit");
  265. printxy(30,15,"Enter your choice..."); gotoxy(50,13);
  266. choice=getch(); choice=toupper(choice);
  267. switch(choice){
  268. case '1': createmenu(); break;
  269. case '2': addmenu(); break;
  270. case '3': listmenu(); break;
  271. case '4': addorder(); break;
  272. case '5': listorder(); break;
  273. case '6': sale(); break;
  274. case '7': Quit(); break;
  275. default: Err_mess(); break;
  276. }
  277. }while(choice!='7');
  278. }
  279.  
  280. //Leave us a command and share it to your friends ..!
  281.  

Share this article :