You are on page 1of 59

SOURCE CODE

/* Computer Science Project


################### C++ ##################
$$$$$$$$$$$ GADGET SHOP $$$$$$$$$$
Saamarth Gupta
XII - C
Board Roll No Bal Bharati Public School, Pitampura
*/
/* **************** Header Files *************** */
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<string.h>
#include<dos.h>
#include<fstream.h>
#include<iomanip.h>
#include<process.h>
#include<stdlib.h>

//read and write files


//clrscr();
//gets and puts
//colors
//string functions
//delay and sleep function
//Input and Output to File
//setw function
//Exit Function
//For Random Function

char adm[10]="admin01";
char admp[10]="lenz";
char cha=' ';
class customer
{
char address[50];

//Admin Username
//Admin Password

//customer address

public:
char custname[20];
//customer name/username
char pass[12];
//Customer Password
char pno[20];
//Phone Number
int custid;
//Customer ID
void enter();
//Enter Data
void display();
//Display Data
void gencno();
//Generate Customer Number
void enter2();
int cno()
{
return custid;
}
customer()
{
strcpy(pass,"");
}

}c;
class product
{

//Product Details

public:
char pname[30]; //Name
int disc;
//Discount
int itno;
//Item No.
double price;
//Price
double priceloc;
int quan;
//Quantity
void getp();
void showp();
}pro,pro1;
int nocheck();
void write();
void read();
int search();
int del();
int rec_change();
int checkout();

//Check Customer Number for Randomising


//Write Data
//Read data
//Search the Record
//Delete a Record
//Update a Record
//Complete Purchase

void product::getp()
{

//Enter Product Details

gotoxy(5,8);
cputs("Product Item No : ");
gotoxy(5,10);
cputs("Product Name : ");
gotoxy(5,12);
cputs("Product Price : ");
gotoxy(5,14);
cputs("Product Discount (%) : ");
gotoxy(45,8);
cin>>itno;
gotoxy(45,10);
gets(pname);
gotoxy(45,12);
cin>>price;
di:
gotoxy(45,14);
cin>>disc;
if(disc>100|disc<0)
{
cout<<"\n\t Discount Cant be this Much. Enter Again.\n";
getch();
goto di;
}
}
void product::showp() //Show Product Details
{
cout<<"
";
cprintf("%d",itno);
cout<<"
";
int len=strlen(pname);

cputs(pname);
for(int i=len;i<30;i++)
cout<<" ";
cout<<price;
cout<<" ";
cprintf("%d",disc);
}
void customer::gencno()
{
int i = nocheck();
custid=i;
}

//Generate Customer Number

int nocheck()
//Check For Customer Number
{
ab:
randomize();
int flag=0;
int a = rand()%30000;
//Ranmdomize
fstream f1;
customer c;
f1.open("main.dat",ios::binary|ios::in);
while(!f1.eof())
{
f1.read((char*)&c,sizeof(c));
//Read from file
if(c.custid==a)
//Check Customer ID Equality From
Records
{
flag=1;
break;
}
}
f1.close();
if(flag==1)
goto ab;
else if(flag==0)
return a;
}
void customer::enter()
//Enter Customer Details
{
re:
int flag=0;
clrscr();
gotoxy(34,4);
cputs("LEGO GADGETS");
gotoxy(28,6);
cputs("New Customer Registration");
gotoxy(5,10);
cputs("Customer Username : ");
gotoxy(5,12);
cputs("Customer Password : ");
gotoxy(5,14);
cputs("Customer Address : ");
gotoxy(5,16);
cputs("Customer Phone Number : ");
gotoxy(5,18);
cputs("Your Customer ID is : ");

gotoxy(45,10);
gets(custname);
fstream ch("main.dat",ios::in|ios::binary);
while(!ch.eof())
//Check for Existing Username.
{
ch.read((char*)&c,sizeof(c));
if(!strcmp(c.custname,custname))
{
clrscr();
gotoxy(15,10);
cout<<"Sorry, The Username Already Exists. Please Try
Again.";
getch();
flag=1;
ch.close();
break;
}
}
if(flag==1)
goto re;
gotoxy(45,12);
for(int i=0;i<11;i++)
//Get password in '*' form.
{
cha=getch();
if(cha==13)
{
pass[i]='\0';
break;
}
pass[i]=cha;
cout<<"*";
}
gotoxy(45,14);
gets(address);
gotoxy(45,16);
gets(pno);
gencno();
gotoxy(45,18);
cout<<custid<<endl;
getch();
}
void customer::enter2()
//Modifocation of User Data.
{
clrscr();
strcpy(pass,"");
gotoxy(34,4);
cputs("LEGO GADGETS");
gotoxy(5,8);
cputs("Customer Username : ");
gotoxy(5,10);
cputs("New Password : ");
gotoxy(5,12);
cputs("New Address : ");
gotoxy(5,14);
cputs("New Phone Number : ");
gotoxy(5,16);
cputs("Your Customer ID is : ");
gotoxy(45,8);

cputs(custname);
gotoxy(45,16);
cout<<custid;
gotoxy(45,10);
for(int i=0;i<11;i++)
{
cha=getch();
if(cha==13)
{
pass[i]='\0';
break;
}
pass[i]=cha;
cout<<"*";
}
gotoxy(45,12);
gets(address);
gotoxy(45,14);
gets(pno);
}
void customer::display()
//Display Data.
{
cout<<endl<<endl;
gotoxy(5,8);
cputs("Customer Name : ");
cputs(custname);
gotoxy(5,10);
cputs("Customer Password : ");
for(int i=0;pass[i]!='\0';i++)
cout<<"*";
gotoxy(5,12);
cputs("Customer Address : ");
cputs(address);
gotoxy(5,14);
cputs("Customer Phone Number : ");
puts(pno);
gotoxy(5,16);
cputs("Customer ID : ");
cout<<custid;
}
void write()
//Write to File.
{
customer user;
ofstream file1;
user.enter();
//Function
Call Enter
file1.open("main.dat",ios::app|ios::binary);
//Open File for Writing
if(file1.fail())
//File Open
Error
{
cout<<"\n\n\t\t\tError Opening File. Exiting Now."<<endl;
delay(4000);
exit(1);
}
file1.write((char*)&user,sizeof(user));
//Writing Class Object
to File
file1.close();

}
void read()
{
customer user;
fstream file1;
file1.open("main.dat",ios::in|ios::binary); //Open File to Read Data
while(!file1.eof())
//Check till the End of
File
{
file1.read((char*)&user,sizeof(user)); //Store File Data in
Object
if(file1.eof())
cout<<"End of File Reached";
else
user.display();
//Display File Data
}
file1.close();
}
int search()
//Search in File
{
clrscr();
int choi,con;
ifstream f1;
f1.open("main.dat",ios::in|ios::binary);
//File to Search
data
if(f1.fail())
{
cout<<"File not Found. Exiting.";
getch();
exit(1);
}
f1.close();
clrscr();
customer u1;
do
{
clrscr();
gotoxy(28,4);
cputs("View Customer Information");
gotoxy(5,8);
cputs("How Would You Like to Search?");
//Search Sub
Menu
gotoxy(5,10);
cputs("1. Enter Username and Password. ");
gotoxy(5,12);
cputs("2. Search by Customer Number.");
gotoxy(5,14);
cputs("3. Go Back To The Previous Menu.");
gotoxy(5,16);
cputs("Enter Choice : ");
cin>>choi;
clrscr();
switch(choi)
//Menu Options Test
{
case 1 :
int count=0;
int k;

krep:
char nam[20];

//Search By Username and

Password
int flag=0;
char pas[20]="";
f1.open("main.dat",ios::in|ios::binary);
gotoxy(8,6);
cputs("Enter Username and Password");
gotoxy(8,10);
cputs("Enter Username : ");
gotoxy(8,12);
cputs("Enter Password : ");
gotoxy(25,10);
gets(nam);
gotoxy(25,12);
for(int i=0;i<11;i++)

//Get

Password.
{
cha=getch();
if(cha==13)
break;
pas[i]=cha;
cout<<"*";
}
while(!f1.eof())
{
f1.read((char*)&u1,sizeof(u1));
if(!strcmp(u1.custname,nam))

//Check

for Equality
{
if(!strcmp(u1.pass,pas))
//Comparison
{
clrscr();
cout<<"Search Was Successful\n Your
Details Are :\n";
u1.display();
flag=1;
f1.close();
break;
}
}
}
if(flag==0)
{
cout<<endl;
cputs("Username and Password Do Not
Match.");
cputs("You have ");
k=2-count; //Number of Attempts to
enter Password
cprintf("%d",k);
count++;
cputs(" tries left.");
cout<<endl;
f1.close();
if(k!=0)
{

cout<<"Press Any Key To Continue\n";


getch();
clrscr();
goto krep;
}
else
{
cputs("Max. tries Reached. Search was
Unsuccesful.");
cout<<endl;
cputs("\nReturning");
for(int p=0;p<5;p++)
{
cout<<"*"<<endl;
delay(200);
}
f1.close();
return 1;
}
}
f1.close();
break;
case 2 : int no;int fla=0;
ifstream f1("main.dat",ios::in|ios::binary);
cout<<"\n\n Enter Customer ID you want to SEARCH
:\t";
cin>>no;
while(!f1.eof())
{
f1.read((char*)&c,sizeof(c));

//Read from

file
if(c.custid==no)

//Check Customer ID

Equality
{
clrscr();
cout<<"Search Was Successful\n Your
Details Are :\n";
c.display();
fla=1;
break;

//Display User Data

}
}
if(fla==0)
cout<<"\n\n\tRECORD NOT
FOUND!!!!!!!!!!!!!\n";
f1.close();
break;

case 3 :
cout<<"\n\n\t\tReturning.....";
return choi;
default:
cout<<"\nWrong Choice Entered. ";
break;
}

cout<<"\n\nWould You Like To Try Again? (Press 1) : ";


cin>>con;
if(con!=1)
return 3;
}while(con==1);
}
int del()
//Delete a Record
{
ifstream f1;
int flag=0;
ofstream f2;
f2.open("temp.dat",ios::out|ios::binary);
int cno,ag,con;
char confirm='n';
char pass[20]="";
char use[20];

//Open a Temporary File

do
//loop for deletion
{
oops:
char find='f';
int count=0;
int k;
clrscr();
int ret;
f1.open("main.dat",ios::in|ios::binary);
gotoxy(32,4);
cputs("Delete a Record");
gotoxy(8,8);
cout<<" Enter Customer ID that you want to DELETE : ";
gotoxy(53,8);
cin>>cno;
while(!f1.eof())
{
f1.read((char*)&c,sizeof(c));
//Read File
if(c.cno()==cno)
{
if(f1.eof())
break;
find='t';
oop:
clrscr();
gotoxy(8,6);
cputs(" Record Found. Enter Username and Password to Confirm
Deletion.");
gotoxy(8,10);
cputs("Enter Username : ");
gotoxy(8,12);
cputs("Enter Password : ");
gotoxy(25,10);
gets(use);
gotoxy(25,12);
for(int i=0;i<11;i++)
//Get password, display *.
{
cha=getch();
if(cha==13)
break;

pass[i]=cha;
cout<<"*";
}
puts(pass);
if((!strcmp(c.custname,use))&&(!strcmp(c.pass,pass)))
{
//Password and Username Match
cout<<"\n\n Are you sure want to DELETE this record ?
(Y/N) : ";
cin>>confirm;
if(confirm=='n'||confirm=='N')
//confirm deletion
{
f2.write((char*)&c,sizeof(c));
cout<<"\t Record Not Deleted.\n";
}
}
else

//Error Match
{
cout<<"\n\tUsername and Password Do Not Match.";
cout<<endl;
k=2-count;
count++;
cout<<"\tYou have ";
cprintf("%d",k);
cputs(" tries left.\n");
if(k==0)
{
cout<<endl;
cout<<"\tMax. tries Reached. Search was

Unsuccesful.";
f2.write((char*)&c,sizeof(c));
getch();
goto map; //Exit Loop when condition is
false
}
cout<<endl;
getch();
goto oop;
}
}
else
{
if(f1.eof())
break;
else
f2.write((char*)&c,sizeof(c));
}
}
if(find=='f')
//Failed Attempt
{
cout<<"\n\tRecord Not Accessible. Would You Like To try Again?
(Press 1)\n";
cout<<"\tNot Pressing 1 Will Take you to The Previous Menu :
";
cin>>ag;

f1.close();
if(ag==1)
goto oops;
else
{
ret=1;
return ret;
}
}
cout<<"Do you Want to Start The Searching Process Again? (Press 1,
else go to Main Menu)\n";
cin>>con;
f1.close();
}while(con==1);
map:
f2.close();
f1.close();
remove("main.dat");
rename("temp.dat","main.dat");
return 1;
}
int rec_change() //Change a Record
{
clrscr();
fstream f1("main.dat",ios::in | ios::out | ios::binary);
int cno;
char use[20];
char pass[20]="";
long pos;
int k=0;
int flag=0;
gotoxy(28,4);
cputs("Modify an Existing Record");
gotoxy(8,6);
cputs("Enter the Customer ID you want to MODIFY : ");
gotoxy(52,6);
cin>>cno;
while(!f1.eof())
{
pos=f1.tellg();
f1.read((char*)&c,sizeof(c));
if(c.cno()==cno)
{
flag=1;
break;
}
}
if(flag==1)
{
while(k<3)
{
clrscr();
gotoxy(8,8);

//obtain location of data

cputs("Record Found. Enter Username and Password to


Confirm.");
gotoxy(8,12);
cputs("Enter Username : ");
gotoxy(8,14);
cputs("Enter Password : ");
gotoxy(25,12);
gets(use);
gotoxy(25,14);
for(int i=0;i<11;i++)
{
cha=getch();
if(cha==13)
break;
pass[i]=cha;
cout<<"*";
}
if((!strcmp(c.custname,use))&&(!strcmp(c.pass,pass)))
{
clrscr();
cout<<"\n\tYour Details As Per Current Record are : \n";
c.display();
cout<<"\n\n\tPress Any Key to Enter Your Modified Details
:\n ";
getch();
clrscr();
c.enter2();
f1.seekg(pos);
//seek to the location
of data
f1.write((char*)&c,sizeof(c));
cout<<"\n\n\tYour Record Has Been Modified.\n";
getch();
return 1;
}
else
{
cout<<endl;
cputs("Username and Password Do not Match");
cout<<endl;
cputs("You have ");
k++;
cprintf("%d",3-k);
//Condition for max 3 Tries.
cputs(" tries left.");
cout<<endl;
cputs("Press Any Key To Try Again");
getch();
if(k==3)
{
cout<<endl;
cputs("Max. tries Reached. Search was
Unsuccesful.");
cout<<endl;
cputs("Going Back Now");
getch();
return 1;
}
}
}
}
if(flag==0)

{
cout<<"\n\n\tRECORD NOT FOUND\n";
cout<<"\n\tPlease Try Again\n";
getch();
return 1;
}
}
int buy()
//Buy Menu
{
int mo,cat,no,itno,quan;
char find='f';
double priceto;
list:
clrscr();
cout<<"\n\n\n\n";
cout<<"\n\t\t\t****************************";
cout<<"\n\t\t\t
PRODUCT LIST";
cout<<"\n\t\t\t****************************";
cout<<"\n\n\t\t\t
1.Pendrives";
cout<<"\n\t\t\t
2.Micro SD Cards";
cout<<"\n\t\t\t
3.Cameras";
cout<<"\n\t\t\t
4.Mobile Phones";
cout<<"\n\t\t\t
5.Graphic Cards";
cout<<"\n\t\t\t
6.RAMs";
cout<<"\n\t\t\t
7.External Hard Disks";
cout<<"\n\t\t\t
8.Check Out";
cout<<"\n\t\t\t
9.Go Back";
cout<<"\n\n\n\t\t
Enter your choice : ";
cin>>cat;
if(cat>9||cat<1) //Check Catalogue Existence
{
cout<<"\n
Sorry. You have entered the wrong
choice.\n";
cout<<"
You will be Redirected to the Menu
Again.\n";
cout<<"
Press Any Key. \n";
getch();
goto list;
}
fstream bill,file;
bill.open("bill.dat",ios::binary|ios::app);
switch(cat)
//User Choice
{
case 1:
repeatpd:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
Pendrives");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;

file.open("pen.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
//Check for Empty List
{
cout<<"\nThe Product List is Currently Empty.\n";
file.close();
cout<<"\tYou cant Buy Anything. Press Any Key to Go
Back.\n";
getch();
goto list;
}
else
{
file.close();
file.open("pen.dat",ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
//Read File
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
//Show Products
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\t\tEnter Item Number to Be Bought : ";
//Buying an Item
cin>>itno;
clrscr();
cout<<endl;
cout<<endl;
file.open("pen.dat",ios::binary|ios::in);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
//Reading File
if(itno==pro.itno)
//Checking for
Existing Product
{
find='t';
cout<<"\n\n\t\tEnter Quantity : ";
cin>>quan;
pro.quan=quan;
pro.priceloc=pro.price*quan*(100pro.disc)/100;
file.close();
find='t';
break;
}
}

if(find=='f')
{
cout<<"\t\tProduct Does Not Exist. Try
Again\n";
getch();
goto list;
}
cout<<"\n\t\tYou have Bought - \n"; //Cart Details
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cputs(" Quantity ");
cputs("Total Price");
cout<<endl;
pro.showp();
cout<<"
"<<pro.quan;
cout<<"
"<<pro.priceloc;
cout<<endl<<endl;
cputs("--------------------------------------------------------------------------");
file.close();
bill.write((char*)&pro,sizeof(pro));
cout<<endl;
cout<<endl;
bill.close();
cout<<"\n\t\t1.Do You Want To Check Out? (Press
1)\n";
cout<<"\t\t2.To Buy More from the Same Category
(Press 2) \n";
cout<<"\t\t3.To go To Product Menu (Press 3) \n\n";
cout<<"\t\t
Enter Your Choice : ";
cin>>mo;
if(mo==1)
{
return 1;
}
else if(mo==2)
goto repeatpd;
else
goto list;
case 2: //Similar to Case 1
repeatmsd:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
Micro SD Cards");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");

cout<<endl;
file.open("msd.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently Empty.\n";
file.close();
cout<<"\tYou cant Buy Anything. Press Any Key to Go
Back.\n";
getch();
goto list;
}
else
{
file.close();
file.open("msd.dat",ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\t\tEnter Item Number to Be Bought : ";
cin>>itno;
clrscr();
cout<<endl;
cout<<endl;
file.open("msd.dat",ios::binary|ios::in);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(itno==pro.itno)
{
find='t';
cout<<"\n\n\t\tEnter Quantity : ";
cin>>quan;
pro.quan=quan;
pro.priceloc=pro.price*quan*(100pro.disc)/100;
file.close();
find='t';
break;
}
}
if(find=='f')
{

cout<<"\t\tProduct Does Not Exist. Try


Again\n";
getch();
goto list;
}
cout<<"\n\t\tYou have Bought - \n";
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cputs(" Quantity ");
cputs("Total Price");
cout<<endl;
pro.showp();
cout<<"
"<<pro.quan;
cout<<"
"<<pro.priceloc;
cout<<endl<<endl;
file.close();
bill.write((char*)&pro,sizeof(pro));
cout<<endl;
cout<<endl;
bill.close();
cout<<"\n\t\t1.Do You Want To Check Out? (Press
1)\n";
cout<<"\t\t2.To Buy More from the Same Category
(Press 2) \n";
cout<<"\t\t3.To go To Product Menu (Press 3) \n\n";
cout<<"\t\t
Enter Your Choice : ";
cin>>mo;
if(mo==1)
{
return 1;
}
else if(mo==2)
goto repeatmsd;
else
goto list;
case 3: //Similar to Case 1
repeatcam:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
Cameras");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("cam.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)

{
cout<<"\nThe Product List is Currently Empty.\n";
file.close();
cout<<"\tYou cant Buy Anything. Press Any Key to Go
Back.\n";
getch();
goto list;
}
else
{
file.close();
file.open("cam.dat",ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\t\tEnter Item Number to Be Bought : ";
cin>>itno;
repen:
clrscr();
cout<<endl;
cout<<endl;
file.open("cam.dat",ios::binary|ios::in);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(itno==pro.itno)
{
find='t';
cout<<"\n\n\t\tEnter Quantity : ";
cin>>quan;
pro.quan=quan;
pro.priceloc=pro.price*quan*(100pro.disc)/100;
file.close();
find='t';
break;
}
}
if(find=='f')
{
cout<<"\t\tProduct Does Not Exist. Try
Again\n";
getch();
goto list;

}
cout<<"\n\t\tYou have Bought - \n";
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cputs(" Quantity ");
cputs("Total Price");
cout<<endl;
pro.showp();
cout<<"
"<<pro.quan;
cout<<"
"<<pro.priceloc;
cout<<endl<<endl;
file.close();
bill.write((char*)&pro,sizeof(pro));
cout<<endl;
cout<<endl;
bill.close();
cout<<"\n\t\t1.Do You Want To Check Out? (Press
1)\n";
cout<<"\t\t2.To Buy More from the Same Category
(Press 2) \n";
cout<<"\t\t3.To go To Product Menu (Press 3) \n\n";
cout<<"\t\t
Enter Your Choice : ";
cin>>mo;
if(mo==1)
{
return 1;
}
else if(mo==2)
goto repeatcam;
else
goto list;
case 4: //Similar to Case 1
repeatmob:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
Mobiles");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("mob.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently Empty.\n";
file.close();

cout<<"\tYou cant Buy Anything. Press Any Key to Go


Back.\n";
getch();
goto list;
}
else
{
file.close();
file.open("mob.dat",ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\t\tEnter Item Number to Be Bought : ";
cin>>itno;
clrscr();
cout<<endl;
cout<<endl;
file.open("mob.dat",ios::binary|ios::in);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(itno==pro.itno)
{
find='t';
cout<<"\n\n\t\tEnter Quantity : ";
cin>>quan;
pro.quan=quan;
pro.priceloc=pro.price*quan*(100pro.disc)/100;
file.close();
find='t';
break;
}
}
if(find=='f')
{
cout<<"\t\tProduct Does Not Exist. Try
Again\n";
getch();
goto list;
}
cout<<"\n\t\tYou have Bought - \n";
cputs("--------------------------------------------------------------------------");

cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cputs(" Quantity ");
cputs("Total Price");
cout<<endl;
pro.showp();
cout<<"
"<<pro.quan;
cout<<"
"<<pro.priceloc;
cout<<endl<<endl;
file.close();
bill.write((char*)&pro,sizeof(pro));
cout<<endl;
cout<<endl;
bill.close();
cout<<"\n\t\t1.Do You Want To Check Out? (Press
1)\n";
cout<<"\t\t2.To Buy More from the Same Category
(Press 2) \n";
cout<<"\t\t3.To go To Product Menu (Press 3) \n\n";
cout<<"\t\t
Enter Your Choice : ";
cin>>mo;
if(mo==1)
{
return 1;
}
else if(mo==2)
goto repeatmob;
else
goto list;
case 5: //Similar to Case 1
repeatgpu:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
Graphic Cards");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("gpu.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently Empty.\n";
file.close();
cout<<"\tYou cant Buy Anything. Press Any Key to Go
Back.\n";
getch();
goto list;
}

else
{
file.close();
file.open("gpu.dat",ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\t\tEnter Item Number to Be Bought : ";
cin>>itno;
clrscr();
cout<<endl;
cout<<endl;
file.open("gpu.dat",ios::binary|ios::in);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(itno==pro.itno)
{
find='t';
cout<<"\n\n\t\tEnter Quantity : ";
cin>>quan;
pro.quan=quan;
pro.priceloc=pro.price*quan*(100pro.disc)/100;
file.close();
find='t';
break;
}
}
if(find=='f')
{
cout<<"\t\tProduct Does Not Exist. Try
Again\n";
getch();
goto list;
}
cout<<"\n\t\tYou have Bought - \n";
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");

cputs(" Quantity ");


cputs("Total Price");
cout<<endl;
pro.showp();
cout<<"
"<<pro.quan;
cout<<"
"<<pro.priceloc;
cout<<endl<<endl;
file.close();
bill.write((char*)&pro,sizeof(pro));
cout<<endl;
cout<<endl;
bill.close();
cout<<"\n\t\t1.Do You Want To Check Out? (Press
1)\n";
cout<<"\t\t2.To Buy More from the Same Category
(Press 2) \n";
cout<<"\t\t3.To go To Product Menu (Press 3) \n\n";
cout<<"\t\t
Enter Your Choice : ";
cin>>mo;
if(mo==1)
{
return 1;
}
else if(mo==2)
goto repeatgpu;
else
goto list;
case 6: //Similar to Case 1
repeatram:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
RAMs");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("ram.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently Empty.\n";
file.close();
cout<<"\tYou cant Buy Anything. Press Any Key to Go
Back.\n";
getch();
goto list;
}
else
{
file.close();
file.open("ram.dat",ios::in|ios::binary);
while(!file.eof())

{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\t\tEnter Item Number to Be Bought : ";
cin>>itno;
clrscr();
cout<<endl;
cout<<endl;
file.open("ram.dat",ios::binary|ios::in);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(itno==pro.itno)
{
find='t';
cout<<"\n\n\t\tEnter Quantity : ";
cin>>quan;
pro.quan=quan;
pro.priceloc=pro.price*quan*(100pro.disc)/100;
file.close();
find='t';
break;
}
}
if(find=='f')
{
cout<<"\t\tProduct Does Not Exist. Try
Again\n";
getch();
goto list;
}
cout<<"\n\t\tYou have Bought - \n";
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cputs(" Quantity ");
cputs("Total Price");
cout<<endl;
pro.showp();
cout<<"
"<<pro.quan;

cout<<"
"<<pro.priceloc;
cout<<endl<<endl;
file.close();
bill.write((char*)&pro,sizeof(pro));
cout<<endl;
cout<<endl;
bill.close();
cout<<"\n\t\t1.Do You Want To Check Out? (Press
1)\n";
cout<<"\t\t2.To Buy More from the Same Category
(Press 2) \n";
cout<<"\t\t3.To go To Product Menu (Press 3) \n\n";
cout<<"\t\t
Enter Your Choice : ";
cin>>mo;
if(mo==1)
{
return 1;
}
else if(mo==2)
goto repeatram;
else
goto list;
case 7: //Similar to Case 1
repeathd:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
Hard Disks");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("hd.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently Empty.\n";
file.close();
cout<<"\tYou cant Buy Anything. Press Any Key to Go
Back.\n";
getch();
goto list;
}
else
{
file.close();
file.open("hd.dat",ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";

break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\t\tEnter Item Number to Be Bought : ";
cin>>itno;
clrscr();
cout<<endl;
cout<<endl;
file.open("hd.dat",ios::binary|ios::in);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(itno==pro.itno)
{
find='t';
cout<<"\n\n\t\tEnter Quantity : ";
cin>>quan;
pro.quan=quan;
pro.priceloc=pro.price*quan*(100pro.disc)/100;
file.close();
find='t';
break;
}
}
if(find=='f')
{
cout<<"\t\tProduct Does Not Exist. Try
Again\n";
getch();
goto list;
}
cout<<"\n\t\tYou have Bought - \n";
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cputs(" Quantity ");
cputs("Total Price");
cout<<endl;
pro.showp();
cout<<"
"<<pro.quan;
cout<<"
"<<pro.priceloc;
cout<<endl<<endl;
file.close();
bill.write((char*)&pro,sizeof(pro));
cout<<endl;

cout<<endl;
bill.close();
cout<<"\n\t\t1.Do You Want To Check Out? (Press
1)\n";
cout<<"\t\t2.To Buy More from the Same Category
(Press 2) \n";
cout<<"\t\t3.To go To Product Menu (Press 3) \n\n";
cout<<"\t\t
Enter Your Choice : ";
cin>>mo;
if(mo==1)
{
return 1;
}
else if(mo==2)
goto repeathd;
else
goto list;
case 8: //Similar to Case 1
clrscr();
file.open("bill.dat",ios::in|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\n\n\t\tThe Cart is Currently Empty.\n";
file.close();
cout<<"\t\t Press any Key to Go Back\n";
getch();
goto list;
}
else
{
file.close();
return 1;
}
case 9:
remove("bill.dat"); //Remove the previously created
Bill File
return cat;
}
}
int checkout()
//Function for Checking Out
{
clrscr();
char use[20];
char pass[20]="";
char phno[20];
char find='f';
fstream bill,file;
int choi,id,num;
int flag=0;
double prito=0;
bill.open("bill.dat",ios::in|ios::binary); //Open Bill
cout<<"\n\t\tYou have Bought - \n";

cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cputs(" Quantity ");
cputs("Total Price");
cout<<endl;
while(!bill.eof())
{
bill.read((char*)&pro,sizeof(pro));
//Reading the Bill
if(bill.eof())
break;
else
{
pro.showp();
cout<<"
"<<pro.quan;
cout<<"
"<<pro.priceloc;
cout<<endl;
prito=prito+pro.priceloc;
}
}
bill.close();
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<"\n\t\t\t Total Amount : Rs. "<<prito<<endl;
//Total price
cout<<"\n\n\tAre you Sure You Want to Buy? (Press 1, Else go to Main
Menu) : ";
cin>>choi;
if(choi==1)
{
clrscr();
cout<<"\n\n\t\t\t Thanks For Buying.";
cout<<"\n Do You have a Customer ID? (10% Discount) (Enter 1
If Yes) : ";
cin>>id;
if(id==1)
{
retry:
file.open("main.dat",ios::in|ios::binary); //Open file
containing Records
gotoxy(8,8);
cputs("Enter Username and Password to Confirm.");
gotoxy(8,12);
cputs("Enter Username : ");
gotoxy(8,14);
cputs("Enter Password : ");
gotoxy(25,12);
gets(use);
gotoxy(25,14);
for(int i=0;i<11;i++)
//Get Password
{
flag=0;
cha=getch();
if(cha==13)

break;
else if(cha==127||cha==8)
{
flag=1;
i=i-1;
}
if(flag==0)
{
pass[i]=cha;
cout<<"*";
}
}
while(!file.eof())
{
file.read((char*)&c,sizeof(c));
if(file.eof())
break;
if((!strcmp(c.custname,use))&&(!strcmp(c.pass,pass)))
{
//Check for Equality
cout<<"\n\n\t\t Username and Password
Match.\n";
cout<<"\t\tWelcome ";
cprintf(c.custname);
cout<<"\n\t\tDiscount has Been Applied.\n";
prito=(prito*9)/10;
strcpy(phno,c.pno);
strcpy(use,c.custname);
find='t';
break;
}
}
file.close();
if(find=='f')
//If Record is Not Found.
{
clrscr();
cout<<"\n\n\t\tCouldn't Find ID.";
cout<<"\n\t\tPress 1 to Try Again, Press 2 to
Continue as Guest\n";
cout<<"\t\tor Press any other Number to Go to Main
Menu. : ";
cin>>num;
if (num==1)
{
clrscr();
goto retry;
}
else if(num==2)
{
clrscr();
cout<<"\n\n\t\tWelcome Guest \n\n";
//Choose
Guest Account
cout<<"\t\tEnter Name : ";
gets(use);
cout<<"\t\tEnter Phone Number : ";
gets(phno);
goto billing;
}

else
return 1;
}
}
else
{

//Deafult Guest
clrscr();
cout<<"\n\n\t\tWelcome Guest \n";
cout<<"\t\tEnter Name : ";
gets(use);
cout<<"\t\tEnter Phone Number\n";
gets(phno);
goto billing;

}
billing:
//Billing System
clrscr();
bill.open("bill.dat",ios::in|ios::binary);
cout<<"\n\n\n\t\tPurchase Successful! ";
cout<<"\n\t\tThank You! Please Visit Again.";
cout<<"\n\t\tName : ";
cprintf(use);
cout<<"\n\t\tPhone Number : ";
cprintf(phno);
cout<<"\n\t\tYour Final Purchase List is : \n\n";
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cputs(" Quantity ");
cputs("Total Price");
cout<<endl;
while(!bill.eof())
//Read Bill to Display Purchased
Prod.
{
bill.read((char*)&pro,sizeof(pro));
if(bill.eof())
break;
else
{
pro.showp();
cout<<"
"<<pro.quan;
cout<<"
"<<pro.priceloc;
cout<<endl;
}
}
bill.close();
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<"\n\tTotal Price - Rs. ";
cout<<prito;
if(find=='t')
{
cout<<" (After Discount of Rs. ";
cout<<prito*0.1<<")";

}
cout<<"\n\n\t\tPress Any Key to Go back to Main Menu.\n";
getch();
remove("bill.dat");
return 1;
}
else
remove("bill.dat");
return 1;
}
int Menu() //Main Menu
{
int choice;
loop:
clrscr();
gotoxy(15,7);
cout<<"###################################################\n";
gotoxy(15,8);
cout<<"#
Welcome To LEGO GADGETS
#\n";
gotoxy(15,9);
cout<<"#
#\n";
gotoxy(15,10);
cout<<"#
One Stop Destination To All Your Tech Needs
#\n";
gotoxy(15,11);
cout<<"#
#\n";
gotoxy(15,12);
cout<<"#
What Would You Like To Do?
#\n";
gotoxy(15,13);
cout<<"#
#\n";
gotoxy(15,14);
cout<<"#
1. New Customer Registration
#\n";
gotoxy(15,15);
cout<<"#
2. Customer Details
#\n";
gotoxy(15,16);
cout<<"#
3. Edit Details
#\n";
gotoxy(15,17);
cout<<"#
4. Delete Account
#\n";
gotoxy(15,18);
cout<<"#
5. Display All Records
#\n";
gotoxy(15,19);
cout<<"#
6. Enter Admin Panel
#\n";
gotoxy(15,20);
cout<<"#
7. Buy
#\n";
gotoxy(15,21);
cout<<"#
8. Exit From Program
#\n";
gotoxy(15,22);
cout<<"#
#\n";
gotoxy(15,23);
cout<<"###################################################\n";
gotoxy(28,25);
cout<<"Enter Your Response : ";
gotoxy(50,25);
cin>>choice;
cout<<endl;
if(choice>8||choice<1)
{

cout<<"\n
choice.\n";
cout<<"
Again.\n";
cout<<"
getch();
goto loop;
}
return choice;
}

Sorry. You have entered the wrong


You will be Redirected to the Menu
Press Any Key. \n";

int admmenu()
//Admin Menu
{
int resp;
clrscr();
loop:
gotoxy(15,7);
cout<<"###################################################\n";
gotoxy(15,8);
cout<<"#
Welcome Admin
#\n";
gotoxy(15,9);
cout<<"#
#\n";
gotoxy(15,10);
cout<<"#
What Would You Like To Do?
#\n";
gotoxy(15,11);
cout<<"#
#\n";
gotoxy(15,12);
cout<<"#
1. New Addition to List
#\n";
gotoxy(15,13);
cout<<"#
2. Delete From List
#\n";
gotoxy(15,14);
cout<<"#
3. Go Back
#\n";
gotoxy(15,15);
cout<<"#
#\n";
gotoxy(15,16);
cout<<"###################################################\n";
gotoxy(28,18);
cout<<"Enter Your Response : ";
cin>>resp;
if(resp>3||resp<1)
{
cout<<"\n
Sorry. You have entered the wrong
choice.\n";
cout<<"
You will be Redirected to the Menu
Again.\n";
cout<<"
Press Any Key. \n";
getch();
goto loop;
}
else
return resp;
}
int editmenu()
//Menu To Display Products for Admin
{
loop:
clrscr();
int cat;
cout<<"\n\n\n";

cout<<"\n\t\t\t****************************";
cout<<"\n\t\t\t
PRODUCT LIST";
cout<<"\n\t\t\t******************************\n";
cout<<"\n\t\t\t
1.Pendrives";
cout<<"\n\t\t\t
2.Micro SD Cards";
cout<<"\n\t\t\t
3.Cameras";
cout<<"\n\t\t\t
4.Mobile Phones";
cout<<"\n\t\t\t
5.Graphic Cards";
cout<<"\n\t\t\t
6.RAMs";
cout<<"\n\t\t\t
7.Hard Disks";
cout<<"\n\t\t\t
8.Go Back";
cout<<"\n\n\t\t
Enter your choice : ";
cin>>cat;
if(cat>10||cat<1)
{
cout<<"\n
Sorry. You have entered the wrong
choice.\n";
cout<<"
You will be Redirected to the Menu
Again.\n";
cout<<"
Press Any Key. \n";
getch();
goto loop;
}
else
return cat;
}
int admin()
//Menu to Edit Product Lists, Deletion and
Addition
{
admain:
int i=admmenu();
fstream file,filet;
int mo;
int j;
switch(i)
{
case 1:
clrscr();
cout<<"\n\n\n\n\n";
cputs("
You have Chosen To Add to
List. (Press Any Key)");
getch();
j = editmenu();
//Obtain Product Category
switch(j)
{
case 1:
repeatpd:
clrscr();
cout<<endl<<endl;
cputs("
Pendrives");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");

cputs(" Discount");
cout<<endl;
file.open("pen.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
//Check for Empty Files
{
cout<<"\nThe Product List is Currently
Empty.\n";
file.close();
}
else
{
file.close();
file.open("pen.dat",ios::in|ios::out|ios::binary); //Read File
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp(); //Show Products
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Press Any Key To Add Details."); //Adding
Details
getch();
repen:
clrscr();
cout<<endl;
cputs("
Enter Product
Details");
cout<<endl;
file.open("pen.dat",ios::binary|ios::in);
pro.getp(); //Get Product Information
while(!file.eof())
{
file.read((char*)&pro1,sizeof(pro1));
if(pro1.itno==pro.itno)
//Check Item Code
{
cout<<"\n\n\tItem Number Exists. Please
Try Again. Press Any Key.";
getch();
file.close();
goto repen;
//Goto Enter
Prod. Details
}
}
file.close();

file.open("pen.dat",ios::binary|ios::app);
file.write((char*)&pro,sizeof(pro));
cout<<endl;
cout<<endl;
cputs("Product Added Successfully");
cout<<endl<<endl;
file.close();
cputs("Do You Wish To Enter More Pendrives?
(Press 1 or Go Back) : ");
cin>>mo;
if(mo==1)
goto repeatpd;
else
goto admain;

case 2: //Similar to Case 1


repeatmsd:
clrscr();
cout<<endl<<endl;
cputs("

Micro SD

Cards");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("msd.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently
Empty.\n";
file.close();
}
else
{
file.close();
file.open("msd.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n End Of File\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();

cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Press Any Key To Add Details.");
getch();
remsd:
clrscr();
cout<<endl;
cputs("
Enter Product
Details");
cout<<endl;
file.open("msd.dat",ios::binary|ios::in);
pro.getp();
while(!file.eof())
{
file.read((char*)&pro1,sizeof(pro1));
if(pro1.itno==pro.itno)
{
cout<<"\n\n\tItem Number Exists. Please
Try Again. Press Any Key.";
getch();
file.close();
goto remsd;
}
}
file.close();
file.open("msd.dat",ios::binary|ios::app);
file.write((char*)&pro,sizeof(pro));
cout<<endl;
cputs("Product Added Successfully");
cout<<endl<<endl;
file.close();
cputs("Do You Wish To Enter More Micro SD
Cards? (Press 1 or Go Back) : ");
cin>>mo;
if(mo==1)
goto repeatmsd;
else
goto admain;
case 3: //Similar to Case 1
repeatcam:
clrscr();
cout<<endl<<endl;
cputs("
Cameras");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("cam.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);

if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently
Empty.\n";
file.close();
}
else
{
file.close();
file.open("cam.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n End Of File\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Press Any Key To Add Details.");
getch();
recam:
clrscr();
cout<<endl;
cputs("
Enter Product
Details");
cout<<endl;
file.open("cam.dat",ios::binary|ios::in);
pro.getp();
while(!file.eof())
{
file.read((char*)&pro1,sizeof(pro1));
if(pro1.itno==pro.itno)
{
cout<<"\n\n\tItem Number Exists. Please
Try Again. Press Any Key.";
getch();
file.close();
goto recam;
}
}
file.close();
file.open("cam.dat",ios::binary|ios::app);
file.write((char*)&pro,sizeof(pro));
cout<<endl;
cputs("Product Added Successfully");
cout<<endl<<endl;
file.close();

cputs("Do You Wish To Enter More Cameras?


(Press 1 or Go Back) : ");
cin>>mo;
if(mo==1)
goto repeatcam;
else
goto admain;
case 4: //Similar to Case 1
repeatmob:
clrscr();
cout<<endl<<endl;
cputs("
Mobiles");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("mob.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently
Empty.\n";
file.close();
}
else
{
file.close();
file.open("mob.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n End Of File\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Press Any Key To Add Details.");
getch();
remob:
clrscr();
cout<<endl;

cputs("

Enter Product

Details");
cout<<endl;
file.open("mob.dat",ios::binary|ios::in);
pro.getp();
while(!file.eof())
{
file.read((char*)&pro1,sizeof(pro1));
if(pro1.itno==pro.itno)
{
cout<<"\n\n\tItem Number Exists. Please
Try Again. Press Any Key.";
getch();
file.close();
goto remob;
}
}
file.close();
file.open("mob.dat",ios::binary|ios::app);
file.write((char*)&pro,sizeof(pro));
cout<<endl;
cputs("Product Added Successfully");
cout<<endl<<endl;
file.close();
cputs("Do You Wish To Enter More Mobiles?
(Press 1 or Go Back) : ");
cin>>mo;
if(mo==1)
goto repeatmob;
else
goto admain;
case 5: //Similar to Case 1
repeatgpu:
clrscr();
cout<<endl<<endl;
cputs("

Graphic

Cards");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("gpu.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently
Empty.\n";
file.close();
}
else
{

file.close();
file.open("gpu.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n End Of File\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Press Any Key To Add Details.");
getch();
regpu:
clrscr();
cout<<endl;
cputs("
Enter Product
Details");
cout<<endl;
file.open("gpu.dat",ios::binary|ios::in);
pro.getp();
while(!file.eof())
{
file.read((char*)&pro1,sizeof(pro1));
if(pro1.itno==pro.itno)
{
cout<<"\n\n\tItem Number Exists. Please
Try Again. Press Any Key.";
getch();
file.close();
goto regpu;
}
}
file.close();
file.open("gpu.dat",ios::binary|ios::app);
file.write((char*)&pro,sizeof(pro));
cout<<endl;
cputs("Product Added Successfully");
cout<<endl<<endl;
file.close();
cputs("Do You Wish To Enter More Graphic Cards?
(Press 1 or Go Back) : ");
cin>>mo;
if(mo==1)
goto repeatgpu;
else
goto admain;

case 6: //Similar to Case 1


repeatram:
clrscr();
cout<<endl<<endl;
cputs("
RAMs");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("ram.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently
Empty.\n";
file.close();
}
else
{
file.close();
file.open("ram.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n End Of File\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Press Any Key To Add Details.");
getch();
reram:
clrscr();
cout<<endl;
cputs("
Enter Product
Details");
cout<<endl;
file.open("ram.dat",ios::binary|ios::in);
pro.getp();
while(!file.eof())
{
file.read((char*)&pro1,sizeof(pro1));

if(pro1.itno==pro.itno)
{
cout<<"\n\n\tItem Number Exists. Please
Try Again. Press Any Key.";
getch();
file.close();
goto reram;
}
}
file.close();
file.open("ram.dat",ios::binary|ios::app);
file.write((char*)&pro,sizeof(pro));
cout<<endl;
cputs("Product Added Successfully");
cout<<endl<<endl;
file.close();
cputs("Do You Wish To Enter More RAMs? (Press 1
or Go Back) : ");
cin>>mo;
if(mo==1)
goto repeatram;
else
goto admain;
case 7: //Similar to Case 1
repeathd:
clrscr();
cout<<endl<<endl;
cputs("
Hard Disks");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("hd.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\nThe Product List is Currently
Empty.\n";
file.close();
}
else
{
file.close();
file.open("hd.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n End Of File\n";

break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Press Any Key To Add Details.");
getch();
rehd:
clrscr();
cout<<endl;
cputs("
Enter Product
Details");
cout<<endl;
file.open("hd.dat",ios::binary|ios::in);
pro.getp();
while(!file.eof())
{
file.read((char*)&pro1,sizeof(pro1));
if(pro1.itno==pro.itno)
{
cout<<"\n\n\tItem Number Exists. Please
Try Again. Press Any Key.";
getch();
file.close();
goto rehd;
}
}
file.close();
file.open("hd.dat",ios::binary|ios::app);
file.write((char*)&pro,sizeof(pro));
cout<<endl;
cputs("Product Added Successfully");
cout<<endl<<endl;
file.close();
cputs("Do You Wish To Enter More Hard Disks?
(Press 1 or Go Back) : ");
cin>>mo;
if(mo==1)
goto repeathd;
else
goto admain;
case 8:
goto admain; //Goto Main Menu of Adding Product
}
break;
case 2: //Delete from List
clrscr();
cout<<"\n\n\n\n\n";
cputs("
You have Chosen To Delete From
List. (Press Any Key)");

getch();
j = editmenu(); //Get product Choice
int itno;
char find='f';
switch(j)
{
case 1:
delpd:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
Pendrives");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("pen.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
//Check for Empty
File
if(file.tellg()==0)
{
cout<<"\n\n\tThe Product List is Currently
Empty.\n";
file.close();
cout<<"\tYou cant Delete Anything. Press Any
Key to Go Back.\n";
getch();
goto admain;
}
else
{
file.close();
file.open("pen.dat",ios::in|ios::out|ios::binary);
filet.open("temp.dat",ios::out|ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
//Display existing
Products
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");

cout<<endl;
cout<<"\n\n\n\t\tEnter Item No. to be Deleted
: ";
cin>>itno;
file.open("pen.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(pro.itno==itno)
{
find='t';
}
else
{
if(file.eof())
break;
else
filet.write((char*)&pro,sizeof(pro));
}
}
if(find=='t')
{
cout<<"\n\n\t\t Item Successfully Deleted!";
}
if(find=='f')
{
cout<<"\n\n\t\t Item Number Not Found!";
}
getch();
filet.close();
file.close();
clrscr();
remove("pen.dat");
rename("temp.dat","pen.dat");
cout<<"Want to Delete More? (Press 1) : ";
cin>>mo;
if(mo==1)
goto delpd;
else
goto admain;
case 2: //Similar to Case 1
delmsd:
find='f';
clrscr();
cout<<endl<<endl;
cputs("

Micro SD

Cards");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;

file.open("msd.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\n\n\tThe Product List is Currently
Empty.\n";
file.close();
cout<<"\tYou cant Delete Anything. Press Any
Key to Go Back.\n";
getch();
goto admain;
}
else
{
file.close();
file.open("msd.dat",ios::in|ios::out|ios::binary);
filet.open("temp.dat",ios::out|ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\n\n\t\tEnter Item No. to be Deleted
: ";
cin>>itno;
file.open("msd.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(pro.itno==itno)
{
find='t';
}
else
{
if(file.eof())
break;
else
filet.write((char*)&pro,sizeof(pro));
}
}
if(find=='t')

{
cout<<"\n\n\t\t Item Successfully Deleted!";
}
if(find=='f')
{
cout<<"\n\n\t\t Item Number Not Found!";
}
getch();
filet.close();
file.close();
clrscr();
remove("msd.dat");
rename("temp.dat","msd.dat");
cout<<"Want to Delete More? (Press 1) : ";
cin>>mo;
if(mo==1)
goto delmsd;
else
goto admain;
case 3: //Similar to Case 1
delcam:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
Cameras");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("cam.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\n\n\tThe Product List is Currently
Empty.\n";
file.close();
cout<<"\tYou cant Delete Anything. Press Any
Key to Go Back.\n";
getch();
goto admain;
}
else
{
file.close();
file.open("cam.dat",ios::in|ios::out|ios::binary);
filet.open("temp.dat",ios::out|ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())

{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\n\n\t\tEnter Item No. to be Deleted
: ";
cin>>itno;
file.open("cam.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(pro.itno==itno)
{
find='t';
}
else
{
if(file.eof())
break;
else
filet.write((char*)&pro,sizeof(pro));
}
}
if(find=='t')
{
cout<<"\n\n\t\t Item Successfully Deleted!";
}
if(find=='f')
{
cout<<"\n\n\t\t Item Number Not Found!";
}
getch();
filet.close();
file.close();
clrscr();
remove("cam.dat");
rename("temp.dat","cam.dat");
cout<<"Want to Delete More? (Press 1) : ";
cin>>mo;
if(mo==1)
goto delcam;
else
goto admain;
case 4: //Similar to Case 1
delmob:
find='f';
clrscr();

cout<<endl<<endl;
cputs("
Mobiles");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("mob.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\n\n\tThe Product List is Currently
Empty.\n";
file.close();
cout<<"\tYou cant Delete Anything. Press Any
Key to Go Back.\n";
getch();
goto admain;
}
else
{
file.close();
file.open("mob.dat",ios::in|ios::out|ios::binary);
filet.open("temp.dat",ios::out|ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\n\n\t\tEnter Item No. to be Deleted
: ";
cin>>itno;
file.open("mob.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(pro.itno==itno)
{
find='t';

}
else
{
if(file.eof())
break;
else
filet.write((char*)&pro,sizeof(pro));
}
}
if(find=='t')
{
cout<<"\n\n\t\t Item Successfully Deleted!";
}
if(find=='f')
{
cout<<"\n\n\t\t Item Number Not Found!";
}
getch();
filet.close();
file.close();
clrscr();
remove("mob.dat");
rename("temp.dat","mob.dat");
cout<<"Want to Delete More? (Press 1) : ";
cin>>mo;
if(mo==1)
goto delmob;
else
goto admain;
case 5: //Similar to Case 1
delgpu:
find='f';
clrscr();
cout<<endl<<endl;
cputs("

Graphic

Cards");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("gpu.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\n\n\tThe Product List is Currently
Empty.\n";
file.close();
cout<<"\tYou cant Delete Anything. Press Any
Key to Go Back.\n";
getch();
goto admain;

}
else
{
file.close();
file.open("gpu.dat",ios::in|ios::out|ios::binary);
filet.open("temp.dat",ios::out|ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\n\n\t\tEnter Item No. to be Deleted
: ";
cin>>itno;
file.open("gpu.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(pro.itno==itno)
{
find='t';
}
else
{
if(file.eof())
break;
else
filet.write((char*)&pro,sizeof(pro));
}
}
if(find=='t')
{
cout<<"\n\n\t\t Item Successfully Deleted!";
}
if(find=='f')
{
cout<<"\n\n\t\t Item Number Not Found!";
}
getch();
filet.close();
file.close();
clrscr();
remove("gpu.dat");

rename("temp.dat","gpu.dat");
cout<<"Want to Delete More? (Press 1) : ";
cin>>mo;
if(mo==1)
goto delgpu;
else
goto admain;
case 6: //Similar to Case 1
delram:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
RAMs");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;
file.open("ram.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\n\n\tThe Product List is Currently
Empty.\n";
file.close();
cout<<"\tYou cant Delete Anything. Press Any
Key to Go Back.\n";
getch();
goto admain;
}
else
{
file.close();
file.open("ram.dat",ios::in|ios::out|ios::binary);
filet.open("temp.dat",ios::out|ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");

cout<<endl;
cout<<"\n\n\n\t\tEnter Item No. to be Deleted
: ";
cin>>itno;
file.open("ram.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(pro.itno==itno)
{
find='t';
}
else
{
if(file.eof())
break;
else
filet.write((char*)&pro,sizeof(pro));
}
}
if(find=='t')
{
cout<<"\n\n\t\t Item Successfully Deleted!";
}
if(find=='f')
{
cout<<"\n\n\t\t Item Number Not Found!";
}
getch();
filet.close();
file.close();
clrscr();
remove("ram.dat");
rename("temp.dat","ram.dat");
cout<<"Want to Delete More? (Press 1) : ";
cin>>mo;
if(mo==1)
goto delram;
else
goto admain;
case 7: //Similar to Case 1
delhd:
find='f';
clrscr();
cout<<endl<<endl;
cputs("
Hard Disks");
cout<<endl;
cputs("--------------------------------------------------------------------------");
cout<<endl;
cputs("Item No.");
cputs(" Product Name
");
cputs(" Price");
cputs(" Discount (%)");
cout<<endl;

file.open("hd.dat",ios::in|ios::out|ios::binary);
file.seekg(0, ios::end);
if(file.tellg()==0)
{
cout<<"\n\n\tThe Product List is Currently
Empty.\n";
file.close();
cout<<"\tYou cant Delete Anything. Press Any
Key to Go Back.\n";
getch();
goto admain;
}
else
{
file.close();
file.open("hd.dat",ios::in|ios::out|ios::binary);
filet.open("temp.dat",ios::out|ios::in|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(file.eof())
{
cout<<"\n\t\t\t End Of File\n\n";
break;
}
pro.showp();
cout<<endl;
}
}
file.close();
cputs("--------------------------------------------------------------------------");
cout<<endl;
cout<<"\n\n\n\t\tEnter Item No. to be Deleted
: ";
cin>>itno;
file.open("hd.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
file.read((char*)&pro,sizeof(pro));
if(pro.itno==itno)
{
find='t';
}
else
{
if(file.eof())
break;
else
filet.write((char*)&pro,sizeof(pro));
}
}
if(find=='t')

{
cout<<"\n\n\t\t Item Successfully Deleted!";
}
if(find=='f')
{
cout<<"\n\n\t\t Item Number Not Found!";
}
getch();
filet.close();
file.close();
clrscr();
remove("hd.dat");
rename("temp.dat","hd.dat");
cout<<"Want to Delete More? (Press 1) : ";
cin>>mo;
if(mo==1)
goto delhd;
else
goto admain;
default:
cout<<"\n\n\t\tWrong Option Entered. Going
Back. Press any Key.";
getch();
goto admain;
}
case 3 :
return i;
default:
cout<<"\n\n\t\tWrong Choice. Press Any Key To Try
Again.";
getch();
goto admain;
}
}
void main()
{
fstream ma;
ma.open("main.dat",ios::binary|ios::app);
//File Containing
Records
ma.close();
fstream inven;
remove("bill.dat");
//Remove Pre Existing Bill
textbackground(LIGHTBLUE);
men:
clrscr();
int choice = Menu();
int choi;
switch(choice)
{
case 1:
//Enter User Information
clrscr();
gotoxy(20,10);
cputs("Please Enter Your User Information\n");
write();
char b;

cout<<"\n\n\t\t Would You Like to Buy Anything? (If


Yes, Press Y) : ";
cin>>b;
if(b=='y'||b=='Y')
buy();
else
{
cout<<"\n\t\t\t Thanks For Your Interest.\n";
cout<<"\t You Will Be Redirected To the User
Menu.\n";
cout<<"\t
getch();
goto men;

Press Any Key. \n";

}
break;
case 2 : //View Customer Information
clrscr();
gotoxy(20,10);
cout<<"You Have Selected to View Customer
Information.\n\n";
choi = search();
if(choi==3||choi==1)
{goto men;}
break;
case 3 : //Edit Customer Details
clrscr();
gotoxy(20,10);
cout<<"You Have Selected to Edit Your Details.
\n\n";
choi=rec_change();
if(choi==1)
{goto men;}
break;
case 4 : //Delete Account (Customer)
clrscr();
gotoxy(20,10);
cout<<"You Have Chosen to Delete Your Account. \n\n
";;
int re=del();
if(re==1)
goto men;
break;
case 5 : //Display All Records (Admin)
res:
int one;
char ch;
int flag;
clrscr();
gotoxy(20,10);
cout<<"You have Chosen To Display All Records.\n ";
gotoxy(20,11);
cout<<"However, You Need Admin Access to Do So.";
char name[50];
char pass[12]="";
gotoxy(25,14);

cout<<"Enter Username : ";


gotoxy(25,16);
cout<<"Enter Password : ";
gotoxy(43,14);
gets(name);
gotoxy(43,16);
for(int i=0;i<11;i++) //Get Password
{
flag=0;
cha=getch();
if(int(cha)==13)
break;
pass[i]=cha;
cout<<"*";
}
if((!strcmp(name,adm))&&(!strcmp(pass,admp)))
{ //Check Entered Information with Pre-existing Admin
Info.
fstream re;
re.open("main.dat",ios::in|ios::binary);
if(re.fail())
{
cout<<"FATAL ERROR!!";
exit(1);
}
clrscr();
re.seekg(0, ios::end);
//Empty File Check
if(re.tellg()==0)
{
cout<<"\n\n\n\t\tThe List of Users is Currently
Empty.\n\n";
getch();
re.close();
}
else
{
re.close();
re.open("main.dat",ios::in|ios::binary);
while(!re.eof())
{
re.read((char*)&c,sizeof(c));
if(re.eof())
{
cout<<"\n\n\n\n\t\t\t End of File.\n";
getch();
break;
}
c.display();
//Show User Info
cout<<endl;
cout<<"\n\t\tPress Any Key To View Next
Record\n";
getch();
clrscr();
}
}

re.close();

//Close Main File containing

Records
}
else
{
cout<<"\n\n\t\t\tUsername & Password Do Not Match";
cout<<"\n\t\t\t Please Press 1 to Try Again : ";
cin>>one;
if(one==1)
goto res;
else
goto men;
}
goto men;
case 6 : //Admin Access
int pt;
int j=0;
clrscr();
gotoxy(25,10);
cout<<"You have Chosen Admin Access.\n ";
char name1[50];
char pass1[12]="";
gotoxy(25,14);
cout<<"Enter Username : ";
gotoxy(25,16);
cout<<"Enter Password : ";
gotoxy(43,14);
gets(name1);
gotoxy(43,16);
for(i=0;i<12;i++)
//Get Password
{
flag=0;
cha=getch();
if(cha==13)
break;
if(flag==0)
{
pass1[i]=cha;
cout<<"*";
}
}
if((!strcmp(name1,adm))&&(!strcmp(pass1,admp)))
{ //Check Entered Information with Pre-existing
Admin Info.
clrscr();
gotoxy(20,10);
cputs("Welcome Admin");
cout<<endl;
}
else
{
clrscr();
gotoxy(20,10);
cout<<"\n\n\t\t\t\tWrong Username/Password\n";
cout<<"\t\t\t\t
Redirecting Back\n";
cout<<"\t\t\t\t
Press Any Key";
getch();

goto men;
}
cout<<"\tWould You Like To Continue? (Press 1) : ";
cin>>pt;
if(pt!=1)
{
goto men;
}
int gb=admin();
if(gb==4)
goto men;
else
goto men;
case 7: //Check Conditions to Go Back.
int bb = buy();
if(bb==9)
goto men;
else if(bb==1) //Checkout if cart isnt Empty.
{
int cc=checkout();
if(cc==1)
goto men;
else
goto men;
}
break;
case 8 :
clrscr();
textbackground(LIGHTBLUE);
delay(200);
gotoxy(28,10);
cout<<"You Have Chosen to Quit.\n"; //Quitting
delay(1000);
gotoxy(27,12);
cout<<" Thanks For Visiting.\n";
delay(1000);
gotoxy(27,14);
cout<<"
Exiting Now";
for(int v=0;v<6;v++)
{delay(400);cout<<".";}
remove("bill.dat");
//Remove Exisyting Bill
exit(0);
}
getch();
}

You might also like