//**********************************************************************************//
//
// Project on ::
// Crime Investigation Department
//// Prepared By :: ASHUTOSH SINGH
//// E-mail :: rahul.301293@gmail.com
////
//**********************************************************************************//
#include<process.h>
#include<string.h>#include<stdio.h>
#include<ctype.h>
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<dos.h>
#include<fstream.h>
class Criminal{ public:
char name[50],crime[800],relation[50],addr[50];
char pass[255];
char status[20];
char ch,ch1,ch2,ans,namec[50];
int n,i,id;
~Criminal()
{
}
void logo()
{
clrscr();
int i,j,k=20,l=5;
for(i=1;i<=10;i++)
{
gotoxy(k,l);
for(j=1;j<=i;j++)
{
cout<<".";
}
cout<<"\n";
k--;l++;
}
k=20;l=6;
for(i=2;i<=10;i++)
{
gotoxy(k,l);
for(j=1;j<=i;j++)
{
cout<<".";
}
cout<<"\n";
l++;
}
k=11;
l=8;
for(i=1;i<=10;i++)
{
gotoxy(k,l);
for(j=10;j>=i;j--)
{
cout<<".";
}
cout<<endl;
k++;l++;
}
k=21;l=8;
for(i=2;i<=10;i++)
{
gotoxy(k,l);
for(j=10;j>=i;j--)
{
cout<<".";
}
cout<<endl;
l++;
}
gotoxy(30,6);
cout<<" . . . . .......... . . . . ";
delay(125);
gotoxy(31,7);
cout<<" . . . . . ........ . . . . ";
delay(125);
gotoxy(31,8);
cout<<" . . .. . . `. . ";
delay(125);
gotoxy(31,9);
cout<<" . . .. . . . . ";
delay(125);
gotoxy(31,10);
cout<<" . . .. . . . . ";
delay(125);
gotoxy(31,11);
cout<<" . . .. .. .. . . . . ..";
delay(125);
gotoxy(31,12);
cout<<" . . .. ........ .. . . . , . ..";
delay(125);
gotoxy(31,13);
cout<<" . . . . . .......... . . . . ";
delay(125);
gotoxy(31,14);
cout<<" . . . . ";
delay(5000);
}
void Display_gun()
{
gotoxy(10,8);
cout<<" . ....................... \n";
delay(125);
gotoxy(10,9);
cout<<" .. ................,........ \n";
delay(125);
gotoxy(10,10);
cout<<" ........................... \n";
delay(125);
gotoxy(10,11);
cout<<" ........................ \n";
delay(125);
gotoxy(10,12);
cout<<" .......`` .. \n";
delay(125);
gotoxy(10,13);
cout<<" .^^^^.. `` .. \n";
delay(125);
gotoxy(10,14);
cout<<" .^^^^.. `` .. \n";
delay(125);
gotoxy(10,15);
cout<<" .^^^^.. . . .. \n";
delay(125);
gotoxy(10,16);
cout<<" .^^^^.. . . .. \n";
delay(125);
gotoxy(10,17);
cout<<" .^^^^.. \n";
delay(125);
gotoxy(10,18);
cout<<" .^^^^.. \n";
delay(125);
gotoxy(10,19);
cout<<" .||||.. \n";
delay(125);
gotoxy(10,20);
cout<<" ------ \n";
delay(125);
cout<<"\n\t|```````````````````````````````````````````````
``````````````````|";
delay(125);
cout<<"\n\t| C R I M E I N V E S T I G A T I O N D E P A R T ME N T |";
delay(125);cout<<"\n\t| |";
delay(125);
cout<<"\n\t````````````````````````````````````````````````
```````````````````";
delay(5000);
}
void Main1();
void Record();
void Write();
void password2();
void password();
void Display();
void Read();
int getid();
void Search();
void Update();
void Record1();
void Deleter();
};
void Criminal::Main1() // MAIN1() IS 1st PART OF MAIN MENU.
{
ret:
clrscr();
cout<<"\n\t\t\t CRIMINALS DEPARTMENT ";
cout<<"\n\t\t\t----------------------------- ";
cout<<"\n\t\t\t ------------------------- \n\n";
cout<<"\n\n\t\t\t||**********************||\n";
cout<<"\n\t\t\t|| 1:Insert Records. ||\n";
cout<<"\n\t\t\t|| 2:Display Records. ||\n";
cout<<"\n\t\t\t|| 3:Search Records. ||\n";
cout<<"\n\t\t\t|| 4:Delete Records. ||\n";
cout<<"\n\t\t\t|| 5:Update Records. ||\n";
cout<<"\n\t\t\t|| 0:EXIT. ||\n";
cout<<"\n\t\t\t||**********************||\n";
cout<<"\n\n\t\tWhat`s your choice: ";
cin>>ch;
switch(ch)
{
case '1':
Write();
cout<<"\n\n\n\nPress any key to
continue....\n";
getch();
Main1();
break;
case '2':
Read();
break;
case '3':
Search();
break;
case '4':
password2();
Deleter();
Main1();
break;
case '5':
password2();
Update();
Main1();
break;
case '0':
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"\n\n\n\n\nPlease Wait...";
cout<<"while closing data....\n";
delay(3000);
exit(0);
break;
default:
cout<<"\n\nInvalid Selection!!!";
delay(1500);
cout<<"\n\nRetry : Press ENTER.";
goto ret;
break;
}
}
void Criminal::Record() // INSERTION OF RECORD FOR
MAIN PURPUS.
{
clrscr();
cout<<"\n\t\t\tAdd Record of Crimnals.\n";
cout<<"\t\t\t============================\n\n";
cout<<"\n\n\n";
cout<<"\n\nInsert ID:\n\n";
cin>>id;
cout<<"\n\nInsert Name:\n\n";
gets(name);
cout<<"\n\nInsert Crime:\n\n";
gets(crime);
cout<<"\n\nInsert Name (Place or People):\n\n";
gets(relation);
cout<<"\n\nRecovery Status:\n\n";
gets(status);
cout<<"\n\nInsert Address:\n\n";
gets(addr);
}
void Criminal::Record1() // INSERTION OF RECORD FOR
UPDATING
{
clrscr();
cout<<"\n\t\t\tModify Record of Crimnals.\n";
cout<<"\t\t\t============================\n\n";
cout<<"\n\nCriminal I.D : "<<id<<endl;
cout<<"\n\nNew Name:\n\n";
gets(name);
cout<<"\n\nNew Crime:\n\n";
gets(crime);
cout<<"\n\nNew Name (Place or People):\n\n";
gets(relation);
cout<<"\n\nNew Recovery Status:\n\n";
gets(status);
cout<<"\n\nNew Address:\n\n";
gets(addr);
}
void Criminal::Write() // WRITE DATA ON A CID.DAT FILE.
{
char ch;
Criminal c;
fstream f1;
c.Record();
f1.open("cid.dat",ios::app | ios::binary);
cout<<"\n\nDo you want to save Record (y/n). ";
cin>>ch;
if(ch=='y')
f1.write((char*) &c,sizeof(c));
f1.close();
}
void Criminal::password() // PASSWARD PROTECT FROM
OUTER PEOPLES
{
int j=0;
char c,temp[20];
clrscr();
gotoxy(30,10);
cout<<"ENTER THE PASSWORD : ";
while(j<15)
{
c=getche();
c=toupper(c);
cout<<"\b";
if(c=='\r')
{
temp[j]='\0';
break;
}
temp[j]=c;
cout<<"*";
j++;
}
if(strcmp(temp,"CID"))
{
gotoxy(20,14);
cout<<"\aERROR !!\a\a YOU ARE NOT AUTHORISED TO
ENTER THE SYSTEM";
delay(3000);
exit(0);
}
else
{
gotoxy(32,37);
cout<<"10 % Loading.";
delay(490);
gotoxy(32,37);
cout<<"20 % Loading..";
delay(400);
gotoxy(32,37);
cout<<"30 % Loading...";
delay(399);
gotoxy(32,37);
cout<<"40 % Loading....";
delay(455);
gotoxy(32,37);
cout<<"50 % Loading.....";
delay(385);
gotoxy(32,37);
cout<<"60 % Loading...";
delay(358);
gotoxy(32,37);
cout<<"70 % Loading..";
delay(395);
gotoxy(32,37);
cout<<"80 % Loading.";
delay(398);
gotoxy(32,37);
cout<<"90 % Loading...";
delay(390);
gotoxy(32,37);
cout<<"100 % Loading.....";
delay(900);
}
}
void Criminal::password2() // PASSWARD USE TO PROTECT
FROM ANOTHER PERSON USING DATA .
{
int j=0;
char c,temp[20];
clrscr();
gotoxy(30,10);
cout<<"ENTER THE PASSWORD : ";
while(j<15)
{
c=getche();
c=toupper(c);
cout<<"\b";
if(c=='\r')
{
temp[j]='\0';
break;
}
temp[j]=c;
cout<<"*";
j++;
}
if(strcmp(temp,"CRIMINAL"))
{
gotoxy(20,14);
cout<<"\aERROR !!\a\a YOU ARE NOT AUTHORISED TO
CHANGE THE DATA";
delay(3000);
exit(0);
}
else
{
gotoxy(32,37);
cout<<"10 % Loading.\n";
delay(490);
gotoxy(32,37);
cout<<"20 % Loading..\n";
delay(400);
gotoxy(32,37);
cout<<"30 % Loading...\n";
delay(399);
gotoxy(32,37);
cout<<"40 % Loading....\n";
delay(455);
gotoxy(32,37);
cout<<"50 % Loading.....\n";
delay(385);
gotoxy(32,37);
cout<<"60 % Loading...\n";
delay(358);
gotoxy(32,37);
cout<<"70 % Loading..\n";
delay(395);
gotoxy(32,37);
cout<<"80 % Loading.\n";
delay(398);
gotoxy(32,37);
cout<<"90 % Loading...\n";
delay(390);
gotoxy(32,37);
cout<<"100 % Loading.....\n";
delay(900);
}
}
void Criminal::Display() // DISPLAY THE DATA OF
CRIMINALS.
{
cout<<"|
"<<id<<"\t"<<name<<"\t"<<crime<<"\t"<<relation<<"\t\t"<<status<<"\t"<
<addr<<"\n";
cout<<"\n\n";
}
void Criminal::Read() // FUNCTION READ THE
VALUES.
{
clrscr();
Criminal c;
fstream f1;
f1.open("cid.dat",ios::in | ios::binary);
f1.read((char*) &c,sizeof(c));
cout<<"\n\n\n\n\t\t\t\t ....D E T A I L S .... \n";
cout<<"\n=================================================
===============================\n";
cout<<"\n\n I.D \tNAME \tCRIME \tPLACE\\PEOPLE
\tSTATUS\t\tADDRESS";
cout<<"\n=================================================
===============================\n";
while(!f1.eof())
{
c.Display();
f1.read((char*) &c,sizeof(c));
if(f1.eof())
cout<<"\n\n\n\n\nEnd of file Reached !!";
}
f1.close();
getch();
Main1();
}
int Criminal::getid() // RETURN ID OF THE CRIMINAL.
{
return id;
}
void Criminal::Search() // TO SEARCH RECORD OF
CRIMINAL.
{
int code;
char M,found='n';
Criminal c;
ifstream fin("cid.dat",ios::in|ios::binary);
clrscr();
z:
cout<<"\n\nEnter I D of Criminal to search...\n";
cin>>code;
while(!fin.eof())
{
fin.read((char*) &c,sizeof(c));
if(c.getid()==code)
{
gotoxy(24,9);
cout<<"\n\nSearching....\n";
delay(2000);
cout<<"\n\nFound .\n";
delay(150);
clrscr();
cout<<"\n\n\t\t\t\t ....D E T A I L S .... \n";
cout<<"\n=================================================
===============================\n";
cout<<"\n\n I.D \tNAME \tCRIME \tPLACE\\PEOPLE
\tSTATUS\t\tADDRESS";
cout<<"\n=================================================
===============================\n";
c.Display();
found='y';
//break;
}
}
if(found=='n')
{
cout<<"\nSearching.....";
delay(3000);
cout<<"\n\nNot Found !!\n";
cout<<"\n\nWant to countinue ? (Y/N).\n";
cin>>ch1;
if(ch1=='y' || ch1=='Y')
goto z;
}
else
{
getch();
Main1();
}
fin.close();
}
void Criminal::Update() // TO UPDATE RECORD OF
CRIMINAL
{
int code;
char M,found='n';
Criminal c;
ifstream fin("cid.dat",ios::in | ios::binary);
ofstream fout("cid2.dat",ios::app | ios::binary);
clrscr();
z:
cout<<"\n\nEnter I.D of Member to modify...\n\n\n";
cin>>code;
fin.read((char*)&c,sizeof(c));
while(!fin.eof())
{
if(c.getid()!=code)
{
fout.write((char*)&c,sizeof(c));
}
else
{
clrscr();
cout<<"\n\n\n\n\t\t\t\t ....D E T A I L S .... \n";
cout<<"\n=================================================
===============================\n";
cout<<"\n\n I.D \tNAME \tCRIME \tPLACE\\PEOPLE
\tSTATUS\t\tADDRESS";
cout<<"\n=================================================
===============================\n";
c.Display();
found='y';
cout<<endl;
cout<<"\n\nWant to modify? (Y/N)";
cin>>M;
if(M=='y' ||M=='Y')
{
c.Record1();
fout.write((char*)&c,sizeof(c));
}
}
fin.read((char*)&c,sizeof(c));
}
if(found=='n')
{
cout<<"\nSearching.....";
delay(3000);
cout<<"\n\nNot Found !!\n";
cout<<"\n\nWant to countinue ? (Y/N).\n";
cin>>ch1;
if(ch1=='y' || ch1=='Y')
goto z;
}
else{
getch();
fin.close();
fout.close();
remove("cid.dat");
rename("cid2.dat","cid.dat");
Main1();
}
}
void Criminal::Deleter()
{
Criminal c;
int code1;
clrscr();
cout<<"\n\n\n\n\n\nEnter The I.D You Want To
delete:\t";
cin>>code1;
int k=0;
fstream k2("cid.dat",ios::in|ios::binary);
fstream k1("cid2.dat",ios::out|ios::binary);
k2.read((char*)&c,sizeof(c));
while(!k2.eof())
{
if(c.getid()!=code1)
{
k1.write((char*)&c,sizeof(c));
}
k2.read((char*)&c,sizeof(c));
}
k1.close();
k2.close();
remove ("cid.dat");
rename ("cid2","cid");
cout<<"\n\n\n\n\n\tPress Any Key...";
getch();
}
/*
********************************************
MEMBERS CLASS *
*
********************************************
*/
class Member
{
public:
char mname[50],madd[50],mpost[10],mspac[10];
char pas[255],ch5;
char mnamec[50],ch1;
int mid;
~Member()
{
}
void Main2();
void Record1();
void Write1();
void password1();
void Display1();
void Read1();
int getid1();
void Search1();
void Update1();
void Record2();
};
void Member::Main2() // MAIN2() IS THE 2nd PART OF MAIN
MENU
{
retry:
clrscr();
cout<<"\n\t\t\t MEMBERS RECORDS ";
cout<<"\n\t\t\t----------------------------- ";
cout<<"\n\t\t\t ------------------------- \n\n";
cout<<"\n\n\n\t\t\t||**********************||\n";
cout<<"\n\t\t\t|| 1:Modify Records. ||\n";
cout<<"\n\t\t\t|| 2:Display Records. ||\n";
cout<<"\n\t\t\t|| 3:Search Records. ||\n";
cout<<"\n\t\t\t|| 4:Update Records. ||\n";
cout<<"\n\t\t\t|| 0:EXIT. ||\n";
cout<<"\n\t\t\t||**********************||\n";
cout<<"\n\n\t\tWhat`s your choice: ";
cin>>ch5;
switch(ch5)
{
case '1':
Write1();
cout<<"\n\n\n\nPress any key to
continue....\n";
getch();
Main2();
break;
case '2':
Read1();
break;
case '3':
Search1();
Main2();
break;
case '4':
password1();
Update1();
Main2();
break;
case '0':
clrscr();
cout<<"\n\n\n\n\nPlease Wait....";
cout<<"\n\nWhile Removing File from the
memory....\n";
delay(2000);
exit(0);
break;
default:
cout<<"\n\nInvalid Selection!!!";
delay(1500);
cout<<"\n\nRetry : Press ENTER.";
goto retry;
break;
}
}
void Member::Record1() // INSERTION FOR MAIN DATA.
{
clrscr();
cout<<"\n\t\t\tMaintain Record of Members.\n";
cout<<"\t\t\t============================\n\n";
cout<<"\n\n\nInsert member ID :\n\n\b";
cin>>mid;
cout<<"\n\nInsert Name:\n\n\b";
gets(mname);
cout<<"\n\nInsert Disignation:\n\n\b";
gets(mpost);
cout<<"\n\nInsert Specialist:\n\n\b";
gets(mspac);
cout<<"\n\nInsert Address:\n\n\b";
gets(madd);
}
void Member::Record2() // INSERTION FOR UPDATING
DATA.
{
clrscr();
cout<<"\n\t\t\tModify Record of Crimnals.\n";
cout<<"\t\t\t============================\n\n";
cout<<"\n\nNew Name:\n\n\b";
gets(mname);
cout<<"\n\nNew Disignation:\n\n\b";
gets(mpost);
cout<<"\n\nNew Specialist:\n\n\b";
gets(mspac);
cout<<"\n\nNew Address:\n\n\b";
gets(madd);
}
void Member::Write1() // WRITE DATA TO A MEMBER.DAT
FILE.
{
char ch;
Member m;
fstream f1;
m.Record1();
f1.open("member.dat",ios::app | ios::binary);
cout<<"\n\nDo you want to save Record (y/n). ";
cin>>ch;
if(ch=='y')
f1.write((char*) &m,sizeof(m));
f1.close();
}
void Member::Display1() // DISPLAY ALL CONTANT....
{
cout<<"
"<<mid<<"\t"<<mname<<"\t\t"<<mpost<<"\t\t"<<mspac<<"\t\t"<<madd;
cout<<"\n\n\n";
}
void Member::Read1() // READ ALL DATA AND DISPLAY .
{
clrscr();
Member n;
fstream f1;
f1.open("member.dat",ios::in | ios::binary);
f1.read((char*) &n,sizeof(n));
cout<<"\n\n\n\n\t\t\t\t ....D E T A I L S .... \n";
cout<<"\n=================================================
===============================\n";
cout<<"\n\n I.D \tNAME \t\tDISIGNATION
\t\tSPECIALIST\t\tADDRESS";
cout<<"\n=================================================
===============================\n";
while(!f1.eof())
{
n.Display1();
f1.read((char*) &n,sizeof(n));
if(f1.eof())
cout<<"\n\n\n\n\nEnd of file Reached !!";
}
f1.close();
getch();
Main2();
}
int Member::getid1() // RETURN ID OF THE MEMBER.
{
return mid;
}
void Member::Search1() // SEARCHING OF DATA WITH
MEMBER I.D.
{
int mcode;
char M,found='n';
Member m;
ifstream fin("member.dat",ios::in|ios::binary);
clrscr();
z:
cout<<"\n\nEnter I D of Member to search...\n";
cin>>mcode;
while(!fin.eof())
{
fin.read((char*) &m,sizeof(m));
if(m.getid1()==mcode)
{
gotoxy(24,9);
cout<<"\n\nSearching....\n";
delay(2000);
cout<<"\n\nFound .\n";
delay(150);
clrscr();
cout<<"\n\n\n\n\t\t\t\t ....D E T A I L S .... \n";
cout<<"\n=================================================
===============================\n";
cout<<"\n\n I.D \tNAME \t\tDISIGNATION
\t\tSPECIALIST\t\tADDRESS";
cout<<"\n=================================================
===============================\n";
m.Display1();
found='y';
//break;
}
}
if(found=='n')
{
cout<<"\nSearching.....";
delay(3000);
cout<<"\n\nNot Found !!\n";
cout<<"\n\nWant to countinue ? (Y/N).\n";
cin>>ch1;
if(ch1=='y' || ch1=='Y')
goto z;
}
else
{
getch();
Main2();
}
fin.close();
}
void Member::Update1() // UPDATE DATA WITH NEW
RECORD.
{
int mcode;
char M,found='n';
Member m;
ifstream fin("member.dat",ios::in|ios::binary);
ofstream fout("member2.dat",ios::app|ios::binary);
clrscr();
z:
gotoxy(20,7);
cout<<"Enter I D of Member to search...\n";
gotoxy(60,7);
cin>>mcode;
fin.read((char*)&m,sizeof(m));
while(!fin.eof())
{
if(m.getid1()!=mcode)
{
fout.write((char*)&m,sizeof(m));
}
else
{
clrscr();
cout<<"\n\n\n\n\t\t\t\t ....D E T A I L S .... \n";
cout<<"\n=================================================
===============================\n";
cout<<"\n\n I.D \tNAME \t\tDISIGNATION
\t\tSPECIALIST\t\tADDRESS";
cout<<"\n=================================================
===============================\n";
m.Display1();
found='y';
cout<<endl;
cout<<"\n\nWant to modify? (Y/N)";
cin>>M;
if(M=='y' ||M=='Y')
{
m.Record2();
fout.write((char*)&m,sizeof(m));
}
}
fin.read((char*)&m,sizeof(m));
}
if(found=='n')
{
cout<<"\n\nSearching.....";
delay(3000);
cout<<"\n\nNot Found !!\n\a";
cout<<"\n\nWant to countinue ? (Y/N).\n";
cin>>ch1;
if(ch1=='y' || ch1=='Y')
goto z;
}
else
{
getch();
fin.close();
fout.close();
remove("member.dat");
rename("member2.dat","member.dat");
Main2();
}
}
void Member::password1() // USE TO PROTECT CID DATA
FROM OUTER SOURCE.
{
int j=0;
char c,temp[20];
clrscr();
gotoxy(30,10);
cout<<"ENTER THE PASSWORD : ";
while(j<15)
{
c=getche();
c=toupper(c);
cout<<"\b";
if(c=='\r')
{
temp[j]='\0';
break;
}
temp[j]=c;
cout<<"*";
j++;
}
if(strcmp(temp,"MEMBER"))
{
gotoxy(20,14);
cout<<"\aERROR !!\a\a YOU ARE NOT AUTHORISED TO
CHANGE THE RECORS.";
delay(3000);
exit(0);
}
else
{
gotoxy(32,37);
cout<<"10 % Loading.\n";
delay(490);
gotoxy(32,37);
cout<<"20 % Loading..\n";
delay(400);
gotoxy(32,37);
cout<<"30 % Loading...\n";
delay(399);
gotoxy(32,37);
cout<<"40 % Loading....\n";
delay(455);
gotoxy(32,37);
cout<<"50 % Loading.....\n";
delay(385);
gotoxy(32,37);
cout<<"60 % Loading...\n";
delay(358);
gotoxy(32,37);
cout<<"70 % Loading..\n";
delay(395);
gotoxy(32,37);
cout<<"80 % Loading.\n";
delay(398);
gotoxy(32,37);
cout<<"90 % Loading...\n";
delay(390);
gotoxy(32,37);
cout<<"100 % Loading.....\n";
delay(900);
}
} /// STARTING OF MAIN.....
void main()
{
clrscr();
Criminal c;
Member m;
clrscr();
c.password();
clrscr();
c.Display_gun();
clrscr();
c.logo();
main: // LABLE
clrscr();
int ch;
cout<<"\n\t\t\tCRIME INVESTIGATION DEPARTMENT ";
cout<<"\n\t\t\t------------------------------\n\n";
cout<<" \n\t\t\t||**********************||\n";
cout<<" \n\t\t\t|| 1:C.I.D ||\n";
cout<<" \n\t\t\t|| Members Records. ||\n";
cout<<" \n\t\t\t|| ||\n";
cout<<" \n\t\t\t|| 2:Criminals ||\n";
cout<<" \n\t\t\t|| Records. ||\n";
cout<<" \n\t\t\t|| ||\n";
cout<<" \n\t\t\t|| 0:EXIT. ||\n";
cout<<" \n\t\t\t||**********************||\n";
cout<<"\n\n\t\tWhat`s your choice: ";
cin>>ch;
if(ch==1)
{
m.Main2();
goto main;
}
else if(ch==2)
{
c.Main1();
goto main;
}
else if(ch==0)
{
cout<<"\n\n\n\n\n\n\n\n\n\nClosing all data...";
delay(1000);
exit(0);
}
getch();
} // E N D
/*
------------------------------------------------------
- T H A N K S....... -
- -
- -
------------------------------------------------------
*/
No comments:
Post a Comment