Home > Back-end >  Staff management system problems, don't understand
Staff management system problems, don't understand

Time:09-28

# # ifndef _STRUCT_H_
# define _STRUCT_H_
Struct the Employee {
//declare the structure of the staff as a linked list node
//data domain
String m_Code;//number
String m_Name;//name
String m_Year;//date of birth
String m_Sex;//gender
String m_Department;//department
Unsigned int m_Wage;
Struct the Employee * Next;
};
Typedef struct Employee Node;
Typedef Node * Link;
//function declaration
Link the Create (Link Head);//create a lead the node empty list
Void Release (Link Head);//modify a single node
The Link to the Add (Link Head);//add employee information
Bool Search (Link Head);//query at the same time meet the name and department worker
The Link Search_Unique (Link Head);//code query meet worker worker information
Void Display_List (Link Head);//show the worker information function
Void Display_Node (Link pNode);//on the standard output device output
Link the Modify (Link Head);//modify the worker information function
The Link Del (Link Head);//delete information
Void Save_ByFile (Link Head);//save function
The Link Sort (Link Head);//wages by the
Void Load_ByFile (Link pNode);
The Link Sort_byname (Link Head);//dictionary sort by name

//modify the worker information function
Link the Modify (Link Head) {
//modify a single node
String co;
Cout<" Enter your employee number: to modify ";
Cin> Co;
The Link PTR.
The Link ptr_front;
Ptr_front=Head;
While (ptr_front) {
PTR=ptr_front - & gt; Next;
If (PTR==NULL)
break;
Else if (PTR - & gt; M_Code==co) {
break;//find
}
Ptr_front=ptr_front - & gt; Next;
}
Cout<" Employee Numbers name date of birth sex department ";
Display_Node (PTR);
Cout<" Input to modify the content: \ n ";
Cout<" 1. The employee Numbers "& lt; Cout<" 2. The name "& lt; Cout<" 3. Date of birth "& lt; Cout<" Gender "& lt; 4. Cout<" 5. Department "& lt; Cout<" 0. Cancel the modified "& lt; int choice;
String again.
int flag=0;
Do {
CoutCin> Choice;
The switch (choice) {
Case 1:
Cout<" Please enter the employee Numbers ";
Cin> PTR - & gt; M_Code;
break;
Case 2:
CoutCin> PTR - & gt; M_Name;
break;
Case 3:
CoutCin> PTR - & gt; M_Year;
break;
Case 4:
Cout<" Please enter the gender (1) male/(2) female) : ";
//cin> Sex;
Cin> PTR - & gt; M_Sex;
break;
Case 5:
Cout<" Please enter the department: ";
//cin> Department;
Cin> PTR - & gt; M_Department;
break;
Case 0:
Return the Head;
Default:
Cout<" Input is wrong, please input again: ";
}
Cout<" Whether to continue (y/n)?" ;
While (1) {
Cin> Again;
If (again=="N" | | again=="N") {flag=0; break; }
Else if (again=="Y" | | again=="Y") {flag=1; break; }
The else cout<" Input is wrong! Please choose again: ";
}
} while (flag);
Cout<" Information modify success ";
Return the Head;
}

//list for new staff information
Link Creat (Link Head) {//create a leading the node empty list
The Head=new Node (Link);
if(! The Head) {
Cout<" Allocate memory failure "& lt; return NULL;
}
The Head - & gt; Next=NULL;
Return the Head;
}

Void Release (Link Head) {
//release list
The Link PTR.//declare an operation with a pointer to the
While (the Head!=NULL) {
PTR=Head;
The Head=Head - & gt; Next;
The delete PTR.
}
}

The Link to the Add (Link Head) {//forward method to Add data
The Link pNew;//declare a new node
String again.
Int flag;
String code, name, sex, year, department;
//unsigned short int year;
Unsigned int wage;
//string wage;
Do {
PNew=new Node (Link);
//data
Cout<" Please enter the employee code: ";
Cin> code;
CoutCin> name;
CoutCin> Year;
While (cin) fail ()) {
Cout<" Please enter the correct date format & lt;" Cin. The clear ();
fflush(stdin);
Cin> Year;
}
CoutWhile (1) {
Cin> Sex;
If (sex=="1" | | sex=="2") break;
The else cout<" Input is wrong! Please input again ";
}
CoutCin> Department;
CoutPNew - & gt; M_Code=code;
PNew - & gt; M_Name=name;
PNew - & gt; M_Year=year;
PNew - & gt; M_Sex=sex;
PNew - & gt; M_Department=department;
//pointer field
PNew - & gt; Next=Head - & gt; Next;
The Head - & gt; Next=pNew;
Cout<" Data add success! Continue to add? (Y/N)?" While (1) {
Cin> Again;
system("cls");
If (again=="N" | | again=="N") {flag=0; break; }
Else if (again=="Y" | | again=="Y") {flag=1; break; }
The else cout<" Input is wrong! Please choose again: ";
}
} while (flag);
Cout<" Add the data successful ";
Return the Head;
}

//delete employee information
The Link Del (Link Head) {
int flag=0;
String code;
Cout<" Please enter the code you want to delete the worker: ";
Cin> code;
The Link PTR.
The Link ptr_front;
Ptr_front=Head;
While (ptr_front) {
PTR=ptr_front - & gt; Next;
If (PTR==NULL) break;
Else if (PTR - & gt; M_Code=={code)
Flag=1;
Ptr_front - & gt; Next=PTR - & gt; Next;
The delete PTR.
}
Ptr_front=ptr_front - & gt; Next;
}
If (flag) cout<" This record has been deleted ";
The else cout<" Couldn't find the staff information, unable to delete "& lt; Return the Head;
}

//query worker information function
Bool Search (Link Head)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related