Project Report

108
Canteen System

Transcript of Project Report

Page 1: Project Report

Canteen System

Page 2: Project Report

INTRODUCTION

ANALYSIS OF CANTEEN MANAGEMENT SYSTEM

The Following problems are faced to manage various accounts running in canteen and to generate the reports: -

1. Problem in adding, searching, modifying and deleting a particular record.

2. To fix certain limit of balanced amount for all account holders.

3. There is no check available on the illegal transaction done by the canteen manager. (From the point of view of account holder).

4. Inability to generate a report for a particular time period like for a particular day, fortnight or month.

5. Inability to modify items in the menu of canteen.

6. Inability to generate reports with certain requirement.

Page 3: Project Report

Objectives:

PROBLEM STATEMENT:-

To manage all the accounts and transactions and to generate reports whenever required by the canteen manager.

GOALS TO BE ACHIEVED :-

1. To develop an interactive interface with which user can interact easily.

2. To manage database of all the account holders.

3. To store information about items in the canteen.

4. To display reports whenever they are generated as per requirement.

Page 4: Project Report

PROJECT MODULES

This project is aimed to manage accounts in canteen and to generate reports. The project is divided in five main modules, which further have their sub modules.The main modules are: -

1. Transaction Management2. Student Database Management3. Faculty Database Management4. Report Generation System5. Canteen Menu Updating System

These modules are explained below: -

1. Transaction Management: - This module handles all the transactions done by student and faculties.This module has following sub modules: -

Student1.1.1 Buys1.1.2 Pays

1.2 Faculty1.2.1 Buys1.2.2 Pays

2. Student Database Management: - This module manages the database of all the students.This module has following sub modules: -

2.1 Search An Account

Page 5: Project Report

2.2 Open New Account2.3 Delete An Account2.4 Modify An Account

3. Faculty Database Management: - This module manages the database of all the faculties.This module has following sub module: -

3.1 Search An Account3.2 Open New Account3.3 Delete An Account3.4 Modify An Account

4. Report Generation System: - This module is aimed to generate reports whenever they are required for one or for all account holders.This module has following sub modules: -

For One Account Holder For All Account Holders

NOTE: - This module also generates reports automatically on the completion of a month, a quarter year, a half-year and a year.

2. Canteen Menu Updating System: - This module is aimed to show and update menu items.

This module has following sub modules: -

Show MenuUpdate MenuModify ItemDelete ItemAdd Item

Page 6: Project Report

NOTE: - Project may contain more modules to make it more efficient and closer to real world.

Page 7: Project Report
Page 8: Project Report

DATABASE DESIGN

As our project is implemented in C++, so our database is created with flat file system.

Our database has following tree of files and folders: -

DATABASE

STUDENT

2006 (Works between July 1st, 2006 and June 30th, 2007) ALL.txt (contains names of all the other file in the folder).

0510075.txt (contains information of account holder & record of all the transactions made by the account holders).

0510069.txt 0510080.txt --- --- ---

2007 (Works between July 1st, 2007 and June 30th, 2008) ALL.txt (contains names of all the other file in the folder).

0510075.txt (contains information of account holder & record of all the transactions made by the account holders).

0510069.txt 0510080.txt --- --- ---

2008 (Works between July 1st, 2008 and June 30th, 2009) ALL.txt (contains names of all the other file in the folder).

0510075.txt (contains information of account holder & record of all the transactions made by the account holders).

0510069.txt 0510080.txt --- ---

Page 9: Project Report

---

--- ALL.txt --- ---

--- ALL.txt --- ---

FACULTY

2006 (Works between July 1st, 2006 and June 30th, 2007) ALL.txt (contains names of all the other file in the folder).

001.txt (contains information of account holder & record of all the transactions made by the account holders).

002.txt 003.txt --- --- ---

2007 (Works between July 1st, 2007 and June 30th, 2008) ALL.txt (contains names of all the other file in the folder).

001.txt (contains information of account holder & record of all the transactions made by the account holders).

002.txt 003.txt --- --- ---

Page 10: Project Report

2008 (Works between July 1st, 2008 and June 30th, 2009) ALL.txt (contains names of all the other file in the folder).

001.txt (contains information of account holder & record of all the transactions made by the account holders).

002.txt 003.txt --- --- ---

--- ALL.txt --- ---

--- ALL.txt --- ---

TODAY MENU FILE (TDYMENU.txt)

It holds temporary item menu of canteen i.e. only for today.

PERMANENT MENU FILE (PERMENU.txt)

It holds permanent item menu of canteen.

NOTE: -

Page 11: Project Report

o Primary key for every student is his/her student number that must be correct at the time of making records.

o Primary key for faculty is his/her unique account number.

SOFTWARE REQUIREMENTS

Page 12: Project Report

Our project could run on a machine with the following minimum requirements: -

OPERATING SYSTEM: - DOS/WINDOWS(98/2000/XP)

FRONT END: - C++

BACK END: - FLAT FILES’ SYSTEM.

HARDWARE REQUIREMENTS

Our project could run on a machine with the following minimum requirements: -

PROCESSOR: - Pentium III or above.

RAM: - 64 MB or above.

HARD DISK DRIVE: - 20 GB.

Page 13: Project Report

SNAPSHOTS

Page 14: Project Report
Page 15: Project Report
Page 16: Project Report
Page 17: Project Report
Page 18: Project Report
Page 19: Project Report
Page 20: Project Report
Page 21: Project Report
Page 22: Project Report
Page 23: Project Report
Page 24: Project Report
Page 25: Project Report
Page 26: Project Report
Page 27: Project Report
Page 28: Project Report
Page 29: Project Report
Page 30: Project Report

PROJECT CODE

CANTEEN . CPP

/*HEADER FILE INCLUDE SECTION*/# include <fstream.h># include <stdio.h># include <conio.h># include <graphics.h># include <dos.h># include <process.h># include <dir.h># include <string.h># include <ctype.h># include <errno.h># include <stdlib.h>/*END OF HEADER FILE INCLUDE SECTION*/

/*INCLUDE SECTION OF RELATED FILES*/#include "c:\canteen\otherfun.cpp"#include "c:\canteen\classes.cpp"#include "c:\canteen\menu.cpp"#include "c:\canteen\trans.cpp"#include "c:\canteen\stufac.cpp"#include "c:\canteen\report.cpp"

///==============including or report file still remain

/*END OF INCLUDE SECTION OF RELATED FILES*/

/*MAIN FUNCTION STARTS*/void main() { clrscr(); gra(); introduction(); path2db d; char path[12]; clrscr(); ifstream ifile; A: ifile.open("c:\\path.txt"); if(!ifile)

Page 31: Project Report

{ ifile.close(); ofstream ofile; ofile.open("c:\\path.txt"); ofile.write((char*)&d,sizeof(d)); ofile.close(); goto A; } else { ifile.read((char*)&d,sizeof(d)); if(d.chngd==1)

{ ifile.close(); strcpy(path,d.path); }

else { cout<<"\n\n\n\t\tYOUR DATABASE IS GOING TO BE MADE IN '"<<d.path[0]<<"'

DRIVE"; cout<<"\n\n\n\n\t\tDO YOU WANT TO CHANGE THE DRIVE? "; char ch; cin>>ch; if(ch=='y'||ch=='Y') { cout<<"\n\n\n\n\t\tENTER THE NAME OF HARD DISK DRIVE AS 'C' or 'D':-"; char dir; cin>>dir; d.path[0]=dir; d.chngd=1; } else { d.chngd=1; } strcpy(path,d.path); ifile.close(); ofstream ofile; ofile.open("c:\\path.txt"); ofile.write((char*)&d,sizeof(d)); ofile.close(); }

} int chk=mkdir(path); if(chk==0 ||(chk==-1&&errno==EACCES)) { chdir(path); } else { cout<<"\n\n\n\n\t\t\tWRONG PATH."; getch(); exit(0); } int n; mm:

Page 32: Project Report

clrscr(); n=menumaker(m_m,infm_m,6); switch(n)

{ case 1: t_action(path); goto mm;

case 2: modstu(path); goto mm;

case 3: modfac(path); goto mm;

case 4: report(path); goto mm;

case 5: editmenu(path); goto mm;

case 6: exit(0); }

}

/*END OF MAIN FUNCTION*/

Page 33: Project Report

CLASS.CPP

// for classes

class path2db { public:

char path[12]; int chngd; path2db() { strcpy(path,"c:\\database"); chngd=0; } };//=======================================student class======================

class student { char name[30]; char stno[8]; char brnch[20]; char sec; int bal; dosdate_t ldt; void setpw(char*);

public: student(); void getdata(); void putdata(); dosdate_t getldt(); void chngbal(int); void chngldt(dosdate_t); int getbal(); char* getstno(); };

student :: student() { strcpy(name,""); strcpy(stno,"0000000"); strcpy(brnch,""); sec=' '; bal=0; _dos_getdate(&ldt); }

void student :: getdata() {

Page 34: Project Report

cout<<"\n\n\t\t\tENTER NAME:-"; gets(name); cout<<"\n\t\t\tENTER STUDENT NO.:-"; cin>>stno; cout<<"\n\t\t\tENTER BRANCH:-"; gets(brnch); cout<<"\n\t\t\tENTER SECTION:-"; cin>>sec; }

void student :: putdata() { clrscr(); cout<<"\n\n\n\t\t\tNAME :--"<<name; cout<<"\n\n\t\t\tSTUDENT NO. :--"<<stno; cout<<"\n\n\t\t\tBRANCH :--"<<brnch; cout<<"\n\n\t\t\tSECTION:--"<<sec; cout<<"\n\n\t\t\tAMOUNT BALANCED:--"<<bal; cout<<"\n\n\t\t\tLAST DATE OF PAYMENT:--"; showdat(ldt); }

dosdate_t student :: getldt() { return(ldt); }

int student::getbal() { return bal; }

void student :: chngbal(int a) { bal=a; }

char* student :: getstno() { return(stno); }

void student :: chngldt(dosdate_t d) { ldt=d; }

//==================================end of student cls======================

//====================================FACULTY==============================class faculty { char name[30]; char deptt[20]; char accno[8];

Page 35: Project Report

int bal; dosdate_t ldt; void setpw(char*);

public: faculty(); void getdata(); void putdata(); dosdate_t getldt(); void chngbal(int a); void chngldt(dosdate_t); int getbal(); char* getaccno(); };

faculty :: faculty() { strcpy(name,""); strcpy(accno,"0000000"); strcpy(deptt,""); bal=0; _dos_getdate(&ldt); }

void faculty :: getdata() { cout<<"\n\n\t\t\tENTER NAME:-"; gets(name); cout<<"\n\t\t\tENTER ACCOUNT NO.:-"; cin>>accno; cout<<"\n\t\t\tENTER DEPTT.:-"; gets(deptt); }

void faculty :: putdata() { cout<<"\n\n\t\t\tNAME :--"<<name; cout<<"\n\n\t\t\tACCOUNT NO. :--"<<accno; cout<<"\n\n\t\t\tDEPARTMENT :--"<<deptt; cout<<"\n\n\t\t\tAMOUNT BALANCED:--"<<bal; cout<<"\n\n\t\t\tLAST DATE OF PAYMENT:--"; showdat(ldt); }

dosdate_t faculty :: getldt() { return(ldt); }

int faculty::getbal() { return bal; }

void faculty :: chngbal(int a) {

Page 36: Project Report

bal=a; }char* faculty :: getaccno() { return(accno); }

void faculty :: chngldt(dosdate_t d) { ldt=d; }//====================================class item { char itmnm[30]; int price;

public: void getdata(); void putdata(); char* getitmnm(); int getprc(); };

void item :: getdata() { cout<<"\n\n\t\t\tENTER NAME:-"; gets(itmnm); cout<<"\n\n\t\t\tENTER RATE PER PIECE:-"; cin>>price; }

void item :: putdata() { cout<<itmnm<<"\t\t"<<price; }

char* item :: getitmnm() { return(itmnm); }

int item :: getprc() { return(price); }//=================================================//=================================================class dlytrans { int amt; dosdate_t date; char borp;

public: void getdata(int,char);

Page 37: Project Report

dosdate_t getdate(); void putdata(); void showdate(dosdate_t date); void dateput1(); void dowput1(); void monput1(); void dateputA(char *); void dowputA(char *); void monputA(char *,int); void hyputA(char *,int); void fyputA(char *,int); char getborp(); int getamt(); };

void dlytrans :: showdate(dosdate_t date) { cout<<(int)date.day<<"/"<<(int)date.month<<"/"<<date.year; }

void dlytrans :: getdata(int a,char ch) { amt=a; borp=ch; _dos_getdate(&date); }

dosdate_t dlytrans :: getdate() { return(date); }

void dlytrans :: putdata() { cout<<amt; showdate(date); cout<<borp; }

void dlytrans :: dateput1() { showdate(date); cout<<"\t\t"; dow(date.dayofweek); cout<<"\t\t"; if(borp=='p') { cout<<"PAY"; } if(borp=='b') { cout<<"BUY"; } cout<<"\t\t\t"; cout<<amt; }

Page 38: Project Report

void dlytrans :: dowput1() { dow(date.dayofweek); cout<<"\t\t"; showdate(date); cout<<"\t\t"; if(borp=='p') { cout<<"PAY"; } if(borp=='b') { cout<<"BUY"; } cout<<"\t\t\t"; cout<<amt; }

void dlytrans :: monput1() { moy(date.month); cout<<"\t\t"; showdate(date); cout<<"\t\t"; if(borp=='p') { cout<<"PAY"; } if(borp=='b') { cout<<"BUY"; } cout<<"\t\t\t"; cout<<amt; }

void dlytrans :: dateputA(char *stno) { cout<<stno; cout<<"\t\t"; showdate(date); cout<<"\t"; dow(date.dayofweek); cout<<"\t"; if(borp=='p') { cout<<"PAY"; } if(borp=='b') { cout<<"BUY"; } cout<<"\t"; cout<<amt; }

Page 39: Project Report

void dlytrans :: dowputA(char *stno) { cout<<stno; cout<<"\t\t"; dow(date.dayofweek); cout<<"\t\t"; showdate(date); cout<<"\t"; if(borp=='p') { cout<<"PAY"; } if(borp=='b') { cout<<"BUY"; } cout<<"\t"; cout<<amt; }

void dlytrans :: monputA(char *no,int mon) { if(amt==0) { return; } cout<<"\n"; cout<<no; cout<<"\t\t"; moy(mon); cout<<"\t\t"; if(borp=='p') { cout<<"PAY"; } if(borp=='b') { cout<<"BUY"; } cout<<"\t\t\t"; cout<<amt; }

void dlytrans :: hyputA(char *no,int hy) { if(amt==0||hy>2||hy<1) { return; } cout<<"\n"; cout<<no; cout<<"\t\t"; cout<<hy; cout<<"\t\t";

Page 40: Project Report

if(borp=='p') { cout<<"PAY"; } if(borp=='b') { cout<<"BUY"; } cout<<"\t\t\t"; cout<<amt; }

void dlytrans :: fyputA(char *no,int y) { if(amt==0) { return; } cout<<"\n"; cout<<no; cout<<"\t\t"; cout<<y; cout<<"\t\t"; if(borp=='p') { cout<<"PAY"; } if(borp=='b') { cout<<"BUY"; } cout<<"\t\t\t"; cout<<amt; }

char dlytrans :: getborp() { return(borp); }

int dlytrans :: getamt() { return(amt); }

//=================================================class allah { public: char accnm[12]; void getdata(char *); char *putdata(); };

void allah :: getdata(char *nm) {

Page 41: Project Report

strcpy(accnm,nm); }

char *allah :: putdata() { return(accnm); }//==============================================

Page 42: Project Report

CLASS.CPP

// for menu function

//============================item related functions=======================

int dispmenu(char *path) { int i=1; ifstream ifile; ifile.open(path,ios::binary); if(!ifile) { ifile.close(); cout<<"\n\n\n\n\t\t\t\tNO ITEM IN MENU."; getch(); return 0; } item itm; cout<<"\n\n\nITEM\t\t\tPRICE"; cout<<endl; ifile.read((char*)&itm,sizeof(itm)); while(!ifile.eof())

{ cout<<"\n"<<i<<"."; itm.putdata(); cout<<endl; i++; ifile.read((char*)&itm,sizeof(itm)); }

ifile.close(); getch(); return i; }

void addnew(char *path) { clrscr(); ofstream ofile; char ch='y'; ofile.open(path,ios::ate|ios::binary); item itm; while(ch=='y'||ch=='Y')

{ itm.getdata(); ofile.write((char *)&itm,sizeof(itm)); cout<<"Want to enter more items(Y/N)"; cin>>ch; }

ofile.close();

Page 43: Project Report

}

void deletitm(char *path) { clrscr(); int f=0; char tpath[24]; strncpy(tpath,path,12); tpath[12]='\0'; strcat(tpath,"temp.txt"); ifstream ifile; ifile.open(path,ios::binary); if(!ifile) { ifile.close(); cout<<"NO item in menu"; getch(); return; } else { char inm[20]; item itm; cout<<"\n\t\tENTER ITEM YOU WANT TO DELETE:- "; gets(inm); ofstream ofile; ofile.open(tpath,ios::binary); ifile.read((char*)&itm,sizeof(itm)); while(!ifile.eof())

{ if(strcmpi(inm,itm.getitmnm())) { ofile.write((char*)&itm,sizeof(itm)); ifile.read((char*)&itm,sizeof(itm)); } else { f=1; ifile.read((char*)&itm,sizeof(itm)); } }

if(!f) { cout<<"\n\nENTERED ITEM NOT FOUND."; getch(); }

else { cout<<"\n\nITEM DELETED."; getch(); }

ifile.close(); ofile.close(); remove(path); rename(tpath,path); }

Page 44: Project Report

}

void moditm(char *path) { ifstream ifile; clrscr(); ifile.open(path,ios::binary); if(!ifile) { ifile.close(); cout<<"NO item in menu"; getch(); return; } else { char inm[20]; item itm; int f=0,pos; cout<<"\nENTER ITEM YOU WANT TO MODIFY:- "; gets(inm); ifile.read((char*)&itm,sizeof(itm)); while(!ifile.eof())

{ if(strcmpi(inm,itm.getitmnm())) { ifile.read((char*)&itm,sizeof(itm)); } else { pos=ifile.tellg(); f=1; break; } }

ifile.close(); if(f)

{ pos=pos-sizeof(itm); ofstream ofile; ofile.open(path,ios::ate|ios::binary); itm.getdata(); ofile.seekp(pos,ios::beg); ofile.write((char*)&itm,sizeof(itm)); ofile.close(); }

else { cout<<"\nITEM NOT FOUND"; getch(); }

} }

void addtmp(char *path) {

Page 45: Project Report

clrscr(); item itm; char ch; char ppath[24]; char tpath[24]; strcpy(ppath,path); strcpy(tpath,path); strcat(ppath,"\\permenu.txt"); strcat(tpath,"\\tdymenu.txt"); ifstream ifile; ofstream ofile; ifile.open(ppath,ios::binary); if(!ifile) { cout<<"PERMANENT MENU DOES NOT EXIST."; cout<<"MAKE IT FIRST"; getch(); return; } ofile.open(tpath,ios::ate|ios::binary); cout<<"\n\nPRESS 'Y' TO ADD ITEM IN TODAY'S MENU."; ifile.read((char *)&itm,sizeof(itm)); while(!ifile.eof())

{ cout<<"\n"; itm.putdata(); ch=getch(); if(ch=='y'||ch=='Y') { ofile.write((char*)&itm,sizeof(itm)); } ifile.read((char *)&itm,sizeof(itm)); }

ifile.close(); ofile.close(); }

void edittm(char *path) { char path1[24]; strcpy(path1,path); strcat(path1,"\\tdymenu.txt"); clrscr(); int n=menumaker(t_itm,inft_itm,4); switch(n)

{ case 1: addtmp(path); break;

case 2: deletitm(path1); break;

case 3: clrscr();

Page 46: Project Report

dispmenu(path1); break;

case 4: break; }

}

void editpm(char *path) { char path1[24]; strcpy(path1,path); strcat(path1,"\\permenu.txt"); clrscr(); int n=menumaker(p_itm,infp_itm,5); switch(n)

{ case 1: addnew(path1); break;

case 2: deletitm(path1); break;

case 3: moditm(path1); break;

case 4: clrscr(); dispmenu(path1); break;

case 5: break; }

}

void editmenu(char *path) { em: clrscr(); int n=menumaker(itm,infitm,3); switch(n)

{ case 1: edittm(path); goto em;

case 2: editpm(path); goto em; }

}

Page 47: Project Report

//==========================end of item related functions===================

OTHERFUN.CPP

//for other important functions

char* m_m[6]={ "TRANSCATIONS", "STUDENT DATABASE", "FACULTY DATABASE", "REPORT GENERATION", "MENU OF CANTEEN", "EXIT" };

char* infm_m[6]={ "To Do Transaction.......", "To Edit Student Database.......", "To Edit Faculty Database.......", "To Generate Reports.......", "To Edit Menu of Canteen.......", "To Exit From Application......." };

char* t_m[3]={ "STUDENT", "FACULTY", "BACK TO MAIN MAENU" };

char* inft_m[3]={ "When Transaction is Made By Student.......", "When Transaction is Made By Faculty.......", "Go Back To Main Menu......." };

char* t_sf_m[2]={ "BUYS", "PAYS" };

char* inft_sf_m[2]={ "If Account Holder Buys.......", "If Account Holder Pays......." };

char* sf_m[5]={ "SEARCH ANY ACCOUNT", "OPEN NEW ACCOUNT", "DELETE AN ACCOUNT", "MODIFY AN ACCOUNT",

Page 48: Project Report

"BACK TO MAIN MENU" };

char* infsf_m[5]={ "To Search A Particular Record.......", "To Open New Account.......", "To Delete An Existing Account.......", "To Modify An Account.......", "Go Back To Main Menu......." };

char* itm[3]={ "TODAY'S MENU", "PERMANENT MENU", "BACK TO MAIN MENU" };

char* infitm[3]={"To Edit Today's Menu.......","To Edit Permanent Menu.......","Go Back To Main Menu......."};

char* t_itm[4]={ "ADD NEW ITEM", "DELETE ITEM", "DISPLAY MENU", "BACK TO PREVIOUS MENU" };

char* inft_itm[4]={ "To Add New Item.......", "To Delete An Item.......", "To Display Complete Menu.......", "Go Back To Last Menu......." };

char* p_itm[5]={ "ADD NEW ITEM", "DELETE ITEM", "MODIFY ITEM", "DISPLAY MENU", "BACK TO PREVIOUS MENU" };

char* infp_itm[5]={ "To Add New Item.......", "To Delete An Item.......", "To Modify An Existing Item.......", "To Display Complete Menu.......", "Go Back To Last Menu......." };

char *r_m[5]={ "FOR ONE STUDENT", "FOR ALL STUDENTS",

Page 49: Project Report

"FOR ONE FACULTY", "FOR ALL FACULTIES", "BACK TO MAIN MENU" };

char *infr_m[5]={ "To Generate Report For One Student", "To Generate Report For All Students", "To Generate Report For One Faculty", "To Generate Report For All Faculties", "GO Back To Main Menu" };

char *r_sm[6]={ "FOR A PARTICULAR DAY", "FOR A DAY OF WEEK", "FOR A MONTH", "FOR A HALF YEAR", "FOR A YEAR", "BACK TO MAIN MENU" };

char *infr_sm[6]={ "To Generate Report For A Day", "To Generate Report For A Day Of Week", "To Generate Report For A Month", "To Generate Report For A Half Year", "To Generate Report For A Year", "GO Back To Main Menu" };

dosdate_t refdat={char(1),(char)7,1980,(char)0};

int datecomp(dosdate_t d1,dosdate_t d2) { if((int)d1.month<(int)d2.month) { return -1; } else { return 1; } }

int datcomp4t(dosdate_t d1/*currentdate*/,dosdate_t d2/*ldt in record*/,int days) { //return 0 whn d1-d2>31days other wise 1; int day1,day2,remday; day1=(d1.year-1980)*365+(int)d1.month*30+(int)d1.day; day2=(d2.year-1980)*365+(int)d2.month*30+(int)d2.day; remday=day1-day2; if(remday>days) { return 0;

Page 50: Project Report

} else { return 1; } }

dosdate_t takedate() { int i; dosdate_t d; cout<<"\nENTER day"; cin>>i; d.day=(char)i; cout<<"\nENTER MONTH"; cin>>i; d.month=(char)i; cout<<"\nENTER YEAR"; cin>>d.year; d.dayofweek=0; return(d); }

int datecmp(dosdate_t dt1,dosdate_t dt2) { if(dt1.day==dt2.day && dt1.month==dt2.month && dt1.year==dt2.year) { return 0; } else if(dt1.year>dt2.year) { return 1; } else if(dt1.year==dt2.year && dt1.month>dt2.month && dt1.month<=12) { return 1; } else if(dt1.year==dt2.year && dt1.month==dt2.month && dt1.day>dt2.day && dt1.day<=31) { return 1; } else { return (-1); } }

void mkmenu(char *menu[],char*info[],int n,int index=0) { int i; clrscr(); cout<<"\n\t\t\tUSE UP AND DOWN ARROW KEYS TO SELECT ITEM"; cout<<"\n\t\t\t-----------------OR----------------------";

Page 51: Project Report

cout<<"\n\t\t\tPRESS INDEX NUMBER OF OPTION\n\n"; for(i=0;i<n;i++)

{cout<<"\n\t\t";if(i==index) { cout<<"===>>>\t"; cout<<i+1<<"."<<menu[i]; }else { cout<<"\t"; cout<<i+1<<"."<<menu[i]; }}

gotoxy(20,18); cout<<info[index]; }

int menumaker(char*menu[],char*info[],int n) { char ch[2]; int count=0; mkmenu(menu,info,n); while(1)

{ ch[0]=getch(); if(ch[0]!=0) { if(ch[0]>='1' && ch[0]<=(char)(n+48)) { return((int)(ch[0]-48)); } return (count+1); } ch[1]=getch(); if(ch[1]=='H') { if(count==0) { count=n-1; mkmenu(menu,info,n,count); continue; } count-=1; mkmenu(menu,info,n,count); } if(ch[1]=='P') { if(count==n-1) { count=0; mkmenu(menu,info,n,count); continue; } count+=1;

Page 52: Project Report

mkmenu(menu,info,n,count); } }

}

void dow(int n) { if(n==0) { cout<<"SUNDAY"; }

else if(n==1) { cout<<"MONDAY"; }

else if(n==2) { cout<<"TUESDAY"; }

else if(n==3) { cout<<"WEDNESDAY"; }

else if(n==4) { cout<<"THRUSDAY"; }

else if(n==5) { cout<<"FRIDAY"; }

else if(n==6) { cout<<"SATURDAY"; }

else; }

void moy(int n) { if(n==1) { cout<<"JANUARY"; }

else if(n==2) { cout<<"FEBRUARY"; }

Page 53: Project Report

else if(n==3) { cout<<"MARCH"; }

else if(n==4) { cout<<"APRIL"; }

else if(n==5) { cout<<"MAY"; }

else if(n==6) { cout<<"JUNE"; }

else if(n==7) { cout<<"JULY"; }

else if(n==8) { cout<<"AUGUST"; }

else if(n==9) { cout<<"SEPTEMBER"; }

else if(n==10) { cout<<"OCTOBER"; }

else if(n==11) { cout<<"NOVEMBER"; }

else if(n==12) { cout<<"DECEMBER"; }

else; }

void showdat(dosdate_t date) { cout<<(int)date.day<<"/"<<(int)date.month<<"/"<<date.year;

Page 54: Project Report

cout<<"\n\t\t\tDAY OF WEEK IS:--"<<(int)date.dayofweek<<"\n"; }

void gra() { int gd=0,gm=0,j,i,k; initgraph(&gd,&gm,"c:\\tc\\bgi"); cleardevice(); for(i=0;i<=4;i++)

{setcolor(14);setlinestyle(2,1,1);rectangle(20+20*i,20+20*i,620-20*i,450-20*i);}

setcolor(10); settextstyle(7,0,4); outtextxy(120,130,"CANTEEN MANAGEMENT"); outtextxy(265,180,"AND"); outtextxy(125,230,"REPORT GENERATION"); outtextxy(255,280,"SYSTEM"); getch(); cleardevice(); settextstyle(4,0,8); setcolor(14); outtextxy(110,80,"WELCOME"); settextstyle(3,0,1); setcolor(4); outtextxy(50,250,"PROJECT BY-"); settextstyle(1,0,2); setcolor(10); outtextxy(50,300,"1. PULIN KUMAR (St. No.-0510075)"); outtextxy(50,330,"2. PRACHI SRIVASTAVA (St. No.-0510069)"); outtextxy(50,360,"3. RASHI VERMA (St. No.-0510018)"); outtextxy(50,390,"4. ANNIE PACHNANDA (St. No.-0510109)"); getch(); closegraph(); delay(1000); clrscr(); }

