123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
STORE-TOLL an Billing Project

--------------------------------------------------------------------------------

Description : This is fully a billing project and a database file is must and i included it at last after the code. cut it from here and put it in a file

Code :
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<time.h>
#include<stdlib.h>


#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;gd<MAX_MENU;gd++)

{
//gd=3

Billprocess.Active[gd]=YES;

//gd=1
Print.Active[gd]=YES;

Management.Active[gd]=YES;
}

//head that is printed on msg

Billprocess.head="processbill";
Print.head="Print";
Management.head="management";
//allocation for image memory

area=imagesize(0,0,150,150);
p=malloc(area);


if(p==NULL)
{
closegraph();
restorecrtmode();
printf("not enough memory");
exit(1);
}


//style of the menu
setfillstyle(1,7);

//full window
bar(0,0,660,650);

welcomescreen();

x=2;
y=2;
process();
//end();
closegraph();
getch();
}




void process()
{
//menu items in billprocess menu

char *bp[]={"Processbill","Openbill","Exit"};


//menu item in print menu
char *pr[]={"Printbill"};

char
*mgt[]={"SalesToday","SalesBydate","Itemsoldtoday","Itemsoldbydate"};

char KEY;

//menu bar position
win(0,0,660,20);

//drawing button for menu items

drawbtn(&Billprocess,"Billprocess");

drawbtn(&Print,"Print");

drawbtn(&Management,"Management");

settextstyle(0,0,0);

//outtextxy(close(x+y),close(y+7),"x");




show();

//instantly menus are idle

Billprocess.Active[3]=NO;
Print.Active[1]=NO;
Management.Active[4]=NO;

while(1)
{
if(kbhit())

{
KEY=getch();

//way to exit press esc or -
if(KEY==27 || KEY==45)
break;
}

status();



if(button==1)
{
//if(mouseon(&close))
//break;
if(mouseon(&Billprocess))
{
pullmenudown(bp,3,&Billprocess);

if(selection==NONE)

msg("no selection");

if(selection==0)
{

char str[3];

struct dosdate_t d;
char todaydate[15];
char month[5],year[5];




// initalization of customerid

int customerid;

// macro to generate customerid in random

randomize();

customerid= rand() % 1000;

customer=customerid;

itoa(customerid,str,10);


_dos_getdate(&d);
itoa(d.day,todaydate,10);
itoa(d.month,month,10);
itoa(d.year,year,10);
strcat(todaydate,month);
strcat(todaydate,year);

date=fopen(todaydate,"a+");

f2=fopen(str,"w");



//user defined function for page design
pagedesign();


gotoxy(6,4);


printf("CUSTOMERID : %d",customerid);

fprintf(f2,"%d",customerid);


//user defined method call for time zone to which customer
arrives
to bill
entertime();

//user defined function for database acess

getdatabaseacess();

}


if(selection==1)
{
char str[3];

setfillstyle(1,0);


bar(5,25,635,448);

gotoxy(10,8);

printf("ENTER THE CUSTOMERID TO OPEN ");

scanf("%s",str);



fop=fopen(str,"r");

if(!fop)
{
gotoxy(10,12);
printf("no customer is available");

}

else

{

pagedesign();

openbill();

}


}


if(selection==2)
{
exit(0);
}
}

if(mouseon(&Print))

{

pullmenudown(pr,1,&Print);

if(selection==NONE)

msg("noselection");


if(selection==0)
{
char str[3];

setfillstyle(1,0);


bar(5,25,635,448);
itoa(customer,str,10);



fop=fopen(str,"r");

if(!fop)
{
gotoxy(10,12);
printf("no customer is available");

}

else

{
printbill();

}


}


}

if(mouseon(&Management))

{

pullmenudown(mgt,4,&Management);

if(selection==NONE)

msg("noselection");

if(selection==0)
{

struct dosdate_t d;
char month[5],year[5];

_dos_getdate(&d);
itoa(d.day,todaydate,10);
itoa(d.month,month,10);
itoa(d.year,year,10);
strcat(todaydate,month);
strcat(todaydate,year);

today=fopen(todaydate,"r");


setfillstyle(1,0);


bar(5,25,635,448);


if(!today)
{

gotoxy(15,12);
printf("NO DATABASE IS AVAILABLE");

}

else

{

todaysales();

}


}


if(selection==1)
{

setfillstyle(1,0);


bar(5,25,635,448);



gotoxy(10,8);

printf("ENTER THE DATE TO OPEN ");

scanf("%s",salebydate);


day=fopen(salebydate,"r");



if(!day)
{
gotoxy(10,10);


printf("NO DATABASE AVAILABLE");

}

else

{

totalsalebydate();

}



}

if(selection==2)
{

struct dosdate_t d;
char month[5],year[5];





_dos_getdate(&d);
itoa(d.day,todaydate,10);
itoa(d.month,month,10);
itoa(d.year,year,10);
strcat(todaydate,month);
strcat(todaydate,year);

itemtoday=fopen(todaydate,"r");


setfillstyle(1,0);


bar(5,25,635,448);


if(!itemtoday)
{

gotoxy(25,12);
printf("NO DATABASE IS AVAILABLE");

}

else

{

itemtodayretrive();

}



}

if(selection==3)
{


setfillstyle(1,0);


bar(5,25,635,448);


gotoxy(10,8);

printf("ENTER THE DATE TO OPEN ");

scanf("%s",str);


itembydate=fopen(str,"r");

if(!itembydate)
{
gotoxy(10,10);
printf("no database is available");

}

else

{

retriveitembydate();

}


}



}

}

else

{
if(mouseon(&Billprocess))

Hlight(&Billprocess);



if(mouseon(&Print))

Hlight(&Print);

if(mouseon(&Management))

Hlight(&Management);


}

}


}




drawbtn(struct MENU *tm,char *txt)

{

setcolor(0);

settextstyle(2,0,4);

//position that name of the menu is written

outtextxy(tm->x+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;i<n;i++)
{
if(!tm->Active[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;i<n;i++)
{
status();

if(mouseon1(tm->x+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]='
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG