hotel management program problem

in this add and modify in customer records in edit menu are not working properly as the contents are not being displayed .only 1 record is displayed and others are not.could you resolve the problem.
the program:
void customer :: add(void)
{
room r ;
menu m1;
char ch ;
int valid = 1 ;
int t_roomno , t_no_cust ;
char t_name[21] , t_address[35] , t_phone[8] , t_nation[16] , t_passport[30] ;
float t_advance , t_misc , t_room_srv ;
clrscr() ;
gotoxy(1,1) ;
cout<<"Enter the details of the Customer" ;
gotoxy(1,3) ;
cout<<"Room no. : " ;
gotoxy(1,4) ;
cout<<"Name : " ;
gotoxy(1,5) ;
cout<<"No. of guests : " ;
gotoxy(1,6) ;
cout<<"Address : " ;
gotoxy(1,7) ;
cout<<"Phone : " ;
gotoxy(1,8) ;
cout<<"Nationality : " ;
gotoxy(1,9) ;
cout<<"Passport no. : " ;
gotoxy(1,11) ;
cout<<"Advance : " ;
gotoxy(1,12) ;
cout<<"Miscellineous : " ;
gotoxy(1,13) ;
cout<<"Room service : " ;
char t_status;
do
{
valid=1;
gotoxy(20,3) ;
cin>>t_roomno ;

t_status = r.room_status(t_roomno) ;
if (!r.room_found(t_roomno) || t_status == 'O')
{ valid=0;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"ROOM NO. NOT FOUND OR NOT VACANT" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,3) ; clreol() ;
}
}while(!valid);
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE NAME OF THE CUSTOMER" ;
gotoxy(20,4) ;
gets(t_name) ;
if ((strlen(t_name) <= 0) || (strlen(t_name) > 20))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT BE ZERO OR GREATER THAN 20" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,4) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE NO. OF GUESTS WITH THE CUSTOMER" ;
gotoxy(20,5) ;
cin>>t_no_cust ;
if ((t_no_cust < 0) || (t_no_cust > 4))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"GUESTS SHOULD NOT BE LESS THAN 0 OR GREATER THAN 4" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,5) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ADDRESS OF THE CUSTOMER" ;
gotoxy(20,6) ;
gets(t_address) ;

if ((strlen(t_address) <= 0) || (strlen(t_address) > 50))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT BE ZERO OR GREATER THAN 50" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,6) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE PHONE NO. OF THE CUSTOMER, ENTER '-' FOR NO PHONE NO." ;
gotoxy(20,7) ;
cin>>t_phone ;
if ((strlen(t_phone) < 8 && strlen(t_phone) > 1) || (strlen(t_phone) > 8))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN 8 OR GREATER THAN 8" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,7) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER NATIONALITY OF THE CUSTOMER" ;
gotoxy(20,8) ;
gets(t_nation) ;

if ((strlen(t_nation) <= 0) || (strlen(t_nation) > 15))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN ZERO OR GREATER THAN 15" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,8) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER PASSPORT NO. OF THE CUSTOMER" ;
gotoxy(20,9) ;
gets(t_passport) ;
if ((strlen(t_passport) <= 0) || (strlen(t_passport) > 15))
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"LENGTH SHOULD NOT LESS THAN ZERO OR GREATER THAN 15" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,9) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ADVANCE IN RS. " ;
gotoxy(20,11) ;
cin>>t_advance ;
if (t_advance < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,11) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE MISCELLENIOUS CHARGES" ;
gotoxy(20,12) ;
cin>>t_misc ;
if (t_misc < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,12) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,25) ;
cout<<"ENTER THE ROOM SERVICE CHARGES" ;
gotoxy(20,13) ;
cin>>t_room_srv ;
getch();
if (t_room_srv < 0)
{
valid = 0 ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout<<"SHOULD NOT LESS THAN ZERO" ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(20,13) ; clreol() ;
}
} while ( !valid ) ;
gotoxy(1,15) ;
cout<<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(42,15) ;
cin>>ch;
getch() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
gotoxy(42,15) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'Y')
{
r.change_status(t_roomno,'O') ;
fstream file ;
file.open("CUSTOMER.DAT", ios::out | ios::app ) ;
roomno = t_roomno ;
strcpy(name,t_name) ;
strcpy(phone,t_phone) ;
advance = t_advance ;
misc = t_misc ;
room_srv = t_room_srv ;
file.write((char*) this, sizeof(customer)) ;
file.close() ;
}
m1.main_menu() ;
}

char room :: room_status(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
char t_status ;
while (file.read((char *) this, sizeof(room)) && !found)
{
if (t_roomno == roomno)
{
found = 1 ;
t_status = status ;
}
}
file.close () ;
return t_status ;
}


void customer :: display_record(int t_roomno)
{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
while (file.read((char *) this, sizeof(customer)) && !found)
{
if (t_roomno == roomno)
{
found = 1 ;
gotoxy(1,5) ;
cout<<"Room no. : " <<roomno ;
gotoxy(1,6) ;
cout<<"Customer Name : " <<name ;
gotoxy(1,7) ;
cout<<"Phone no. : " <<phone ;
gotoxy(1,8) ;
cout<<"Advance : " <<advance ;
gotoxy(1,9) ;
cout<<"Misc. charges : " <<misc ;
gotoxy(1,10) ;
cout<<"Room Service Charges : " <<room_srv ;
}
}
file.close () ;
}


int customer :: recordno(int t_roomno)
{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0) ;
int count = 0 ;
while (file.read((char *) this, sizeof(customer)))
{
count++ ;
if (t_roomno == roomno)
break ;
}
file.close() ;
return count ;
}


Topic archived. No new replies allowed.