1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
void adminMenu();
void write_ticketinfo();
void searchRecord(string n);
void editRecord(string n);
void deleteRecord(string n);
int main()
{
customer u;
int uchoice;
bool done;
do
{
u.userMenu(); //calling the displayMenu function
cin >> uchoice; //user input for choice
switch (uchoice) //choice selection to proceed to the rest of the program
{
case 1 : write_ticketinfo();
break;
case 2 : adminMenu();
break;
case 3 : done = true;
break;
default : cout << "Invalid selection, try again!" << endl;
system("pause>nul");
}
} while (!done);
cout << "Good Bye!" << endl;
cout << endl;
system("pause>nul"); // to pause the system without showing Press any key message
return 0;
}
void adminMenu()
{
string num;
int adchoice;
bool done02;
string ic;
do
{
system("cls");
cout << " +---------------------------------------------+" << endl;
cout << " | ^^Express Bus Ticketing System^^ |" << endl;
cout << " |=============================================|" << endl;
cout << " | Administrater control panel |" << endl;
cout << " | |" << endl;
cout << " | Select: |" << endl;
cout << " | 1 => Add Record |" << endl;
cout << " | 2 => Search Record |" << endl;
cout << " | 3 => Edit Record |" << endl;
cout << " | 4 => Delete Record |" << endl;
cout << " | 5 => Exit |" << endl;
cout << " | |" << endl;
cout << " | Request/info/feedback: expressbus@gmail.com |" << endl;
cout << " +---------------------------------------------+" << endl;
cout << endl;
cout << "Choice => ";
cin >> adchoice; //user input for choice
switch (adchoice) //choice selection to proceed to the rest of the program
{
case 1 : write_ticketinfo();
break;
case 2 : cout<<"Enter IC no: ";
cin>>ic;
searchRecord(num);
break;
case 3 : cout<<"Enter IC no: ";
cin>>ic;
editRecord(num);
break;
case 4 : cout<<"Enter IC no: ";
deleteRecord(num);
break;
case 5 : done02 = true;
break;
default : cout << "Invalid selection, try again!" << endl;
system("pause>nul");
}
} while (!done02);
cout << "Good Bye!" << endl;
cout << endl;
system("pause>nul"); // to pause the system without showing Press any key message
return ;
}
void write_ticketinfo()
{
customer rc;
ofstream outFile;
outFile.open("record.dat",ios::app);
rc.getticket();
outFile.close();
}
void searchRecord(string n)
{
admin rc;
bool flag=false;
ifstream inFile;
inFile.open("record.dat");
if(!inFile)
{
cout<<"Not exist !! Press any Key...";
return;
}
cout<<"\nCUSTOMER DETAILS\n";
while(inFile.read(reinterpret_cast<char *> (&rc), sizeof(admin)))
{
if(rc.retic()==n)
{
rc.show_record(n);
flag=true;
}
}
inFile.close();
if(flag==false)
cout<<"\n\nNot exist";
}
void editRecord(string n)
{
admin rc;
bool found=false;
fstream File;
File.open("record.dat",ios::in|ios::out);
if(!File)
{
cout<<"Not exist !! Press any Key...";
return;
}
while(!File.eof() && found==false)
{
File.read(reinterpret_cast<char *> (&rc), sizeof(admin));
if(rc.retic()==n)
{
rc.show_record(n);
cout<<"\n\nEnter The new details:"<<endl;
rc.modify_record();
int pos=(-1)*static_cast<int>(sizeof(admin));
File.seekp(pos,ios::cur);
File.write(reinterpret_cast<char *> (&rc), sizeof(admin));
cout<<"\n\n\t Record Updated";
found=true;
}
}
File.close();
if(found==false)
cout<<"\n\n Record Not Found ";
}
void deleteRecord(string n)
{
admin rc;
ifstream inFile;
ofstream outFile;
inFile.open("record.dat");
if(!inFile)
{
cout<<"Not exist !! Press any Key...";
return;
}
outFile.open("Temp.dat");
inFile.seekg(0,ios::beg);
while(inFile.read(reinterpret_cast<char *> (&rc), sizeof(admin)))
{
if(rc.retic()!=n)
{
outFile.write(reinterpret_cast<char *> (&rc), sizeof(admin));
}
}
inFile.close();
outFile.close();
remove("record.dat");
rename("Temp.dat","record.dat");
cout<<"\n\n\tRecord Deleted ..";
}
|