void introduction(void) { clrscr(); int col=1; textcolor(15); gotoxy(24,2); cprintf("CANTEEN MANAGEMENT SYSTEM"); gotoxy(24,3); cprintf("--------------------------"); gotoxy(15,5); cprintf("This project ,Canteen Management ,is aimed at "); gotoxy(15,6); cprintf("maintanance of account running in canteen. It "); gotoxy(15,7); cprintf("handles all the transactions. It is also capable"); gotoxy(15,8);

Page 55: Project Report

cprintf("of generating reports for different requirements. "); gotoxy(15,10); cprintf("Rules and Regulations"); gotoxy(15,11); cprintf("1. Student No. or Account No. must be right."); gotoxy(15,12); cprintf("2. System date must be correct."); gotoxy(3,17); cprintf("Developed By:"); gotoxy(3,18); cprintf("1. PULIN KUMAR (St. No.-0510075)"); gotoxy(3,19); cprintf("2. PRACHI SRIVASTAVA (St. No.-0510069)"); gotoxy(3,20); cprintf("3. RASHI VERMA (St. No.-0510018)"); gotoxy(3,21); cprintf("4. ANNIE PACHNANDA (St. No.-0510109)"); textcolor(4); gotoxy(20,22);

do { if (col==1) col=0; else col=1; delay(500);

for (int i=1;i<=40;i++) {

if (col==1)if (i%2==0)

textcolor(4);else

textcolor(14); else

if (i%2==0)textcolor(14);

elsetextcolor(4);

gotoxy((2*i)-1,1); cprintf("*"); gotoxy((2*i)-1,23); cprintf("*"); } for (int j=2;j<24;j++) { if (col==1)

if (j%2==0)textcolor(4);

elsetextcolor(14);

elseif (j%2==0)

Page 56: Project Report

textcolor(14);else

textcolor(4);

gotoxy(1,j); cprintf("*");

if (col==1)if (j%2==0)

textcolor(14);else

textcolor(4); else

if (j%2==0)textcolor(4);

elsetextcolor(14);

gotoxy(79,j); cprintf("*"); } } while (!kbhit()); getch(); textcolor(15);

}

Page 57: Project Report

REPORT.CPP

void ones(char *path,char *year) { cout<<"\n\nENTER STUDENT NO.:--"; char* stno; cin>>stno; char *path1; strcpy(path1,path); strcat(path1,"\\student\\"); strcat(path1,year); strcat(path1,"\\"); strcat(path1,stno); strcat(path1,".txt"); dosdate_t date; ifstream ifile; ifile.open(path1,ios::binary); if(!ifile) { ifile.close(); clrscr(); cout<<"\n\n\n\t\t\tRECORD DOES NOT EXIST"; getch(); return; } else { ifile.close(); dlytrans dtrans; int f=0; int n1=menumaker(r_sm,infr_sm,6); switch(n1)

{ case 1: cout<<"\nENTER DATE:-\n"; date=takedate(); ifile.open(path1,ios::binary); ifile.seekg(sizeof(student),ios::beg); clrscr(); cout<<"\n\n\n\n\t\t\tFOR STUDENT NO.-"<<stno; cout<<"\n\n\n\nDATE\t\t\tDAY\t\t\tMODE\t\t\tAMOUNT"; ifile.read((char *)&dtrans,sizeof(dtrans)); while(!ifile.eof())

{ if(!datecmp(date,dtrans.getdate())) { cout<<endl<<endl;

Page 58: Project Report

dtrans.dateput1();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans)); }

ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 2: cout<<"\n\nENTER 0 FOR SUNDAY AND 6 FOR SATURDAY:-"; int day; cin>>day; ifile.open(path1,ios::binary); ifile.seekg(sizeof(student),ios::beg); clrscr(); cout<<"\n\n\n\n\t\t\tFOR STUDENT NO.-"<<stno; cout<<"\n\n\n\nDAY\t\tDATE\t\t\tMODE\t\t\tAMOUNT"; ifile.read((char *)&dtrans,sizeof(dtrans)); while(!ifile.eof())

{ date=dtrans.getdate(); if((int)date.dayofweek==day) { cout<<endl; dtrans.dowput1();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans)); }

ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 3: cout<<"\n\nENTER MONTH:- "; int mon; cin>>mon; ifile.open(path1,ios::binary); ifile.seekg(sizeof(student),ios::beg); clrscr(); cout<<"\n\n\n\n\t\t\tFOR STUDENT NO.-"<<stno; cout<<"\n\n\n\nMONTH\t\tDATE\t\t\tMODE\t\t\tAMOUNT"; ifile.read((char *)&dtrans,sizeof(dtrans)); while(!ifile.eof())

{ date=dtrans.getdate(); if(date.month==mon)

Page 59: Project Report

{ cout<<endl; dtrans.monput1();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans)); }

ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 4: cout<<"\n\nWHICH HALF OF YEAR(1st OR 2nd):- "; int hy; cin>>hy; _dos_getdate(&date); if(date.month>=7&&date.month<=12 &&hy==1 &&date.year==atoi(year)) { cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } if(date.month>=7&&date.month<=12 &&hy==2 &&date.year==atoi(year)) { cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } if(date.month>=1&&date.month<=6 &&hy==2 &&date.year==atoi(year)) { cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } ifile.open(path1,ios::binary); ifile.seekg(sizeof(student),ios::beg); clrscr(); cout<<"\n\n\n\n\t\t\tFOR STUDENT NO.-"<<stno; cout<<"\n\n\n\nMONTH\t\tDATE\t\t\tMODE\t\t\tAMOUNT"; ifile.read((char *)&dtrans,sizeof(dtrans)); while(!ifile.eof())

{ date=dtrans.getdate(); if(hy==1) { if(date.month>=7 && date.month<=12) { cout<<endl; dtrans.monput1();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans));

Page 60: Project Report

} else if(hy==2) { if(date.month>=1 && date.month<=6) { cout<<endl; dtrans.monput1();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans)); } else { cout<<"WRONG ENTRY FOR HALF YEAR"; } }

ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 5: _dos_getdate(&date); int y=atoi(year); if(y==date.year||(date.year==y+1 && date.month<7)||y>date.year) { ifile.close(); cout<<"REPORT GENERATION IS NOT POSSIBLE"; getch(); return; } ifile.open(path1,ios::binary); ifile.seekg(sizeof(student),ios::beg); clrscr(); cout<<"\n\n\n\n\t\t\tFOR STUDENT NO.-"<<stno; cout<<"\n\n\n\nMONTH\t\tDATE\t\t\tMODE\t\t\tAMOUNT\n"; ifile.read((char *)&dtrans,sizeof(dtrans)); while(!ifile.eof())

{ date=dtrans.getdate(); if(date.year==y) { cout<<"\n"; dtrans.putdata();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans)); }

if(!f) { cout<<"\n NO RECORD TO SHOW"; } ifile.close();

Page 61: Project Report

if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 6: break; }

} }

void onef(char *path,char *year) { cout<<"\n\nENTER ACCOUNT NO.:--"; char* accno; cin>>accno; char *path1; strcpy(path1,path); strcat(path1,"\\faculty\\"); strcat(path1,year); strcat(path1,"\\"); strcat(path1,accno); strcat(path1,".txt"); dosdate_t date; ifstream ifile; ifile.open(path1,ios::binary); if(!ifile) { ifile.close(); cout<<"\n\n\n\t\t\tRECORD DOES NOT EXIST."; getch(); return; } else { ifile.close(); dlytrans dtrans; int f=0; int n1=menumaker(r_sm,infr_sm,6); switch(n1)

{ case 1: cout<<"\n\nENTER DATE:-\n"; date=takedate(); ifile.open(path1,ios::binary); ifile.seekg(sizeof(faculty),ios::beg); clrscr(); cout<<"\n\n\n\n\t\t\tFOR ACCOUNT NO.-"<<accno; cout<<"\n\n\n\nDATE\t\t\tDAY\t\t\tMODE\t\t\tAMOUNT"; ifile.read((char *)&dtrans,sizeof(dtrans)); while(!ifile.eof())

{ if(!datecmp(date,dtrans.getdate())) {

Page 62: Project Report

cout<<endl<<endl; dtrans.dateput1();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans)); }

ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 2: cout<<"\n\nENTER 0 FOR SUNDAY AND 6 FOR SATURDAY:- "; int day; cin>>day; ifile.open(path1,ios::binary); ifile.seekg(sizeof(faculty),ios::beg); clrscr(); cout<<"\n\n\n\n\t\t\tFOR ACCOUNT NO.-"<<accno; cout<<"\n\n\n\nDAY\t\tDATE\t\t\tMODE\t\t\tAMOUNT"; ifile.read((char *)&dtrans,sizeof(dtrans)); while(!ifile.eof())

{ date=dtrans.getdate(); if((int)date.dayofweek==day) { cout<<endl; dtrans.dowput1();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans)); }

ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 3: cout<<"\n\nENTER MONTH:- "; int mon; cin>>mon; ifile.open(path1,ios::binary); clrscr(); cout<<"\n\n\n\n\t\t\tFOR ACCOUNT NO.-"<<accno; cout<<"\n\n\n\nMONTH\t\tDATE\t\t\tMODE\t\t\tAMOUNT"; ifile.seekg(sizeof(faculty),ios::beg); ifile.read((char *)&dtrans,sizeof(dtrans)); while(!ifile.eof())

{ date=dtrans.getdate();

Page 63: Project Report

if((int)date.month==mon) { cout<<endl; dtrans.monput1();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans)); }

ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 4: cout<<"\n\nWHICH HALF OF YEAR (1st or 2nd):- "; int hy; cin>>hy; _dos_getdate(&date); if(date.month>=7&&date.month<=12 &&hy==1 &&date.year==atoi(year)) { cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } if(date.month>=7&&date.month<=12 &&hy==2 &&date.year==atoi(year)) { cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } if(date.month>=1&&date.month<=6 &&hy==2 &&date.year==atoi(year)) { cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } ifile.open(path1,ios::binary); ifile.seekg(sizeof(faculty),ios::beg); clrscr(); cout<<"\n\n\n\n\t\t\tFOR ACCOUNT NO.-"<<accno; cout<<"\n\n\n\nMONTH\t\tDATE\t\t\tMODE\t\t\tAMOUNT"; ifile.read((char *)&dtrans,sizeof(dtrans)); while(!ifile.eof())

{ date=dtrans.getdate(); if(hy==1) { if(date.month>=7 && date.month<=12) { cout<<endl; dtrans.monput1();//for one day putdata f=1; }

Page 64: Project Report

ifile.read((char *)&dtrans,sizeof(dtrans)); } else if(hy==2) { if(date.month>=1 && date.month<=6) { cout<<endl; dtrans.monput1();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans)); } else { cout<<"WRONG ENTRY FOR HALF YEAR"; } }

ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 5://for a year _dos_getdate(&date); int y=atoi(year); if(y==date.year||(date.year==y+1 && date.month<7)||y>date.year) { ifile.close(); cout<<"REPORT GENERATION IS NOT POSSIBLE"; getch(); return; } ifile.open(path1,ios::binary); ifile.seekg(sizeof(faculty),ios::beg); clrscr(); cout<<"\n\n\n\n\t\t\tFOR ACCOUNT NO.-"<<accno; cout<<"\n\n\n\nMONTH\t\tDATE\t\t\tMODE\t\t\tAMOUNT\n"; ifile.read((char *)&dtrans,sizeof(dtrans)); while(!ifile.eof())

{ date=dtrans.getdate(); if(date.year==y) { cout<<endl; dtrans.monput1();//for one day putdata f=1; } ifile.read((char *)&dtrans,sizeof(dtrans)); }

ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW.";

Page 65: Project Report

} getch(); break;

case 6: break; }

} }

void alls(char *path,char *year) { char *path1,*ipath,*fpath,*stno; strcpy(path1,path); strcat(path1,"\\student\\"); strcat(path1,year); strcat(path1,"\\"); strcpy(ipath,path1); strcat(path1,"all.txt"); allah a; dosdate_t date; ifstream ifile,ifile1; ifile.open(path1,ios::binary); if(!ifile || ifile.eof()) { ifile.close(); cout<<"\n\nRECORDS DOES NOT EXIST."; getch(); return; } else { int f=0; dlytrans dtrans; int n=menumaker(r_sm,infr_sm,6); switch(n)

{ case 1: cout<<"\n\nENTER DATE:-\n"; date=takedate(); clrscr(); cout<<"\t\t\tPRESS ENTER FOR NEXT RECORD"; cout<<"\n\n\n\nSTUDENT NO.\tDATE\t\tDAY\tMODE\tAMOUNT\n"; ifile.read((char *)&a,sizeof(a)); while(!ifile.eof()) { strcpy(fpath,ipath); strcat(fpath,a.accnm); stno=strtok(a.accnm,"."); ifile1.open(fpath,ios::binary); ifile1.seekg(sizeof(student),ios::beg); ifile1.read((char *)&dtrans,sizeof(dtrans)); while(!ifile1.eof())

{ if(!datecmp(date,dtrans.getdate())) {

Page 66: Project Report

cout<<"\n"; dtrans.dateputA(stno);//for all, one day putdata f=1; } ifile1.read((char *)&dtrans,sizeof(dtrans)); }

ifile1.close(); getch(); cout<<endl; ifile.read((char *)&a,sizeof(a)); } ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 2: cout<<"\n\nENTER 0 FOR SUNDAY AND 6 FOR SATURDAY:- "; int day; cin>>day; clrscr(); cout<<"\t\t\tPRESS ENTER FOR NEXT RECORD"; cout<<"\n\n\n\nSTUDENT NO.\tDAY\t\tDATE\t\tMODE\tAMOUNT\n"; ifile.read((char *)&a,sizeof(a)); while(!ifile.eof()) { strcpy(fpath,ipath); strcat(fpath,a.accnm); stno=strtok(a.accnm,"."); ifile1.open(fpath,ios::binary); ifile1.seekg(sizeof(student),ios::beg); ifile1.read((char *)&dtrans,sizeof(dtrans)); while(!ifile1.eof())

{ date=dtrans.getdate(); if((int)date.dayofweek==day) { cout<<"\n"; dtrans.dowputA(stno);//for one day putdata f=1; } ifile1.read((char *)&dtrans,sizeof(dtrans)); }

ifile1.close(); getch(); cout<<endl; ifile.read((char *)&a,sizeof(a)); } ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; }

Page 67: Project Report

getch(); break;

case 3: cout<<"\n\nENTER MONTH:- "; int mon,amtp=0,amtb=0; cin>>mon; clrscr(); cout<<"\t\t\tPRESS ENTER FOR NEXT RECORD"; cout<<"\n\n\n\nSTUDENT NO.\tMONTH\t\tMODE\t\tTOTAL AMOUNT\n"; ifile.read((char *)&a,sizeof(a)); while(!ifile.eof()) { strcpy(fpath,ipath); strcat(fpath,a.accnm); stno=strtok(a.accnm,"."); ifile1.open(fpath,ios::binary); ifile1.seekg(sizeof(student),ios::beg); ifile1.read((char *)&dtrans,sizeof(dtrans)); while(!ifile1.eof())

{ date=dtrans.getdate(); if((int)date.month==mon) { if(dtrans.getborp()=='p') { amtp+=dtrans.getamt(); } else { amtb+=dtrans.getamt(); } } ifile1.read((char *)&dtrans,sizeof(dtrans)); }

ifile1.close(); dtrans.getdata(amtb,'b'); dtrans.monputA(stno,mon);//for one day putdata dtrans.getdata(amtp,'p'); dtrans.monputA(stno,mon); amtb=amtp=0; getch(); cout<<endl; ifile.read((char *)&a,sizeof(a)); } getch(); ifile.close(); break;

case 4: cout<<"\n\nWHICH HALF OF YEAR (1st or 2nd):- "; int hy; cin>>hy; int amtB=0,amtP=0; _dos_getdate(&date); if(date.month>=7&&date.month<=12 &&hy==1 &&date.year==atoi(year))

Page 68: Project Report

{ ifile.close(); cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } if(date.month>=7&&date.month<=12 &&hy==2 &&date.year==atoi(year)) { ifile.close(); cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } if(date.month>=1&&date.month<=6 &&hy==2 &&date.year==atoi(year)) { ifile.close(); cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } clrscr(); cout<<"\t\t\tPRESS ENTER FOR NEXT RECORD"; cout<<"\n\n\n\nSTUDENT NO.\tHALF YEAR\tMODE\t\t\tTOTAL AMOUNT\n"; ifile.read((char *)&a,sizeof(a)); while(!ifile.eof())

{ strcpy(fpath,ipath); strcat(fpath,a.accnm); stno=strtok(a.accnm,"."); ifile1.open(fpath,ios::binary); ifile1.seekg(sizeof(student),ios::beg); ifile1.read((char *)&dtrans,sizeof(dtrans)); while(!ifile1.eof()) { date=dtrans.getdate(); if(hy==1) { if(date.month>=7 && date.month<=12) { if(dtrans.getborp()=='p') { amtP+=dtrans.getamt(); } if(dtrans.getborp()=='b') { amtB+=dtrans.getamt(); } } ifile1.read((char *)&dtrans,sizeof(dtrans)); }

else if(hy==2) { if(date.month>=1 && date.month<=6) { if(dtrans.getborp()=='p')

Page 69: Project Report

{ amtP+=dtrans.getamt(); } if(dtrans.getborp()=='b') { amtB+=dtrans.getamt(); } } ifile1.read((char *)&dtrans,sizeof(dtrans)); } else { cout<<"WRONG ENTRY FOR HALF YEAR"; } } ifile1.close(); dtrans.getdata(amtB,'b'); dtrans.hyputA(stno,hy);//for one day putdata dtrans.getdata(amtP,'p'); dtrans.hyputA(stno,hy); amtB=amtP=0; getch(); cout<<endl; ifile.read((char *)&a,sizeof(a)); }

ifile.close(); getch(); break;

case 5: _dos_getdate(&date); int y=atoi(year); amtB=0,amtP=0; if(y==date.year||(date.year==y+1 && date.month<7)||y>date.year) { ifile.close(); cout<<"REPORT GENERATION IS NOT POSSIBLE"; getch(); return; } clrscr(); cout<<"\t\t\tPRESS ENTER FOR NEXT RECORD"; cout<<"\n\n\n\nSTUDENT NO.\tYEAR\t\tMODE\t\t\tTOTAL AMOUNT\n"; ifile.read((char *)&a,sizeof(a)); while(!ifile.eof())

{ strcpy(fpath,ipath); strcat(fpath,a.accnm); stno=strtok(a.accnm,"."); ifile1.open(fpath,ios::binary); ifile1.seekg(sizeof(student),ios::beg); ifile1.read((char *)&dtrans,sizeof(dtrans)); while(!ifile1.eof()) { date=dtrans.getdate(); if(dtrans.getborp()=='p')

Page 70: Project Report

{amtP+=dtrans.getamt();}

if(dtrans.getborp()=='b'){amtB+=dtrans.getamt();}

ifile1.read((char *)&dtrans,sizeof(dtrans)); } ifile1.close(); dtrans.getdata(amtB,'b'); dtrans.fyputA(stno,y);//for one day putdata dtrans.getdata(amtP,'p'); dtrans.fyputA(stno,y); amtB=amtP=0; getch(); cout<<endl; ifile.read((char *)&a,sizeof(a)); }

ifile.close(); getch(); break;

case 6: break; }

} }

void allf(char *path,char *year) { char *path1,*ipath,*fpath,*accno; strcpy(path1,path); strcat(path1,"\\faculty\\"); strcat(path1,year); strcat(path1,"\\"); strcpy(ipath,path1); strcat(path1,"all.txt"); allah a; dosdate_t date; ifstream ifile,ifile1; ifile.open(path1,ios::binary); if(!ifile || ifile.eof()) { ifile.close(); cout<<"\n\nRECORDS DOES NOT EXIST."; getch(); return; } else { int f=0; dlytrans dtrans; int n=menumaker(r_sm,infr_sm,6); switch(n)

{

Page 71: Project Report

case 1: cout<<"\n\nENTER DATE:-\n"; date=takedate(); clrscr(); cout<<"\t\t\tPRESS ENTER FOR NEXT RECORD"; cout<<"\n\n\n\nACCOUNT NO.\tDATE\t\tDAY\tMODE\tAMOUNT\n"; ifile.read((char *)&a,sizeof(a)); while(!ifile.eof()) { strcpy(fpath,ipath); strcat(fpath,a.accnm); accno=strtok(a.accnm,"."); ifile1.open(fpath,ios::binary); ifile1.seekg(sizeof(faculty),ios::beg); ifile1.read((char *)&dtrans,sizeof(dtrans)); while(!ifile1.eof())

{ if(!datecmp(date,dtrans.getdate())) { cout<<"\n"; dtrans.dateputA(accno);//for all, one day putdata f=1; } ifile1.read((char *)&dtrans,sizeof(dtrans)); }

ifile1.close(); getch(); cout<<endl; ifile.read((char *)&a,sizeof(a)); } ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 2: cout<<"\n\nENTER 0 FOR SUNDAY AND 6 FOR SATURDAY:- "; int day; cin>>day; clrscr(); cout<<"\t\t\tPRESS ENTER FOR NEXT RECORD"; cout<<"\n\n\n\nSTUDENT NO.\tDAY\t\tDATE\t\tMODE\tAMOUNT\n"; ifile.read((char *)&a,sizeof(a)); while(!ifile.eof()) { strcpy(fpath,ipath); strcat(fpath,a.accnm); accno=strtok(a.accnm,"."); ifile1.open(fpath,ios::binary); ifile1.seekg(sizeof(faculty),ios::beg); ifile1.read((char *)&dtrans,sizeof(dtrans)); while(!ifile1.eof())

{

Page 72: Project Report

date=dtrans.getdate(); if((int)date.dayofweek==day) { cout<<"\n"; dtrans.dowputA(accno);//for one day putdata f=1; } ifile1.read((char *)&dtrans,sizeof(dtrans)); }

ifile1.close(); getch(); cout<<endl; ifile.read((char *)&a,sizeof(a)); } ifile.close(); if(!f) { cout<<"\n\nNO RECORDS TO SHOW."; } getch(); break;

case 3: cout<<"\n\nENTER MONTH:- "; int mon,amtb=0,amtp=0; cin>>mon; clrscr(); cout<<"\t\t\tPRESS ENTER FOR NEXT RECORD"; cout<<"\n\n\n\nACCOUNT NO.\tMONTH\t\tMODE\t\tTOTAL AMOUNT\n"; ifile.read((char *)&a,sizeof(a)); while(!ifile.eof()) { strcpy(fpath,ipath); strcat(fpath,a.accnm); accno=strtok(a.accnm,"."); ifile1.open(fpath,ios::binary); ifile1.seekg(sizeof(faculty),ios::beg); ifile1.read((char *)&dtrans,sizeof(dtrans)); while(!ifile1.eof())

{ date=dtrans.getdate(); if((int)date.month==mon) { if(dtrans.getborp()=='p') { amtp+=dtrans.getamt(); } else { amtb+=dtrans.getamt(); } } ifile1.read((char *)&dtrans,sizeof(dtrans)); }

ifile1.close(); dtrans.getdata(amtb,'b');

Page 73: Project Report

dtrans.monputA(accno,mon);//for one day putdata dtrans.getdata(amtp,'p'); dtrans.monputA(accno,mon); amtb=amtp=0; getch(); cout<<endl; ifile.read((char *)&a,sizeof(a)); } getch(); ifile.close(); break;

case 4: cout<<"\n\nWHICH HALF OF YEAR (1st or 2nd):- "; int hy; cin>>hy; int amtB=0,amtP=0; _dos_getdate(&date); if(date.month>=7&&date.month<=12 &&hy==1 &&date.year==atoi(year)) { ifile.close(); cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } if(date.month>=7&&date.month<=12 &&hy==2 &&date.year==atoi(year)) { ifile.close(); cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } if(date.month>=1&&date.month<=6 &&hy==2 &&date.year==atoi(year)) { ifile.close(); cout<<"\n\nREPORT GENERATION IS NOT POSSIBLE FOR THIS HALF YEAR"; getch(); return; } clrscr(); cout<<"\t\t\tPRESS ENTER FOR NEXT RECORD"; cout<<"\n\n\n\nACCOUNT NO.\tHALF YEAR\tMODE\t\t\tTOTAL AMOUNT\n"; ifile.read((char *)&a,sizeof(a)); while(!ifile.eof())

{ strcpy(fpath,ipath); strcat(fpath,a.accnm); accno=strtok(a.accnm,"."); ifile1.open(fpath,ios::binary); ifile1.seekg(sizeof(faculty),ios::beg); ifile1.read((char *)&dtrans,sizeof(dtrans)); while(!ifile1.eof()) { date=dtrans.getdate(); if(hy==1) {

Page 74: Project Report

if(date.month>=7 && date.month<=12) { if(dtrans.getborp()=='p') { amtP+=dtrans.getamt(); } if(dtrans.getborp()=='b') { amtB+=dtrans.getamt(); } } ifile1.read((char *)&dtrans,sizeof(dtrans)); } else if(hy==2) { if(date.month>=1 && date.month<=6) { if(dtrans.getborp()=='p') { amtP+=dtrans.getamt(); } if(dtrans.getborp()=='b') { amtB+=dtrans.getamt(); } } ifile1.read((char *)&dtrans,sizeof(dtrans)); } else { cout<<"\n\nWRONG ENTRY FOR HALF YEAR."; } } ifile1.close(); dtrans.getdata(amtB,'b'); dtrans.hyputA(accno,hy);//for one day putdata dtrans.getdata(amtP,'p'); dtrans.hyputA(accno,hy); amtB=amtP=0; getch(); cout<<endl; ifile.read((char *)&a,sizeof(a)); }

ifile.close(); getch(); break;

case 5: _dos_getdate(&date); int y=atoi(year); amtB=0,amtP=0; if(y==date.year||(date.year==y+1 && date.month<7)||y>date.year) { ifile.close(); cout<<"REPORT GENERATION IS NOT POSSIBLE"; getch();

Page 75: Project Report

return; } clrscr(); cout<<"\t\t\tPRESS ENTER FOR NEXT RECORD"; cout<<"\n\n\n\nSTUDENT NO.\tYEAR\t\tMODE\t\t\tTOTAL AMOUNT\n"; ifile.read((char *)&a,sizeof(a)); while(!ifile.eof())

{ strcpy(fpath,ipath); strcat(fpath,a.accnm); accno=strtok(a.accnm,"."); ifile1.open(fpath,ios::binary); ifile1.seekg(sizeof(faculty),ios::beg); ifile1.read((char *)&dtrans,sizeof(dtrans)); while(!ifile1.eof()) { date=dtrans.getdate(); if(dtrans.getborp()=='p')

{amtP+=dtrans.getamt();}

if(dtrans.getborp()=='b'){amtB+=dtrans.getamt();}

ifile1.read((char *)&dtrans,sizeof(dtrans)); } ifile1.close(); dtrans.getdata(amtB,'b'); dtrans.fyputA(accno,y);//for one day putdata dtrans.getdata(amtP,'p'); dtrans.fyputA(accno,y); amtB=amtP=0; getch(); cout<<endl; ifile.read((char *)&a,sizeof(a)); }

ifile.close(); getch(); break;

case 6: break; }

} }

void report(char *path) { clrscr(); cout<<"\n\t\tENTER YEAR FOR WHICH YOU WANT TO GENERATE REPORT."; cout<<"\n\t\tFOR EXAMPLE ENTER '2006' FOR SESSION '2006-07'"; cout<<"\n\n\t\t"; char*year; cin>>year;

Page 76: Project Report

int n=menumaker(r_m,infr_m,5); switch(n)

{ case 1: ones(path,year); break;

case 2: alls(path,year); break;

case 3: onef(path,year); break;

case 4: allf(path,year);

break;

case 5: break; }

}

Page 77: Project Report

STUFAC.CPP

//for student database functions// &//for faculty database functions

void delet(char *path,char *nm) { int f=0; char tpath[33]; allah a; strncpy(tpath,path,25); tpath[25]='\0'; strcat(tpath,"temp.txt"); ifstream ifile; ifile.open(path,ios::binary); ofstream ofile; ofile.open(tpath,ios::binary); ifile.read((char*)&a,sizeof(a)); while(!ifile.eof())

{ if(strcmp(nm,a.putdata())) { ofile.write((char*)&a,sizeof(a)); ifile.read((char*)&a,sizeof(a)); } else { f=1; ifile.read((char*)&a,sizeof(a)); } }

if(!f) { clrscr(); cout<<"\n\n\n\t\t\t\tENTERED RECORD NOT FOUND."; getch(); } else { clrscr(); cout<<"\n\n\n\n\t\t\tRECORD DELETED."; getch(); } ifile.close(); ofile.close();

Page 78: Project Report

remove(path); rename(tpath,path); }

void modstu(char *path) { student stu; char ch1; char *stno,*dir,path1[37]; char *tpath; allah a; s: chdir(path); ofstream ofile; ifstream ifile; strcpy(path1,path); strcat(path1,"\\student"); int chk=mkdir(path1); if(chk==0 ||(chk==-1&&errno==EACCES)) { chdir(path1); dosdate_t curdate; _dos_getdate(&curdate); refdat.year=curdate.year; if(datecomp(curdate,refdat)==-1)

{ itoa(curdate.year-1,dir,10); }

else { itoa(curdate.year,dir,10); }

strcat(path1,"\\"); strcat(path1,dir); int chk1=mkdir(path1); if(chk1==0 ||(chk1==-1 &&errno==EACCES))

{ chdir(path1); // display menu int n; clrscr(); n=menumaker(sf_m,infsf_m,5); clrscr(); switch(n) { case 1: //for searching a account student stu1; cout<<"\n\n\nENTER STUDENT NO."; cin>>stno; //chk whether stno is a no. or not strcat(stno,".txt"); strcat(path1,"\\"); strcat(path1,stno); ifile.open(path1,ios::binary); if(!ifile)

{

Page 79: Project Report

cout<<"\n\n\nACCOUNT DOES NOT EXIST"; getch(); goto s; }

else { ifile.read((char*)&stu1,sizeof(stu1)); clrscr(); cout<<"\n\t\t\t\tINFORMATION IS:---"; stu1.putdata(); getch(); }

ifile.close(); goto s;

case 2: //to open a new account clrscr(); cout<<"\n\t\t\tENTER INFORMATION:---"; stu.getdata(); strcpy(stno,stu.getstno()); strcat(stno,".txt"); strcpy(a.accnm,stno); strcat(path1,"\\"); strcpy(tpath,path1); strcat(tpath,"all.txt"); strcat(path1,stno); ifile.open(path1,ios::binary); if(ifile) //to chk whether acc already exist or not

{ cout<<"\n\nRECORD WITH STUDENT NO. "<<stu.getstno()<<" ALREADY

EXIST"; ifile.close(); getch(); goto s; }

else { ifile.close(); ofile.open(tpath,ios::ate|ios::binary); ofile.write((char*)&a,sizeof(a)); ofile.close(); ofile.open(path1,ios::binary); if(ofile) { ofile.write((char*)&stu,sizeof(stu)); ofile.close(); } else { cout<<"\n\nRECORD CANT BE CREATED"; getch(); goto s; } }

goto s;

Page 80: Project Report

case 3: // to delete an account cout<<"\n\n\nENTER ACCOUNT NO.:-"; cin>>stno; strcat(stno,".txt"); strcat(path1,"\\"); strcpy(tpath,path1); strcat(tpath,"all.txt"); strcat(path1,stno); ifile.open(path1,ios::binary); ifile.read((char *)&stu,sizeof(stu)); ifile.close(); clrscr(); cout<<"\n\n\t\t\t\tACCOUNT INFORMATION IS:-"; stu.putdata(); cout<<"\n\nWANT TO DELETE IT?"; cin>>ch1; if(ch1=='y'||ch1=='Y')

{ if(stu.getbal()!=0) { cout<<"\n\n\t\t\tBALANCE IS:-"<<stu.getbal(); cout<<"\n\n\t\t\tACCOUNT CAN'T BE DELETED"; getch(); } else { delet(tpath,stno); remove(path1); } }

else { getch(); }

goto s;

case 4: //modify cout<<"\n\n\nENTER STUDENT NO.:-"; cin>>stno; strcat(stno,".txt"); strcat(path1,"\\"); strcat(path1,stno); ifile.open(path1,ios::binary); ifile.seekg(0,ios::beg); if(!ifile)

{ cout<<"\n\n\nACCOUNT DOES NOT EXIST"; ifile.close(); getch(); goto s; }

else { ifile.read((char*)&stu,sizeof(stu)); ifile.close(); clrscr();

Page 81: Project Report

cout<<"\n\n\t\tCURRENT ACCOUNT INFORMATION IS:-"; stu.putdata(); cout<<"\n\nWANT TO MODIFY INFORMATION?(Y/N)"; cin>>ch1; if(ch1=='y'||ch1=='Y') { clrscr(); cout<<"YOU ARE NOT SUPPOSED TO CHANGE THE STUDENT NO."; stu.getdata(); strcpy(stno,stu.getstno()); strcat(stno,".txt"); ofile.open(path1,ios::ate|ios::binary); ofile.seekp(0,ios::beg); ofile.write((char*)&stu,sizeof(stu)); ofile.close(); ifile.open(path1,ios::ate|ios::binary); ifile.read((char*)&stu,sizeof(stu)); ifile.close(); clrscr(); cout<<"\n\n\t\t\tNOW ACCOUNT INFORMATION IS:-"; stu.putdata(); getch(); } }

goto s; } }

} }

void modfac(char *path) { faculty fac; char ch1; allah a; char *accno,*dir,path1[37],*tpath; f: chdir(path); ofstream ofile; ifstream ifile; strcpy(path1,path); strcat(path1,"\\faculty"); int chk=mkdir(path1); if(chk==0 ||(chk==-1&&errno==EACCES)) { chdir(path1); dosdate_t curdate; _dos_getdate(&curdate); refdat.year=curdate.year; if(datecomp(curdate,refdat)==-1)

{ itoa(curdate.year-1,dir,10); }

else { itoa(curdate.year,dir,10);

Page 82: Project Report

} strcat(path1,"\\"); strcat(path1,dir); int chk1=mkdir(path1); if(chk1==0 ||(chk1==-1 &&errno==EACCES))

{ chdir(path1); // display menu int n; clrscr(); n=menumaker(sf_m,infsf_m,5); clrscr(); switch(n) { case 1: //for searching a account faculty fac1; cout<<"\n\nENTER ACCOUNT NO."; cin>>accno; //chk whether accno is a no. or not strcat(accno,".txt"); strcat(path1,"\\"); strcat(path1,accno); ifile.open(path1,ios::binary); if(!ifile)

{ clrscr(); cout<<"\n\n\n\n\t\t\tACCOUNT DOES NOT EXIST"; getch(); goto f; }

else { clrscr(); ifile.read((char*)&fac1,sizeof(fac1)); cout<<"\n\n\t\t\t\tINFORMATION IS:---"; fac1.putdata(); getch(); }

ifile.close(); goto f;

case 2: //to open a new account cout<<"\n\n\t\t\tENTER INFORMATION:---"; fac.getdata(); strcpy(accno,fac.getaccno()); strcat(accno,".txt"); strcpy(a.accnm,accno); strcat(path1,"\\"); strcpy(tpath,path1); strcat(tpath,"all.txt"); strcat(path1,accno); ifile.open(path1,ios::binary); if(ifile) //to chk whether acc already exist or not

{ cout<<"\n\nRECORD WITH ACCOUNT NO. "<<fac.getaccno()<<" ALREADY

EXIST";

Page 83: Project Report

ifile.close(); getch(); goto f; }

else { ifile.close(); ofile.open(tpath,ios::ate|ios::binary); ofile.write((char*)&a,sizeof(a)); ofile.close(); ofile.open(path1,ios::binary); if(ofile) { ofile.write((char*)&fac,sizeof(fac)); ofile.close(); } else { clrscr(); cout<<"\n\n\n\n\t\t\t\tRECORD CANT BE CREATED"; getch(); goto f; } }

goto f;

case 3: // to delete an account cout<<"\n\nENTER ACCOUNT NO.:-"; cin>>accno; strcat(accno,".txt"); strcat(path1,"\\"); strcpy(tpath,path1); strcat(tpath,"all.txt"); strcat(path1,accno); ifile.open(path1,ios::binary); ifile.read((char *)&fac,sizeof(fac)); ifile.close(); clrscr(); cout<<"\n\n\t\t\tACCOUNT INFORMATION IS:-"; fac.putdata(); cout<<"\n\nWANT TO DELETE IT?"; cin>>ch1; if(ch1=='y'||ch1=='Y')

{ if(fac.getbal()!=0) { clrscr(); cout<<"\n\n\n\t\t\tBALANCE IS:-"<<fac.getbal(); cout<<"\n\n\t\t\tACCOUNT CAN'T BE DELETED"; getch(); } else { delet(tpath,accno); remove(path1); }

Page 84: Project Report

} else

{ getch(); }

goto f;

case 4: //modify cout<<"\n\nENTER ACCOUNT NO.:-"; cin>>accno; strcat(accno,".txt"); strcat(path1,"\\"); strcat(path1,accno); ifile.open(path1,ios::binary); ifile.seekg(0,ios::beg); if(!ifile)

{ clrscr(); cout<<"\n\n\t\t\tACCOUNT DOES NOT EXIST"; ifile.close(); getch(); goto f; }

else { ifile.read((char*)&fac,sizeof(fac)); ifile.close(); cout<<"\n\t\tCURRENT ACCOUNT INFORMATION IS:-"; fac.putdata(); cout<<"\n\nWANT TO MODIFY INFORMATION?(Y/N)"; cin>>ch1; if(ch1=='y'||ch1=='Y') { cout<<"\nYOU ARE NOT SUPPOSED TO CHANGE ACCOUNT NO."; fac.getdata(); strcpy(accno,fac.getaccno()); strcat(accno,".txt"); ofstream ofile; ofile.open(path1,ios::ate|ios::binary); ofile.seekp(0,ios::beg); ofile.write((char*)&fac,sizeof(fac)); ofile.close(); ifile.open(path1,ios::ate|ios::binary); ifile.read((char*)&fac,sizeof(fac)); ifile.close(); clrscr(); cout<<"\n\n\t\t\tNOW ACCOUNT INFORMATION IS:-"; fac.putdata(); getch(); } }

goto f; } }

} }

Page 85: Project Report

TRANS.CPP

//for transaction functions

int chklmt(int bal,dosdate_t ldt,int days,int maxbal) { dosdate_t curdate; _dos_getdate(&curdate); if(datcomp4t(curdate,ldt,days) && bal<=maxbal)

{return 1;}

else{return 0;}

}

int calcamt(char *mpath) { char ch='y'; int pos,index,qty,amt=0; strcat(mpath,"\\tdymenu.txt"); clrscr(); cout<<"\nTODAY'S MENU IS:-\n\n"; int i=dispmenu(mpath); if(!i) { return 0; } ifstream ifile; ifile.open(mpath,ios::binary); item itm; while(ch=='y'||ch=='Y')

{ cout<<"\nENTER INDEX OF BOUGHT ITEM:---"; cin>>index; if(index<=0 || index>=i) { cout<<"\nWRONG INDEX.\n\n"; goto x; } pos=(index-1)*sizeof(itm); cout<<"\n\nITEM\t\tPRICE\t\tQUANTITY\n\n";

Page 86: Project Report

ifile.seekg(pos,ios::beg); ifile.read((char*)&itm,sizeof(itm)); itm.putdata(); cout<<"\t\t"; cin>>qty; amt+=qty* itm.getprc(); x: cout<<"\nBUY MORE ITEMS.(Y/N)"; cin>>ch; }

ifile.close(); return amt; }

void sbuy(char*path) { cout<<endl; int amt; char *stno,path1[37],mpath[13]; strncpy(mpath,path,12); mpath[12]='\0'; cout<<"\n\nENTER STUDENT NO.:-"; cin>>stno; strcpy(path1,path); strcat(stno,".txt"); strcat(path1,"\\"); strcat(path1,stno); student stu; ifstream ifile; ifile.open(path1,ios::binary); if(!ifile) { ifile.close(); cout<<"\n\nACCOUNT DOES NOT EXIST"; getch(); } else { clrscr(); ifile.read((char*)&stu,sizeof(stu)); ifile.close(); if(chklmt(stu.getbal(),stu.getldt(),30,1000))

{ amt=calcamt(mpath); if(!amt) { cout<<"\n\n\nNOTHING IS BOUGHT"; getch(); return; } cout<<"\n\nTOTAL AMOUNT OF BOUGHT ITEMS:-"; cout<<amt; getch(); //write object of daily transaction on the same file in appended mode dlytrans dtrans; dtrans.getdata(amt,'b');

Page 87: Project Report

strcpy(path1,path); strcat(path1,"\\"); strcat(path1,stno); stu.chngbal(stu.getbal()+amt); ofstream ofile; ofile.open(path1,ios::ate|ios::binary); ofile.write((char*)&dtrans,sizeof(dtrans)); ofile.seekp(0,ios::beg); ofile.write((char*)&stu,sizeof(stu)); ofile.close(); }

else { clrscr(); cout<<"\n\n\n\t\t\tYOUR TRANSACTION LIMITS EXCEEDS"; cout<<"\n\n\t\t\t\YOU CANT BUY ANYTHING."; getch(); return; }

} }

void fbuy(char *path) { cout<<endl; int amt; char *accno,path1[37],mpath[13]; strncpy(mpath,path,12); mpath[12]='\0'; cout<<"\n\nENTER ACCOUNT NO.:-"; cin>>accno; strcpy(path1,path); strcat(accno,".txt"); strcat(path1,"\\"); strcat(path1,accno); faculty fac; ifstream ifile; ifile.open(path1,ios::binary); if(!ifile) { ifile.close(); clrscr(); cout<<"\n\n\n\n\t\t\t\tACCOUNT DOES NOT EXIST"; getch(); return; } else { clrscr(); ifile.read((char*)&fac,sizeof(fac)); ifile.close(); if(chklmt(fac.getbal(),fac.getldt(),45,1500))

{ amt=calcamt(mpath); if(!amt) {

Page 88: Project Report

clrscr(); cout<<"\n\n\n\n\t\t\t\tNOTHNG IS BOUGHT"; getch(); return; } cout<<"\n\nTOTAL AMOUNT OF BOUGHT ITEMS:-"; cout<<amt; getch(); //write object of daily transaction on the same file in appended mode dlytrans dtrans; dtrans.getdata(amt,'b'); fac.chngbal(fac.getbal()+amt); strcpy(path1,path); strcat(path1,"\\"); strcat(path1,accno); ofstream ofile; ofile.open(path1,ios::ate|ios::binary); ofile.write((char*)&dtrans,sizeof(dtrans)); ofile.seekp(0,ios::beg); ofile.write((char*)&fac,sizeof(fac)); ofile.close(); }

else { clrscr(); cout<<"\n\n\n\n\t\t\tYOUR TRANSACTION LIMITS EXCEEDS"; cout<<"\n\n\t\t\tYOU CANT BUY ANYTHING."; getch(); return; }

} }

void spay(char *path) { int amt; dosdate_t curdate; _dos_getdate(&curdate); char *stno,path1[37]; cout<<"\n\nENTER STUDENT NO.:-"; cin>>stno; strcpy(path1,path); strcat(stno,".txt"); strcat(path1,"\\"); strcat(path1,stno); student stu; ifstream ifile; ifile.open(path1,ios::binary); if(!ifile) { ifile.close(); clrscr(); cout<<"\n\n\n\n\t\t\tACCOUNT DOES NOT EXIST"; getch(); return; }

Page 89: Project Report

else { clrscr(); ifile.read((char*)&stu,sizeof(stu)); ifile.close(); cout<<"\n\n\nENTER AMOUNT TO BE DEPOSITED:-"; cin>>amt; //for report generation module //write object of daily transaction on the same file in appended mode dlytrans dtrans; dtrans.getdata(amt,'p'); amt=(-1)*amt; stu.chngbal(stu.getbal()+amt); stu.chngldt(curdate); ofstream ofile; ofile.open(path1,ios::ate|ios::binary); ofile.write((char*)&dtrans,sizeof(dtrans)); ofile.seekp(0,ios::beg); ofile.write((char*)&stu,sizeof(stu)); ofile.close(); } }

void fpay(char *path) { int amt; dosdate_t curdate; _dos_getdate(&curdate); char *accno,path1[37]; cout<<"\n\nENTER ACCOUNT NO.:- "; cin>>accno; strcpy(path1,path); strcat(accno,".txt"); strcat(path1,"\\"); strcat(path1,accno); faculty fac; ifstream ifile; ifile.open(path1,ios::binary); if(!ifile) { ifile.close(); clrscr(); cout<<"\n\n\n\n\t\t\tACCOUNT DOES NOT EXIST"; getch(); return; } else { clrscr(); ifile.read((char*)&fac,sizeof(fac)); ifile.close(); cout<<"\n\nENTER AMOUNT TO BE DEPOSITED:-"; cin>>amt; //for report generation module //write object of daily transaction on the same file in appended mode dlytrans dtrans;

Page 90: Project Report

dtrans.getdata(amt,'p'); amt=(-1)*amt; fac.chngbal(fac.getbal()+amt); fac.chngldt(curdate); ofstream ofile; ofile.open(path1,ios::ate|ios::binary); ofile.write((char*)&dtrans,sizeof(dtrans)); ofile.seekp(0,ios::beg); ofile.write((char*)&fac,sizeof(fac)); ofile.close(); } }

void t_action(char *path) { int n1,chk,chk1; char path1[25],*dir; clrscr(); int n=menumaker(t_m,inft_m,3); switch(n)

{ case 1: strcpy(path1,path); strcat(path1,"\\student"); chk=mkdir(path1); if(chk==0 ||(chk==-1&&errno==EACCES)) { chdir(path1); dosdate_t curdate; _dos_getdate(&curdate); refdat.year=curdate.year; if(datecomp(curdate,refdat)==-1) { itoa(curdate.year-1,dir,10); } else { itoa(curdate.year,dir,10); } strcat(path1,"\\"); strcat(path1,dir); chk1=mkdir(path1); if(chk1==0||(chk1==-1&&errno==EACCES)) { chdir(path1); n1=menumaker(t_sf_m,inft_sf_m,2); switch(n1)

{ case 1: sbuy(path1); break;

case 2: spay(path1); break; }

Page 91: Project Report

} } break;

case 2: strcpy(path1,path); strcat(path1,"\\faculty"); chk=mkdir(path1); if(chk==0 ||(chk==-1&&errno==EACCES)) { chdir(path1); dosdate_t curdate; _dos_getdate(&curdate); refdat.year=curdate.year; if(datecomp(curdate,refdat)==-1) { itoa(curdate.year-1,dir,10); } else { itoa(curdate.year,dir,10); } strcat(path1,"\\"); strcat(path1,dir); chk1=mkdir(path1); if(chk1==0||(chk1==-1&&errno==EACCES)) { chdir(path1); n1=menumaker(t_sf_m,inft_sf_m,2); switch(n1)

{ case 1: fbuy(path1); break;

case 2: fpay(path1); break; }

} } break;

case 3: break; }

}

Page 92: Project Report