⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recordkeepingsystem.cpp

📁 DataBase keeping program explaining with a sample program a) Ranking Database. b) Library keeping. c
💻 CPP
字号:
//Record Keeping System
//dt.17/7/00

//To Enter Few Records and to sort according to the choice of

//the data member. (USING NESTED STRUCTURE)


/**************************************************************/
/*Programmed by : Vivek Patel**********************************/
/*For Bugs Free feel to contact********************************/
/*Website : www.vivekpatel.cjb.net*****************************/
/*Email : vivek_patel9@rediffmail.com**************************/
/**************************************************************/


#include <iostream.h>

#include <iomanip.h>

#include <conio.h >

//GLOBAL DECLARATION OF STRUCTURE

struct date

{

int year,month,day;

};

struct person

{

int recno;

char name[20];

date dob; //using date structure as datatype

int salary;

};

void line(void); //Global Declaration of function as it is called in another function other than main.

int s;

person rec[50]; //Declaration of person datatype

void main()

{

void starting(void);

void sorting(struct person[],int);

void display(struct person[]);

void search(void);

void end(void);

starting();

textcolor(111); 

textbackground(196);

clrscr();

cout<<"\n\n"<<setw(48)<<"RECORD INFORMATION";

//for inserting records

cout<<"\n\nHow many Record you are interested to insert:-"; 

cin>>s;

clrscr();

cout<<"\n\n\n\n\tEnter "<<s<<" Records\n\n\n\n";

for(int i=0;i<s;i++)

{

cout<<"Information for Record No. "<<(i+1)< <endl;

line();

cout<<"\n\nEnter Record Number:-";

cin>>rec[i].recno; //RECORD NUMBER AS PRIMARY KEY

for(int j=0;j<i;j++)

{

if(rec[i].recno==rec[j].recno)

{

if(i==j)

break;

else

{

cout<<"\n\nEntered Record has Already exsist\n";

cout<<"TRY AGAIN\n\n\n";

i--;

goto skip;

}

}

}

cout<<"Enter Name :-";

cin>>rec[i].name;

cout<<"\nFOR Birth_Date\n";

cout<< "--------------\n";

cout<<"Enter Year:-";

cin>>rec[i].dob.year;

cout<< "Enter Month:-";

cin>>rec[i].dob.month;

cout<<"Enter Day:-";

cin >>rec[i].dob.day;

cout<<"\nEnter salary:-";

cin>>rec[i].salary;

line();

cout <<endl<<endl;

skip:

}

clrscr();

display(rec);

clrscr();

cout< <endl<<endl;

int choice;

do

{

cout<<endl<<endl;

cout<<"\n\nWhat Operation Would you Like to Perform\n";

cout<<"1) sort by Record Number\n";

cout<<"2) sort by Name\n";

cout<<"3) sort by Date\n";

cout<<"4) sort by Salary\n";

cout<<"5) DISPLAYING\n";

cout<<"6) Search By Name\n";

cout<<"7) QUIT\n ";

cout<<"Enter Your Choice:-";

cin>>choice;

switch(choice)

{

case 1:

case 2:

case 3:

case 4:sorting(rec,choice);

break;

case 5:display(rec);

break;

case 6:search();

break;

case 7:goto out;

default:cout<<"Entered Choice is Invalid, Try Again";

}

getch();

clrscr();

}while(1);

out:

}

//sorting function

void sorting(struct person rec[],int choice)

{

struct person tempq; 

//record Number wise Sorting

if(choice==1)

{

for(int i=0;i<s;i++)

{

for(int j=i+1;j<s;j++)

{

if(rec[i].recno > rec[j].recno)

{

tempq = rec[i];

rec[i] = rec[j]; 

rec[j] = tempq;

}

}

}

}

//namewise sorting

if(choice==2)

{

for(int i=0;i<s;i++)

{

for(int j=i+1;j<s;j++)

{

if(strcmp(rec[i].name,rec[j].name)>0) 

{

tempq = rec[i];

rec[i] = rec[j];

rec[j] = tempq;

}

}

}

}

//datewise

if(choice==3)

{

for(int i=0;i<s;i++)

{

for(int j=i+1;j<s;j++) 

{

if(rec[i].dob.year > rec[j].dob.year)

{

tempq = rec[i];

rec[i] = rec[j];

rec[j] = tempq;

if(rec[i].dob.month > rec[j].dob.month)

{

tempq = rec[i];

rec[i] = rec[j]; 

rec[j] = tempq;

if(rec[i].dob.day > rec[j].dob.day)

{

tempq = rec[i];

rec[i] = rec[j];

rec[j] = tempq;

}

}

}

}

}

}

//for salary wise

if(choice==4)

{

for(int i=0;i<s;i++)

{

for(int j=i+1;j<s;j++)

{

if(rec[i].salary > rec[j].salary)

{

tempq = rec[i];

rec[i] = rec[j];

rec[j] = tempq;

}

}

} 

}

}

//display function

void display(struct person rec[])

{

textcolor(106);

textbackground(104);

clrscr();

cout<<endl<<endl<<endl;

line();

cout< <setw(10)<< "Record No."<<setw(25)<<"NAME OF PERON"<<setw(20)<<"DATE OF BIRTH"<<setw(23)<<"SALARY AT PRESENT"<<endl;

line();

cout<<endl; 

for(int i=0;i<s;i++)

{

cout<<setw(6)<<rec[i].recno;

cout<<setw(27)<<rec[i].name;

cout<<setw(15)<<rec[i].dob.day<<"\\"<<rec[i].dob.month<<"\\" <<rec[i].dob.year;

cout <<setw(15)<<rec[i].salary;

cout<<endl;

}

getch();

}

//Line function

void line(void)

{

for(int i=0;i<40;i++)

{

cout <<"--";

}

cout<<endl;

}

//Starting function

void starting(void)

{

//START OF programer details\\

textcolor(105);

textbackground(104);

clrscr();

cout<<endl;

cout<<"|";

for(int i=0;i <39;i++)

{

cout<<"--";

}

cout<<"|";

cout<<" ";

for(int i=0;i<34;i++)

cout <<"=";

cout<<"VIVEK PATEL";

for(int i=0;i <33;i++)

cout<<"=";

cout<<endl;

cout<<"|";

for(int i=0;i<39;i++)

{

cout <<"--";

}

cout<<"|";

cout<<endl<<endl <<endl;

line();

cout<<setw(49)<<"WELLCOME VIEWERS\n";

line();

cout<<setw(55)< <"SAMPLE DATABASE APPLICATION\n\n";

line();

line();

cout<<setw(79)<<"Created By VIVEK PATEL\n\n";

line();

line();

cout<<setw(55)<<"EMAIL US AT vivek_patel9@rediffmail.com";

getch();

//END OF PROGRAMMER DETAILS\\

}

void search (void)

{

clrscr();

cout<<"\nEnter Which name you want to search:-";

char ch[20];

cin>>ch;

for(int i=0;i<s;i++)

{

if(strcmp(rec[i].name,ch)==0)

{

cout<<"\n\nEntered Search is Legal and is located at "<<(i+1)<<" Position\n";

cout<<"\nPerson Salary is "<<rec[i].salary;

goto out;

}

}

cout<<"\n\nEntered Search is Illegal\nTRY AGAIN\n";

out:

getch();

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -