You are on page 1of 11

//-----------------------------------------------------------//

SHOWROOM MANAGEMENT
//---------------------^^^^^^^^^^^^^^^^^^^-------------------// INCLUDED HEADER FILES
// ^^^^^^^^^^^^^^^^^^^^^
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<time.h>
#include<string.h>
#include<ctype.h>
//____________________________________________________________
// THIS CLASS CONTAINS RELATED DATA MEMBERS & MEMBER FUNCTIONS
//____________________________________________________________
class showroom
{ private:
//Private data members
long garno;
char type[25], brand[20], colour[20];
int size;
float mrp,discount;
public:
void input();
void output();
void del();
void search();
void exiting();
void modify();
float finalcost();
int lastcode();

//Public member functions

};
//This Function Inputs The Records
void showroom::input()
{
s:
clrscr();
fstream fout;
int tcode,valid;
char ch,ch1;
tcode=lastcode();
tcode++;
garno=tcode;
cout<<"\n\n\t\t\tRECORDS INPUT SECTION \n";
cout<<"\t\t\t---------------------\n\n";
cout<<"\n The garment number is : ";
cout<<garno<<endl;

cout<<"\n Enter Garment type : ";


gets(type);
//Converts lowercase type to uppercase type
for(int i=0;i<strlen(type);i++)
type[i]=toupper(type[i]);
cout<<"\n Enter Brand name : ";
gets(brand);
//Converts lowercase brand to uppercase brand
for(i=0;i<strlen(brand);i++)
brand[i]=toupper(brand[i]);
cout<<"\n Enter colour : ";
gets(colour);
//Converts lowercase colour to uppercase colour
for(i=0;i<strlen(colour);i++)
colour[i]=toupper(colour[i]);
cout<<"\n Enter size : ";
cin>>size;
cout<<"\n Enter COST (incl. of all taxes ) : Rs.";
cin>>mrp;
cout<<endl;
cout<<" Enter DISCOUNT (%) : ";
cin>>discount;
cout<<"\n\t DO YOU WISH TO SAVE THIS RECORD (Y/N) : ";
cin>>ch;
if(toupper(ch) == 'Y')
{
fout.open("show.dat",ios::app|ios::binary);
fout.write((char*)this,sizeof(showroom));
fout.close();
}
cout<<"\n\n\t\t\t\tDo You Want To Add More Records (Y/N) : ";
cin>>ch1;
if(toupper(ch1) == 'Y')
goto s;
else
{
}
}

//This Function Displays The Record


void showroom::output()
{ clrscr();
cout<<"\n\n\n\t\t\tRECORDS DISPLAY SECTION \n";
cout<<"\t\t\t-----------------------\n\n";
ifstream fin("show.dat",ios::in|ios::binary);
while(!fin.eof())
{ fin.read((char*)this,sizeof(showroom));
if(fin.eof())

break;
cout<<"\n\n Garment number: "<<this->garno<<endl;
cout<<"\n Garment type : ";
puts(this->type);
cout<<"\n Brand name : ";
puts(this->brand);
cout<<"\n colour : ";
puts(this->colour);
cout<<"\n Size : "<<this->size;
cout<<endl;
cout<<"\n MAXIMUM RETAIL PRICE : Rs."<<this->mrp;
cout<<endl;
cout<<"\n DISCOUNT available : "<<this->discount<<'%';
cout<<endl;
cout<<"\n Press any key to continue..............";
cout<<"\n\n\n\n\n";
getch();
}
}
//This Function Searches a Particular Item
void showroom::search()
{
s:
clrscr();
fstream fin;
int n,check=0;
char ch1;
cout<<"\n\n\t\t\tSEARCH RECORDS SECTION \n";
cout<<"\t\t\t----------------------\n\n";
cout<<"\n\n Enter Garment no. you want to search : ";
cin>>n;
fin.open("show.dat",ios::in|ios::binary);
while(!fin.eof())
{ fin.read((char*)this,sizeof(showroom));
if(fin.eof())
break;
if(n==garno)
{
check=1;
cout<<"\n Garment Type : ";
puts(type);
cout<<"\n Brand name : ";
puts(brand);
cout<<"\n Colour : ";
puts(colour);
cout<<"\n Size : "<<size;
cout<<endl;
cout<<"\n MRP (incl. of all taxes) : Rs."<<mrp;
cout<<endl;
cout<<"\n Discount : "<<discount<<'%';
cout<<endl;

cout<<"\n Final cost : Rs."<<finalcost();


getch();
}
}
fin.close();
if(check==0)
{
cout<<"\n\n\n\n\n\n\n\t\t\tRECORD NOT FOUND \n";
cout<<"\t\t\t^^^^^^^^^^^^^^^^ ";
}
cout<<"\n\n\n\n\n\t\t\t\tDo You Want To SEARCH More Records (Y/N) : ";
cin>>ch1;
if(toupper(ch1) == 'Y')
goto s;
else
{
}
}
//This Function Deletes Records Of a Sold Item
void showroom::del()
{
s:
clrscr();
int x,check=0;
char ch1;
cout<<"\n\n\t\t\tDELETE RECORDS SECTION \n";
cout<<"\t\t\t----------------------\n\n";
fstream afile,tempfile;
afile.open("show.dat",ios::in|ios::binary);
tempfile.open("abc.dat",ios::out|ios::binary);
if(!afile)
{cout<<"opening errors ";
exit(0);
}
if(!tempfile)
{cout<<"opening errors ";
exit(0);
}
cout<<"\n\n Enter garment no. you want to delete : ";
cin>>x;
while(!afile.eof())
{
afile.read((char*)this,sizeof(showroom));

if(afile.eof())
break;
if(garno!=x)
tempfile.write((char*)this,sizeof(showroom));
else
check=1;
}
afile.close();
tempfile.close();
afile.open("show.dat",ios::out|ios::binary);
tempfile.open("abc.dat",ios::in|ios::binary);
if(!afile)
{cout<<"opening errors ";
exit(0);
}
if(!tempfile)
{cout<<"opening errors ";
exit(0);
}
while(!tempfile.eof())
{
tempfile.read((char*)this,sizeof(showroom));
if(tempfile.eof())
break;
afile.write((char*)this,sizeof(showroom));
}
afile.close();
tempfile.close();
if(check==0)
cout<<"\n\n\n\n\n\n\n\t\t\tRECORD NOT FOUND !!! ";
else
cout<<"\n\n\n\n\n\n\n\t\t\tRECORD HAS BEEN DELETED !!! ";
cout<<"\n\n\n\n\n\t\t\t\tDo You Want To DELETE More Records (Y/N) : ";
cin>>ch1;
if(toupper(ch1) == 'Y')
goto s;
else
{
}
}
//This Function Modifies An Existing Record
void showroom::modify()
{
clrscr();

int r,recsize,check=0;
char ch;
cout<<"\n\n\t\t\tMODIFY RECORDS SECTION \n";
cout<<"\t\t\t---------------------- \n\n";
fstream afile;
afile.open("show.dat",ios::in|ios::out|ios::binary);
if(!afile)
{
cout<<"opening errors ";
exit(0);
}
cout<<"\n Enter Garment no. you want to modify : ";
cin>>r;
while(!afile.eof())
{
afile.read((char*)this,sizeof(showroom));
if(afile.eof())
break;
if(r==garno)
{
check=1;
cout<<"\n Garment no. : "<<garno;
cout<<endl;
cout<<"\n Garment type : ";
puts(type);
cout<<"\n Brand : ";
puts(brand);
cout<<"\n Colour : ";
puts(colour);
cout<<"\n Size : "<<size;
cout<<endl;
cout<<"\n MAXIMUM RETAIL PRICE : "<<mrp;
cout<<endl;
cout<<"\n Discount : "<<discount;
cout<<endl;
cout<<"\n Purchasable Price :"<<finalcost();
cout<<"\n\n<><><><><><><><><><><><><><><><><><><><><><><><><><> ";
cout<<endl;
recsize=sizeof(showroom);
afile.seekp(-recsize,ios::cur);
cout<<"\n Enter Garment type : ";
gets(type);
//Converts lowercase type to uppercase type
for(int i=0;i<strlen(type);i++)
type[i]=toupper(type[i]);
cout<<"\n Enter Brand name : ";
gets(brand);
//Converts lowercase brand to uppercase brand
for(i=0;i<strlen(brand);i++)
brand[i]=toupper(brand[i]);

cout<<"\n Enter colour : ";


gets(colour);
//Converts lowercase colour to uppercase colour
for(i=0;i<strlen(colour);i++)
colour[i]=toupper(colour[i]);
cout<<"\n Enter size : ";
cin>>size;
cout<<"\n Enter COST (incl. of all taxes ) : Rs.";
cin>>mrp;
cout<<endl;
cout<<" Enter DISCOUNT (%) : ";
cin>>discount;
cout<<"\n\t DO YOU WISH TO MODIFY (Y/N) : ";
cin>>ch;
if(toupper(ch) == 'Y')
afile.write((char*)this,sizeof(showroom));
afile.close();
break;
}
afile.close();
if(check==0)
cout<<"RECORD NOT FOUND !!! ";
}

//This Function Is For Calculating The Final Cost


float showroom::finalcost()
{
float i;
i = (mrp-(mrp/discount));
return i;
}
//This Function Is For Exiting From The Main Program
void showroom::exiting()
{
clrscr();
int x,y;
for(y=2;y<24;y++)
{
gotoxy(1,y);

cout<<"||";
gotoxy(78,y);
cout<<" ||";
}
gotoxy(1,1);
cout<<"*";
gotoxy(1,24);
cout<<"*";
gotoxy(79,1);
cout<<"*";
gotoxy(79,24);
cout<<"*";
for(x=2;x<79;x++)
{
gotoxy(x,1);
cout<<"=";
gotoxy(x,24);
cout<<"=";
}
gotoxy(24,5);
cout<<"\\* WISH YOU A PROSPEROUS FUTURE */";
gotoxy(24,6);
cout<<"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
";
gotoxy(53,12);
cout<<" Made by:- ";
gotoxy(53,13);
cout<<" ============== ";
gotoxy(53,14);
cout<<" SHIVAM ";
gotoxy(53,15);
cout<<" Class : XII-A ";
gotoxy(47,17);
cout<<" ROSARY SENIOR SECONDARY SCHOOL ";
gotoxy(47,18);
cout<<" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ";
gotoxy(5,21);
cout<<" THOUGHT -> A Man Who Never Makes a Mistake is \n";
cout<<"
The Man Who Never Does Anything....
getchar();
exit(0);
}
//This function checks last entered garment number
int showroom::lastcode()
{
fstream fin("show.dat",ios::in|ios::binary);
if(!fin)
{
gotoxy(11,38);
cout<<"OPENING ERROR.............";
return 0;
}

";

int t=0;
while(!fin.eof())
{
fin.read((char*)this,sizeof(showroom));
if(fin.eof())
break;
t=garno;
}
fin.close();
return t;
}
//++++++++++++ DEFINITIONS OF CLASS MEMBER FUNCTIONS ARE OVER ++++++++++++
//________________________________________________________________________
//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

//__________________________________________________________________________
// THIS IS MAIN FUNCTION WHICH DISPLAYS MENU & CALLS ALL THE MAIN FUNCTIONS
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
void main()
{
clrscr();
showroom show;
fstream afile,tempfile;
int n,j;
char q[9];
gotoxy(32,3);
cout<<" USER VERIFICATION ";
gotoxy(32,4);
cout<<" ================= ";
gotoxy(31,12);
cout<<" ENTER YOUR PASSWORD -> ";
gets(q);
if(strcmp(q,"YASH KANT")==0)
{
}
else
{
clrscr();
gotoxy(27,7);
cout<<" AUTHENTIFICATION FAILURE ";
gotoxy(27,8);
cout<<" ======================== ";
gotoxy(25,10);
cout<<" Sorry !!! ";
gotoxy(25,12);
cout<<" THE ENTERED PASSWORD IS WRONG ";
getchar();
exit(0);
}
{ k:

clrscr();
time_t t;
time(&t);
gotoxy(27,3);
printf("\t\t\t

%s\n", ctime(&t));

gotoxy(23,7);
cprintf(" ___SHOWROOM MANAGEMENT__ ");
gotoxy(24,8);
cprintf("_ ^_^_^_^_^_^_^_^_^_^_^_ ");
gotoxy(30,11);
cprintf(" 1_ INPUT RECORDS ");
gotoxy(30,13);
cprintf(" 2_ DISPLAY RECORDS ");
gotoxy(30,15);
cprintf(" 3_ MODIFY RECORDS ");
gotoxy(30,17);
cprintf(" 4_ SEARCH FOR A PARTICULAR GARMENT ");
gotoxy(30,19);
cprintf(" 5_ DELETE DETAILS OF A SOLD GARMENT ");
gotoxy(30,21);
cprintf(" 6_ EXIT ");
gotoxy(30,24);
cprintf(" Enter Your Choice____ -> ");
cin>>j;
if((j<1) || (j>6))
{
clrscr();
cout<<"\n\n\n\n\n\n\n"<<"\t\t\t\tWRONG CHOICE !!!";
getchar();
goto k;
}
//-------------*RUN ACCORDING TO THE CHOICE OF THE USER*-------------------switch(j)
{
case 1:
{
show.input();
goto k;
}
case 2:
{
show.output();
goto k;
}
case 3:

{
show.modify();
goto k;
}
case 4:
{
show.search();
goto k;
}
case 5:
{
show.del();
goto k;
}
case 6:
{ show.exiting(); }
}
}
}

You might also like