Professional Documents
Culture Documents
Class 12th Computer Science Project
Class 12th Computer Science Project
Roll No. :-
CERTIFICATE
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 employee’s 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.
Thank You.
HEADER FILES USED
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()
{
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;
}
::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()
{
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));
f.close();
}
void displaycustomers()
{
clrscr();
border('$');
int i=7;
while(f.read((char*)&c,sizeof(c)))
{
gotoxy(20,i++);c.putdata();
}
f.close();
}
void searchbyname()
{
border('$');
char search[20];
int found=0;
shop c;
while(f.read((char*)&c,sizeof(c)))
{
if(strcmpi(search,c.returnname())==0)
{
found=1;
gotoxy(4,6);cout<<"THE SEARCHED CUSTOMER "<<endl;
gotoxy(4,8);c.putdata();
break;
}
}
if(found==0)
{
gotoxy(4,8);cout<<"NO SUCH CUSTOMER EXISTS";
}
f.close();
}
void modify()
{
border('$');
fstream f("Rishabh.dat",ios::binary|ios::out|ios::in);
char search[20];
int found=0;
shop c;
while(f.read((char*)&c,sizeof(c)))
{
if(strcmpi(search,c.returnname())==0)
{
found=1;
clrscr();
border('$');
gotoxy(3,3);c.putdata();
int pos=f.tellg();
f.seekp(pos-sizeof(c),ios::beg);
c.modify_rec();
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';
shop c;
while(f.read((char*)&c,sizeof(c)))
{
if(strcmpi(search,c.returnname())==0)
{
gotoxy(4,7);c.putdata();
found=1;
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()
{
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()
{
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;
}
}
int shop::emp_returneno()
{
return e.eno;
}
char* shop::emp_returnname()
{
return e.name;
}
void newemployee()
{
border('$');
char choice='y';
fstream f("EXP.dat",ios::binary|ios::app);
shop c;
while(choice=='y'||choice=='Y')
{
clrscr();
border('$');
c.emp_getdata();
f.write((char*)&c,sizeof(c));
f.close();
}
void displayemployees()
{
clrscr();
border('$');
int i=7;
gotoxy(25,3);cout<<"DEVRIS DIGITAL FORTRESS EMPLOYEES DATABASE";
fstream f("EXP.dat",ios::binary|ios::in);
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;
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];
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();
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';
shop c;
while(f.read((char*)&c,sizeof(c)))
{
if(strcmpi(search,c.emp_returnname())==0)
{
gotoxy(4,7);c.emp_putdata();
found=1;
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('$');
getch();
char type='c';
int choice=0;
while(type!='n')
{
again:
clrscr();
border('$');
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";
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 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";
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 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
SIMILARLY 10 CUSTOMERS WERE
ADDED
FLOWCHART
DEVRIS DIGITAL
Fortress
ADD ADD
SEARCH SEARCH
MODIFY MODIFY
Devris Digital Fortress Devris Digital Fortress
Customers
DELETE Database Employees
DELETE Database
EXIT
BACK BACK
EXIT EXIT
BIBLIOGRAPHY
Programming in C++ - E. Balaguruswamy