Académique Documents
Professionnel Documents
Culture Documents
INTRODUCTION
The Following problems are faced to manage various accounts running in canteen
and to generate the reports: -
4. Inability to generate a report for a particular time period like for a particular day,
fortnight or month.
GOALS TO BE ACHIEVED:-
1. To develop an interactive interface with which user can interact easily.
1. Transaction Management
2. Student Database Management
3. Faculty Database Management
4. Report Generation System
5. Canteen Menu Updating System
1. Transaction Management: -
This module handles all the transactions done by student and faculties.
This module has following sub modules: -
Student
1.1.1 Buys
1.1.2 Pays
1.2 Faculty
1.2.1 Buys
1.2.2 Pays
Show Menu
Update Menu
Modify Item
Delete Item
Add Item
M
DATABASE DESIGN
As our project is implemented in C++, so our database is created with flat file system.
DATABASE
STUDENT
2006 (Works between July 1st, 2006 and June 30th, 2007)
• ALL.txt (contains names of all the other file in the folder).
2007 (Works between July 1st, 2007 and June 30th, 2008)
• ALL.txt (contains names of all the other file in the folder).
2008 (Works between July 1st, 2008 and June 30th, 2009)
• ALL.txt (contains names of all the other file in the folder).
---
• 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).
2007 (Works between July 1st, 2007 and June 30th, 2008)
• ALL.txt (contains names of all the other file in the folder).
2008 (Works between July 1st, 2008 and June 30th, 2009)
• ALL.txt (contains names of all the other file in the folder).
---
• ALL.txt
• ---
• ---
---
• ALL.txt
• ---
• ---
o Primary key for every student is his/her student number that must be
correct at the time of making records.
HARDWARE REQUIREMENTS
Our project could run on a machine with the following minimum requirements: -
RAM: - 64 MB or above.
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*/
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);
}
}
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);
}
int student::getbal()
{
return bal;
}
//====================================FACULTY==============================
class faculty
{
char name[30];
char deptt[20];
char accno[8];
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);
}
int faculty::getbal()
{
return bal;
}
public:
void getdata();
void putdata();
char* getitmnm();
int getprc();
};
public:
void getdata(int,char);
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();
};
//=================================================
class allah
{
public:
char accnm[12];
void getdata(char *);
char *putdata();
};
case 2:
deletitm(path1);
break;
case 3:
clrscr();
dispmenu(path1);
break;
case 4:
break;
}
}
case 2:
deletitm(path1);
break;
case 3:
moditm(path1);
break;
case 4:
clrscr();
dispmenu(path1);
break;
case 5:
break;
}
}
case 2:
editpm(path);
goto em;
}
}
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",
"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",
"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};
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 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;
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";
}
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 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);
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);
if (col==1)
if (i%2==0)
textcolor(4);
else
textcolor(14);
else
if (i%2==0)
textcolor(14);
else
textcolor(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);
else
textcolor(14);
else
if (j%2==0)
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);
else
textcolor(14);
gotoxy(79,j);
cprintf("*");
}
}
while (!kbhit());
getch();
textcolor(15);
}
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;
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)
{
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));
}
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();
if(!f)
{
cout<<"\n\nNO RECORDS TO SHOW.";
}
getch();
break;
case 6:
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();
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;
}
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 6:
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.";
}
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))
{
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')
{
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')
{
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;
}
}
}
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())
{
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');
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)
{
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();
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;
}
}
}
case 3:
onef(path,year);
break;
case 4:
allf(path,year);
break;
case 5:
break;
}
}
STUFAC.CPP
//for student database functions
// &
//for faculty database functions
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();
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;
}
}
}
}
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;
}
}
}
}
TRANS.CPP
//for transaction functions
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');
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;
}
}
}
case 2:
spay(path1);
break;
}
}
}
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;
}