Web Search

Custom Search

Search Results

Wednesday, July 2, 2008

Request Board

If you wanna have some specific project which u r nt able to make u can request here...i ll try all my best to upload here..

:)

Thursday, June 19, 2008

!!!... School Fee Enquiry Sytem ...!!!

Made by Aanchal saxena.
//*********************************************************
// PROJECT SCHOOL FEE ENQUIRY
//**********************************************************

//**********************************************************
// INCLUDED HEADER FILES
//**********************************************************

#include<iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <dos.h>
#include <iomanip.h>

int i,j,li,lp,rec,valid;
void help();
//*********************************************************
// GLOBAL VARIABLE DECLARATIONS
//*********************************************************

//int i,j,li,lp;
char ch,choice;


//*********************************************************
// THIS CLASS DRAWS LINES, BOXES, ETC.
//**********************************************************

class DRAW
{
public :
void LINE_HOR(int, int, int, char) ;
void LINE_VER(int, int, int, char) ;
void BOX(int,int,int,int,char) ;
} ;


//**********************************************************
// THIS CLASS CONTROLS ALL THE FUNCTIONS RELATED TO FEES
//**********************************************************

class FEE
{
private :
int Class ;
float tuition, ac, science, computer, activity ;
void DISPLAY(int) ;
void MODIFY_RECORD(int, float, float, float, float, float) ;

public :
void ADDITION(void) ;
void MODIFICATION(void) ;
void FEE_SLIP(void) ;
void LIST(void) ;
void HELP(void);
}fee ;

//**********************************************************
// MAIN MENU FUNCTION
//**********************************************************

void mainmenu()
{ clrscr();
textcolor(WHITE);
for(li=30;li<=50;li++)
{
textcolor(WHITE);
gotoxy(li,14);
delay(30);
printf("*");
}
for(li=50;li>=30;li--)
{
textcolor(WHITE);
gotoxy(li,30);
delay(30);
printf("*");
}
for(lp=15;lp<30;lp++)
{
gotoxy(30,lp);
delay(100);
printf("|");
}
for(lp=29;lp>=15;lp--)
{
gotoxy(50,lp);
delay(100);
printf("|");
}
gotoxy(15,10);
textcolor(LIGHTGRAY);
cprintf("Press the corresponding Keys for the desired action");
gotoxy(35,16);
textcolor(BROWN);
cprintf("F: FEE SLIP");
gotoxy(35,19);
textcolor(LIGHTMAGENTA);
cprintf("M: MODIFY");
gotoxy(35,22);
textcolor(LIGHTBLUE);
cprintf("L: LIST");
gotoxy(35,25);
textcolor(LIGHTRED);
cprintf("H: HELP");
gotoxy(35,28);
textcolor(GREEN);
cprintf("Q: QUIT");
choice=getch();
ch=toupper(choice);
switch(ch)
{
case'F':fee.FEE_SLIP();
break;
case'M':fee.MODIFICATION();
break;
case'L':fee.LIST();
break;
case'H':fee.HELP();
break;
case'Q':exit(0);
break;
default:gotoxy(33,40);
cout<<"Illegal Choic Press any key to return to Main Menu";
getch();
mainmenu();
}
} //Main Menu Function End


//**********************************************************
// FUNCTION TO DRAW HORIZONTAL LINE
//**********************************************************

void DRAW :: LINE_HOR(int column1, int column2, int row, char c)
{
for ( column1; column1<=column2; column1++ )
{
gotoxy(column1,row) ;
cout <<c ;
}
}


//**********************************************************
// FUNCTION TO DRAW VERTICAL LINE
//**********************************************************

void DRAW :: LINE_VER(int row1, int row2, int column, char c)
{
for ( row1; row1<=row2; row1++ )
{
gotoxy(column,row1) ;
cout <<c ;
}
}


//**********************************************************
// FUNCTION TO DRAW BOX LINE
//**********************************************************

void DRAW :: BOX(int column1, int row1, int column2, int row2, char c)
{
char ch=218 ;
char c1, c2, c3, c4 ;
char l1=196, l2=179 ;
if (c == ch)
{
c1=218 ;
c2=191 ;
c3=192 ;
c4=217 ;
l1 = 196 ;
l2 = 179 ;
}
else
{
c1=c ;
c2=c ;
c3=c ;
c4=c ;
l1 = c ;
l2 = c ;
}
gotoxy(column1,row1) ;
cout <<c1 ;
gotoxy(column2,row1) ;
cout <<c2 ;
gotoxy(column1,row2) ;
cout <<c3 ;
gotoxy(column2,row2) ;
cout <<c4 ;
column1++ ;
column2-- ;
LINE_HOR(column1,column2,row1,l1) ;
LINE_HOR(column1,column2,row2,l1) ;
column1-- ;
column2++ ;
row1++ ;
row2-- ;
LINE_VER(row1,row2,column1,l2) ;
LINE_VER(row1,row2,column2,l2) ;
}


//**********************************************************
// FUNCTION TO ADD FEE STRUCTURE IN FEE FILE
//**********************************************************

void FEE :: ADDITION(void)
{
fstream file ;
file.open("FEE.DAT", ios::in) ;
if (!file.fail())
return ;
file.close() ;
file.open("FEE.DAT", ios::app) ;
for (int i=1; i<=12; i++)
{
Class = i ;
tuition = 0.0 ;
ac = 0.0 ;
science = 0.0 ;
computer= 0.0 ;
activity= 0.0 ;
file.write((char *) this, sizeof(FEE)) ;
}
file.close() ;
MODIFY_RECORD(12,450,50,60,60,50) ;
MODIFY_RECORD(11,450,50,60,60,50) ;
MODIFY_RECORD(10,350,50,30,60,50) ;
MODIFY_RECORD(9,350,50,20,60,50) ;
MODIFY_RECORD(8,300,50,20,40,50) ;
MODIFY_RECORD(7,300,50,20,40,50) ;
MODIFY_RECORD(6,300,50,20,40,50) ;
MODIFY_RECORD(5,250,50,0,40,40) ;
MODIFY_RECORD(4,250,50,0,40,40) ;
MODIFY_RECORD(3,250,50,0,40,40) ;
MODIFY_RECORD(2,250,50,0,40,40) ;
MODIFY_RECORD(1,250,50,0,40,40) ;
}


//**********************************************************
// FUNCTION TO DISPLAY TOTAL FEE AS LIST
//**********************************************************

void FEE :: LIST()
{
clrscr() ;
DRAW d ;
textcolor(MAGENTA);
d.BOX(1,2,80,24,218) ;
gotoxy(27,3) ;
cout <<"TOTAL FEES FOR THE CLASSES" ;
d.LINE_HOR(2,79,4,196) ;
gotoxy(5,5) ;
cout <<"CLASS TOTAL FEES" ;
d.LINE_HOR(2,79,6,196) ;
d.LINE_HOR(2,79,22,196) ;
float total ;
int row=8 ;
fstream file ;
file.open("FEE.DAT", ios::in) ;
while (file.read((char *) this, sizeof(FEE)))
{
total = tuition + ac + science + computer + activity ;
gotoxy(6,row) ;
cout <<Class ;
gotoxy(23,row) ;
cout <<total ;
row++ ;
}
file.close() ;
gotoxy(5,23) ;
cout <<"Press any key to continue............." ;
getch() ;
mainmenu();
}


//**********************************************************
// FUNCTION TO DISPLAY THE RECORD FOR THE GIVEN CLASS
//**********************************************************

void FEE :: DISPLAY(int tclass)
{
fstream file ;
file.open("FEE.DAT", ios::in) ;
while (file.read((char *) this, sizeof(FEE)))
{
if (Class == tclass)
{
gotoxy(5,5) ;
cout <<"Class : " <<Class ;
gotoxy(5,7) ;
cout <<"~~~~~~~~~~~~" ;
gotoxy(5,8) ;
cout <<"Tution Fee : " <<tuition ;
gotoxy(5,9) ;
cout <<"Annual charges Fee : " <<ac ;
gotoxy(5,10) ;
cout <<"Science Fee : " <<science ;
gotoxy(5,11) ;
cout <<"Computer Fee: " <<computer ;
gotoxy(5,12) ;
cout <<"Activity Fee : " <<activity ;
break ;
}
}
file.close() ;
}


//**********************************************************
// FUNCTION TO MODIFY THE FEE RECORD FOR THE GIVEN DATA
//**********************************************************

void FEE :: MODIFY_RECORD(int tclass, float ttution, float tac, float
tscience, float tcomputer, float tactivity)
{
fstream file ;
file.open("FEE.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while (!file.eof())
{
file.read((char *) this, sizeof(FEE)) ;
if (file.eof())
break ;
if (tclass == Class)
{
Class = tclass ;
tuition = ttution ;
ac = tac ;
science = tscience ;
computer= tcomputer ;
activity= tactivity ;
temp.write((char *) this, sizeof(FEE)) ;
}
else
temp.write((char *) this, sizeof(FEE)) ;
}
file.close() ;
temp.close() ;
file.open("FEE.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while (!temp.eof())
{
temp.read((char *) this, sizeof(FEE)) ;
if (temp.eof())
break ;
file.write((char *) this, sizeof(FEE)) ;
}
file.close() ;
temp.close() ;
}


//**********************************************************
// FUNCTION TO GIVE DATA TO MODIFY THE FEE RECORD
//**********************************************************

void FEE :: MODIFICATION(void)
{
clrscr() ;
textcolor(WHITE);
char ch, t1[10] ;
int valid=0, t=0, tclass=0 ;
float t2=0 ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Press <ENTER> for EXIT" ;
gotoxy(5,5) ; clreol() ;
cout <<"Enter Class for the Modification of the Fee Structure : " ;
gets(t1) ;
t = atoi(t1) ;
tclass = t ;
if (strlen(t1) == 0)
return ;
if (tclass < 1 || tclass > 12)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"7Enter correctly" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
gotoxy(71,1) ;
cout <<"<0>=Exit" ;
DISPLAY(tclass) ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,15) ; clreol() ;
cout <<"Do you want to modify the fee structure (y/n) : " ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
mainmenu();
float ttution=0.0, tac=0.0, tscience=0.0, tcomputer=0.0, tactivity=0.0 ;
gotoxy(5,13) ; clreol() ;
gotoxy(5,17) ;
cout <<"Tuition Fee : " ;
gotoxy(5,18) ;
cout <<"Annual Charges Fee : " ;
gotoxy(5,19) ;
cout <<"Science Fee : " ;
gotoxy(5,20) ;
cout <<"Computer Fee : " ;
gotoxy(5,21) ;
cout <<"Activity Fee : " ;
int modified = 5 ;
fstream file ;
file.open("FEE.DAT", ios::in) ;
while (file.read((char *) this, sizeof(FEE)))
if (Class == tclass)
break ;
file.close() ;
do
{
valid = 1 ;
gotoxy(5,27) ; clreol() ;
cout <<"Enter TUITION FEE or Press <ENTER> for no change" ;
gotoxy(19,17) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
ttution = t2 ;
if (t1[0] == '0')
return;
if (strlen(t1) == 0)
break ;
if (ttution > 1000)
{
valid = 0 ;
gotoxy(5,27) ; clreol() ;
cout <<"7Enter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(t1) == 0)
{
modified-- ;
ttution = tuition ;
gotoxy(20,17) ;
cout <<ttution ;
}
do
{
valid = 1 ;
gotoxy(5,27) ; clreol() ;
cout <<"Enter ANNUAL CHARGES fee or Press <ENTER> for no change" ;
gotoxy(26,18) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tac = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
if (tac > 1000)
{
valid = 0 ;
gotoxy(5,27) ; clreol() ;
cout <<"7Enter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(t1) == 0)
{
modified-- ;
tac = ac ;
gotoxy(26,18) ;
cout <<tac ;
}
do
{
valid = 1 ;
gotoxy(5,27) ; clreol() ;
cout <<"Enter SCIENCE FEES or Press <ENTER> for no change" ;
gotoxy(19,19) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tscience = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
if (tscience > 1000)
{
valid = 0 ;
gotoxy(5,27) ; clreol() ;
cout <<"7Enter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(t1) == 0)
{
modified-- ;
tscience = science ;
gotoxy(19,19) ;
cout <<tscience ;
}
do
{
valid = 1 ;
gotoxy(5,27) ; clreol() ;
cout <<"Enter COMPUTER FEES or Press <ENTER> for no change" ;
gotoxy(19,20) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tcomputer = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
if (tcomputer > 1000)
{
valid = 0 ;
gotoxy(5,27) ; clreol() ;
cout <<"7Enter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(t1) == 0)
{
modified-- ;
tcomputer = computer ;
gotoxy(19,20) ;
cout <<tcomputer ;
}
do
{
valid = 1 ;
gotoxy(5,27) ; clreol() ;
cout <<"Enter ACTIVITY FEES or Press <ENTER> for no change" ;
gotoxy(19,21) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tactivity = t2 ;
if (t1[0] == '0')
return;
if (strlen(t1) == 0)
break;
if (tactivity > 1000)
{
valid = 0 ;
gotoxy(5,27) ; clreol() ;
cout <<"7Enter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(t1) == 0)
{
modified-- ;
tactivity = activity ;
gotoxy(19,21) ;
cout <<tactivity ;
}
if (!modified)
mainmenu();
gotoxy(5,27) ; clreol() ;
do
{
gotoxy(5,25) ; clreol() ;
cout <<"Do you want to save (y/n) : " ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
MODIFY_RECORD(tclass,ttution,tac,tscience,tcomputer,tactivity);
gotoxy(5,27) ;
cout <<"7Record Modified" ;
gotoxy(5,29) ;
cout <<"Press any key to continue..........." ;
getch() ;
mainmenu();
}


//**********************************************************
// FUNCTION TO DISPLAY THE FEE SLIP FOR THE CLASS
//**********************************************************

void FEE :: FEE_SLIP(void)
{
clrscr() ;
textcolor(RED);
char ch, t1[10] ;
int valid=0, t=0, tclass=0 ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Press <ENTER> for EXIT" ;
gotoxy(5,5) ; clreol() ;
cout <<"Enter Class to see the Fee Structure : " ;
gets(t1) ;
t = atoi(t1) ;
tclass = t ;
if (strlen(t1) == 0)
return ;
if (tclass < 1 || tclass > 12)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"7Enter correctly" ;
getch() ;
}
} while (!valid) ;
char name[26] ;
do
{
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NAME OF THE STUDENT" ;
valid = 1 ;
gotoxy(5,7) ; clreol() ;
cout <<"Name : " ;
gets(name) ;
if (strlen(name) < 1 || strlen(name) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<" NAME SHOULD NOT BE GREATER THAN 25" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
DRAW d ;
d.BOX(20,2,61,24,987) ;
gotoxy(24,3) ;
cout <<" CARMEL CONVENT SCHOOL " ;
int d1, m1, y1 ;
struct date dt;
getdate(&dt);
d1 = dt.da_day ;
m1 = dt.da_mon ;
y1 = dt.da_year ;
gotoxy(45,4) ;
cout <<"Date: " <<d1 <<"/" <<m1 <<"/" <<y1 ;
d.LINE_HOR(21,60,5,196) ;
gotoxy(22,6) ;
cout <<"NAME : " <<name ;
gotoxy(22,7) ;
cout <<"CLASS : " <<tclass ;
d.LINE_HOR(21,60,8,196) ;
gotoxy(21,9) ;
cout <<" PARTICULARS AMOUNT" ;
d.LINE_HOR(21,60,10,196) ;
d.LINE_HOR(21,60,22,196) ;
d.LINE_HOR(46,60,20,196) ;
gotoxy(25,21) ;
cout <<"TOTAL" ;
gotoxy(54,23) ;
cout <<"CASHIER" ;
fstream file ;
file.open("FEE.DAT", ios::in) ;
while (file.read((char *) this, sizeof(FEE)))
if (Class == tclass)
break ;
file.close() ;
float total=0.0 ;
gotoxy(23,12) ;
cout <<"Tuition fees " <<setprecision(2) <<tuition ;
total = total+tuition ;
gotoxy(23,13) ;
cout <<"Annual charges fees " <<setprecision(2) <<ac ;
total = total+ac ;
gotoxy(23,14) ;
cout <<"Science fees " <<setprecision(2) <<science ;
total = total+science ;
gotoxy(23,15) ;
cout <<"Computer fees " <<setprecision(2) <<computer ;
total = total+computer ;
gotoxy(23,16) ;
cout <<"Activity fees " <<setprecision(2) <<activity ;
total = total+activity ;
d.LINE_VER(9,21,46,179) ;
char tt[15] ;
sprintf(tt,"%f",total) ;
gotoxy(49,21) ;
cout <<tt ;
gotoxy(33,40);
cout<<"Press any key to return to the main menu........";
getch() ;
mainmenu();
}

void FEE::HELP()
{ clrscr();
textcolor(WHITE);
cout<<"This is a fee structure program";
cout<<"It can be used to : ";
cout<<"1. View the fee slip of a student of a class";
cout<<"2. Modify the fee structure of the school";
cout<<"3. View the fee structure of the school in the form of alist";
cout<<"The menu functions are described as follows";
cout<<"1. FEE SLIP: This function displays the fee slip for a givenstudent";
cout<<" from the class entered by the user. ";
cout<<"2. MODIFY: This function modifies the fee structure for agive class.";
cout<<" The user can change the fees for various fields";
cout<<"3. LIST: This function displays the list of total feesfor all the";
cout<<" classes in the school ";
cout<<"If you encounter any problems, just press ctrl+break. You willget out ";
cout<<"of the program.";
getch();
cout<<"Press any key to continue...........";
getch();
mainmenu();
}


//**********************************************************
// MAIN FUNCTION TO CREATE MENU AND CALL OTHER FUNCTIONS
//**********************************************************

void main()
{
FEE fee;
fee.ADDITION();
clrscr();
textcolor(MAGENTA);
for(i=10;i<71;i++)
{
textcolor(MAGENTA);
gotoxy(i,15);
delay(30);
printf("/");
}
for(i=70;i>=10;i--)
{
gotoxy(i,22);
delay(30);

}
for(j=16;j<=21;j++)
{
gotoxy(10,j);
delay(100);
printf("-");
}
for(j=21;j>=16;j--)
{
gotoxy(70,j);
delay(100);
printf("-");
}
gotoxy(16,17);
textcolor(BLINK + MAGENTA);
cprintf(" Welcome To Aanchal's Fee Structure System");
gotoxy(12,20);
cprintf("Designed and Coded By Special Technologies (C) 2005-2006");
gotoxy(36,28);
textcolor(LIGHTGREEN);
cprintf("Coded By");
gotoxy(24,34);
textcolor(3);
cprintf("Aanchal Saxena XII 'B'");
gotoxy(44,48);
textcolor(WHITE);
cprintf("Press Any Key To ..........Continue");
getch();
mainmenu();
}

!!!... Employee Management System ...!!!

//Employee management system. A very small project i made in 11th.
//http://www.orkut.co.in/Profile.aspx?uid=1078490536694044848



#include<iostream.h>
#include<string.h>
#include<iomanip.h>
#include<dos.h>
#include<conio.h>
#include<stdio.h>
#define max 20
struct employee
{
char name[20];
long int code;
char designation[20];
int exp;
int age;
};
int num;
employee emp[max],tempemp[max],sortemp[max],sortemp1[max];
void main()
{
clrscr();
void build();
void list();
void insert();
void deletes();
void edit();
void search();
void sort();
char option;
void menu();
menu();
while((option=cin.get())!='q')
{
switch(option)
{
case 'b':
build();
break;
case 'l':
list();
break;
case 'i':
insert();
break;
case 'd':
deletes();
break;
case 'e':
edit();
break;
case 's':
search();
break;
case 'n':
sort();
break;
}
menu();
}
}
void menu()
{
clrscr();
highvideo();
cout<<" ";
cprintf("*****WelCome To Employee Data Centre*****");
normvideo();
cout<<endl;
cout<<" ";
cout<<"Press b---->Built The Employee Table ";
cout<<" ";
cout<<"Press l---->List The Employee Table";
cout<<" ";
cout<<"Press i---->Insert New Entry";
cout<<" ";
cout<<"Press d---->Delete An Entry";
cout<<" ";
cout<<"Press e---->Edit An Entry";
cout<<" ";
cout<<"Press s---->Search Arecord";
cout<<" ";
cout<<"Press n---->Sort The Table";
cout<<" ";
cout<<"Press q---------->QUIT ";
cout<<" ";
cout<<"Option Please ----->";
}

void build()
{

clrscr();
highvideo();
cprintf("Build The Table ");
cout<<endl;
normvideo();
cout<<"maximum number of entries ----- > 20"<<endl;
cout<<"how many do you want ----->";
cin>>num;
cout<<"Enter The Following Items";
for(int i=0;i<=num-1;i++)
{
cout<<" Name ";
cin>>emp[i].name;
cout<<"Code ";
cin>>emp[i].code;
cout<<"Designation ";
cin>>emp[i].designation;
cout<<"Years of Experience ";
cin>>emp[i].exp;
cout<<"Age ";
cin>>emp[i].age;
}
cout<<"going to main menu";
delay(500);
}

void list()
{
clrscr();
highvideo();
cprintf(" ********List The Table********");
cout<<endl;
normvideo();
cout<<" Name Code Designation Years(EXP) Age";
cout<<" ------------------------------------------------------";
for(int i=0;i<=num-1;i++)
{
cout<<setw(13)<<emp[i].name;
cout<<setw(6)<<emp[i].code;
cout<<setw(15)<<emp[i].designation;
cout<<setw(10)<<emp[i].exp;
cout<<setw(15)<<emp[i].age;
cout<<endl;
}
cout<<"going to main menu";
getch();
}
void insert()
{
clrscr();
int i=num;
num+=1;
highvideo();
cprintf("Insert New Record");
cout<<endl;
normvideo();
cout<<"Enter The Following Items";
cout<<"Name ";
cin>>emp[i].name;
cout<<"Code ";
cin>>emp[i].code;
cout<<"Designation ";
cin>>emp[i].designation;
cout<<"Years of Experience ";
cin>>emp[i].exp;
cout<<"Age ";
cin>>emp[i].age;
cout<<endl<<endl;
cout<<"going to main menu";
delay(500);

}


void deletes()
{
clrscr();
highvideo();
int code;
int check;
cprintf("Delete An Entry");
normvideo();
cout<<endl;
cout<<"Enter An JobCode To Delete That Entry ";
cin>>code;
int i;
for(i=0;i<=num-1;i++)
{
if(emp[i].code==code)
{
check=i;
}
}
for(i=0;i<=num-1;i++)
{
if(i==check)
{
continue;
}
else
{
if(i>check)
{
tempemp[i-1]=emp[i];
}
else
{
tempemp[i]=emp[i];
}
}
}
num--;

for(i=0;i<=num-1;i++)
{
emp[i]=tempemp[i];
}
}

void edit()
{
clrscr();
int jobcode;
highvideo();
cprintf(" Edit An Entry ");
cout<<endl;
cout<<endl;
int i;
void editmenu();
void editname(int);
void editcode(int);
void editdes(int);
void editexp(int);
void editage(int);
char option;
normvideo();
cout<<"Enter An jobcode To Edit An Entry---- ";
cin>>jobcode;
editmenu();
for(i=0;i<=num-1;i++)
{
if(emp[i].code==jobcode)
{

while((option=cin.get())!='q')
{
switch(option)
{
case 'n':
editname(i);
break;
case 'c':
editcode(i);
break;
case 'd':
editdes(i);
break;
case 'e':
editexp(i);
break;
case 'a':
editage(i);
break;
}
editmenu();
}
}
}
}
void editmenu()
{
clrscr();
cout<<" What Do You Want To edit";
cout<<" n--------->Name";
cout<<" c--------->Code";
cout<<" d--------->Designation";
cout<<" e--------->Experience";
cout<<" a--------->Age";
cout<<" q----->QUIT";
cout<<" Options Please ---->>> ";
}
void editname(int i)
{
cout<<"Enter New Name-----> ";
cin>>emp[i].name;
}
void editcode(int i)
{
cout<<"Enter New Job Code-----> ";
cin>>emp[i].code;
}
void editdes(int i)
{
cout<<"enter new designation-----> ";
cin>>emp[i].designation;
}
void editexp(int i)
{
cout<<"Enter new Years of Experience";
cin>>emp[i].exp;
}
void editage(int i)
{
cout<<"Enter new Age";
cin>>emp[i].age;
}

void search()
{
clrscr();
highvideo();
cprintf("Welcome To Search Of Employee Database");
normvideo();
cout<<endl;
cout<<endl;
int jobcode;
cout<<"You Can Search Only By Jobcode Of An Employee";
cout<<"Enter Code Of An Employee";
cin>>jobcode;
for(int i=0;i<=num-1;i++)
{
if(emp[i].code==jobcode)
{

cout<<" Name Code Designation Years(EXP) Age";
cout<<" ------------------------------------------------------";
cout<<setw(13)<<emp[i].name;
cout<<setw(6)<<emp[i].code;
cout<<setw(15)<<emp[i].designation;
cout<<setw(10)<<emp[i].exp;
cout<<setw(15)<<emp[i].age;
cout<<endl;
}

}
cout<<"going to main menu";
getch();


}

void sort()
{
clrscr();
highvideo();
cprintf("Sort The Databse By JobCode");
normvideo();
void sortmenu();
void sortname();
void sortcode();
void sortdes();
void sortexp();
char option;
void sortage();

cout<<endl;
cout<<endl;
sortmenu();
while((option=cin.get())!='q')
{
switch(option)
{
case 'n':
sortname();
break;
case 'c':
sortcode();
break;
case 'd':
sortdes();
break;
case 'e':
sortexp();
break;
case 'a':
sortage();
break;
}
sortmenu();
}
}


void sortmenu()
{
clrscr();
cout<<" What Do You Want To edit";
cout<<" n--------->Name";
cout<<" c--------->Code";
cout<<" d--------->Designation";
cout<<" e--------->Experience";
cout<<" a--------->Age";
cout<<" q----->QUIT";
cout<<" Options Please ---->>> ";
}



void sortname()
{
clrscr();
int i,j;
struct employee temp[max];
for(i=0;i<=num-1;i++)
{
sortemp1[i]=emp[i];
}
for(i=0;i<=num-1;i++)
{
for(j=0;j<=num-1;j++)
{
if(strcmp(sortemp1[i].name,sortemp1[j].name)<=0)
{
temp[i]=sortemp1[i];
sortemp1[i]=sortemp1[j];
sortemp1[j]=temp[i];
}
}
}

for( i=0;i<=num-1;i++)
{

cout<<" Name Code Designation Years(EXP) Age";
cout<<" ------------------------------------------------------";
for( i=0;i<=num-1;i++)
{
cout<<setw(13)<<sortemp1[i].name;
cout<<setw(6)<<sortemp1[i].code;
cout<<setw(15)<<sortemp1[i].designation;
cout<<setw(10)<<sortemp1[i].exp;
cout<<setw(15)<<sortemp1[i].age;
cout<<endl;
}
cout<<"Press Any Key To Go Back";
getch();

} }

void sortcode()
{
clrscr();
int i,j;
struct employee temp[max];
for(i=0;i<=num-1;i++)
{
sortemp1[i]=emp[i];
}
for(i=0;i<=num-1;i++)
{
for(j=0;j<=num-1;j++)
{
if(sortemp1[i].code<sortemp1[j].code)
{
temp[i]=sortemp1[i];
sortemp1[i]=sortemp1[j];
sortemp1[j]=temp[i];
}
}
}

for( i=0;i<=num-1;i++)
{

cout<<" Name Code Designation Years(EXP) Age";
cout<<" ------------------------------------------------------";
for( i=0;i<=num-1;i++)
{
cout<<setw(13)<<sortemp1[i].name;
cout<<setw(6)<<sortemp1[i].code;
cout<<setw(15)<<sortemp1[i].designation;
cout<<setw(10)<<sortemp1[i].exp;
cout<<setw(15)<<sortemp1[i].age;
cout<<endl;
}
cout<<"Press Any Key To Go Back";
getch();

} }


void sortdes()
{
clrscr();
int i,j;
struct employee temp[max];
for(i=0;i<=num-1;i++)
{
sortemp1[i]=emp[i];
}
for(i=0;i<=num-1;i++)
{
for(j=0;j<=num-1;j++)
{
if(strcmp(sortemp1[i].designation,sortemp1[j].designation)<=0)
{
temp[i]=sortemp1[i];
sortemp1[i]=sortemp1[j];
sortemp1[j]=temp[i];
}
}
}

for( i=0;i<=num-1;i++)
{

cout<<" Name Code Designation Years(EXP) Age";
cout<<" ------------------------------------------------------";
for( i=0;i<=num-1;i++)
{
cout<<setw(13)<<sortemp1[i].name;
cout<<setw(6)<<sortemp1[i].code;
cout<<setw(15)<<sortemp1[i].designation;
cout<<setw(10)<<sortemp1[i].exp;
cout<<setw(15)<<sortemp1[i].age;
cout<<endl;
}
cout<<"Press Any Key To Go Back";
getch();

} }

void sortage()
{
clrscr();
int i,j;
struct employee temp[max];
for(i=0;i<=num-1;i++)
{
sortemp1[i]=emp[i];
}
for(i=0;i<=num-1;i++)
{
for(j=0;j<=num-1;j++)
{
if(sortemp1[i].age<sortemp1[j].age)
{
temp[i]=sortemp1[i];
sortemp1[i]=sortemp1[j];
sortemp1[j]=temp[i];
}
}
}

for( i=0;i<=num-1;i++)
{

cout<<" Name Code Designation Years(EXP) Age";
cout<<" ------------------------------------------------------";
for( i=0;i<=num-1;i++)
{
cout<<setw(13)<<sortemp1[i].name;
cout<<setw(6)<<sortemp1[i].code;
cout<<setw(15)<<sortemp1[i].designation;
cout<<setw(10)<<sortemp1[i].exp;
cout<<setw(15)<<sortemp1[i].age;
cout<<endl;
}
cout<<"Press Any Key To Go Back";
getch();

} }


void sortexp()
{
clrscr();
int i,j;
struct employee temp[max];
for(i=0;i<=num-1;i++)
{
sortemp1[i]=emp[i];
}
for(i=0;i<=num-1;i++)
{
for(j=0;j<=num-1;j++)
{
if(sortemp1[i].exp<sortemp1[j].exp)
{
temp[i]=sortemp1[i];
sortemp1[i]=sortemp1[j];
sortemp1[j]=temp[i];
}
}
}

for( i=0;i<=num-1;i++)
{

cout<<" Name Code Designation Years(EXP) Age";
cout<<" ------------------------------------------------------";
for( i=0;i<=num-1;i++)
{
cout<<setw(13)<<sortemp1[i].name;
cout<<setw(6)<<sortemp1[i].code;
cout<<setw(15)<<sortemp1[i].designation;
cout<<setw(10)<<sortemp1[i].exp;
cout<<setw(15)<<sortemp1[i].age;
cout<<endl;
}
cout<<"Press Any Key To Go Back";
getch();

} }

!!!Hospital Management System ...!!!

This project is the hospital management system and use the queue data strucutre. A small but a very handy project.

http://www.orkut.co.in/Profile.aspx?uid=1078490536694044848


#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>

// define maximum number of patients in a queue
#define MAXPATIENTS 100

// define structure for patient data
struct patient
{
char FirstName[50];
char LastName[50];
char ID[20];
};


// define class for queue
class queue
{
public:
queue (void);
int AddPatientAtEnd (patient p);
int AddPatientAtBeginning (patient p);
patient GetNextPatient (void);
int RemoveDeadPatient (patient * p);
void OutputList (void);
char DepartmentName[50];
private:
int NumberOfPatients;
patient List[MAXPATIENTS];
};


// declare member functions for queue

queue::queue ()
{
// constructor
NumberOfPatients = 0;
}


int queue::AddPatientAtEnd (patient p)
{
// adds a normal patient to the end of the queue.
// returns 1 if successful, 0 if queue is full.
if (NumberOfPatients >= MAXPATIENTS)
{
// queue is full
return 0;
}
// put in new patient
else
List[NumberOfPatients] = p; NumberOfPatients++;
return 1;
}


int queue::AddPatientAtBeginning (patient p)
{
// adds a critically ill patient to the beginning of the queue.
// returns 1 if successful, 0 if queue is full.
int i;
if (NumberOfPatients >= MAXPATIENTS)
{
// queue is full
return 0;
}

// move all patients one position back in queue
for (i = NumberOfPatients-1; i >= 0; i--)
{
List[i+1] = List[i];
}
// put in new patient
List[0] = p; NumberOfPatients++;
return 1;
}


patient queue::GetNextPatient (void)
{
// gets the patient that is first in the queue.
// returns patient with no ID if queue is empty

int i; patient p;
if (NumberOfPatients == 0) {
// queue is empty
strcpy(p.ID,"");
return p;}
// get first patient
p = List[0];
// move all remaining patients one position forward in queue
NumberOfPatients--;
for (i=0; i<NumberOfPatients; i++)
{
List[i] = List[i+1];
}
// return patient
return p;
}


int queue::RemoveDeadPatient (patient * p)
{
// removes a patient from queue.
// returns 1 if successful, 0 if patient not found
int i, j, found = 0;
// search for patient
for (i=0; i<NumberOfPatients; i++)
{
if (stricmp(List[i].ID, p->ID) == 0)
{
// patient found in queue
*p = List[i]; found = 1;
// move all following patients one position forward in queue
NumberOfPatients--;
for (j=i; j<NumberOfPatients; j++)
{
List[j] = List[j+1];
}
}
}
return found;
}


void queue::OutputList (void)
{
// lists entire queue on screen
int i;
if (NumberOfPatients == 0)
{
cout << "Queue is empty";
}
else
{

for (i=0; i<NumberOfPatients; i++)
{
cout << "" << List[i].FirstName;
cout << " " << List[i].LastName;
cout << " " << List[i].ID;
}
}
}


// declare functions used by main:

patient InputPatient (void)
{
// this function asks user for patient data.
patient p;
cout << "Please enter data for new patient First name: ";
cin.getline(p.FirstName, sizeof(p.FirstName));
cout << "Last name: ";
cin.getline(p.LastName, sizeof(p.LastName));
cout << "Social security number: ";
cin.getline(p.ID, sizeof(p.ID));
// check if data valid
if (p.FirstName[0]==0 || p.LastName[0]==0 || p.ID[0]==0)
{
// rejected
strcpy(p.ID,"");
cout << "Error: Data not valid. Operation cancelled.";
getch();
}
return p;
}


void OutputPatient (patient * p)
{
// this function outputs patient data to the screen
if (p == NULL || p->ID[0]==0)
{
cout << "No patient";
return;
}
else
cout << "Patient data:";
cout << "First name: " << p->FirstName;
cout << "Last name: " << p->LastName;
cout << "Social security number: " << p->ID;
}


int ReadNumber()
{
// this function reads an integer number from the keyboard.
// it is used because input with cin >> doesn't work properly!
char buffer[20];
cin.getline(buffer, sizeof(buffer));
return atoi(buffer);
}


void DepartmentMenu (queue * q)
{
// this function defines the user interface with menu for one department
int choice = 0, success;
patient p;
while (choice != 6)
{
// clear screen
clrscr();
// print menu
cout << "Welcome to department: " << q->DepartmentName;
cout << "Please enter your choice:";
cout << "1: Add normal patient\n";
cout << "2: Add critically ill patient\n";
cout << "3: Take out patient for operation\n";
cout << "4: Remove dead patient from queue\n";
cout << "5: List queue\n";
cout << "6: Change department or exit\n";
// get user choice
choice = ReadNumber();
// do indicated action
switch (choice)
{
case 1: // Add normal patient
p = InputPatient();
if (p.ID[0])
{
success = q->AddPatientAtEnd(p);
clrscr();
if (success)
{
cout << "Patient added:";

}
else
{
// error
cout << "Error: The queue is full. Cannot add patient:";
}
OutputPatient(&p);
cout << "Press any key";
getch();
}
break;

case 2: // Add critically ill patient
p = InputPatient();
if (p.ID[0])
{
success = q->AddPatientAtBeginning(p);
clrscr();
if (success)
{
cout << "Patient added:";
}
else
{
// error
cout << "Error: The queue is full. Cannot add patient:";
}

OutputPatient(&p);
cout << "Press any key";
getch();
}
break;

case 3: // Take out patient for operation
p = q->GetNextPatient();
clrscr();
if (p.ID[0])
{
cout << "Patient to operate:";
OutputPatient(&p);}
else
{
cout << "There is no patient to operate.";
}
cout << "Press any key";
getch();
break;

case 4: // Remove dead patient from queue
p = InputPatient();
if (p.ID[0])
{
success = q->RemoveDeadPatient(&p);
clrscr();
if (success)
{
cout << "Patient removed:";
}
else
{
// error
cout << "Error: Cannot find patient:";
}
OutputPatient(&p);
cout << "Press any key";
getch();
}
break;

case 5: // List queue
clrscr();
q->OutputList();
cout << "Press any key";
getch(); break;
}
}
}


// main function defining queues and main menu
void main ()
{
int i, MenuChoice = 0;
// define three queues
queue departments[3];
// set department names
strcpy (departments[0].DepartmentName, "Heart clinic");
strcpy (departments[1].DepartmentName, "Lung clinic");
strcpy (departments[2].DepartmentName, "Plastic surgery");

while (MenuChoice != 4)
{
// clear screen
clrscr();
// print menu
cout << "Welcome to Software City Hospital";
cout << "Please enter your choice:";
for (i = 0; i < 3; i++)
{
// write menu item for department i
cout << "" << (i+1) << ": " << departments[i].DepartmentName;
}
cout << "4: Exit";
// get user choice
MenuChoice = ReadNumber();
// is it a department name?
if (MenuChoice >= 1 && MenuChoice <= 3)
{
// call submenu for department
// (using pointer arithmetics here:)
DepartmentMenu (departments + (MenuChoice-1));
}
}
}


!!!... Books Library Project ...!!!

I Got this project from my cousin.Very very nice project.

http://www.orkut.co.in/Profile.aspx?uid=1078490536694044848


//**********************************************************
// PROJECT BOOK LIBRARY
//**********************************************************

//**********************************************************
// INCLUDED HEADER FILES
//**********************************************************

#include <iostream.h>
#include <fstream.h>
#include <process.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <dos.h>


//**********************************************************
// THIS CLASS CONTROL ALL THE FUNCTIONS IN THE MENU
//**********************************************************


class MENU
{
public :
void main_menu(void) ;
void introduction(void) ;
private :
void edit_menu(void) ;
void edit_book(void) ;
void edit_member(void) ;
} ;


//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO BOOKS
//**********************************************************

class BOOK
{
public :
void list(void) ;
char *bookname(int) ;
protected :
void add_new_book(int, char tname[33], char tauthor[26], float, int, int) ;
void update_copies(int, int, int) ;
void modify(int, char[], char[], float) ;
void deletion(void) ;
int book_found(int) ;
int bookname_found(char []) ;
int recordno(int) ;
int available(int) ;
char *authorname(int) ;
float bookprice(int) ;
int no_of_copies(int) ;
int bookcodeof(char[]) ;
void display(int) ;
int reccount(void) ;
void delete_rec(int) ;
private :
int bookcode, copies ;
char name[33], author[26] ;
float price ;
int avail ;
} ;


//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO MEMBERS
//**********************************************************

class MEMBER
{
public :
void Mlist(void) ;
protected :
void Madd_mem(int, int, char [], char [], char[], int, int, int) ;
void Mmodify(int, char[], char[], char[]) ;
void Mdeletion(void) ;
int Mmember_found(int) ;
void Mupdate_book(int, int, int, int, int) ;
char *Mmembername(int) ;
char *Mmemberphone(int) ;
char *Mmemberaddress(int) ;
int Mrecordno(int) ;
int Mlastcode(void) ;
int Missued(int) ;
int Mfine(int) ;
int Mreccount(void);
void Mdisplay(int) ;
void Mdelete_rec(int) ;
private :
int memcode, bookcode ;
char name[26], phone[10], address[33] ;
int dd, mm, yy ; // DATE OF RETURNING THE BOOK //
} ;


//**********************************************************
// THIS IS DERIVED FROM CLASS BOOK & MEMBER AND CONTAINS
// FUNCTIONS FOR WORKING (ISSUE,RETURN,ETC).
//**********************************************************

class WORKING : public BOOK, MEMBER
{
public :
void issuebook(void) ;
void returnbook(void) ;
void add_book(void) ;
void add_member(void) ;
void modify_book(void) ;
void modify_member(void) ;
void delete_book(void) ;
void delete_member(void) ;
} ;


//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED DATE & FINE
//**********************************************************

class DATE
{
public :
void extend_date(int,int,int,int) ;
int diff(int, int, int, int, int, int) ;
int day, mon, year ;
} ;



//**********************************************************
// FUNCTION TO EXTEND GIVEN DATE BY 15 DAYS
//**********************************************************

void DATE :: extend_date(int d1, int m1, int y1, int days)
{
static int month[] = {31,29,31,30,31,30,31,31,30,31,30,31} ;
for (int i=1; i<=days; i++)
{
d1++ ;
if ((d1 > month[m1-1]) || (y1%4 != 0 && m1 == 2 && d1 > 28))
{
d1 = 1 ;
m1++ ;
}
if (m1 > 12)
{
m1 = 1 ;
y1++ ;
}
}
day = d1 ;
mon = m1 ;
year = y1 ;
}


//**********************************************************
// THIS FUNCTION RETURN THE DIFFERENCE BETWEEN TWO GIVEN
// DATES
//**********************************************************

int DATE :: diff(int d1, int m1, int y1, int d2, int m2, int y2)
{
int days = 0 ;
if ((y2<y1) || (y2==y1 && m2<m1) || (y2==y1 && m2==m1 && d2<d1))
return days ;
static int month[] = {31,29,31,30,31,30,31,31,30,31,30,31} ;
while (d1 != d2 || m1 != m2 || y1 != y2)
{
days++ ;
d1++ ;
if ((d1 > month[m1-1]) || (y1%4 != 0 && m1 == 2 && d1 > 28))
{
d1 = 1 ;
m1++ ;
}
if (m1 > 12)
{
m1 = 1 ;
y1++ ;
}
}
return days ;
}


//**********************************************************
// FUNCTION TO DISPLAY MAIN MENU & CONTROL ALL THE FUNCTION
// IN THE MAIN MENU.
//**********************************************************

void MENU :: main_menu(void)
{
char ch ;
while (1)
{
clrscr() ;
gotoxy(29,6) ;
cout <<"B O O K L I B R A R Y" ;
gotoxy(29,7) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(30,10) ;
cout <<"1. INTRODUCTION" ;
gotoxy(30,11) ;
cout <<"2. ADD NEW BOOK" ;
gotoxy(30,12) ;
cout <<"3. ADD NEW MEMBER" ;
gotoxy(30,13) ;
cout <<"4. ISSUE BOOK" ;
gotoxy(30,14) ;
cout <<"5. RETURN BOOK" ;
gotoxy(30,15) ;
cout <<"6. LIST OF BOOKS" ;
gotoxy(30,16) ;
cout <<"7. LIST OF MEMBERS" ;
gotoxy(30,17) ;
cout <<"8. EDIT" ;
gotoxy(30,18) ;
cout <<"0. QUIT" ;
gotoxy(30,20) ;
cout <<"Enter your choice : " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
introduction() ;
else
if (ch == '2')
{
WORKING W ;
W.add_book() ;
}
else
if (ch == '3')
{
WORKING W ;
W.add_member() ;
}
else
if (ch == '4')
{
WORKING W ;
W.issuebook() ;
}
else
if (ch == '5')
{
WORKING W ;
W.returnbook() ;
}
else
if (ch == '6')
{
BOOK B ;
B.list() ;
}
else
if (ch == '7')
{
MEMBER M ;
M.Mlist() ;
}
else
if (ch == '8')
edit_menu() ;
else
if (ch == '0')
break ;
}
}


//**********************************************************
// FUNCTION TO DISPLAY EDIT MENU
//**********************************************************

void MENU :: edit_menu(void)
{
char ch ;
while (1)
{
clrscr() ;
gotoxy(32,9) ;
cout <<"E D I T M E N U";
gotoxy(32,10) ;
cout <<"~~~~~~~~~~~~~~~~" ;
gotoxy(34,13) ;
cout <<"1. BOOKS" ;
gotoxy(34,14) ;
cout <<"2. MEMBERS" ;
gotoxy(34,15) ;
cout <<"0. EXIT" ;
gotoxy(31,17) ;
cout <<"Enter your choice : " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch =='1')
edit_book() ;
else
if (ch == '2')
edit_member() ;
else
if (ch == '0')
break ;
}
}


//**********************************************************
// FUNCTION TO DISPLAY EDIT MENU FOR BOOK & CONTROL
// ALL THE FUNCTION IN THE EDIT MENU.
//**********************************************************

void MENU :: edit_book(void)
{
char ch ;
while (1)
{
clrscr() ;
gotoxy(31,9) ;
cout <<"E D I T B O O K S";
gotoxy(31,10) ;
cout <<"~~~~~~~~~~~~~~~~~~" ;
gotoxy(34,13) ;
cout <<"1. MODIFY" ;
gotoxy(34,14) ;
cout <<"2. DELETE" ;
gotoxy(34,15) ;
cout <<"0. EXIT" ;
gotoxy(31,17) ;
cout <<"Enter your choice : " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
{
WORKING W ;
W.modify_book() ;
}
else
if (ch == '2')
{
WORKING W ;
W.delete_book() ;
}
else
if (ch == '0')
break ;
}
}


//**********************************************************
// FUNCTION TO DISPLAY EDIT MENU FOR MEMBERS & CONTROL
// ALL THE FUNCTION IN THE EDIT MENU.
//**********************************************************

void MENU :: edit_member(void)
{
char ch ;
while (1)
{
clrscr() ;
gotoxy(29,9) ;
cout <<"E D I T M E M B E R S";
gotoxy(29,10) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(34,13) ;
cout <<"1. MODIFY" ;
gotoxy(34,14) ;
cout <<"2. DELETE" ;
gotoxy(34,15) ;
cout <<"0. EXIT" ;
gotoxy(29,17) ;
cout <<"Enter your choice : " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
{
WORKING W ;
W.modify_member() ;
}
else
if (ch == '2')
{
WORKING W ;
W.delete_member() ;
}
else
if (ch == '0')
break ;
}
}


//**********************************************************
// FUNCTION TO DISPLAY THE INTRODUCTION FOR THE PROJECT.
//**********************************************************

void MENU :: introduction(void)
{
clrscr() ;
gotoxy(26,2);
cout<<"BOOKS ARE YOUR BEST FRIEND";
gotoxy(26,3);
cout<<"***************************";
gotoxy(31,5) ;
cout <<"Welcome to Project" ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(33,7) ;
cprintf(" BOOK LIBRARY ") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
gotoxy(15,10) ;
cout <<"This project has facility of maintaining records" ;
gotoxy(15,11) ;
cout <<"of BOOKS and MEMBERS." ;
gotoxy(15,13) ;
cout <<"This project can hold large number of books" ;
gotoxy(15,14) ;
cout <<"records." ;
gotoxy(15,16) ;
cout <<"One member can issue one book at a time. If he/she" ;
gotoxy(15,17) ;
cout <<"does not return book upto 15 days he/she have to" ;
gotoxy(15,18) ;
cout <<"pay fine of Rs.2/- per day." ;
textcolor(LIGHTGRAY+BLINK) ;
gotoxy(27,24) ;
cprintf("Press any key to continue") ;
textcolor(LIGHTGRAY) ;
getch() ;
}


//**********************************************************
// THIS FUNCTION RETURN 0 IF GIVEN BOOK CODE NOT FOUND
//**********************************************************

int BOOK :: book_found(int tcode)
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(BOOK)))
{
if (bookcode == tcode)
{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}


//**********************************************************
// THIS FUNCTION RETURN 0 IF GIVEN BOOK NAME NOT FOUND
//**********************************************************

int BOOK :: bookname_found(char t1code[33])
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(BOOK)))
{
if (!strcmpi(name,t1code))
{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}


//**********************************************************
// THIS FUNCTION RETURN RECORD NO. FOR THE BOOK CODE
//**********************************************************

int BOOK :: recordno(int tcode)
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(BOOK)))
{
count++ ;
if (bookcode == tcode)
break ;
}
file.close() ;
return count ;
}


//**********************************************************
// THIS FUNCTION RETURNS THE AVAILABLE COPIES FOR THE GIVEN
// BOOK CODE.
//**********************************************************

int BOOK :: available(int tcode)
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int tavail=0 ;
while (file.read((char *) this, sizeof(BOOK)))
{
if (bookcode == tcode)
{
tavail = avail ;
break ;
}
}
file.close() ;
return tavail ;
}


//**********************************************************
// THIS FUNCTION RETURNS THE NO. OF COPIES FOR THE GIVEN
// BOOK CODE.
//**********************************************************

int BOOK :: no_of_copies(int tcode)
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int tcopies=0 ;
while (file.read((char *) this, sizeof(BOOK)))
{
if (bookcode == tcode)
{
tcopies = copies ;
break ;
}
}
file.close() ;
return tcopies ;
}


//**********************************************************
// THIS FUNCTION RETURNS THE BOOK NAME OF THE GIVEN BOOK
// CODE.
//**********************************************************

char *BOOK :: bookname(int tcode)
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
char tname[33] ;
while (file.read((char *) this, sizeof(BOOK)))
{
if (bookcode == tcode)
{
strcpy(tname,name) ;
break ;
}
}
file.close() ;
return tname ;
}


//**********************************************************
// THIS FUNCTION RETURNS THE AUTHOR NAME OF THE GIVEN BOOK
// CODE.
//**********************************************************

char *BOOK :: authorname(int tcode)
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
char tauthor[26] ;
while (file.read((char *) this, sizeof(BOOK)))
{
if (bookcode == tcode)
{
strcpy(tauthor,author) ;
break ;
}
}
file.close() ;
return tauthor ;
}


//**********************************************************
// THIS FUNCTION RETURNS THE BOOK PRICE OF THE GIVEN BOOK
// CODE.
//**********************************************************

float BOOK :: bookprice(int tcode)
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
float tprice=0.0 ;
while (file.read((char *) this, sizeof(BOOK)))
{
if (bookcode == tcode)
{
tprice = price ;
break ;
}
}
file.close() ;
return tprice ;
}


//**********************************************************
// THIS FUNCTION RETURNS THE BOOK CODE OF THE GIVEN BOOK
// NAME.
//**********************************************************

int BOOK :: bookcodeof(char t1code[33])
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int tcode=0 ;
while (file.read((char *) this, sizeof(BOOK)))
{
if (!strcmpi(name,t1code))
{
tcode = bookcode ;
break ;
}
}
file.close() ;
return tcode ;
}


