📄 user.cpp
字号:
fstream o;
char picture[10000]; //PICTURE 10000
int administer=LIGHTGRAY;
//background
void setbk()
{
cleardevice();
setfillstyle(1,9);
bar(0,0,480,getmaxy());
setfillstyle(9,12);
bar(465,0,480,getmaxy());
setfillstyle(1,1);
bar(480,0,getmaxx(),getmaxy());
setcolor(1);
setlinestyle(2,1,1);
for(int i=0;i<465;i+=2)
{
line(i,0,i,getmaxy());
}
setcolor(12);
arc(340,210,270,90,320);
setcolor(4);
arc(340,210,180,90,340);
setfillstyle(1,4);
floodfill(1,getmaxy()-1,4);
setfillstyle(1,4);
floodfill(getmaxx()-1,1,12);
floodfill(getmaxx()-1,getmaxy()-1,12);
setcolor(1);
setpalette(0,4);
setfillstyle(11,12);
bar(480,0,495,getmaxy());
o.open("logo.dat",ios::in|ios::out|ios::binary|ios::nocreate|ios::noreplace);
if(!o.good()){cleardevice();outtextxy(200,200,"ERROR IN LOGO.DAT");getch();}
o.read(picture,10000);
o.close();
putimage(20,20,picture,0);
o.open("jr2.dat",ios::in|ios::out|ios::binary|ios::nocreate|ios::noreplace);
if(!o.good()){cleardevice();outtextxy(200,200,"ERROR IN JR2.DAT");getch();}
o.read(picture,10000);
o.close();
putimage(0,getmaxy()-15,picture,0);
//getch();
setlinestyle(0,0,0);
}
//DECLARATION
void about();
void employee();
void newusermain();
void loginmain();
void personalmain();
void modifyfamily();
void modifyloan();
void modifyleave();
void modifypersonal();
void modifyPF();
void modifypayslip();
void modifymedicaldetails();
void administratormain();
void viewindex();
void changepassword();
void applicationfiles();
void loopc(char *);
void loopi(int *);
void workflow();
void appreciation();
int counter; //It keeps the totall number employees.
class user
{public:
char status;
char ID[13];
int RRN;
char password[13];
char mother[13];
char father[13];
char native[13];
char fname[13];
char lname[13];
char add1[13];
char addc[13];
char adds[13];
char addp[13];
char namem[13];
char rs[13];
char doctor[13];
char disease[13];
char hospital[13];
int age;
char dept[13];
char pos[13];
char phone[13];
char email[13];
char sex[13];
char ms[13];
int amountm;
int basic;
int DA;
int empPF;
int emprPF;
int NOD; //Number of dependents.
int NOF; //Number of family members.
int NOM; //Number of minors.
int HRA;
int grossearn;
int splallow;
int conveyance;
//int PF;
int taxd;
int otherd;
int nets;
int EL;
int CL;
int ML;
int LT; //Leaves Taken.
char typel[13]; //Type of loan.
int amountl; //Amount of loan.
char whenl[13];
int months;
int noofinstall;
int balance;
int interest;
int amounttobepaid;
int mesageb[3];
int mesaged[3];
char postup[13];
int incbasic;
char inckind[13];
int inccash;
int NPF;
user()
{status=NULL;
counter=no_of_user_in_index();
loopc(fname);loopc(lname);loopc(add1);loopc(addc);
loopc(adds);loopc(addp);age=0;loopc(dept);loopc(pos);
loopc(ID);loopc(phone);loopc(email);loopc(sex);loopc(ms);
NOD=0;NOF=0;NOM=0;basic=0;HRA=0;/*PF=0;*/RRN=counter;
taxd=0;nets=0;EL=0;CL=0;ML=0;LT=0;
loopc(typel);amountl=0;interest=0;//PFS=0;PFI=0;PFD=0;
NPF=0;loopc(password);//messageno=-1;loopc(message);
loopc(father);loopc(mother);loopc(native);loopc(whenl);noofinstall=0;
amounttobepaid=0;balance=0;months=0;DA=0;empPF=0;emprPF=0;grossearn=0;
conveyance=0;splallow=0;otherd=0;loopc(namem);loopc(rs);loopc(doctor);
amountm=0;loopc(hospital);loopc(disease);
inccash=0;loopc(postup);incbasic=0;loopc(inckind);
mesageb[0]=-1;mesageb[1]=-1;mesageb[2]=-1;mesaged[0]=-1;mesaged[1]=-1;mesaged[2]=-1;
}
int no_of_user_in_index();
int no_of_user_in_index_notdeleted();
int no_of_user_in_user();
void spprofile();
void sleavedetails();
void sfprofile();
void sPF();
void sloandetails();
void spayslip();
void smedicaldetails();
int search_delete();
void writetodisk(user*);
void writetodisk(int);
void overwrite(int,user*);
void readfromdisk(int);
int deleteuser(char*);
void sappreciation();
//void loopc(char *);
//void loopi(int *);
int search(char*);
void gid(char*id,char *pass){strcpy(ID,id);strcpy(password,pass);}
void gpprofile(char *f,char *l,char *a1,char *ac,char *as,char * ap,
int g,char *d,char *p,char* ph,char *em,
char *s,char *m)
{
strcpy(fname,f);
strcpy(lname,l);
strcpy(add1,a1);
strcpy(addc,ac);
strcpy(adds,as);
strcpy(addp,ap);
age=g;
strcpy(dept,d);
strcpy(pos,p);
strcpy(phone,ph);
strcpy(email,em);
strcpy(sex,s);
strcpy(ms,m);
}
void gfprofile(char fa[],char mo[],int d,int f,int m,char n[])
{
strcpy(father,fa);
strcpy(mother,mo);
strcpy(native,n);
NOD=d;
NOF=f;
NOM=m;
}
void gpayslips(int a,int b,int c,int d,int e,int f,int g,int h)
{
basic=a;
DA=b;
HRA=c;
conveyance=d;
splallow=e;
NPF=f;
taxd=g;
otherd=h;
//grossearn=i;
//nets=j;
}
void gmedicaldetails(char n[],char r[],int a,char h[],char d[],char doc[])
{
strcpy(namem,n);
strcpy(rs,r);
amountm=a;
strcpy(hospital,h);
strcpy(disease,d);
strcpy(doctor,doc);
}
void gleavedetails(int e,int c,int m,int l)
{
EL=e;
CL=c;
ML=m;
LT=l;
}
void gloandetails(char *t,char d[],int a,int i,int m,int p,int n,int b )
{
strcpy(typel,t);
strcpy(whenl,d);
amountl=a;
interest=i;
months=m;
amounttobepaid=p;
noofinstall=n;
balance=b;
}
void gPF(int s,int d,int i,int n,int net)
{
basic=s;
DA=d;
empPF=i;
emprPF=n;
//PFS=s;
////PFD=d;
//PFI=i;
NPF=net;
}
void gappreciation(char *p,int a,char* b,int c)
{
strcpy(postup,p);
strcpy(inckind,b);
incbasic=a;
inccash=c;
}
//void wpprofile();
//void wfprofile();
//void wpayslips();
//void wmedicaldetails();
//void wleavedetails();
//void wloandetails();
//void wPF();
}current;
void loopc(char *x)
{
for(int i=0;i<13;i++)
{
x[i]=NULL;
}
}
void loopi(int *x)
{
for(int i=0;i<13;i++);
{
x[i]=NULL;
}
}
void user::writetodisk(user *j)
{
fstream f,l;
f.open("USER.DAT",ios::in|ios::out|ios::nocreate|ios::binary|ios::noreplace);
if(!f.good()){cleardevice();setcolor(RED);outtextxy(150,150,"ERROR IN USER.DAT");getch();exit(1);}
l.open("INDEX.DAT",ios::in|ios::out|ios::nocreate|ios::binary|ios::noreplace);
if(!l.good()){cleardevice();setcolor(RED);outtextxy(150,150,"ERROR IN INDEX.DAT");getch();exit(1);}
f.seekp(0,ios::end);
l.seekp(0,ios::end);
f.write((const char*)j,sizeof(user));
l.write((const char*)j,16);
f.close();
l.close();
}
void user::writetodisk(int m)
{
fstream f,l;
f.open("USER.DAT",ios::in|ios::out|ios::nocreate|ios::binary|ios::noreplace);
if(!f.good()){cleardevice();setcolor(RED);outtextxy(150,150,"ERROR IN USER.DAT");getch();exit(1);}
//l.open("INDEX.DAT",ios::in|ios::out|ios::nocreate|ios::binary|ios::noreplace);
//if(!l.good()){cleardevice();setcolor(RED);outtextxy(150,150,"ERROR IN INDEX.DAT");getch();exit(1);}
f.seekp(0+(sizeof(user)*m),ios::beg);
//l.seekp(0,ios::end);
f.write((const char*)¤t,sizeof(user));
//l.write((const char*)j,15);
f.close();
//l.close();
}
int user::deleteuser(char *a)
{
char t;
char temp[13];
int rrr;
fstream l;
l.open("index.dat",ios::in|ios::out|ios::binary|ios::nocreate|ios::noreplace);
if(!l.good()){cleardevice();setcolor(RED);outtextxy(150,150,"ERROR IN INDEX.DAT");getch();exit(1);}
while(!l.eof())
{
l.read(&t,1);
l.read(temp,13);
l.read((char *)&rrr,2);
if(strcmp(temp,a)==0 && t!='*')
{
//setbk();
//outtextxy(150,150,"EMPLOYEE FOUND ");
//outtextxy(150,180,"DELETING ");
l.seekp(l.tellg(),ios::beg);
l.seekp(-16,ios::cur);
char aa='*';
l.write(&aa,1);
return TRUE;
}
}
return -1;
//outtextxy(150,150,"EMPLOYEE NOT FOUND ");
}
void user::readfromdisk(int a)
{
fstream f;
f.open("USER.DAT",ios::in|ios::out|ios::nocreate|ios::binary|ios::noreplace);
if(!f.good()){outtextxy(100,100,"ERROR IN USER.DAT");getch();return;}
f.seekg(0+(sizeof(user)*a),ios::beg);
f.read((char*)¤t,sizeof(user));
}
void user::smedicaldetails()
{
mouse.hidemouseptr();
setbk();
o.open("logo.dat",ios::in|ios::out|ios::binary|ios::nocreate|ios::noreplace);
if(!o.good()){cleardevice();outtextxy(200,200,"ERROR IN LOGO.DAT");getch();}
o.read(picture,10000);
o.close();
putimage(20,20,picture,0);
/*button back(578,432,614,464);
back.show(4);
putimage(580,435,backlog,0);*/
//button back(578,432,614,464);
//back.show(4);
button back(594,443,15,15);
back.tbutton(2);
back.show();
o.open("back.dat",ios::in|ios::out|ios::nocreate|ios::noreplace|ios::binary);
if(!o.good()){cleardevice();outtextxy(200,200,"ERROR IN BACK.DAT");getch();}
o.read(picture,10000);
o.close();
//putimage(580,427,picture,0);
putimage(580,427,picture,0);
button down(100,360,570,365);
down.show(0);
button change(220,390,310,420);
//back.show();
change.show(4);
setcolor(15);
outtextxy(270,402,"EDIT");
o.open("edit.dat",ios::in|ios::out|ios::binary|ios::nocreate|ios::noreplace);
if(!o.good()){cleardevice();outtextxy(200,200,"ERROR IN EDIT.DAT");getch();}
o.read(picture,10000);
o.close();
putimage(222,392,picture,0);
char am[13];
itoa(amountm,am,10);
setcolor(YELLOW);
outtextxy(190,120,"NAME :-");outtextxy(370,120,namem);
outtextxy(190,160,"RELATION :-");outtextxy(370,160,rs);
outtextxy(190,200,"AMOUNT :-");outtextxy(370,200,am);
outtextxy(190,240,"HOSPITAL :-");outtextxy(370,240,hospital);
outtextxy(190,280,"DISEASE :-");outtextxy(370,280,disease);
outtextxy(190,320,"DOCTOR'S NAME :-");outtextxy(370,320,doctor);
while(1)
{
mouse.showmouseptr();
if(back.check()==TRUE)
{personalmain();return;}
if(change.check()==TRUE)
{
modifymedicaldetails();
return;
}
}
}
void user::sleavedetails()
{mouse.hidemouseptr();
setbk();
o.open("logo.dat",ios::in|ios::out|ios::binary|ios::nocreate|ios::noreplace);
if(!o.good()){cleardevice();outtextxy(200,200,"ERROR IN LOGO.DAT");getch();}
o.read(picture,10000);
o.close();
putimage(20,20,picture,0);
button down(150,320,500,325);
down.show(0);
button modify(260,350,350,380);
//button back(360,350,450,380);
//back.show();
//button back(578,432,614,464);
//back.show(4);
//putimage(580,435,backlog,0);
//button back(578,432,614,464);
//back.show(4);
button back(594,443,15,15);
back.tbutton(2);
back.show();
o.open("back.dat",ios::in|ios::out|ios::nocreate|ios::noreplace|ios::binary);
if(!o.good()){cleardevice();outtextxy(200,200,"ERROR IN BACK.DAT");getch();}
o.read(picture,10000);
o.close();
putimage(580,427,picture,0);
setcolor(15);
//outtextxy(410,365,"BACK");
//putimage(362,352,backlog,0);
char string[13];
int xx=350;
itoa(EL,string,10);
setcolor(14);
outtextxy(190,130,"EARNED LEAVES :-"); moveto(xx,130); outtext((const char*)&string);
itoa(ML,string,10);
outtextxy(190,180,"MEDICAL LEAVES :-"); moveto(xx,180); outtext((const char*)&string);
itoa(CL,string,10);
outtextxy(190,230,"CASUAL LEAVES :-"); moveto(xx,230); outtext((const char*)&string);
itoa(LT,string,10);
outtextxy(190,280,"LEAVES TAKEN :-"); moveto(xx,280); outtext((const char*)&string);
modify.show(4);setcolor(15);outtextxy(310,363,"EDIT");
o.open("edit.dat",ios::in|ios::out|ios::binary|ios::nocreate|ios::noreplace);
if(!o.good()){cleardevice();outtextxy(200,200,"ERROR IN EDIT.DAT");getch();}
o.read(picture,10000);
o.close();
putimage(262,352,picture,0);
while(1)
{
mouse.showmouseptr();
if(back.check()==TRUE)
{personalmain();return;}
if(modify.check()==TRUE)
{
modifyleave();
return;
}
}
}
void user::sPF()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -