Add to Favorites    Make Home Page 18571 Online  
 Language Categories  
 Our Services  

Home » C Home » File Operations Home » STORE-TOLL an Billing Project

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title STORE-TOLL an Billing Project
Author MAHENDRAN.P
Author Email mahen1984 [at] gmail.com
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
Category C » File Operations
Hits 13472
Code Select and Copy the Code
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]='; chdir("faculty"); cout<<" Enter The Year : "; gets(year); chdir(year); cout<<" Enter The Name Of A Faculty : "; gets(name); chdir(name); cout<<" Enter The Name Of A Person : "; gets(name); cout<<" Are You Sure You Want To Remove It (y/n) : "; cin>>ch; if(ch=='y') { status=rmdir(name); if(status==0) { cout<<" Record Have Been Removed Succesfully "; cout<<" Press Any Key To Return To Main Menu "; getch(); chdir("\"); mainwindow(); } else { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } } else { chdir("\"); mainwindow(); } } // FUNCTION FOR PRINTING THE DATA void prin() { clrscr(); cout<<" Enter The Option "; cout<<" 1. Faculty "; cout<<" 2. Student "; cout<<" Option------> "; cin>>option; chdir("data"); if(option==1) { chdir("faculty"); cout<<" Enter The Year "; gets(year); chdir(year); cout<<" Enter The Name Of Faculty "; gets(name); chdir(name); cout<<" Want Take A Print Document Of Personal Or Admin Details "; cout<<" 1. Personal "; cout<<" 2. Adminstration "; cout<<" Option------> "; cin>>option; if(option==1) { strcpy(newfile,"p"); strcat(newfile,name); strcat(newfile,".txt"); ifstream fin; fin.open(newfile); if(!fin) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } ofstream fout; fout.open("PRN"); if(!fout) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } while(fin.get(ch)!=0) { mod=~ch; fout.put(mod); } fout.close(); fin.close(); } if(option==2) { strcpy(newfile,"a"); strcat(newfile,name); strcat(newfile,".txt"); ifstream fin; fin.open(newfile); if(!fin) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } ofstream fout; fout.open("PRN"); if(!fin) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } while(fin.get(ch)!=0) { mod=~ch; fout.put(mod); } fout.close(); fin.close(); } } if(option==2) { chdir("student"); cout<<" Enter The Year "; gets(year); chdir(year); cout<<" Enter The Name Of Student "; gets(name); chdir(name); cout<<" Want Take A Print Document Of Personal Or Admin Details "; cout<<" 1. Personal "; cout<<" 2. Academic "; cout<<" Option------> "; cin>>option; if(option==1) { strcpy(newfile,"p"); strcat(newfile,name); strcat(newfile,".txt"); ifstream fin; fin.open(newfile); if(!fin) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } ofstream fout; fout.open("PRN"); if(!fout) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } while(fin.get(ch)!=0) { mod=~ch; fout.put(mod); } fout.close(); fin.close(); } if(option==2) { strcpy(newfile,"a"); strcat(newfile,name); strcat(newfile,".txt"); ifstream fin; fin.open(newfile); if(!fin) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } ofstream fout; fout.open("PRN"); if(!fout) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } while(fin.get(ch)!=0) { mod=~ch; fout.put(mod); } fout.close(); fin.close(); } } chdir("\"); mainwindow(); } // FUNCTION FOR SHOWING A MAIN WINDOW OF STUDENT INFORMATION void student() { clrscr(); box(); gotoxy(26,4);cout<<"INSTITUTE MANAGEMENT SYSTEM "; gotoxy(26,5);cout<<"==========================="; gotoxy(26,8);cout<<"Choose You Option........"; gotoxy(26,10);cout<<"1. Add A New Student Record "; gotoxy(26,12);cout<<"2. See All Students "; gotoxy(26,14);cout<<"3. Full Access To Any Student Information "; gotoxy(26,16);cout<<"4. Modify Any Information "; gotoxy(26,18);cout<<"5. Delete Any Information "; gotoxy(26,20);cout<<"Press 0 To Exit....... "; gotoxy(26,22);cout<<"Option------> "; cin>>option; switch(option) { case 1 : enterdatast(); break; case 2 : seetotalst(); break; case 3 : fullaccessst(); break; case 4 : modifyst(); break; case 5 : deletest(); break; default : closeprog(); break; }; } // FUNCTION TO ENTER A STUDENT DATA void enterdatast() { clrscr(); cout<<" Enter The Year Which you Want To Add The Data "; cout<<" =============================================== "; gets(year); mkdir("data"); chdir("data"); mkdir("student"); chdir("student"); mkdir(year); chdir(year); personalst(); chdir("\"); mainwindow(); } // FUNCTION TO ENTER A PERSONAL DETAILS OF A STUDENT void personalst() { cout<<" Enter The Personal Details "; cout<<" ========================== "; cout<<" Enter The The Name Of The Student : "; gets(name); mkdir(name); chdir(name); strcpy(newfile,"p"); strcat(newfile,name); strcat(newfile,".txt"); ofstream fout(newfile); if(!fout) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } fout<<" NAME : "<<name; cout<<" Fathers Name : "; gets(temp); fout<<" Fathers Name : "<<temp; cout<<" Date Of Birth : "; gets(temp); fout<<" Date Of Birth : "<<temp; cout<<" Contact Number : "; gets(temp); fout<<" Contact Number : "<<temp; cout<<" Address : "; gets(temp); fout<<" ADDRESS :"<<temp; cout<<" Course Name : "; gets(temp); fout<<" Course Name : "<<temp; fout.close(); encrypt(newfile); academic(name); } // FUNCTION TO ENTER A ACADEMIC DETAILS OF A STUDENT void academic(char *name) { clrscr(); cout<<" Enter The Academic Detials "; cout<<" ========================== "; strcpy(newfile,"a"); strcat(newfile,name); strcat(newfile,".txt"); ofstream foutt(newfile); if(!foutt) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } foutt<<" NAME : "<<name; cout<<" Type Of Course (Semster/Annual) : "; gets(temp); foutt<<" Type Of Course (Semester/Annual) : "<<temp; cout<<" Year Of Admission : "; gets(temp); foutt<<" Year Of Admission : "<<temp; cout<<" Admission Number : "; gets(temp); foutt<<" Admission Number : "<<temp; cout<<" Percentage In Intermediate : "; gets(temp); foutt<<" Percentage In Intermediate : "<<temp; cout<<" Percentage In College :"; foutt<<" Percentage In College : "; cout<<" First Year : "; gets(temp); foutt<<" First Year :"<<temp; cout<<" Second Year : "; gets(temp); foutt<<" Second Year :"<<temp; cout<<" Third Year : "; gets(temp); foutt<<" third Year :"<<temp; foutt.close(); encrypt(newfile); } // FUNCTION TO SEE A TOTAL STUDENTS OF A PARTICULAR YEAR void seetotalst() { clrscr(); chdir("data"); chdir("student"); cout<<" Enter The Year Of Which You Want To See The Students "; gets(year); chdir(year); cout<<" These Are The Students "; system("dir /b /ad /w"); getch(); chdir("\"); mainwindow(); } // FUNCTION TO SEE ALL DETAILS OF A STUDENT void fullaccessst() { clrscr(); chdir("data"); chdir("student"); cout<<" Enter The Year Of The Student : "; gets(year); chdir(year); cout<<" Enter The Name Of The Student : "; gets(name); chdir(name); cout<<" What You Want To See Personal Information Or Academic Information "; cout<<" 1. Personal "; cout<<" 2. Academic "; cout<<" Option------> "; cin>>option; clrscr(); cout<<" "; if(option==1) { strcpy(newfile,"p"); strcat(newfile,name); strcat(newfile,".txt"); ifstream fin(newfile); if(!fin) { clrscr(); perror(" Cannot Open The File "); cout<<" PRESS ANY KEY TO Return To Main Menu "; getch(); chdir("\"); mainwindow(); } while(fin.get(ch)!=0) { mod=~ch; cout<<mod; } getch(); fin.close(); } if(option==2) { strcpy(newfile,"a"); strcat(newfile,name); strcat(newfile,".txt"); ifstream fin(newfile); if(!fin) {

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi դ ? ??
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions
Copyright ©2003-2017 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1141


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review