//**********************************************************
// THIS FUNCTION RETURNS THE NO. OF THE RECORDS IN THE BOOK
// FILE.
//**********************************************************

int BOOK :: reccount(void)
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(BOOK)))
count++ ;
file.close() ;
return count ;
}

//**********************************************************
// THIS FUNCTION RETURNS THE NO. OF THE MEMBERS.
//**********************************************************

int MEMBER :: Mreccount(void)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(MEMBER)))
count++ ;
file.close() ;
return count ;
}


//**********************************************************
// THIS FUNCTION DELETES THE RECORD OF THE GIVEN BOOK CODE.
//**********************************************************

void BOOK :: delete_rec(int tcode)
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
fstream temp ;
temp.open("temp.dat", ios::out|ios::binary) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(BOOK)) ;
if ( file.eof() )
break ;
if ( bookcode != tcode )
temp.write((char *) this, sizeof(BOOK)) ;
}
file.close() ;
temp.close() ;
file.open("BOOK.DAT", ios::out|ios::binary) ;
temp.open("temp.dat", ios::in|ios::binary) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(BOOK)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(BOOK)) ;
}
file.close() ;
temp.close() ;
}


//**********************************************************
// THIS FUNCTION ADD THE RECORD IN THE BOOK FILE
//**********************************************************

