/*There are 2 files : 1. Source Code copy (STORETOLL.C). Open this in your Turbo C. 2. Database file (MHN.TXT). This is after the source code in the box below. After running the program, there will be three menus: 1. Process bill, 2. Print bill, 3. Management On processbill menu, click billprocess. Then give the item code between 101 to 105. To exit from billprocess, give 1 and press enter.*/ //////// FILE 1 - STORETOLL.C ///////////////// //////// LOOK BELOW FOR THE DATABASE FILE ///// #include #include #include #include #include #include #define NO 0 #define YES 1 #define NONE -1 //in a menu there can be three items #define MAX_MENU 6 int x,y; int selection; int button,x,y; void *p; size_t area; int validate(int); FILE *date; FILE *f2; FILE *fop; FILE *today; char todaydate[15]; FILE *day; char salebydate[10]; FILE *itemtoday; FILE *itembydate; char str[10]; int customer; struct MENU { int x; int y; int x1; int y1; unsigned char Active[MAX_MENU]; char *head; }; int mouseon(struct MENU *t); void process(); void xorbar(int sx,int sy,int ex,int ey,int c); void show(); void hide(); void status(); //position of the billprocess menu struct MENU Billprocess = {0,0,80,20}; //position of the print menu struct MENU Print = {90,0,165,20}; struct MENU Management = {175,0,260,20}; void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"f:\tcpp"); selection=NONE; for(gd=0;gdx+15,tm->y+4,txt); } Hlight(struct MENU *t) { winp(t,0); msg(t->head); while(mouseon(t)) { status(); if(button!=0) break; if(kbhit()) break; } setcolor(7); hide(); //MESSAGE WINDOW rectangle(t->x,t->y,t->x1,t->y1); msg("WELCOME TO STORE-TOLL"); show(); } //mouse placement int mouseon(struct MENU *t) { int flag; flag=0; if(x>=t->x && x<=t->x1 && y>=t->y && y<=t->y1) flag=1; return flag; } //MENU ITEM DISPAY void xorbar(int sx,int sy,int ex, int ey, int c) { int i; setwritemode(1); setcolor(4); hide(); for(i=sy;i<=ey;i++) line(sx,i,ex,i); show(); setwritemode(0); } push(struct MENU *tm) { winp(tm,1); while(button==1) { status(); if(kbhit()) break; } } up(struct MENU *tm) { setcolor(7); hide(); rectangle(tm->x,tm->y,tm->x1,tm->y1); show(); while(button==1) { status(); if(kbhit()) break; } } pullmenudown(char *h[],int n,struct MENU *tm) { int i; i=n*20; push(tm); hide(); getimage(tm->x+1, tm->y1+2,tm->x+100,tm->y1+i+5,p); win(tm->x+1,tm->y1+2,tm->x+100,tm->y1+i+5); setcolor(5); settextstyle(2,0,4); for(i=0;iActive[i]) { setcolor(15); outtextxy(tm->x+15,tm->y1+9+i*20,h[i]); setcolor(0); outtextxy(tm->x+14,tm->y1+8+i*20,h[i]); } else { //position to write menu items outtextxy(tm->x+14,tm->y1+8+i*20,h[i]); } } show(); while(button==1) status(); handlemenu(n,tm); } pullmenuup(struct MENU *tm) { int i; hide(); putimage(tm->x+1,tm->y1+2,p,COPY_PUT); show(); up(tm); } handlemenu(int n,struct MENU *tm) { int i; char key; setcolor(0); selection=NONE; i=0; while(1) { status(); if(button==1) break; for(i=0;ix+4, tm->y1+6+i*20, tm->x+99, tm->y1+22+i*20)) { xorbar(tm->x+3,tm->y1+6+i*20,tm->x+97,tm->y1+22+i*20,14); while(mouseon1(tm->x+4,tm->y1+8+i*20,tm->x+97,tm->y1+22+i*20)) { status(); if(button==1) { if(tm->Active[i]==YES) { selection=i; break; } else { selection=NONE; } } if(kbhit()) break; } xorbar(tm->x+3,tm->y1+6+i*20,tm->x+97,tm->y1+22+i*20,14); } } } pullmenuup(tm); } mouseon1(int cx, int cy, int cx1, int cy1) { int flag; flag=0; if(x>=cx && y>=cy && x<=cx1 && y<=cy1) flag=1; return flag; } union REGS i,o; struct SREGS ss; void show() { i.x.ax=1; int86(0x33,&i,&o); } void hide() { i.x.ax=2; int86(0x33,&i,&o); } void status() { i.x.ax=3; int86(0x33,&i,&o); button=o.x.bx; x=o.x.cx; y=o.x.dx; } //state of the menu winp(struct MENU *t ,int state) { hide(); if(state==1) { setcolor(0); line(t->x,t->y,t->x,t->y1); line(t->x,t->y,t->x1,t->y); setcolor(15); line(t->x1,t->y,t->x1,t->y1); line(t->x,t->y1,t->x1,t->y1); } else { setcolor(5); line(t->x,t->y,t->x,t->y1); line(t->x,t->y,t->x1,t->y); setcolor(5); line(t->x1,t->y,t->x1,t->y1); line(t->x,t->y1,t->x1,t->y1); } show(); } //pull down menu design win(int sx, int sy, int ex,int ey) { hide(); setfillstyle(1,7); bar(sx,sy,ex,ey); setcolor(15); line(sx,sy,sx,ey); line(sx,sy,ex,sy); setcolor(0); line(ex,sy,ex,ey); line(sx,ey,ex,ey); show(); } msg(char *m) { int l; setcolor(14); rectangle(5,25,635,477); setfillstyle(1,0); bar(20,455,620,475); settextstyle(2,0,6); setcolor(3); l=textwidth(m)/2; outtextxy(320-l,455,m); outtextxy(321-l,456,m); } welcomescreen() { setfillstyle(1,0); bar(5,25,635,425); settextstyle(4,0,3); setcolor(2); outtextxy(210,120,"STORE TOLL"); settextstyle(4,0,3); setcolor(3); outtextxy(220,160,"WELCOMES"); settextstyle(4,0,3); setcolor(5); outtextxy(265,200,"YOU"); } pagedesign() { //setting text color setcolor(2); //full outline setfillstyle(1,0); bar(5,25,635,448); //text style settextstyle(4,0,3); //name of SHOP outtextxy(200,25,"STORE-TOLL"); //first horizontal line line(0,65,650,65); //second horizontal line line(0,78,650,78); //first vertical line line(120,65,120,450); //second vertical line line(275,65,275,450); //third vertical line line(350,65,350,450); //fourth vertical line line(450,65,450,450); //fifth vertical line line(530,65,530,450); //text style settextstyle(2,0,5); outtextxy(10,65,"ITEM CODE"); outtextxy(140,65,"ITEM NAME"); outtextxy(280,65,"kg/gm"); outtextxy(375,65,"PRICE"); outtextxy(465,65,"NUMBER"); outtextxy(555,65,"AMOUNT"); //line for total at bottom line(450,430,650,430); outtextxy(470,430,"TOTAL"); return(0); } entertime(void) { time_t timer; struct tm *tblock; /* gets time of day */ timer = time(NULL); /* converts date/time to a structure */ tblock = localtime(&timer); //position for time display gotoxy(55,4); printf("%s", asctime(tblock)); fprintf(f2," %s", asctime(tblock)); return(0); } getdatabaseacess() { FILE *file; int code,itemcode,num,yax,quantity,i=0,curY; char itemname[30]; char buf[6],ip; int counter=0; float rate,sum,total=0.0; //first y axis position yax=5; file=fopen("mhn.txt","r"); while(i<20) { msg("BILL ON PROCESS"); //x,y position to get code gotoxy(6,++yax); //get code input msg("GET ITEM CODE"); curY= wherey(); printf("|"); ip=getch(); while(ip!=' ') { if(isdigit(ip)) { printf("%c",ip); buf[counter++]=ip; } ip=getch(); if(counter>=5) break; } buf[counter]='