Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- #include<conio.h>
- #include<antheader.h>
- #include<time.h>
- #include<string.h>
- #include<fstream>
- #include<sstream>
- //rf1,rf2,rf3,rf4,rf5,rf6;
- FILE *SIFile;
- FILE *TempFile;
- class staffinformation
- {
- public:
- char id[5],firstname[15],lastname[15],sex[7],phone[10],salary[10];
- };
- staffinformation si;
- void fAdminlogin(); //line 30
- void fMenu();//line 207
- void fInput();//line 359
- void fView();//line 572
- void fSearch();//line 668
- void fUpdate();//line 975
- void fDelete();//line 1069
- main()
- {
- fAdminlogin();
- }
- void fAdminlogin()
- {
- //label r1,r2,r3,r4,rc1,rc2;
- string username,password;
- int i,focus=0;
- char ch;
- foreColor(11);//Light Aqua Color
- //Adminlogin Header
- gotoxy(24.5,3);cout<<" Staff Management Software ";
- foreColor(14);//Light Yellow Color
- //Adminlogin Header Box
- //x
- for(i=0;i<31;i++)
- {
- gotoxy(i+24.5,2);cout<<(char)205;
- gotoxy(i+24.5,4);cout<<(char)205;
- }
- //y
- gotoxy(23.5,3);cout<<(char)186;gotoxy(55.5,3);cout<<(char)186;
- foreColor(11);//Light Aqua Color
- //Please Login
- gotoxy(34,8);cout<<"Please Login";
- gotoxy(27,11);cout<<"Username:";gotoxy(27,14);cout<<"Password:";
- foreColor(14);//Light Yellow Color
- //Please Login box
- //x
- for(i=0;i<28;i++)
- {
- gotoxy(i+26,7);cout<<(char)205;
- gotoxy(i+26,9);cout<<(char)205;
- gotoxy(i+26,16);cout<<(char)205;
- }
- //y
- for(i=0;i<8;i++)
- {
- gotoxy(25,i+8);cout<<(char)186;
- gotoxy(54,i+8);cout<<(char)186;
- }
- //coner
- gotoxy(25,7);cout<<(char)201;gotoxy(25,16);cout<<(char)200;
- gotoxy(54,7);cout<<(char)187;gotoxy(54,16);cout<<(char)188;
- gotoxy(25,9);cout<<(char)204;gotoxy(54,9);cout<<(char)185;
- foreColor(11);//Light Aqua Color
- //Username box
- //x
- for(i=0;i<15;i++)
- {
- gotoxy(i+37,10);cout<<(char)196;
- gotoxy(i+37,12);cout<<(char)196;
- }
- //y
- gotoxy(36,11);cout<<(char)179;gotoxy(52,11);cout<<(char)179;
- //coner
- gotoxy(36,10);cout<<(char)218;gotoxy(36,12);cout<<(char)192;
- gotoxy(52,10);cout<<(char)191;gotoxy(52,12);cout<<(char)217;
- foreColor(11);//Light Aqua Color
- //Password box
- //x
- for(i=0;i<15;i++)
- {
- gotoxy(i+37,13);cout<<(char)196;
- gotoxy(i+37,15);cout<<(char)196;
- }
- //y
- gotoxy(36,14);cout<<(char)179;gotoxy(52,14);cout<<(char)179;
- //coner
- gotoxy(36,13);cout<<(char)218;gotoxy(36,15);cout<<(char)192;
- gotoxy(52,13);cout<<(char)191;gotoxy(52,15);cout<<(char)217;
- foreColor(9);//Light Blue Color
- rc1:gotoxy(37,11);ch=getch();
- while(1)
- {
- if(ch>=33&&ch<=126)
- {
- username.push_back(ch);
- cout<<ch;
- foreColor(9);//Light Blue Color
- ch=getch();
- }
- else if(ch==8)//8 is backspace ascii code
- {
- if(username.length()==0)
- {
- goto r1;
- }
- username.erase(username.length()-1,1);
- gotoxy(username.length()+37,11);cout<<' ';
- r1: foreColor(9);//Light Blue Color
- gotoxy(username.length()+37,11);ch=getch();
- }
- else if(ch==13)//13 is enter ascii code
- {
- if(username=="")
- {
- goto rc1;
- }
- goto r2;
- }
- else
- {
- foreColor(9);//Light Blue Color
- gotoxy(username.length()+37,11);ch=getch();
- }
- }
- r2:
- rc2:gotoxy(37,14);ch=getch();
- while(1)
- {
- if(ch>=32&&ch<=127)
- {
- password.push_back(ch);
- cout<<'*';
- foreColor(9);//Light Blue Color
- ch=getch();
- }
- else if(ch==8)//8 is backspace ascii code
- {
- if(password.length()==0)
- {
- goto r3;
- }
- password.erase(password.length()-1,1);
- gotoxy(password.length()+37,14);cout<<' ';
- r3: foreColor(9);//Light Blue Color
- gotoxy(password.length()+37,14);ch=getch();
- }
- else if(ch==13)//13 is enter ascii code
- {
- if(password=="")
- {
- goto rc2;
- }
- goto r4;
- }
- else
- {
- foreColor(9);//Light Blue Color
- gotoxy(password.length()+37,14);ch=getch();
- }
- }
- r4: if(ToLower(username)=="admin"&&password=="123456")
- {
- foreColor(11);//Light Aqua Color
- gotoxy(35,17);cout<<"Loading";
- delay(500);gotoxy(42,17);cout<<".";delay(500);gotoxy(43,17);cout<<".";delay(500);gotoxy(44,17);cout<<".";
- delay(500);gotoxy(42,17);cout<<" ";//clear ...
- delay(500);gotoxy(42,17);cout<<".";delay(500);gotoxy(43,17);cout<<".";delay(500);gotoxy(44,17);cout<<".";
- delay(500);gotoxy(42,17);cout<<" ";//clear ...
- delay(500);gotoxy(42,17);cout<<".";delay(500);gotoxy(43,17);cout<<".";delay(500);gotoxy(44,17);cout<<".";
- delay(500);gotoxy(35,17);cout<<" ";//clear Loading
- foreColor(10);//Light Green Color
- gotoxy(33.5,17);cout<<"Login Succeed";
- delay(700);
- password.clear();//clear all old string in password
- cls();
- fMenu();
- }
- else
- {
- foreColor(11);//Light Aqua Color
- gotoxy(35,17);cout<<"Loading";
- delay(500);gotoxy(42,17);cout<<".";delay(500);gotoxy(43,17);cout<<".";delay(500);gotoxy(44,17);cout<<".";
- delay(500);gotoxy(35,17);cout<<" ";//clear Loading
- foreColor(12);//Light Red Color
- gotoxy(25,17);cout<<"Worng username or password...!";
- password.clear();//clear all old string in password
- foreColor(11);//Light Aqua Color
- gotoxy(25.5,19);cout<<"Press any key to try again...";
- getch();
- gotoxy(37,11);cout<<" ";//clear username
- gotoxy(37,14);cout<<" ";//clear passwrod
- gotoxy(25,17);cout<<" ";//clear Worng password or username
- gotoxy(25.5,19);cout<<" ";//clear Press any key to try again...
- goto r1;
- }
- }
- void fMenu()
- {
- string Options[]={"Input staff information",
- "View staff information",
- "Search/Update/Delete information",
- "Logout..."
- };
- int i,j,focus=0;
- char ch;
- foreColor(11);//Light Aqua Color
- //Menu Header
- gotoxy(24.5,3);cout<<" Staff Management Software ";
- foreColor(14);//Light Yellow Color
- //Menu Header Box
- //x
- for(i=0;i<31;i++)
- {
- gotoxy(i+24.5,2);cout<<(char)205;
- gotoxy(i+24.5,4);cout<<(char)205;
- }
- //y
- gotoxy(23.5,3);cout<<(char)186;gotoxy(55.5,3);cout<<(char)186;
- foreColor(11);//Light Aqua Color
- //Options
- gotoxy(37,8);cout<<"Menu";
- foreColor(14);//Light Yellow Color
- //Menu box
- //x
- for(i=0;i<39;i++)
- {
- gotoxy(i+20,7);cout<<(char)205;
- gotoxy(i+20,9);cout<<(char)205;
- gotoxy(i+20,16);cout<<(char)205;
- }
- //y
- for(i=0;i<8;i++)
- {
- gotoxy(19,i+8);cout<<(char)186;
- gotoxy(58,i+8);cout<<(char)186;
- }
- //coner
- gotoxy(19,7);cout<<(char)201;gotoxy(19,16);cout<<(char)200;
- gotoxy(58,7);cout<<(char)187;gotoxy(58,16);cout<<(char)188;
- gotoxy(19,9);cout<<(char)204;gotoxy(58,9);cout<<(char)185;
- //List
- for(i=0,j=10;i<4;i++)
- {
- j+=1;
- if(i==0)
- {
- foreColor(9);//Light Blue Color
- gotoxy(21,j);cout<<"=>"<<Options[i];
- }
- else
- {
- foreColor(11);//Light Aqua Color
- gotoxy(23,j);cout<<""<<Options[i];
- }
- }
- while(1)
- {
- ch=getch();
- switch(ch)
- {
- case 80://Arrow key down
- if(focus<3)
- {
- focus++;
- }
- else
- {
- focus=0;
- }
- //cls();
- gotoxy(21,11);cout<<" ";
- gotoxy(21,12);cout<<" ";
- gotoxy(21,13);cout<<" ";
- gotoxy(21,14);cout<<" ";
- gotoxy(21,15);cout<<" ";
- j=10;
- for(i=0;i<4;i++)
- {
- j+=1;
- if(i==focus)
- {
- foreColor(9);//Light Blue Color
- gotoxy(21,j);cout<<"=>"<<Options[i];
- }
- else
- {
- foreColor(11);//Light Aqua Color
- gotoxy(23,j);cout<<""<<Options[i];
- }
- }
- break;
- case 72://Arrow key up
- if(focus>0)
- {
- focus--;
- }
- else
- {
- focus=3;
- }
- //cls();
- gotoxy(21,11);cout<<" ";
- gotoxy(21,12);cout<<" ";
- gotoxy(21,13);cout<<" ";
- gotoxy(21,14);cout<<" ";
- j=10;
- for(i=0;i<4;i++)
- {
- j+=1;
- if(i==focus)
- {
- foreColor(9);//Light Blue Color
- gotoxy(21,j);cout<<"=>"<<Options[i];
- }
- else
- {
- foreColor(11);//Light Aqua Color
- gotoxy(23,j);cout<<""<<Options[i];
- }
- }
- break;
- case 13://Enter key
- if(focus==0)
- {
- cls();
- fInput();
- }
- else if(focus==1)
- {
- cls();
- fView();
- }
- else if(focus==2)
- {
- cls();
- fSearch();
- }
- else if(focus==3)
- {
- cls();
- fAdminlogin();
- }
- break;
- }
- }
- }
- void fInput()
- {
- //label rc1,rc2,rc3,rc4,rc5,rc6,rw1,rw2,rw3,rw4;
- int focus=0,n=0,i;
- char ch;
- string fn,ln,s,ph,sa;
- foreColor(11);//Light Aqua Color
- //Input Header
- gotoxy(12.5,1);cout<<"Input information";
- foreColor(14);//Light Yellow Color
- //Input box
- //x
- for(int i=0;i<42;i++)
- {
- gotoxy(i,0);cout<<(char)205;
- gotoxy(i,2);cout<<(char)205;
- gotoxy(i,11);cout<<(char)205;
- }
- //y
- for(int i=0;i<11;i++)
- {
- gotoxy(0,i);cout<<(char)186;
- gotoxy(42,i);cout<<(char)186;
- }
- //coner
- gotoxy(0,0);cout<<(char)201;gotoxy(0,11);cout<<(char)200;
- gotoxy(42,0);cout<<(char)187;gotoxy(42,11);cout<<(char)188;
- gotoxy(0,2);cout<<(char)204;gotoxy(42,2);cout<<(char)185;
- foreColor(11);//Light Aqua Color
- gotoxy(1,4);cout<<"ID: ";
- gotoxy(1,5);cout<<"Input Firstname: ";
- gotoxy(1,6);cout<<"Input Lastname: ";
- gotoxy(1,7);cout<<"Input Sex: ";
- gotoxy(1,8);cout<<"Input Phone: ";
- gotoxy(1,9);cout<<"Input Salary: ";
- SIFile=fopen("SIFile.txt","rb");
- while(fread(&si,sizeof(si),1,SIFile))
- {
- n++;
- }
- fclose(SIFile);
- n++;
- foreColor(9);//Light Blue Color
- gotoxy(5,4);cout<<n;
- rc1:gotoxy(18,5);getline(cin,fn);
- if(fn=="")
- {
- goto rc1;
- }
- rc2:gotoxy(17,6);getline(cin,ln);
- if(ln=="")
- {
- goto rc2;
- }
- rc3:gotoxy(12,7);getline(cin,s);
- if(s=="")
- {
- goto rc3;
- }
- rc4:gotoxy(14,8);ch=getch();
- while(1)
- {
- if(ch>=48&&ch<=57)
- {
- ph.push_back(ch);
- cout<<ch;
- foreColor(9);//Light Blue Color
- ch=getch();
- }
- else if(ch==8)//8 is backspace ascii code
- {
- if(ph.length()==0)
- {
- goto rw1;
- }
- ph.erase(ph.length()-1,1);
- gotoxy(ph.length()+14,8);cout<<' ';
- rw1:foreColor(9);//Light Blue Color
- gotoxy(ph.length()+14,8);ch=getch();
- }
- else if(ch==13)//13 is enter ascii code
- {
- if(ph=="")
- {
- goto rc4;
- }
- goto rw2;
- }
- else
- {
- foreColor(9);//Light Blue Color
- gotoxy(ph.length()+14,8);ch=getch();
- }
- }
- rw2:
- rc5:gotoxy(15,9);ch=getch();
- while(1)
- {
- if(ch>=48&&ch<=57)
- {
- sa.push_back(ch);
- cout<<ch;
- foreColor(9);//Light Blue Color
- ch=getch();
- }
- else if(ch==8)//8 is backspace ascii code
- {
- if(sa.length()==0)
- {
- goto rw3;
- }
- sa.erase(sa.length()-1,1);
- gotoxy(sa.length()+15,9);cout<<' ';
- rw3:foreColor(9);//Light Blue Color
- gotoxy(sa.length()+15,9);ch=getch();
- }
- else if(ch==13)//13 is enter ascii code
- {
- if(sa=="")
- {
- goto rc5;
- }
- goto rw4;
- }
- else
- {
- foreColor(9);//Light Blue Color
- gotoxy(sa.length()+15,9);ch=getch();
- }
- }
- rw4:
- itoa(n,si.id,10);
- strcpy(si.firstname,fn.c_str());
- strcpy(si.lastname,ln.c_str());
- strcpy(si.sex,s.c_str());
- strcpy(si.phone,ph.c_str());
- strcpy(si.salary,sa.c_str());
- //Write into file
- SIFile=fopen("SIFile.txt","ab");
- fwrite(&si,sizeof(si),1,SIFile);
- fclose(SIFile);
- foreColor(11);//Light Aqua Color
- gotoxy(0,12);cout<<"Do you want to input more staff information?";
- foreColor(9);//Light Blue Color
- gotoxy(0,14);cout<<"=>Yes";
- foreColor(11);//Light Aqua Color
- gotoxy(2,15);cout<<"No";
- while(1)
- {
- ch=getch();
- switch(ch)
- {
- case 80://Arrow key down
- if(focus<1)
- {
- focus++;
- gotoxy(0,14);cout<<" ";
- foreColor(11);//Light Aqua Color
- gotoxy(2,14);cout<<"Yes";
- foreColor(9);//Light Blue Color
- gotoxy(0,15);cout<<"=>No";
- break;
- }
- else
- {
- gotoxy(0,15);cout<<" ";
- focus=0;
- foreColor(9);//Light Blue Color
- gotoxy(0,14);cout<<"=>Yes";
- foreColor(11);//Light Aqua Color
- gotoxy(2,15);cout<<"No";
- break;
- }
- //break;
- case 72://Arrow key up
- if(focus>0)
- {
- focus--;
- gotoxy(0,15);cout<<" ";
- foreColor(9);//Light Blue Color
- gotoxy(0,14);cout<<"=>Yes";
- foreColor(11);//Light Aqua Color
- gotoxy(2,15);cout<<"No";
- break;
- }
- else
- {
- gotoxy(0,14);cout<<" ";
- focus=1;
- foreColor(11);//Light Aqua Color
- gotoxy(2,14);cout<<"Yes";
- foreColor(9);//Light Blue Color
- gotoxy(0,15);cout<<"=>No";
- break;
- }
- //break;
- case 13://Enter key
- if(focus==0)
- {
- cls();
- fInput();
- }
- else if(focus==1)
- {
- cls();
- fMenu();
- }
- //break;
- }
- }
- }
- void fView()
- {
- int i,y=5,n=0;
- string ts;
- long totalsalary=0;
- foreColor(11);//Light Aqua Color
- gotoxy(29,1);cout<<"View Staff Information";
- gotoxy(2,3);cout<<"ID";
- gotoxy(18,3);cout<<"Name";
- gotoxy(38,3);cout<<"Sex";
- gotoxy(51,3);cout<<"Phone";
- gotoxy(68,3);cout<<"Salary";
- foreColor(9);//Light Blue Color
- rewind(SIFile);
- SIFile=fopen("SIFile.txt","rb");
- while(fread(&si,sizeof(si),1,SIFile))
- {
- gotoxy(2,y);cout<<si.id;
- gotoxy(8,y);cout<<si.firstname;
- gotoxy(19,y);cout<<si.lastname;
- gotoxy(36,y);cout<<si.sex;
- gotoxy(49,y);cout<<si.phone;
- gotoxy(64,y);cout<<si.salary<<" $";
- ts=string(si.salary);
- totalsalary+=atol(ts.c_str());
- y++;
- n++;
- }
- fclose(SIFile);
- foreColor(11);//Light Aqua Color
- gotoxy(49,n+6);cout<<"Total Salary:";
- foreColor(9);//Light Blue Color
- gotoxy(64,n+6);cout<<totalsalary<<" $";
- foreColor(14);//Light Yellow Color
- //View Staff Information box
- //x
- for(i=0;i<78;i++)
- {
- gotoxy(i+1,0);cout<<(char)205;
- gotoxy(i+1,2);cout<<(char)205;
- gotoxy(i+1,4);cout<<(char)205;
- gotoxy(i+1,n+5);cout<<(char)205;
- }
- for(i=0;i<16;i++)
- {
- gotoxy(i+63,n+7);cout<<(char)205;
- }
- //y
- for(i=0;i<3;i++)
- {
- gotoxy(0,1+i);cout<<(char)186;
- gotoxy(79,1+i);cout<<(char)186;
- }
- for(i=0;i<1;i++)
- {
- gotoxy(6,3);cout<<(char)186;
- gotoxy(34,3);cout<<(char)186;
- gotoxy(44,3);cout<<(char)186;
- gotoxy(62,3);cout<<(char)186;
- gotoxy(62,n+6);cout<<(char)186;
- gotoxy(79,n+6);cout<<(char)186;
- }
- for(i=0;i<n;i++)
- {
- gotoxy(0,5+i);cout<<(char)186;
- gotoxy(6,5+i);cout<<(char)186;
- gotoxy(34,5+i);cout<<(char)186;
- gotoxy(44,5+i);cout<<(char)186;
- gotoxy(62,5+i);cout<<(char)186;
- gotoxy(79,5+i);cout<<(char)186;
- }
- //coner
- gotoxy(0,0);cout<<(char)201;gotoxy(0,4);cout<<(char)204;
- gotoxy(79,0);cout<<(char)187;gotoxy(79,4);cout<<(char)185;
- gotoxy(0,2);cout<<(char)204;gotoxy(79,2);cout<<(char)185;
- gotoxy(0,n+5);cout<<(char)200;gotoxy(62,n+7);cout<<(char)200;
- gotoxy(79,n+7);cout<<(char)188;
- gotoxy(6,n+5);cout<<(char)202;gotoxy(34,n+5);cout<<(char)202;gotoxy(44,n+5);cout<<(char)202;
- gotoxy(79,n+5);cout<<(char)185;gotoxy(62,n+5);cout<<(char)206;
- for(i=0;i<4;i++)
- {
- gotoxy(6,2);cout<<(char)203;
- gotoxy(34,2);cout<<(char)203;
- gotoxy(44,2);cout<<(char)203;
- gotoxy(62,2);cout<<(char)203;
- gotoxy(6,4);cout<<(char)206;
- gotoxy(34,4);cout<<(char)206;
- gotoxy(44,4);cout<<(char)206;
- gotoxy(62,4);cout<<(char)206;
- }
- foreColor(11);//Light Aqua Color
- gotoxy(0,n+6);cout<<"Press any key back to Menu...";
- getch();
- cls();
- fMenu();
- }
- void fSearch()
- {
- //label r1,r3,r,rw1,rw2;
- string id;
- char ch,ids[5];
- r3: int i,n=0,y=5,focus=0;
- foreColor(11);//Light Aqua Color
- gotoxy(4,1);cout<<"Search Information";
- gotoxy(1,4);cout<<"Input ID to search:";
- foreColor(14);//Light Yellow Color
- //Search box
- //x
- for(i=0;i<24;i++)
- {
- gotoxy(i+1,0);cout<<(char)205;
- gotoxy(i+1,2);cout<<(char)205;
- gotoxy(i+1,6);cout<<(char)205;
- }
- //y
- for(i=0;i<5;i++)
- {
- gotoxy(0,i+1);cout<<(char)186;
- gotoxy(25,i+1);cout<<(char)186;
- }
- //coner
- gotoxy(0,0);cout<<(char)201;gotoxy(0,6);cout<<(char)200;
- gotoxy(25,0);cout<<(char)187;gotoxy(25,6);cout<<(char)188;
- gotoxy(0,2);cout<<(char)204;gotoxy(25,2);cout<<(char)185;
- r:foreColor(9);//Light Blue Color
- gotoxy(21,4);ch=getch();
- while(1)
- {
- if(ch>=48&&ch<=57)
- {
- id.push_back(ch);
- cout<<ch;
- foreColor(9);//Light Blue Color
- ch=getch();
- }
- else if(ch==8)//8 is backspace ascii code
- {
- if(id.length()==0)
- {
- goto rw1;
- }
- id.erase(id.length()-1,1);
- gotoxy(id.length()+21,4);cout<<' ';
- rw1:foreColor(9);//Light Blue Color
- gotoxy(id.length()+21,4);ch=getch();
- }
- else if(ch==13)//13 is enter ascii code
- {
- if(id=="")
- {
- goto r;
- }
- goto rw2;
- }
- else
- {
- foreColor(9);//Light Blue Color
- gotoxy(id.length()+21,4);ch=getch();
- }
- }
- rw2:
- /*r1: foreColor(9);//Light Blue Color
- gotoxy(21,4);getline(cin,id);
- if(id=="")
- {
- goto r1;
- }*/
- strcpy(ids,id.c_str());
- SIFile=fopen("SIFile.txt","rb");
- while(fread(&si,sizeof(si),1,SIFile))
- {
- if(atoi(si.id)==atoi(ids))
- {
- cls();
- gotoxy(2,y);cout<<si.id;
- gotoxy(8,y);cout<<si.firstname;
- gotoxy(19,y);cout<<si.lastname;
- gotoxy(36,y);cout<<si.sex;
- gotoxy(49,y);cout<<si.phone;
- gotoxy(64,y);cout<<si.salary<<" $";
- n++;
- }
- }
- fclose(SIFile);
- if(n==0)
- {
- foreColor(12);//Light Red Color
- gotoxy(0,7);cout<<"ID not found!";
- foreColor(11);//Light Aqua Color
- gotoxy(0,8);cout<<"Do you want to try again?";
- foreColor(9);//Light Blue Color
- gotoxy(0,10);cout<<"=>Yes";
- foreColor(11);//Light Aqua Color
- gotoxy(2,11);cout<<"No";
- while(1)
- {
- ch=getch();
- switch(ch)
- {
- case 80://Arrow key down
- if(focus<1)
- {
- focus++;
- gotoxy(0,10);cout<<" ";
- foreColor(11);//Light Aqua Color
- gotoxy(2,10);cout<<"Yes";
- foreColor(9);//Light Blue Color
- gotoxy(0,11);cout<<"=>No";
- break;
- }
- else
- {
- gotoxy(0,11);cout<<" ";
- focus=0;
- foreColor(9);//Light Blue Color
- gotoxy(0,10);cout<<"=>Yes";
- foreColor(11);//Light Aqua Color
- gotoxy(2,11);cout<<"No";
- break;
- }
- //break;
- case 72://Arrow key up
- if(focus>0)
- {
- focus--;
- gotoxy(0,11);cout<<" ";
- foreColor(9);//Light Blue Color
- gotoxy(0,10);cout<<"=>Yes";
- foreColor(11);//Light Aqua Color
- gotoxy(2,11);cout<<"No";
- break;
- }
- else
- {
- gotoxy(0,10);cout<<" ";
- focus=1;
- foreColor(11);//Light Aqua Color
- gotoxy(2,10);cout<<"Yes";
- foreColor(9);//Light Blue Color
- gotoxy(0,11);cout<<"=>No";
- break;
- }
- //break;
- case 13://Enter key
- if(focus==0)
- {
- gotoxy(21,4);cout<<" ";
- gotoxy(0,7);cout<<" ";
- gotoxy(0,8);cout<<" ";
- gotoxy(0,10);cout<<" ";
- gotoxy(0,11);cout<<" ";
- goto r3;
- }
- else if(focus==1)
- {
- cls();
- fMenu();
- }
- }
- }
- }
- foreColor(11);//Light Aqua Color
- gotoxy(31.5,1);cout<<"Staff Information";
- gotoxy(2,3);cout<<"ID";
- gotoxy(18,3);cout<<"Name";
- gotoxy(38,3);cout<<"Sex";
- gotoxy(51,3);cout<<"Phone";
- gotoxy(68,3);cout<<"Salary";
- foreColor(14);//Light Yellow Color
- //Search Staff Information box
- //x
- for(i=0;i<78;i++)
- {
- gotoxy(i+1,0);cout<<(char)205;
- gotoxy(i+1,2);cout<<(char)205;
- gotoxy(i+1,4);cout<<(char)205;
- gotoxy(i+1,6);cout<<(char)205;
- }
- //y
- for(i=0;i<5;i++)
- {
- gotoxy(0,1+i);cout<<(char)186;
- gotoxy(79,1+i);cout<<(char)186;
- }
- for(i=0;i<1;i++)
- {
- gotoxy(6,3);cout<<(char)186;
- gotoxy(34,3);cout<<(char)186;
- gotoxy(44,3);cout<<(char)186;
- gotoxy(62,3);cout<<(char)186;
- gotoxy(6,5);cout<<(char)186;
- gotoxy(34,5);cout<<(char)186;
- gotoxy(44,5);cout<<(char)186;
- gotoxy(62,5);cout<<(char)186;
- }
- //coner
- gotoxy(0,0);cout<<(char)201;gotoxy(0,4);cout<<(char)204;
- gotoxy(79,0);cout<<(char)187;gotoxy(79,4);cout<<(char)185;
- gotoxy(0,2);cout<<(char)204;gotoxy(79,2);cout<<(char)185;
- gotoxy(0,6);cout<<(char)200;
- gotoxy(6,6);cout<<(char)202;gotoxy(34,6);cout<<(char)202;
- gotoxy(44,6);cout<<(char)202;gotoxy(62,6);cout<<(char)202;
- gotoxy(79,6);cout<<(char)188;
- for(i=0;i<4;i++)
- {
- gotoxy(6,2);cout<<(char)203;
- gotoxy(34,2);cout<<(char)203;
- gotoxy(44,2);cout<<(char)203;
- gotoxy(62,2);cout<<(char)203;
- gotoxy(6,4);cout<<(char)206;
- gotoxy(34,4);cout<<(char)206;
- gotoxy(44,4);cout<<(char)206;
- gotoxy(62,4);cout<<(char)206;
- }
- r4: focus=0;
- foreColor(9);//Light Blue Color
- gotoxy(0,8);cout<<"=>Update information";
- foreColor(11);//Light Aqua Color
- gotoxy(2,9);cout<<"Delete information";
- gotoxy(2,10);cout<<"Back...";
- while(1)
- {
- ch=getch();
- switch(ch)
- {
- case 80://Arrow key down
- if(focus==0)
- {
- focus=1;
- gotoxy(0,8);cout<<" ";
- foreColor(11);//Light Aqua Color
- gotoxy(2,8);cout<<"Update information";
- gotoxy(2,10);cout<<"Back...";
- foreColor(9);//Light Blue Color
- gotoxy(0,9);cout<<"=>Delete information";
- break;
- }
- else if(focus==1)
- {
- focus=2;
- gotoxy(0,9);cout<<" ";
- foreColor(11);//Light Aqua Color
- gotoxy(2,8);cout<<"Update information";
- gotoxy(2,9);cout<<"Delete information";
- foreColor(9);//Light Blue Color
- gotoxy(0,10);cout<<"=>Back...";
- break;
- }
- else if(focus==2)
- {
- focus=0;
- gotoxy(0,10);cout<<" ";
- foreColor(11);//Light Aqua Color
- gotoxy(2,10);cout<<"Back...";
- gotoxy(2,9);cout<<"Delete information";
- foreColor(9);//Light Blue Color
- gotoxy(0,8);cout<<"=>Update information";
- break;
- }
- //break;
- case 72://Arrow key up
- if(focus==0)
- {
- focus=2;
- gotoxy(0,8);cout<<" ";
- foreColor(11);//Light Aqua Color
- gotoxy(2,8);cout<<"Update information";
- gotoxy(2,9);cout<<"Delete information";
- foreColor(9);//Light Blue Color
- gotoxy(0,10);cout<<"=>Back...";
- break;
- }
- else if(focus==1)
- {
- focus=0;
- gotoxy(0,9);cout<<" ";
- foreColor(11);//Light Aqua Color
- gotoxy(2,10);cout<<"Back...";
- gotoxy(2,9);cout<<"Delete information";
- foreColor(9);//Light Blue Color
- gotoxy(0,8);cout<<"=>Update information";
- break;
- }
- else if(focus==2)
- {
- focus=1;
- gotoxy(0,10);cout<<" ";
- foreColor(11);//Light Aqua Color
- gotoxy(2,8);cout<<"Update information";
- gotoxy(2,10);cout<<"Back...";
- foreColor(9);//Light Blue Color
- gotoxy(0,9);cout<<"=>Delete information";
- break;
- }
- //break;
- case 13://Enter key
- if(focus==0)
- {
- //fUpdate
- cls();
- string fn,ln,s,ph,sa;
- SIFile=fopen("SIFile.txt","rb+");
- while(fread(&si,sizeof(si),1,SIFile))
- {
- if(strcmp(si.id,ids)==0)
- {
- fseek(SIFile,-(int)sizeof(si),SEEK_CUR);
- //label rc1,rc2,rc3,rc4,rc5,rc6;
- int focus=0,i;
- char ch;
- string fn,ln,s,ph,sa;
- foreColor(11);//Light Aqua Color
- //Input Header
- gotoxy(13,1);cout<<"Update information";
- foreColor(14);//Light Yellow Color
- //Input box
- //x
- for(int i=0;i<42;i++)
- {
- gotoxy(i,0);cout<<(char)205;
- gotoxy(i,2);cout<<(char)205;
- gotoxy(i,11);cout<<(char)205;
- }
- //y
- for(int i=0;i<11;i++)
- {
- gotoxy(0,i);cout<<(char)186;
- gotoxy(42,i);cout<<(char)186;
- }
- //coner
- gotoxy(0,0);cout<<(char)201;gotoxy(0,11);cout<<(char)200;
- gotoxy(42,0);cout<<(char)187;gotoxy(42,11);cout<<(char)188;
- gotoxy(0,2);cout<<(char)204;gotoxy(42,2);cout<<(char)185;
- foreColor(11);//Light Aqua Color
- gotoxy(1,4);cout<<"ID: ";
- gotoxy(5,4);cout<<ids;
- gotoxy(1,5);cout<<"Input Firstname: ";
- gotoxy(1,6);cout<<"Input Lastname: ";
- gotoxy(1,7);cout<<"Input Sex: ";
- gotoxy(1,8);cout<<"Input Phone: ";
- gotoxy(1,9);cout<<"Input Salary: ";
- foreColor(9);//Light Blue Color
- rc1:gotoxy(18,5);getline(cin,fn);
- if(fn=="")
- {
- goto rc1;
- }
- ToUpper(fn);
- rc2:gotoxy(17,6);getline(cin,ln);
- if(ln=="")
- {
- goto rc2;
- }
- ToUpper(ln);
- rc3:gotoxy(12,7);getline(cin,s);
- if(s=="")
- {
- goto rc3;
- }
- rc4:gotoxy(14,8);getline(cin,ph);
- if(ph=="")
- {
- goto rc4;
- }
- rc5:gotoxy(15,9);getline(cin,sa);
- if(sa=="")
- {
- goto rc5;
- }
- strcpy(si.firstname,fn.c_str());
- strcpy(si.lastname,ln.c_str());
- strcpy(si.sex,s.c_str());
- strcpy(si.phone,ph.c_str());
- strcpy(si.salary,sa.c_str());
- //Wite into file
- fwrite(&si,sizeof(si),1,SIFile);
- fclose(SIFile);
- }
- }
- foreColor(11);//Light Aqua Color
- gotoxy(0,12);cout<<"Updating";
- delay(500);gotoxy(8,12);cout<<".";delay(500);gotoxy(9,12);cout<<".";delay(500);gotoxy(10,12);cout<<".";
- foreColor(10);//Light Green Color
- delay(500);gotoxy(0,12);cout<<"Update Completed";
- foreColor(11);//Light Aqua Color
- gotoxy(0,13);cout<<"Press any key back to menu...";
- getch();
- cls();
- fMenu();
- }
- else if(focus==1)
- {
- //fDelete
- //label r2,r4;
- int i,n=0;
- int focus=0;
- foreColor(11);//Light Aqua Color
- gotoxy(0,12);cout<<"Are you sure you want to delete this information?";
- foreColor(9);//Light Blue Color
- gotoxy(0,14);cout<<"=>Yes";
- foreColor(11);//Light Aqua Color
- gotoxy(2,15);cout<<"No";
- while(1)
- {
- ch=getch();
- switch(ch)
- {
- case 80://Arrow key down
- if(focus<1)
- {
- focus++;
- gotoxy(0,14);cout<<" ";
- foreColor(11);//Light Aqua Color
- gotoxy(2,14);cout<<"Yes";
- foreColor(9);//Light Blue Color
- gotoxy(0,15);cout<<"=>No";
- break;
- }
- else
- {
- gotoxy(0,15);cout<<" ";
- focus=0;
- foreColor(9);//Light Blue Color
- gotoxy(0,14);cout<<"=>Yes";
- foreColor(11);//Light Aqua Color
- gotoxy(2,15);cout<<"No";
- break;
- }
- //break;
- case 72://Arrow key up
- if(focus>0)
- {
- focus--;
- gotoxy(0,15);cout<<" ";
- foreColor(9);//Light Blue Color
- gotoxy(0,14);cout<<"=>Yes";
- foreColor(11);//Light Aqua Color
- gotoxy(2,15);cout<<"No";
- break;
- }
- else
- {
- gotoxy(0,14);cout<<" ";
- focus=1;
- foreColor(11);//Light Aqua Color
- gotoxy(2,14);cout<<"Yes";
- foreColor(9);//Light Blue Color
- gotoxy(0,15);cout<<"=>No";
- break;
- }
- //break;
- case 13://Enter key
- if(focus==0)
- {
- gotoxy(0,12);cout<<" ";
- gotoxy(0,14);cout<<" ";
- gotoxy(2,15);cout<<" ";
- SIFile=fopen("SIFile.txt","rb");
- TempFile=fopen("TempFile.txt","a+b");
- while(fread(&si,sizeof(si),1,SIFile))
- {
- if(strcmp(si.id,ids)!=0)
- {
- fwrite(&si,sizeof(si),1,TempFile);
- }
- }
- fclose(SIFile);
- fclose(TempFile);
- remove("SIFile.txt");
- rename("TempFile.txt","SIFile.txt");
- //Sortdown ID
- SIFile=fopen("SIFile.txt","rb");
- TempFile=fopen("TempFile.txt","a+b");
- while(fread(&si,sizeof(si),1,SIFile))
- {
- if(atoi(si.id)<atoi(ids))
- {
- fwrite(&si,sizeof(si),1,TempFile);
- }
- else if(atoi(si.id)>atoi(ids))
- {
- n=atoi(si.id)-1;
- itoa(n,si.id,10);
- fwrite(&si,sizeof(si),1,TempFile);
- }
- }
- fclose(SIFile);
- fclose(TempFile);
- remove("SIFile.txt");
- rename("TempFile.txt","SIFile.txt");
- foreColor(11);//Light Aqua Color
- gotoxy(0,12);cout<<"Deleting";
- delay(500);gotoxy(8,12);cout<<".";delay(500);gotoxy(9,12);cout<<".";delay(500);gotoxy(10,12);cout<<".";
- foreColor(10);//Light Green Color
- delay(500);gotoxy(0,12);cout<<"Delete Completed";
- foreColor(11);//Light Aqua Color
- gotoxy(0,13);cout<<"Press any key back to menu...";
- getch();
- cls();
- fMenu();
- }
- else if(focus==1)
- {
- gotoxy(0,12);cout<<" ";
- gotoxy(0,14);cout<<" ";
- gotoxy(0,15);cout<<" ";
- gotoxy(0,8);cout<<" ";
- gotoxy(0,9);cout<<" ";
- gotoxy(0,10);cout<<" ";
- goto r4;
- }
- //break;
- }
- }
- }
- else if(focus==2)
- {
- cls();
- fMenu();
- }
- //break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement