Professional Documents
Culture Documents
C++ Class 12th Project
C++ Class 12th Project
Roll No. :-
ST.GEORGES SCHOOL
CERTIFICATE
of
ACKNOWLEDGEMENT
INDEX
INTRODUCTION
HEADER FILES
SOURCE CODE
OUTPUT
FLOWCHART
BIBLIOGRAPHY
INTRODUCTION
The DEVRIS DIGITAL FORTRESS is a C++ portal to access and handle all types of
accounts that are it the records. This portal enables us to access the employees record as
well as the customers record. It also helps in managing the discounts and in modifying
the details of an employee or customer. It is user- friendly portal which can be easily
handled by anyone. One can easily add an account, modify it, delete it, etc.
I hope youll all like this portal.
Thank You.
FSTREAM.H
CONIO.H
UDF.H(self-made header file)
STDIO.H
STRING.H
STDLIB.H
SOURCE CODE
#include<fstream.h>
#include<conio.h>
#include<udf.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int eno=1;
int cno=1;
struct employee
{
char name[20]; //EMPLOYEE NAME
int eno,bonus;
//Eno:- EMPLOYEE NUMBER
float basic,sal; //BASIC: Basic | Sal: Salary
char phone[11];
};
struct customer
{
char name[20]; //CUSTOMER NAME
int cno,disc;
//Cno:- CUSTOMER NUMBER | Disc:-Discount
float total,bill; //TOTAL:- Total Amount | Bill:- Total after Discount
char phone[11];
//Phone:- Phone number.
};
//CUSTOMER NUMBER IS SELF GENERATING.
class shop
{
customer c;
employee e;
public:
void getdata(); void emp_getdata();
void putdata();
void emp_putdata();
void modify_rec();
void emp_modify_rec();
int returncno(); int emp_returneno();
char* returnname();
char* emp_returnname();
};
void shop::getdata()
{
c.cno=::cno; //SELF ASSIGNMENT
gotoxy(10,3);cout<<"ENTER CUSTOMER NAME :-";gets(c.name);
gotoxy(10,5);cout<<"ENTER PHONE NUMBER :-";gets(c.phone);
gotoxy(10,7);cout<<"ENTER AMOUNT :-";cin>>c.total;
if(c.total<=500)
{
c.bill=c.total;
//NO DISCOUNT
c.disc=0;
}
else if(c.total>500 && c.total<=1000)
{
c.bill=c.total-(c.total/20);
c.disc=5;
//5% DISCOUNT
}
else if(c.total>1000 && c.total<=1500)
{
c.bill=c.total-(c.total/10); //10% DISCOUNT
c.disc=10;
}
else if(c.total>1500 && c.total<=2000)
{
c.bill=c.total-((15*c.total)/100); //15% DISCOUNT
c.disc=15;
}
else if(c.total>200)
{
c.bill=c.total-(c.total/5); //20% DISCONT
c.disc=20;
}
::cno++;
}
void shop::putdata()
{
cout<<c.cno<<'\t'<<c.name<<'\t'<<c.phone<<'\t'<<c.total<<'\t'<<c.bill<<'\t'<<c.disc<<
"%"<<endl;
}
void shop::modify_rec()
{
gotoxy(10,5);cout<<"ENTER CUSTOMER NAME :-";gets(c.name);
gotoxy(10,7);cout<<"ENTER PHONE NUMBER :-";cin>>c.phone;
gotoxy(10,9);cout<<"ENTER AMOUNT :-";cin>>c.total;
if(c.total<=500)
{
c.bill=c.total;
//NO DISCOUNT
c.disc=0;
}
else if(c.total>500 && c.total<=1000)
{
c.bill=c.total-(c.total/20); //5% DISCOUNT
c.disc=5;
}
else if(c.total>1000 && c.total<=1500)
{
c.bill=c.total-(c.total/10); //10% DISCOUNT
c.disc=10;
}
else if(c.total>1500 && c.total<=2000)
{
c.bill=c.total-((15*c.total)/100); //15% DISCOUNT
c.disc=15;
}
else if(c.total>200)
{
c.bill=c.total-(c.total/5); //20% DISCONT
c.disc=20;
}
}
int shop::returncno()
{
return c.cno;
}
char* shop::returnname()
{
return c.name;
}
void newcustomer()
{
border('*');
char choice='y';
fstream f("Rishabh.dat",ios::binary|ios::app);
shop c;
while(choice=='y'||choice=='Y')
{
clrscr();
border('*');
c.getdata();
f.write((char*)&c,sizeof(c));
gotoxy(4,10);cout<<"Add More Customers:-";
cin>>choice;
}
f.close();
}
void displaycustomers()
{
clrscr();
border('$');
int i=7;
gotoxy(25,3);cout<<"DEVRIS DIGITAL FORTRESS CUSTOMERS DATABASE ";
fstream f("Rishabh.dat",ios::binary|ios::in);
gotoxy(18,5);cout<<"CNO\t NAME\t
shop c;
while(f.read((char*)&c,sizeof(c)))
{
gotoxy(20,i++);c.putdata();
}
PHONE\t
f.close();
}
void searchbyname()
{
border('$');
char search[20];
int found=0;
AMT\tBILL\tDISC";
f.write((char*)&c,sizeof(c));
break;
}
}
if(found==0)
{
cout<<"NO SUCH CUSTOMER EXISTS IN THE DATABASE";
}
f.close();
}
void delete_record()
{
border('$');
fstream f("Rishabh.dat",ios::binary|ios::in);
fstream f1("temp.dat",ios::binary|ios::out);
char confirm='y';
int found=0; char search[20];
gotoxy(4,5);cout<<"Enter the Customer NAME whose details you want to
DELETE :-";
gets(search);
shop c;
while(f.read((char*)&c,sizeof(c)))
{
if(strcmpi(search,c.returnname())==0)
{
gotoxy(4,7);c.putdata();
found=1;
gotoxy(6,9);cout<<endl<<"ARE YOU SURE WANT TO DELETE(N/Y) ??";
cin>>confirm;
if(confirm=='n' || confirm=='N')
{
f1.write((char*)&c,sizeof(c));
}
else if(confirm=='y'||confirm=='Y')
{
gotoxy(4,11);cout<<"RECORD DELETED ";
}
}
else
{
f1.write((char*)&c,sizeof(c));
}
}
f.close();
f1.close();
remove("Rishabh.dat");
rename("temp.dat","Rishabh.dat");
if(found==0)
{
cout<<"NO SUCH CUSTOMER EXISTS";
}
}
void shop::emp_getdata()
{
e.eno=::eno; //SELF ASSIGNMENT
gotoxy(10,3);cout<<"ENTER EMPLOYEE NAME :-";gets(e.name);
gotoxy(10,5);cout<<"ENTER PHONE NUMBER :-";gets(e.phone);
gotoxy(10,7);cout<<"ENTER BASIC :-";cin>>e.basic;
if(e.basic<=500)
{
e.sal=e.basic;
//NO DISCOUNT
e.bonus=0;
}
else if(e.basic>500 && e.basic<=1000)
{
e.sal=e.basic+(e.basic/20); //5% DISCOUNT
e.bonus=5;
}
else if(e.basic>1000 && e.basic<=1500)
{
e.sal=e.basic+(e.basic/10); //10% DISCOUNT
e.bonus=10;
}
else if(e.basic>1500 && e.basic<=2000)
{
e.sal=e.basic+((15*e.basic)/100); //15% DISCOUNT
e.bonus=15;
}
else if(e.basic>200)
{
e.sal=e.basic+(e.basic/5); //20% DISCONT
e.bonus=20;
}
::eno++;
}
void shop::emp_putdata()
{
cout<<e.eno<<'\t'<<e.name<<'\t'<<e.phone<<'\t'<<e.basic<<'\t'<<e.sal<<'\t'<<e.bonus<<
"%"<<endl;
}
void shop::emp_modify_rec()
{
gotoxy(10,5);cout<<"ENTER CUSTOMER NAME :-";gets(e.name);
gotoxy(10,7);cout<<"ENTER PHONE NUMBER :-";cin>>e.phone;
gotoxy(10,9);cout<<"ENTER AMOUNT :-";cin>>e.basic;
if(e.basic<=500)
{
e.sal=e.basic;
e.bonus=0;
}
//NO DISCOUNT
int i=7;
gotoxy(25,3);cout<<"DEVRIS DIGITAL FORTRESS EMPLOYEES DATABASE";
fstream f("EXP.dat",ios::binary|ios::in);
gotoxy(18,5);cout<<"ENO\t NAME\t
shop c;
PHONE\t
BASIC\tSALARY\tBONUS";
while(f.read((char*)&c,sizeof(c)))
{
gotoxy(20,i++);c.emp_putdata();
}
f.close();
}
void emp_searchbyname()
{
border('*');
char search[20];
int found=0;
gotoxy(4,4);cout<<"Enter the name of the Employee you want to
search :-";gets(search);
fstream f("EXP.dat",ios::binary|ios::in);
shop c;
while(f.read((char*)&c,sizeof(c)))
{
if(strcmpi(search,c.emp_returnname())==0)
{
found=1;
gotoxy(4,6);cout<<"THE SEARCHED EMPLOYEE "<<endl;
gotoxy(4,8);c.emp_putdata();
break;
}
}
if(found==0)
{
gotoxy(4,8);cout<<"NO SUCH EMPLOYEE EXISTS";
}
f.close();
}
void emp_modify()
{
border('$');
fstream f("EXP.dat",ios::binary|ios::out|ios::in);
char search[20];
gotoxy(4,5);cout<<"Enter the Employee NAME of the customer you want to
modify :-";
gets(search);
int found=0;
shop c;
while(f.read((char*)&c,sizeof(c)))
{
if(strcmpi(search,c.emp_returnname())==0)
{
found=1;
clrscr();
border('$');
gotoxy(3,3);c.emp_putdata();
gotoxy(3,4);cout<<"ENTER NEW DETAILS :-";
int pos=f.tellg();
f.seekp(pos-sizeof(c),ios::beg);
c.emp_modify_rec();
f.write((char*)&c,sizeof(c));
break;
}
}
if(found==0)
{
cout<<"NO SUCH EMPLOYEE EXISTS IN THE DATABASE";
}
f.close();
}
void emp_delete_record()
{
border('$');
fstream f("EXP.dat",ios::binary|ios::in);
fstream f1("temp.dat",ios::binary|ios::out);
char confirm='y';
int found=0; char search[20];
gotoxy(4,5);cout<<"Enter the Employee NAME whose details you want to
DELETE :-";
gets(search);
shop c;
while(f.read((char*)&c,sizeof(c)))
{
if(strcmpi(search,c.emp_returnname())==0)
{
gotoxy(4,7);c.emp_putdata();
found=1;
gotoxy(6,9);cout<<endl<<"ARE YOU SURE WANT TO DELETE(N/Y) ??";
cin>>confirm;
if(confirm=='n' || confirm=='N')
{
f1.write((char*)&c,sizeof(c));
}
else if(confirm=='y'||confirm=='Y')
{
gotoxy(4,11);cout<<"RECORD DELETED ";
}
}
else
{
f1.write((char*)&c,sizeof(c));
}
}
f.close();
f1.close();
remove("EXP.dat");
rename("temp.dat","EXP.dat");
if(found==0)
{
cout<<"NO SUCH EMPLOYEE EXISTS";
}
}
void main()
{
textcolor(CYAN);
MENU: //label
clrscr();
border('$');
gotoxy(19,4);cout<<"WELCOME to DEVRIS DIGITAL
gotoxy(19,6);cout<<"GET THE BEST PRODUCTS AND
gotoxy(30,13);cout<<"SUMMER SALE !!!...";
gotoxy(17,15);cout<<"GET UPTO 20% DISCOUNT ON
gotoxy(31,20);cout<<"T&C apply^^";
gotoxy(31,21);cout<<"^^To check the terms and
gotoxy(31,22);cout<<" Website: Devris.com";
FORTRESS";
DEALS HERE !!!!";
SHOPPING WORTH
Rs2000";
getch();
char type='c';
int choice=0;
while(type!='n')
{
again:
clrscr();
border('$');
gotoxy(15,3);cout<<"CUSTOMER DATABASE"; gotoxy(50,3);cout<<"EMPLOYEE
DATABASE";
gotoxy(20,5);cout<<"Press 'C'"; gotoxy(54,5);cout<<"Press 'E'";
for(int i=1;i<=80;i++)
{
gotoxy(i,7);cout<<".";
}
for(i=1;i<=7;i++)
{
gotoxy(40,i);cout<<".";
}
gotoxy(32,24);cout<<"Press 'N' to EXIT";
gotoxy(26,10);cout<<"DATABASE YOU WANT TO ACCESS :-";cin>>type;
if(type=='c'||type=='C')
{
while(choice!=7)
{
border('$');
gotoxy(36,3);cout<<"MENU";
gotoxy(24,5);cout<<"1. NEW CUSTOMER ";
gotoxy(24,7);cout<<"2. ALL CUSTOMERS ";
gotoxy(24,9);cout<<"3. SEARCH (by name) ";
gotoxy(24,11);cout<<"4. MODIFY details of a CUSTOMER";
gotoxy(24,13);cout<<"5. DELETE details of a Customer";
gotoxy(24,15);cout<<"6. BACK";
gotoxy(24,17);cout<<"7. EXIT";
gotoxy(24,19);cout<<"Enter your choice :-";
cin>>choice;
switch(choice)
{
case 1:
newcustomer();
getch();
clrscr();
break;
case 2:
displaycustomers();
getch();
clrscr();
break;
case 3: searchbyname();
getch();
clrscr();
break;
case 4:
modify();
getch();
clrscr();
break;
case 5:
delete_record();
getch();
clrscr();
break;
case 6:
goto again;
break;
case 7: clrscr();
border('*');
gotoxy(30,12);cout<<"EXITTING CUSTOMER DATABASE";
getch();
exit(0);
break;
default:clrscr();
getch();
gotoxy(30,12);cout<<"INVALID CHOICE";
getch();
exit(0);
}
}
}
else if(type=='e'||type=='E')
{
while(choice!=7)
{
border('$');
gotoxy(36,3);cout<<"MENU";
gotoxy(24,5);cout<<"1. NEW EMPLOYEE ";
gotoxy(24,7);cout<<"2. ALL EMPLOYEE ";
gotoxy(24,9);cout<<"3. SEARCH (by name) ";
gotoxy(24,11);cout<<"4. MODIFY details of a EMPLOYEE";
gotoxy(24,13);cout<<"5. DELETE details of a EMPLOYEE";
gotoxy(24,15);cout<<"6. BACK";
gotoxy(24,17);cout<<"7. EXIT";
gotoxy(24,18);cout<<"Enter your choice :-";
cin>>choice;
switch(choice)
{
case 1: newemployee();
getch();
clrscr();
break;
case 2: displayemployees();
getch();
clrscr();
break;
case 3: emp_searchbyname();
getch();
clrscr();
break;
case 4: emp_modify();
getch();
clrscr();
break;
case 5: emp_delete_record();
getch();
clrscr();
break;
case 6: goto again;
break;
case 7: clrscr();
border('^');
gotoxy(30,12);cout<<"EXITTING EMPLOYEE DATABASE";
getch();
exit(0);
break;
default:clrscr();
getch();
gotoxy(30,12);cout<<"INVALID CHOICE";
getch();
exit(0);
}
}
}
else if(type=='n'||type=='N')
{
gotoxy(31,15);cout<<"EXITTIMG PROGRAMME";
getch();
exit(0);
}
}
getch();
}
OUTPUT
FLOWCHART
DEVRIS DIGITAL
Fortress
ADD
ADD
SHOW ALL
SHOW ALL
SEARCH
SEARCH
MODIFY
Devris
Digital Fortress
DELETE
Customers
Database
BACK
EXIT
MODIFY
Devris
Digital Fortress
DELETE Database
Employees
EXIT
BACK
EXIT
BIBLIOGRAPHY
Programming in C++
- E. Balaguruswamy
- Robert Lafore
in C++
Computer Science with C++
www.cprogramming.com
www.cprogramming.blogspot.in
- Sumita Arora