سورس سی پلاس پلاس

عرض سلام و خسته نباشید خدمت تمامی کاربیران عزیز سایت آموزش برنامه نویسی سورس باران. توی این مطلب سورس سیستم مدیریت کارمندان و وام آن ها به زبان سی پلاس پلاس رو براتون گذاشتیم. با مراجعه به ادامه مطلب میتونید این سورس رو دانلود و مشاهده نمایید.

جهت دانلود سورس سیستم مدیریت کارمندان و وام آن ها به زبان سی پلاس پلاس به ادامه مطلب مراجعه نمایید.

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
struct per{
int code;
char name[20];
char fam[25];
char semat[20];
}p;
struct ho{
int code;
int hp;
int ezafeh;
int padash;
char name[20];
}h;
struct vam{
int code;
char name[20];
char fam[25];
int mvam;
}v;
void search();
void searchp();
void searchh();
void searchv();
void change();
void changep();
void changev();
void changeh();
void delet();
void delhogh(void);
void delper(void);
void delvam(void);
void sinputper(void);
void sinputh(void);
void sinputv(void);
void inputper(void);
void inputh(void);
void inputv(void);
void inputp(void);
void insho(void);
void input(void);




void main(){
input();
}




void inputp(void){
int selecti;
clrscr();
cout<<"                                       <input>    ";
cout<<"       \t\t\t\t\t            \t -------------------\n";
cout<<"                             |1.moshakhasat persenel |\n";
cout<<"                             |2.etelaat hoghughi     |\n";
cout<<"                             |3.dariaft vam          |\n";
cout<<"                             |4.exit                 |\n" ;
cout<<"                             | ----------------------|\n";
cout<<"                             |SELECT a NUMBER:       |\n";
cout<<"                              -----------------------\n";
gotoxy(50,8);cin>>selecti;
switch(selecti){
case 1:
inputper();
break;
case 2:
inputh();
break;
case 3:
inputv();
break;
case 4:exit(1);
break;
default : cout<<"Error in number" ;

}

}






void input(){
int select;
cout<<"                                      <MAIN MENU>    \n";
cout<<"                              -----------------------\n";
cout<<"                             |1.INPUT DATA           |\n";
cout<<"                             |2.SEARCH               |\n";
cout<<"                             |3.DELETE               |\n";
cout<<"                             |4.CHANGE               |\n" ;
cout<<"                             |5.SHOW LIST            |\n" ;
cout<<"                             |6.EXIT                 |\n" ;
cout<<"                             | ----------------------|\n";
cout<<"                             |SELECT a NUMBER:       |\n";
cout<<"                              -----------------------\n";
gotoxy(50,10);cin>>select;
switch(select){
case 1:
inputp();
break;
case 2:
search();

break;
case 3:
delet();
break;
case 4:
change();
break;
case 5:
insho();
break;
case 6:exit(1);
default:cout<<"error in number";

}
}





void inputper(void){
clrscr();
char ch;
ofstream fp("persenel.dat",ios::ate|ios::binary);
if (!fp){cout<<"not found the file";getche();return;}
while(1){
cout<<"Enter Code=  "<<"\n";
cin>>p.code;
cout<<"Enter Fmily=  "<<"\n";
gets(p.fam);
cout<<"Enter semat=  "<<"\n";
gets(p.semat);
cout<<"Enter Name=  "<<"\n";
gets(p.name);
fp.write((char*)&p,sizeof(struct per));
cout<<"continue   ? (Y/N)"<<"\n";
ch=getche();
cout<<"\n";
if(ch =='n'||ch=='N'){
clrscr();
fp.close();
inputp(); }
}
}




void inputh(void){

clrscr();
char ch;
ofstream fh("hoghughi.dat",ios::ate|ios::binary);
if (!fh){cout<<"not found the file";getche();return;}
while(1){
cout<<"Enter Code=  "<<"\n";
cin>>h.code;

cout<<"Enter hoghugh paie=  "<<"\n";
cin>>h.hp;
cout<<"Enter padash=  "<<"\n";
cin>>h.padash;
cout<<"Enter ezafeh kari=  "<<"\n";
cin>>h.ezafeh;
cout<<"Enter name=  "<<"\n";
gets(h.name);
fh.write((char*)&h,sizeof(struct ho));
cout<<"continue   ? (Y/N)"<<"\n";
ch=getche();
cout<<"\n";
if(ch =='n'||ch=='N'){
clrscr();
fh.close();
inputp();}
}
}




void inputv(void){
clrscr();
char ch;
ofstream fv("vamp.dat",ios::ate|ios::binary);
if (!fv){cout<<"not found the file";getche();return;}
while(1){
cout<<"Enter Code=  "<<"\n";
cin>>v.code;
cout<<"Enter Name=  "<<"\n";
gets(v.name);
cout<<"Enter Fmily=  "<<"\n";
gets(v.fam);
cout<<"Enter mablagh vam=  "<<"\n";
cin>>v.mvam;
fv.write((char*)&v,sizeof(struct vam));
cout<<"continue   ? (Y/N)"<<"\n";
ch=getche();
cout<<"\n";
if(ch =='n'||ch=='N'){
clrscr();
fv.close();
inputp();}
}
}


void insho(void){
int selectb;
clrscr();
cout<<"                                      <DISPLAY>      \n";
cout<<"                              -----------------------\n";
cout<<"                             |1.moshakhasat persenel |\n";
cout<<"                             |2.etelaat hoghughi     |\n";
cout<<"                             |3.dariaft vam          |\n";
cout<<"                             |4.exit                 |\n" ;
cout<<"                             | ----------------------|\n";
cout<<"                             |SELECT a NUMBER:       |\n";
cout<<"                              -----------------------\n";
gotoxy(50,8);cin>>selectb;
switch(selectb){
case 1:
sinputper();
break;
case 2:
sinputh();
break;
case 3:
sinputv();
break;
case 4:
exit(1);
break;

default : cout<<"Error in number" ;

}
}


void sinputper(void){
clrscr();
ifstream sip("persenel.dat",ios::in|ios::binary);
while(sip.read((char *)&p,sizeof(struct per))){
cout<<"code= "<<p.code<<"\n";
cout<<"name= "<<p.name<<"\n";
cout<<"family= "<<p.fam<<"\n";
cout<<"semat= "<<p.semat<<"\n";
cout<<"-----------------------next user-------------------"<<"\n";
}
sip.close();
}




void sinputh(void){
clrscr();
ifstream sho("hoghughi.dat",ios::in|ios::binary);
while(sho.read((char *)&h,sizeof(struct ho))){
cout<<"code= "<<h.code<<"\n";
cout<<"name= "<<h.name<<"\n";
cout<<"hoghugh paie= "<<h.hp<<"\n";
cout<<"ezafeh kari= "<<h.ezafeh<<"\n";
cout<<"padash= "<<h.padash<<"\n";
cout<<"-----------------------next user-------------------"<<"\n";
}
sho.close();
}
void sinputv(void){
 clrscr();
ifstream sva("vamp.dat",ios::in|ios::binary);
while(sva.read((char *)&v,sizeof(struct vam))){
cout<<"code= "<<v.code<<"\n";
cout<<"name= "<<v.name<<"\n";
cout<<"family= "<<v.fam<<"\n";
cout<<"mablagh vam= "<<v.mvam<<"\n";
cout<<"-----------------------next user-------------------"<<"\n";
}
sva.close();
}

void delet(){
int select;
clrscr();
cout<<"                                      <DELETE>        \n";
cout<<"                              ----------------------- \n";
cout<<"                             |1.moshakhasat persenel |\n";
cout<<"                             |2.etelaat hoghughi     |\n";
cout<<"                             |3.dariaft vam          |\n";
cout<<"                             |4.Exit                 |\n";
cout<<"                              ----------------------- \n";
cout<<"                             |select:                |\n";
cout<<"                              -----------------------\n";
gotoxy(50,8);
cin>>select;
switch(select){
case 1 : delper();
			break;
case 2:  delhogh();
break;
case 3:delvam();
break;
case 4:exit(1);}
}





void delper(){
clrscr();
int id,find=0;
ofstream temp("temp.dat",ios::out|ios::binary);
ifstream pf("persenel.dat",ios::in|ios::binary);
cout<<"enter code to delete:";cin>>id;
while(pf.read((char *)&p,sizeof(struct per))) {
if(p.code==id) find=1;
else temp.write((char *)&p,sizeof(struct per));  }
pf.close();temp.close();
if(find==1){
remove("persenel.dat");
rename("temp.dat","persenel.dat"); }
else remove("temp.dat");
delet();
}




void delhogh(){
clrscr();
int id,find=0;
ofstream temp("temp.dat",ios::out|ios::binary);
ifstream hf("hoghughi.dat",ios::in|ios::binary);
cout<<"enter code to delete:";cin>>id;
while(hf.read((char *)&h,sizeof(struct ho))) {
if(h.code==id) find=1;
else temp.write((char *)&h,sizeof(struct ho));  }
hf.close();temp.close();
if(find==1){
remove("hoghughi.dat");
rename("temp.dat","hoghughi.dat"); }
else remove("temp.dat");
delet();
}


void delvam(){
clrscr();
int id,find=0;
ofstream temp("temp.dat",ios::out|ios::binary);
ifstream vf("vamp.dat",ios::in|ios::binary);
cout<<"enter code to delete:";cin>>id;
while(vf.read((char *)&v,sizeof(struct vam))) {
if(v.code==id) find=1;
else temp.write((char *)&v,sizeof(struct vam));  }
vf.close();temp.close();
if(find==1){
remove("vamp.dat");
rename("temp.dat","vamp.dat"); }
else remove("temp.dat");
delet();
}





void change(){
int select;
clrscr();
cout<<"                                      <change>        \n";
cout<<"                              ----------------------- \n";
cout<<"                             |1.moshakhasat persenel |\n";
cout<<"                             |2.etelaat hoghughi     |\n";
cout<<"                             |3.dariaft vam          |\n";
cout<<"                             |4.Exit                 |\n";
cout<<"                              ----------------------- \n";
cout<<"                             |select:                |\n";
cout<<"                              -----------------------\n";
gotoxy(50,8);
cin>>select;
switch(select){
case 1 : changep();
			break;
case 2:  changeh();
break;
case 3:  changev();
break;
case 4:exit(1); }
}


void changep(){
int id;long int n=0;
clrscr();
fstream pf("persenel.dat",ios::in|ios::out|ios::binary);
cout<<"enter code to change:";cin>>id;
while(pf.read((char *)&p,sizeof(struct per)))
if(p.code==id){
cout<<"code= "<<p.code<<"\n";
cout<<"name= "<<p.name<<"\n";
cout<<"family= "<<p.fam<<"\n";
cout<<"semat= "<<p.semat<<"\n";
cout<<"----------new data--------------\n";
cout<<"code:";cin>>p.code;
cout<<"name:";gets(p.name);
cout<<"family= ";cin>>p.fam;
cout<<"semat= ";cin>>p.semat;
n=pf.tellg();
pf.seekp(n-sizeof(struct per),ios::beg);
pf.write((char *)& p,sizeof(struct per));  }
pf.close();
}


void changeh(){
int id;long int n=0;
clrscr();
fstream hf("hoghughi.dat",ios::in|ios::out|ios::binary);
cout<<"enter code to change:";cin>>id;
while(hf.read((char *)&h,sizeof(struct ho)))
if(h.code==id){
cout<<" code= "<<h.code<<"\n";
cout<<"hoghugh paie= "<<h.hp<<"\n";
cout<<"ezafeh= "<<h.ezafeh<<"\n";
cout<<"padash= "<<h.padash<<"\n";
cout<<"name= "<<h.name<<"\n";
cout<<"----------new data--------------\n";
cout<<"code:";cin>>h.code;
cout<<"hoghugh paie= ";cin>>h.hp;
cout<<"ezafeh kar= ";cin>>h.ezafeh;
cout<<"padash= ";cin>>h.padash;
cout<<"name:";gets(h.name);
n=hf.tellg();
hf.seekp(n-sizeof(struct ho),ios::beg);
hf.write((char *)& h,sizeof(struct ho));  }
hf.close();
}





void changev(){
int id;long int n=0;
clrscr();
fstream vf("vamp.dat",ios::in|ios::out|ios::binary);
cout<<"enter code to change:";cin>>id;
while(vf.read((char *)&v,sizeof(struct vam)))
if(v.code==id){
cout<<" code= "<<v.code<<"\n";
cout<<"name= "<<v.name<<"\n";
cout<<"family= "<<v.fam<<"\n";
cout<<"mablagh vam= "<<v.mvam<<"\n";
cout<<"----------new data--------------\n";
cout<<"code:";cin>>v.code;
cout<<"name:";gets(v.name);
cout<<"family= ";cin>>v.fam;
cout<<"mablagh vam= ";cin>>v.mvam;
n=vf.tellg();
vf.seekp(n-sizeof(struct vam),ios::beg);
vf.write((char *)& v,sizeof(struct vam));  }
vf.close();
}

void search(){
int select;
clrscr();
cout<<"                                      <search>        \n";
cout<<"                              ----------------------- \n";
cout<<"                             |1.moshakhasat persenel |\n";
cout<<"                             |2.etelaat hoghughi     |\n";
cout<<"                             |3.dariaft vam          |\n";
cout<<"                             |4.Exit                 |\n";
cout<<"                              ----------------------- \n";
cout<<"                             |select:                |\n";
cout<<"                              -----------------------\n";
gotoxy(50,8);
cin>>select;
switch(select){
case 1 : searchp();
			break;
case 2:  searchh();
break;
case 3: searchv();
break;
case 4:exit(1); }
}


void searchp(void){
clrscr();
int key;
cout<<"enter code to search:";cin>>key;
ifstream pf("persenel.dat",ios::in|ios::binary);
if(!pf){cout<<"can't open";getch();return;}
while(pf.read((char *)&p,sizeof(struct per)))
if(p.code==key){
cout<<"code= "<<p.code<<"\n";
cout<<"name= "<<p.name<<"\n";
cout<<"family= "<<p.fam<<"\n";
cout<<"semat= "<<p.semat<<"\n";
cout<<"-----------------------------\n"; }
getch();
pf.close();
}


void searchv(void){
clrscr();
int key;
cout<<"enter code to search:";cin>>key;
ifstream vf("vamp.dat",ios::in|ios::binary);
if(!vf){cout<<"can't open";getch();return;}
while(vf.read((char *)&v,sizeof(struct vam)))
if(v.code==key){
cout<<"code= "<<v.code<<"\n";
cout<<"name= "<<v.name<<"\n";
cout<<"family= "<<v.fam<<"\n";
cout<<"mablagh vam= "<<v.mvam<<"\n";
cout<<"-----------------------------\n"; }
getch();
vf.close();
}


void searchh(void){
clrscr();
int key;
cout<<"enter code to search:";cin>>key;
ifstream hf("hoghughi.dat",ios::in|ios::binary);
if(!hf){cout<<"can't open";getch();return;}
while(hf.read((char *)&h,sizeof(struct ho)))
if(h.code==key){
cout<<"code= "<<h.code<<"\n";
cout<<"name= "<<h.name<<"\n";
cout<<"hoghugh paie= "<<h.hp<<"\n";
cout<<"ezafeh kar= "<<h.ezafeh<<"\n";
cout<<"padash= "<<h.padash<<"\n";
cout<<"-----------------------------\n"; }
getch();
hf.close();
}
به این مطلب امتیاز دهید post

راستی! برای دریافت مطالب جدید در کانال تلگرام یا پیج اینستاگرام سورس باران عضو شوید.

بزرگترین پک آموزشی طراحی وب و تمام زبان های برنامه نویسی
دانلود با لینک مستقیم

دسته بندی موضوعات

آخرین محصولات فروشگاه

مشاهده همه

نظرات

بازخوردهای خود را برای ما ارسال کنید

این سایت از اکیسمت برای کاهش هرزنامه استفاده می کند. بیاموزید که چگونه اطلاعات دیدگاه های شما پردازش می‌شوند.