void BOOK :: add_new_book(int tcode,char tname[33], char tauthor[26], float tprice, int tcopies, int tavail)
{
fstream file ;
file.open("BOOK.DAT", ios::app|ios::binary) ;
bookcode = tcode ;
strcpy(name,tname) ;
strcpy(author,tauthor) ;
price = tprice ;
copies = tcopies ;
avail = tavail ;
file.write((char *) this, sizeof(BOOK)) ;
file.close() ;
}


//**********************************************************
// THIS FUNCTION UPDATE THE RECORD IN THE BOOK FILE FOR THE
// GIVEN BOOK CODE
//**********************************************************

void BOOK :: update_copies(int tcode, int tcopies, int tavail)
{
int recno ;
recno = recordno(tcode) ;
fstream file ;
file.open("BOOK.DAT", ios::out | ios::ate|ios::binary) ;
copies = tcopies ;
avail = tavail ;
int location ;
location = (recno-1) * sizeof(BOOK) ;
file.seekp(location) ;
file.write((char *) this, sizeof(BOOK)) ;
file.close() ;
}


//**********************************************************
// THIS FUNCTION MODIFY THE RECORD IN THE BOOK FILE FOR THE
// GIVEN BOOK CODE
//**********************************************************

void BOOK :: modify(int tcode, char tname[33], char tauthor[26], float tprice)
{
int recno ;
recno = recordno(tcode) ;
fstream file ;
file.open("BOOK.DAT", ios::out | ios::ate|ios::binary) ;
strcpy(name,tname) ;
strcpy(author,tauthor) ;
price = tprice ;
int location ;
location = (recno-1) * sizeof(BOOK) ;
file.seekp(location) ;
file.write((char *) this, sizeof(BOOK)) ;
file.close() ;
}


//**********************************************************
// THIS FUNCTION DISPLAY THE RECORD FROM THE BOOK FILE
// FOR THE GIVEN BOOK CODE
//**********************************************************

void BOOK :: display(int tcode)
{
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(BOOK)))
{
if (bookcode == tcode)
{
gotoxy(5,5) ;
cout <<"Book Code : " <<bookcode ;
gotoxy(5,7) ;
cout <<"Book Name : " <<name ;
gotoxy(5,8) ;
cout <<"Author Name : " <<author ;
gotoxy(5,9) ;
cout <<"Price : Rs." <<price ;
gotoxy(5,10) ;
cout <<"Copies : " <<copies ;
gotoxy(5,11) ;
cout <<"Available : " <<avail ;
break ;
}
}
file.close() ;
}


//**********************************************************
// THIS FUNCTION DISPLAY THE LIST OF BOOKS.
//**********************************************************

void BOOK :: list(void)
{
clrscr() ;
int row = 6 , found=0, flag=0 ;
char ch ;
gotoxy(33,2) ;
cout <<"LIST OF BOOKS" ;
gotoxy(32,3) ;
cout <<"~~~~~~~~~~~~~~~" ;
gotoxy(1,4) ;
cout <<"CODE BOOK NAME AUTHOR PRICE COPIES" ;
gotoxy(1,5) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
fstream file ;
file.open("BOOK.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(BOOK)))
{
flag = 0 ;
delay(20) ;
found = 1 ;
gotoxy(2,row) ;
cout <<bookcode ;
gotoxy(7,row) ;
cout <<name ;
gotoxy(40,row) ;
cout <<author ;
gotoxy(66,row) ;
cout <<price ;
gotoxy(73,row) ;
cout <<copies ;
textbackground(WHITE) ; textcolor(BLACK) ;
gotoxy(40,row+1) ;
cprintf("STATUS: ") ;
textcolor(BLACK+BLINK) ;
cprintf("%d copies available",avail) ;
textbackground(BLACK) ; textcolor(LIGHTGRAY) ;
if ( row == 22 )
{
flag = 1 ;
row = 6 ;
gotoxy(1,25) ;
cout <<"Press any key to continue or Press <ESC> to exit" ;
ch = getch() ;
if (ch == 27)
break ;
clrscr() ;
gotoxy(33,2) ;
cout <<"LIST OF BOOKS" ;
gotoxy(32,3) ;
cout <<"~~~~~~~~~~~~~~~" ;
gotoxy(1,4) ;
cout <<"CODE BOOK NAME AUTHOR PRICE COPIES" ;
gotoxy(1,5) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
}
else
row = row + 2 ;
}
if (!found)
{
gotoxy(5,10) ;
cout <<"\7Records not found" ;
}
if (!flag)
{
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getche() ;
}
file.close () ;
}


//**********************************************************
// THIS FUNCTION RETURN 0 IF THE GIVEN MEMBER CODE NOT FOUND
//**********************************************************

int MEMBER :: Mmember_found(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}


//**********************************************************
// THIS FUNCTION RETURN 0 IF THE MEMBER HAVE NOT ISSUED ANY
// BOOK.
//**********************************************************

int MEMBER :: Missued(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int missue=0 ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
missue = bookcode ;
break ;
}
}
file.close() ;
return missue ;
}


//**********************************************************
// THIS FUNCTION CALCULATE AND RETURN FINE FOR THE GIVEN
// MEMBER CODE.
//**********************************************************

int MEMBER :: Mfine(int mcode)
{
DATE D ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int days, t_fine ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
days = D.diff(dd,mm,yy,d1,m1,y1) ;
t_fine = days * 2 ;
break ;
}
}
file.close() ;
return t_fine ;
}


//**********************************************************
// THIS FUNCTION RETURN THE LAST CODE OF THE MEMBER FILE.
//**********************************************************

int MEMBER :: Mlastcode(void)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int mcode=0 ;
while (file.read((char *) this, sizeof(MEMBER)))
mcode = memcode ;
file.close() ;
return mcode ;
/*


fstream file ;
file.open("MEMBER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int mcode=0 ;
do
{
file.read((char *) this, sizeof(MEMBER));
if (memcode<=0)
{
break;
}
mcode++;
}while (!file.eof());
file.close() ;
return mcode ;*/
}


//**********************************************************
// THIS FUNCTION RETURNS MEMBER NAME OF THE GIVEN MEMBER
// CODE.
//**********************************************************

char *MEMBER :: Mmembername(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
char mname[26] ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
strcpy(mname,name) ;
break ;
}
}
file.close() ;
return mname ;
}


//**********************************************************
// THIS FUNCTION RETURNS MEMBER PHONE OF THE GIVEN MEMBER
// CODE.
//**********************************************************

char *MEMBER :: Mmemberphone(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
char mphone[10] ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
strcpy(mphone,phone) ;
break ;
}
}
file.close() ;
return mphone ;
}


//**********************************************************
// THIS FUNCTION RETURNS MEMBER ADDRESS OF THE GIVEN MEMBER
// CODE.
//**********************************************************

char *MEMBER :: Mmemberaddress(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
char maddress[33] ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
strcpy(maddress,address) ;
break ;
}
}
file.close() ;
return maddress ;
}


//**********************************************************
// THIS FUNCTION RETURNS RECORD NO. OF THE GIVEN MEMBER
// CODE.
//**********************************************************

int MEMBER :: Mrecordno(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(MEMBER)))
{
count++ ;
if (memcode == mcode)
break ;
}
file.close() ;
return count ;
}


//**********************************************************
// THIS FUNCTION DELETE RECORD FOR THE GIVEN MEMBER CODE.
//**********************************************************

void MEMBER :: Mdelete_rec(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
fstream temp ;
temp.open("temp.dat", ios::out|ios::binary) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(MEMBER)) ;
if ( file.eof() )
break ;
if ( memcode != mcode )
temp.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
file.open("MEMBER.DAT", ios::out|ios::binary) ;
temp.open("temp.dat", ios::in|ios::binary) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(MEMBER)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
}


//**********************************************************
// THIS FUNCTION UPDATE RECORD FOR THE GIVEN MEMBER CODE.
//**********************************************************

void MEMBER :: Mupdate_book(int mcode, int tcode, int d1, int m1, int y1)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
fstream temp ;
temp.open("temp.dat", ios::out|ios::binary) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(MEMBER)) ;
if ( file.eof() )
break ;
if ( memcode == mcode )
{
bookcode = tcode ;
dd = d1 ;
mm = m1 ;
yy = y1 ;
temp.write((char *) this, sizeof(MEMBER)) ;
}
else
temp.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
file.open("MEMBER.DAT", ios::out|ios::binary) ;
temp.open("temp.dat", ios::in|ios::binary) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(MEMBER)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
}


//**********************************************************
// THIS FUNCTION MODIFY RECORD FOR THE GIVEN MEMBER CODE.
//**********************************************************

void MEMBER :: Mmodify(int mcode, char mname[26], char mphone[10], char maddress[33])
{
int recno ;
recno = Mrecordno(mcode) ;
fstream file ;
file.open("MEMBER.DAT", ios::out |ios::binary| ios::ate) ;
strcpy(name,mname) ;
strcpy(phone,mphone) ;
strcpy(address,maddress) ;
int location ;
location = (recno-1) * sizeof(MEMBER) ;
file.seekp(location) ;
file.write((char *) this, sizeof(MEMBER)) ;
file.close() ;
}


//**********************************************************
// THIS FUNCTION ADD RECORD IN THE FILE FOR THE GIVEN
// MEMBER CODE.
//**********************************************************

void MEMBER :: Madd_mem(int mcode, int bcode, char* mname, char* maddress, char* mphone, int d1, int m1, int y1)
{
// printf("%d",mcode);
fstream file ;
file.open("MEMBER.DAT",ios::binary|ios::out|ios::app);
memcode = mcode ;
bookcode = bcode ;
strcpy(name,mname) ;
strcpy(address,maddress) ;
strcpy(phone,mphone) ;
dd = d1 ;
mm = m1 ;
yy = y1 ;
file.write((char *) this, sizeof(MEMBER)) ;
file.close() ;
}


//**********************************************************
// THIS FUNCTION DISPLAY THE RECORD FOR THE GIVEN MEMBER
// CODE.
//**********************************************************

void MEMBER :: Mdisplay(int mcode)
{
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
gotoxy(5,3) ;
cout <<"Member Code " <<mcode ;
gotoxy(5,4) ;
cout <<"~~~~~~~~~~~~~~~~~" ;
gotoxy(5,6) ;
cout <<"Name : " <<name ;
gotoxy(5,7) ;
cout <<"Phone : " <<phone ;
gotoxy(5,8) ;
cout <<"Address : " <<address ;
break ;
}
}
file.close() ;
}


//**********************************************************
// THIS FUNCTION DISPLAY THE LIST OF THE MEMBERS
//**********************************************************

void MEMBER :: Mlist(void)
{
clrscr() ;
BOOK B ;
int row = 6 , found=0, flag=0 ;
char ch ;
gotoxy(32,2) ;
cout <<"LIST OF MEMBERS" ;
gotoxy(31,3) ;
cout <<"~~~~~~~~~~~~~~~~~" ;
gotoxy(1,4) ;
cout <<"CODE BOOK CODE NAME PHONE" ;
gotoxy(1,5) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
fstream file ;
file.open("MEMBER.DAT", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
file.read((char *) this, sizeof(MEMBER));
do
{
flag = 0 ;
if (memcode<=0)
goto rss;
delay(20) ;
found = 1 ;
gotoxy(2,row) ;
cout <<memcode ;
gotoxy(10,row) ;
cout <<bookcode ;
gotoxy(19,row) ;
cout <<name ;
gotoxy(48,row) ;
cout <<phone ;
textbackground(WHITE) ; textcolor(BLACK) ;
gotoxy(7,row+1) ;
if (bookcode == 0)
cprintf("BOOK NAME: (Not Issued)") ;
else
{
cprintf("BOOK NAME: %s",B.bookname(bookcode)) ;
gotoxy(42,row+1) ;
cprintf("Date of return: ") ;
textcolor(BLACK+BLINK) ;
cprintf("%d/%d/%d",dd,mm,yy) ;
}
textbackground(BLACK) ; textcolor(LIGHTGRAY) ;
if ( row == 22 )
{
flag = 1 ;
row = 6 ;
gotoxy(1,25) ;
cout <<"Press any key to continue or Press <ESC> to exit" ;
ch = getch() ;
if (ch == 27)
break ;
clrscr() ;
gotoxy(32,2) ;
cout <<"LIST OF MEMBERS" ;
gotoxy(31,3) ;
cout <<"~~~~~~~~~~~~~~~~~" ;
gotoxy(1,4) ;
cout <<"CODE BOOK CODE NAME PHONE" ;
gotoxy(1,5) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
}
else
row = row + 2 ;
file.read((char *) this, sizeof(MEMBER));
}while (!file.eof());
rss:
if (!found)
{
gotoxy(5,10) ;
cout <<"\7Records not found" ;
}
if (!flag)
{
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getche() ;
}
file.close () ;
}


//**********************************************************
// THIS FUNCTION GIVES DATA TO ADD RECORD IN THE BOOK FILE.
//**********************************************************

void WORKING :: add_book(void)
{
if (!reccount()) // MEMBER FUNCTION OF BOOK
{
add_new_book(0,"null","null",0.0,0,0) ;
BOOK::delete_rec(0) ;
}
char ch ;
int tcode, tcopies, tavail ;
char tname[33], tauthor[26] ;
float tprice=0.0 ;
do
{
int found=0, valid=0 ;
int tc ;
float t2=0.0 ;
char t[10], t1[10] ;
clrscr() ;
gotoxy(29,3) ;
cout <<"ADDITION OF THE BOOKS" ;
gotoxy(29,4) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,25) ;
cout <<"Enter code no. of the book" ;
gotoxy(5,5) ;
cout <<"Code no. " ;
gets(t) ;
tc = atoi(t) ;
tcode = tc ;
if (tcode == 0)
return ;
if (book_found(tcode))
{
found = 1 ;
gotoxy(19,8) ;
cout <<bookname(tcode) ;
gotoxy(19,9) ;
cout <<authorname(tcode) ;
gotoxy(22,10) ;
cout <<bookprice(tcode) ;
}
gotoxy(5,8) ;
cout <<"Book Name : " ;
gotoxy(5,9) ;
cout <<"Author Name : " ;
gotoxy(5,10) ;
cout <<"Price : Rs." ;
gotoxy(5,12) ;
cout <<"Copies : " ;
valid = 0 ;
while (!valid && !found)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the name of the book" ;
gotoxy(19,8) ; clreol() ;
gets(tname) ;
strupr(tname) ;
if (tname[0] == '0')
return ;
if (strlen(tname) < 1 || strlen(tname) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..32)" ;
getch() ;
}
}
valid = 0 ;
while (!valid && !found)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the author's name of the book" ;
gotoxy(19,9) ; clreol() ;
gets(tauthor) ;
strupr(tauthor) ;
if (tauthor[0] == '0')
return ;
if (strlen(tauthor) < 1 || strlen(tauthor) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..25)" ;
getch() ;
}
}
valid = 0 ;
while (!valid && !found)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the price of the book" ;
gotoxy(22,10) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tprice = t2 ;
if (t1[0] == '0')
return ;
if (tprice < 1 || tprice > 9999)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
}
valid = 0 ;
while (!valid)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter no. of copies of book to be added" ;
gotoxy(19,12) ; clreol() ;
gets(t) ;
tc = atoi(t) ;
tcopies = tc ;
if (t[0] == '0')
return ;
if (tcopies < 1 || tcopies > 50)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
}
tavail = available(tcode) + tcopies ;
tcopies = no_of_copies(tcode) + tcopies ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,15) ; clreol() ;
cout <<"Do you want to save (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;

if (ch == 'Y')
{
if (found)
update_copies(tcode,tcopies,tavail) ;
else
add_new_book(tcode,tname,tauthor,tprice,tcopies,tavail) ;
}
do
{
gotoxy(5,17) ; clreol() ;
cout <<"Do you want to add more (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
} while (ch == 'Y') ;
}


//**********************************************************
// THIS FUNCTION GIVES DATA TO ADD RECORD IN THE MEMBER FILE
//**********************************************************

void WORKING :: add_member(void)
{

// if (!Mreccount()) // MEMBER FUNCTION OF BOOK
// {
// MEMBER::Madd_mem(0, 0, "null","null","null", 0, 0, 0) ;
// MEMBER::Mdelete_rec(0) ;
// }
char ch ;
int mcode, bcode ;
char mname[26], mphone[10], maddress[33] ;
int d1, m1, y1 ;
// mcode = Mlastcode() ;
// mcode++ ;

do
{
mcode = Mlastcode() ;
mcode++ ;
int valid=0 ;
clrscr() ;
gotoxy(28,3) ;
cout <<"ADDITION OF THE MEMBERS" ;
gotoxy(28,4) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,7) ;
cout <<"Member Code # " <<mcode ;
gotoxy(5,8) ;
cout <<"~~~~~~~~~~~~~~~~~" ;
gotoxy(5,10) ;
cout <<"Name : " ;
gotoxy(5,12) ;
cout <<"Phone : " ;
gotoxy(5,14) ;
cout <<"Address : " ;

do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the name of the New Member" ;
gotoxy(15,10) ; clreol() ;
gets(mname) ;
strupr(mname) ;
if (mname[0] == '0')
return ;
if (strlen(mname) < 1 || strlen(mname) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter Phone no. of the Member or Press <ENTER> for none" ;
gotoxy(15,12) ; clreol() ;
gets(mphone) ;
if (mphone[0] == '0')
return ;
if ((strlen(mphone) < 6 && strlen(mphone) > 0) || (strlen(mphone) > 9))
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(mphone) == 0)
strcpy(mphone,"-") ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the address of the New Member" ;
gotoxy(15,14) ; clreol() ;
gets(maddress) ;
strupr(maddress) ;
if (maddress[0] == '0')
return ;
if (strlen(maddress) < 1 || strlen(maddress) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..32)" ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,17) ; clreol() ;
cout <<"Do you want to save (y/n) : " ;
cin>>ch ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'Y')
{
bcode = 0 ;
d1 = 0 ;
m1 = 0 ;
y1 = 0 ;
Madd_mem(mcode,bcode,mname,maddress,mphone,d1,m1,y1) ;
}
do
{
gotoxy(5,19) ; clreol() ;
cout <<"Do you want to add more (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
} while (ch == 'Y') ;
}


//**********************************************************
// THIS FUNCTION ISSUES THE BOOK
//**********************************************************

void WORKING :: issuebook(void)
{
BOOK B ;
MEMBER M ;
DATE D ;
char t1code[33], ch ;
int t2code=0, tcode=0, mcode=0 ;
int valid ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(5,2) ;
cout <<"Date : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,5) ;
cout <<"Enter Code or Name of the Book to be issued" ;
gotoxy(5,6) ;
cout <<" or " ;
gotoxy(5,7) ;
cout <<"Press <ENTER> for help " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
B.list() ;
else
break ;
}
t2code = atoi(t1code) ;
tcode = t2code ;
if ((tcode == 0 && !bookname_found(t1code)) || (tcode != 0 && !book_found(tcode)))
{
valid = 0 ;
gotoxy(5,10) ;
cout <<"\7Record not found" ;
gotoxy(5,11) ;
cout <<"Press <ESC> to exit or any other key to continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
if (tcode == 0)
tcode = bookcodeof(t1code) ;
if (!available(tcode))
{
gotoxy(5,10) ;
cout <<"\7Sorry! Book (" <<bookname(tcode) <<") is not available" ;
gotoxy(5,11) ;
cout <<"Kindly issue any other Book" ;
gotoxy(5,12) ;
cout <<"See List of Books" ;
getch() ;
return ;
}
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,2) ;
cout <<"Date : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
gotoxy(5,5) ;
cout <<"Book Name: " <<bookname(tcode) ;
gotoxy(5,7) ;
cout <<"Enter Code no. of the Member" ;
gotoxy(5,8) ;
cout <<" or " ;
gotoxy(5,9) ;
cout <<"Press <ENTER> for help " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
M.Mlist() ;
else
break ;
}
t2code = atoi(t1code) ;
mcode = t2code ;
if (mcode == 0)
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7Enter Correctly" ;
getch() ;
}
if (!Mmember_found(mcode) && valid)
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7Record not found" ;
gotoxy(5,14) ;
cout <<"Press <ESC> to exit or any other key to continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
int tcopies, tavail ;
tcopies = no_of_copies(tcode) ; // member function of BOOK
tavail = available(tcode) - 1 ; // member function of BOOK
update_copies(tcode,tcopies,tavail) ; // member function of BOOK
D.extend_date(d1,m1,y1,15) ;
d1 = D.day ;
m1 = D.mon ;
y1 = D.year ;
Mupdate_book(mcode,tcode,d1,m1,y1) ; // member function of MEMBER
gotoxy(5,13) ;
cout <<"\7Book is issued to " <<Mmembername(mcode) ;
gotoxy(5,15) ;
cout <<"Date of Return : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
getch() ;
}


//**********************************************************
// THIS FUNCTION RETURNS THE BOOK FOR THE MEMBER
//**********************************************************

void WORKING :: returnbook(void)
{
MEMBER M ;
char t1code[5], ch ;
int t2code=0, mcode=0, valid ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,2) ;
cout <<"Date : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
gotoxy(5,7) ;
cout <<"Enter Code no. of the Member who wants to return book" ;
gotoxy(5,8) ;
cout <<" or " ;
gotoxy(5,9) ;
cout <<"Press <ENTER> for help " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
M.Mlist() ;
else
break ;
}
t2code = atoi(t1code) ;
mcode = t2code ;
if (mcode == 0)
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7Enter Correctly" ;
getch() ;
}
if (!Mmember_found(mcode) && valid)
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7Record not found" ;
gotoxy(5,14) ;
cout <<"Press <ESC> to exit or any other key to continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
if (!Missued(mcode) && valid)
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7Member have no book to return" ;
gotoxy(5,14) ;
cout <<"Press <ESC> to exit or any other key to continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
int bcode, tcopies, tavail ;
bcode = Missued(mcode) ;
gotoxy(5,13) ;
cout <<"Book Code : " <<bcode ;
gotoxy(5,14) ;
cout <<"Book Name : " <<bookname(bcode) ;
tcopies = no_of_copies(bcode) ;
tavail = available(bcode) + 1 ;
int f ;
f = Mfine(mcode) ;
if (f != 0)
{
gotoxy(5,16) ;
cout <<"You have to pay a fine of Rs." <<f ;
gotoxy(5,17) ;
cout <<"Please do not delay the Return of Book again" ;
}
update_copies(bcode,tcopies,tavail) ;
Mupdate_book(mcode,0,0,0,0) ;
gotoxy(5,19) ;
cout <<"\7Book has been returned" ;
getch() ;
}


//**********************************************************
// THIS FUNCTION GIVES DATA TO MODIFY THE BOOK RECORD
//**********************************************************

void WORKING :: modify_book(void)
{
BOOK B ;
char t1code[5], tname[33], tauthor[26], *t1, ch ;
int t2code=0, tcode=0 ;
float t2=0.0, tprice=0.0 ;
int valid ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,5) ;
cout <<"Enter Code or Name of the Book to be modified" ;
gotoxy(5,6) ;
cout <<" or " ;
gotoxy(5,7) ;
cout <<"Press <ENTER> for help " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
B.list() ;
else
break ;
}
t2code = atoi(t1code) ;
tcode = t2code ;
if ((tcode == 0 && !bookname_found(t1code)) || (tcode != 0 && !book_found(tcode)))
{
valid = 0 ;
gotoxy(5,10) ;
cout <<"\7Record not found" ;
gotoxy(5,11) ;
cout <<"Press <ESC> to exit or any other key to continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
if (tcode == 0)
tcode = bookcodeof(t1code) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
BOOK::display(tcode) ;
do
{
gotoxy(5,13) ; clreol() ;
cout <<"Do you want to modify this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
gotoxy(5,16) ;
cout <<"Book Name : " ;
gotoxy(5,17) ;
cout <<"Author Name : " ;
gotoxy(5,18) ;
cout <<"Price : Rs." ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the name of the book or <ENTER> for no change" ;
gotoxy(19,16) ; clreol() ;
gets(tname) ;
strupr(tname) ;
if (tname[0] == '0')
return ;
if (strlen(tname) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..32)" ;
getch() ;
}
} while (!valid) ;
if (strlen(tname) == 0)
strcpy(tname,bookname(tcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the author's name or <ENTER> for no change" ;
gotoxy(19,17) ; clreol() ;
gets(tauthor) ;
strupr(tauthor) ;
if (tauthor[0] == '0')
return ;
if (strlen(tauthor) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
if (strlen(tauthor) == 0)
strcpy(tauthor,authorname(tcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter price or <ENTER> for no change" ;
gotoxy(22,18) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tprice = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
if (tprice < 1 || tprice > 9999)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(t1) == 0)
tprice = bookprice(tcode) ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,20) ; clreol() ;
cout <<"Do you want to save changes (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
BOOK::modify(tcode,tname,tauthor,tprice) ;
gotoxy(5,23) ;
cout <<"\7Record Modified" ;
getch() ;
}


//**********************************************************
// THIS FUNCTION GIVES DATA TO MODIFY THE MEMBER RECORD
//**********************************************************

void WORKING :: modify_member(void)
{
MEMBER M ;
char m1code[10], mname[26], mphone[10], maddress[33], ch ;
int m2code=0, mcode=0 ;
int valid ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,7) ;
cout <<"Enter Code no. of the Member to be Modify" ;
gotoxy(5,8) ;
cout <<" or " ;
gotoxy(5,9) ;
cout <<"Press <ENTER> for help " ;
gets(m1code) ;
m2code = atoi(m1code) ;
mcode = m2code ;
if (m1code[0] == '0')
return ;
if (strlen(m1code) == 0)
M.Mlist() ;
else
break ;
}
if (mcode == 0)
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7Enter Correctly" ;
getch() ;
}
if (valid && !Mmember_found(mcode))
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7Record not found" ;
gotoxy(5,14) ;
cout <<"Press <ESC> to exit or any other key to continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
MEMBER::Mdisplay(mcode) ;
do
{
gotoxy(5,10) ; clreol() ;
cout <<"Do you want to modify this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
gotoxy(5,13) ;
cout <<"Name : " ;
gotoxy(5,14) ;
cout <<"Phone : " ;
gotoxy(5,15) ;
cout <<"Address : " ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the name of the member or <ENTER> for no change" ;
gotoxy(19,13) ; clreol() ;
gets(mname) ;
strupr(mname) ;
if (mname[0] == '0')
return ;
if (strlen(mname) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
if (strlen(mname) == 0)
strcpy(mname,Mmembername(mcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the Phone no. of Member or <ENTER> for no change" ;
gotoxy(19,14) ; clreol() ;
gets(mphone) ;
if (mphone[0] == '0')
return ;
if ((strlen(mphone) < 7 && strlen(mphone) > 0) || (strlen(mphone) > 9))
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(mphone) == 0)
strcpy(mphone,Mmemberphone(mcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the address of the member or <ENTER> for no change" ;
gotoxy(19,15) ; clreol() ;
gets(maddress) ;
strupr(maddress) ;
if (maddress[0] == '0')
return ;
if (strlen(maddress) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..32)" ;
getch() ;
}
} while (!valid) ;
if (strlen(maddress) == 0)
strcpy(maddress,Mmemberaddress(mcode)) ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,18) ; clreol() ;
cout <<"Do you want to save changes (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
MEMBER::Mmodify(mcode,mname,mphone,maddress) ;
gotoxy(5,23) ;
cout <<"\7Record Modified" ;
getch() ;
}


//**********************************************************
// THIS FUNCTION GIVES BOOK CODE TO DELETE THE BOOK RECORD
//**********************************************************

void WORKING :: delete_book(void)
{
BOOK B ;
char t1code[5], tname[33], tauthor[26], ch ;
int t2code=0, tcode=0 ;
int valid ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,5) ;
cout <<"Enter Code or Name of the Book to be Deleted" ;
gotoxy(5,6) ;
cout <<" or " ;
gotoxy(5,7) ;
cout <<"Press <ENTER> for help " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
B.list() ;
else
break ;
}
t2code = atoi(t1code) ;
tcode = t2code ;
if ((tcode == 0 && !bookname_found(t1code)) || (tcode != 0 && !book_found(tcode)))
{
valid = 0 ;
gotoxy(5,10) ;
cout <<"\7Record not found" ;
gotoxy(5,11) ;
cout <<"Press <ESC> to exit or any other key to continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
if (tcode == 0)
tcode = bookcodeof(t1code) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
BOOK::display(tcode) ;
do
{
gotoxy(5,13) ; clreol() ;
cout <<"Do you want to delete this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
int tavail, tcopies ;
tavail = available(tcode) ;
tcopies = no_of_copies(tcode) ;
if (tavail != tcopies)
{
gotoxy(5,15) ;
cout <<"\7Record cannot be deleted. This book is issued." ;
getch() ;
return ;
}
BOOK::delete_rec(tcode) ;
gotoxy(5,23) ;
cout <<"\7Record Deleted" ;
getch() ;
}


//**********************************************************
// THIS FUNCTION GIVES MEMBER CODE TO DELETE THE MEMBER
// RECORD
//**********************************************************

void WORKING :: delete_member(void)
{
MEMBER M ;
char m1code[5], mname[26], mphone[10], maddress[33], ch ;
int m2code=0, mcode=0 ;
int valid ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,7) ;
cout <<"Enter Code no. of the Member to be Deleted" ;
gotoxy(5,8) ;
cout <<" or " ;
gotoxy(5,9) ;
cout <<"Press <ENTER> for help " ;
gets(m1code) ;
m2code = atoi(m1code) ;
mcode = m2code ;
if (m1code[0] == '0')
return ;
if (strlen(m1code) == 0)
M.Mlist() ;
else
break ;
}
if (mcode == 0)
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7Enter Correctly" ;
getch() ;
}
if (valid && !Mmember_found(mcode))
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7Record not found" ;
gotoxy(5,14) ;
cout <<"Press <ESC> to exit or any other key to continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
MEMBER::Mdisplay(mcode) ;
do
{
gotoxy(5,10) ; clreol() ;
cout <<"Do you want to Delete this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
if (Missued(mcode))
{
gotoxy(5,15) ;
cout <<"\7Record cannot be delete. Member has a book" ;
getch() ;
return ;
}
MEMBER::Mdelete_rec(mcode) ;
gotoxy(5,23) ;
cout <<"\7Record Deleted" ;
getch() ;
}



//**********************************************************
// MAIN FUNCTION CALLING INTRODUCTION AND MAIN MENU
//**********************************************************

void main(void)
{
clrscr();
int a;
cout<<"Enter your password";
cin>>a;
if(a==1233){
MENU menu ;
menu.introduction() ;
menu.main_menu() ;}
else
exit(0);

}