|
|
@ -0,0 +1,472 @@
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <conio.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct worker
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char ID[20];//工号
|
|
|
|
|
|
|
|
char name[20];//姓名
|
|
|
|
|
|
|
|
char sex[5];//性别
|
|
|
|
|
|
|
|
char born[20];//生日
|
|
|
|
|
|
|
|
char edu[20];//学历
|
|
|
|
|
|
|
|
char position[20];//职务
|
|
|
|
|
|
|
|
char wage[10];//工资
|
|
|
|
|
|
|
|
char address[100];//住址
|
|
|
|
|
|
|
|
char tel[15];//电话
|
|
|
|
|
|
|
|
}work[1000];
|
|
|
|
|
|
|
|
int n ;
|
|
|
|
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//文件读写模块
|
|
|
|
|
|
|
|
void read()//读入数据
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if( (fp = fopen("d:\\date.txt","r")) == NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("请在D盘根目录下新建一个文本文件,文件名为date\n\n\n");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
return ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fscanf(fp,"%d\n",&n);
|
|
|
|
|
|
|
|
while(i < n)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",work[i].ID,work[i].name,work[i].sex,work[i].born,work[i].edu,work[i].position,work[i].wage,work[i].address,work[i].tel);
|
|
|
|
|
|
|
|
i ++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void write()//写入数据
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if( (fp = fopen("d:\\date.txt","w")) == NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("无法打开文件!\n");
|
|
|
|
|
|
|
|
return ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp,"%d\n",n);
|
|
|
|
|
|
|
|
while(i < n)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fprintf(fp,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",work[i].ID,work[i].name,work[i].sex,work[i].born,work[i].edu,work[i].position,work[i].wage,work[i].address,work[i].tel);
|
|
|
|
|
|
|
|
i ++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//输入模块
|
|
|
|
|
|
|
|
void input()// 从键盘输入
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
int flag;//标记工号是否已存在
|
|
|
|
|
|
|
|
int sz;//标记char型数组是否存贮非数字信息
|
|
|
|
|
|
|
|
char sex;//输入性别
|
|
|
|
|
|
|
|
char c;//指令Y?N
|
|
|
|
|
|
|
|
read();//输入数据前先将文件中原有的数据读入(读取到内存)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
|
|
printf("\t\t请输入职工的工号:(0001-1000) \n\t\t");
|
|
|
|
|
|
|
|
scanf("%s",work[n].ID);
|
|
|
|
|
|
|
|
for(i = 0 ; i < n ; i ++) //与已有工号作比较
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
temp=atoi(work[n].ID);
|
|
|
|
|
|
|
|
if(!(temp>0000&&temp<=1000&&strlen(work[n].ID)<=4))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t工号不在规定范围!请重新输入。\n\n\t\t");
|
|
|
|
|
|
|
|
getch();system("cls");
|
|
|
|
|
|
|
|
input();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(work[i].ID,work[n].ID) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
flag = 1; //ID已存在,则flag为1
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(flag) //显示比较结果工号存在/不存在
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t该工号已存在!\n\n");
|
|
|
|
|
|
|
|
printf("\t\t是否继续输入?(Y/N): ");
|
|
|
|
|
|
|
|
scanf("%*c%c",&c);
|
|
|
|
|
|
|
|
if(c == 'N' || c == 'n') break;
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\t\t请输入职工的信息: \n\n");
|
|
|
|
|
|
|
|
printf("\t\t姓名:\t\t");
|
|
|
|
|
|
|
|
scanf("%s",work[n].name);
|
|
|
|
|
|
|
|
printf("\t\t性别:\t\t");
|
|
|
|
|
|
|
|
scanf("%s",work[n].sex);
|
|
|
|
|
|
|
|
printf("\t\t出生年月:\t");
|
|
|
|
|
|
|
|
scanf("%s",work[n].born);
|
|
|
|
|
|
|
|
printf("\t\t学历:\t\t");
|
|
|
|
|
|
|
|
scanf("%s",work[n].edu);
|
|
|
|
|
|
|
|
printf("\t\t职务:\t\t");
|
|
|
|
|
|
|
|
scanf("%s",work[n].position);
|
|
|
|
|
|
|
|
do //输入工资,并检验是否有非数字信息
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int j;
|
|
|
|
|
|
|
|
char pay[10];
|
|
|
|
|
|
|
|
sz=1;
|
|
|
|
|
|
|
|
printf("\t\t工资:\t\t");
|
|
|
|
|
|
|
|
scanf("%s",pay);
|
|
|
|
|
|
|
|
for(j=0;j<strlen(pay);j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(pay[j]>='0'&&pay[j]<='9');
|
|
|
|
|
|
|
|
else sz=0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sz==0) printf("\t\t请不要输入数字以外的信息!\n\n");
|
|
|
|
|
|
|
|
else strcpy(work[n].wage,pay);
|
|
|
|
|
|
|
|
}while(sz==0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\t\t住址:\t\t");
|
|
|
|
|
|
|
|
scanf("%s",work[n].address);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do //输入电话号码,并检验是否有非数字信息
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int j;
|
|
|
|
|
|
|
|
char num[15];
|
|
|
|
|
|
|
|
sz=1;
|
|
|
|
|
|
|
|
printf("\t\t电话:\t\t");
|
|
|
|
|
|
|
|
scanf("%s",num);
|
|
|
|
|
|
|
|
for(j=0;j<strlen(num);j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(num[j]>='0'&&num[j]<='9');
|
|
|
|
|
|
|
|
else sz=0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sz==0) printf("\t\t请不要输入数字以外的信息!\n\n");
|
|
|
|
|
|
|
|
else strcpy(work[n].tel,num);
|
|
|
|
|
|
|
|
}while(sz==0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n\t\t是否继续输入?(Y/N): ");
|
|
|
|
|
|
|
|
scanf("%*c%c",&c);
|
|
|
|
|
|
|
|
n ++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while( c != 'N' && c != 'n');
|
|
|
|
|
|
|
|
write(); //将输入(到内存)的数据写进文件
|
|
|
|
|
|
|
|
printf("\n\n\t\t数据已保存!\n\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//显示模块
|
|
|
|
|
|
|
|
void output_inf(int id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t|* *|\n");
|
|
|
|
|
|
|
|
printf("\t\t| 工号:\t%s\n",work[id].ID);
|
|
|
|
|
|
|
|
printf("\t\t| 姓名:\t%s\n",work[id].name);
|
|
|
|
|
|
|
|
printf("\t\t| 性别:\t%s\n",work[id].sex);
|
|
|
|
|
|
|
|
printf("\t\t| 出生年月:\t%s\n",work[id].born);
|
|
|
|
|
|
|
|
printf("\t\t| 学历:\t%s\n",work[id].edu);
|
|
|
|
|
|
|
|
printf("\t\t| 职务:\t%s\n",work[id].position);
|
|
|
|
|
|
|
|
printf("\t\t| 工资:\t%s\n",work[id].wage);
|
|
|
|
|
|
|
|
printf("\t\t| 住址:\t%s\n",work[id].address);
|
|
|
|
|
|
|
|
printf("\t\t| 电话:\t%s\n",work[id].tel);
|
|
|
|
|
|
|
|
printf("\t\t|* *|\n");
|
|
|
|
|
|
|
|
printf("\t\t|---------------------------------------------|\n");
|
|
|
|
|
|
|
|
//printf("\n\n\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void show()//显示所有职工信息
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
read();
|
|
|
|
|
|
|
|
if(n == 0) printf("无记录!\n\n");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
for(i = 0 ; i < n ; i ++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(i==0) printf("\n\t\t|=============================================|\n");
|
|
|
|
|
|
|
|
output_inf(i);//调用显示模块
|
|
|
|
|
|
|
|
if(i==(n-1)) printf("\t\t|=============================================|\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询模块
|
|
|
|
|
|
|
|
void que()//查询信息
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char num;
|
|
|
|
|
|
|
|
int flag,i;
|
|
|
|
|
|
|
|
char q_id[20] ;//查询工号
|
|
|
|
|
|
|
|
char q_name[20] ;//查询姓名
|
|
|
|
|
|
|
|
char q_edu[20] ; //查询学历
|
|
|
|
|
|
|
|
char q_position[20] ;//查询职位
|
|
|
|
|
|
|
|
char c;//指令Y?N
|
|
|
|
|
|
|
|
read();//打开程序后,要查询以前的数据,要先读入
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
|
|
|
printf("\t\t|====================================================|\n");
|
|
|
|
|
|
|
|
printf("\t\t| 查询 |\n");
|
|
|
|
|
|
|
|
printf("\t\t|====================================================|\n");
|
|
|
|
|
|
|
|
printf("\t\t|* *|\n");
|
|
|
|
|
|
|
|
printf("\t\t| 1.按工号查询 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 2.按姓名查询 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 3.按学历查询 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 4.按职务查询 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 输入其他任意键退出本模块 |\n");
|
|
|
|
|
|
|
|
printf("\t\t|* *|\n");
|
|
|
|
|
|
|
|
printf("\t\t|====================================================|\n");
|
|
|
|
|
|
|
|
printf("\t\t请输入指令(1-4):");
|
|
|
|
|
|
|
|
scanf("%*c%c",&num);
|
|
|
|
|
|
|
|
if(num <'1' || num >'4')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t错误指令!\n\n");
|
|
|
|
|
|
|
|
//printf( "即将退回主菜单!\n");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
printf( "\n\t\t即将退回主菜单!\n\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
flag = 0;//用来标记职工信息是否存在
|
|
|
|
|
|
|
|
if(num == '1')//按工号查询
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t请输入您要查询职工的工号:");
|
|
|
|
|
|
|
|
scanf("%s",q_id);
|
|
|
|
|
|
|
|
for(i = 0 ; i < n ;i ++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if( strcmp(work[i].ID,q_id) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
output_inf(i);
|
|
|
|
|
|
|
|
flag = 1;//标记
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(num == '2')//按姓名查询
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t请输入您要查询职工的姓名:");
|
|
|
|
|
|
|
|
scanf("%s",q_name);
|
|
|
|
|
|
|
|
for(i = 0 ; i < n ;i ++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if( strcmp(work[i].name,q_name) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
output_inf(i);
|
|
|
|
|
|
|
|
flag = 1;//标记
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(num == '3')//按学历查询
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t请输入您要查询职工的学历:");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scanf("%s",q_edu);
|
|
|
|
|
|
|
|
for(i = 0 ; i < n ;i ++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if( strcmp(work[i].edu,q_edu) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
output_inf(i);
|
|
|
|
|
|
|
|
flag = 1;//标记
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(num == '4')//按职务查询
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t请输入您要查询职工的职务:");
|
|
|
|
|
|
|
|
scanf("%s",q_position);
|
|
|
|
|
|
|
|
for(i = 0 ; i < n ;i ++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if( strcmp(work[i].position,q_position) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
output_inf(i);
|
|
|
|
|
|
|
|
flag = 1;//标记
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!flag)//判断是否有该职工信息
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\n\t\t无该职工信息!\n\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\n\t\t是否继续查询(Y/N):");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scanf("%*c%c",&c);
|
|
|
|
|
|
|
|
if(c == 'N' || c == 'n') break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改信息模块
|
|
|
|
|
|
|
|
void mod()//修改职工信息
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char change_ID[20];//需修改的职工的工号
|
|
|
|
|
|
|
|
int number;//职工信息在数据中的位置
|
|
|
|
|
|
|
|
char num;//指令
|
|
|
|
|
|
|
|
char message[100];//修改的信息
|
|
|
|
|
|
|
|
char c;//指令Y?N
|
|
|
|
|
|
|
|
int flag;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
int sz;
|
|
|
|
|
|
|
|
read();
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf("\n\n\t\t请输入需修改的职工的工号:");
|
|
|
|
|
|
|
|
scanf("%s",change_ID);
|
|
|
|
|
|
|
|
for(i = 0 ; i < n ; i ++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if( strcmp(work[i].ID,change_ID) == 0 )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
number = i;
|
|
|
|
|
|
|
|
flag = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!flag)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\n\t\t无此员工信息!!\n\n");
|
|
|
|
|
|
|
|
printf("\n\n\t\t是否继续修改(Y/N):");
|
|
|
|
|
|
|
|
scanf("%*c%c",&c);
|
|
|
|
|
|
|
|
if(c == 'N' || c == 'n') break;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sz=1;
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
|
|
|
printf("\t\t|====================================================|\n");
|
|
|
|
|
|
|
|
printf("\t\t| 修改 |\n");
|
|
|
|
|
|
|
|
printf("\t\t|====================================================|\n");
|
|
|
|
|
|
|
|
printf("\t\t|* *|\n");
|
|
|
|
|
|
|
|
printf("\t\t| 1.修改姓名 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 2.修改学历 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 3.修改职务 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 4.修改工资 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 5.修改住址 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 6.修改电话 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 输入其他任意键退出本模块 |\n");
|
|
|
|
|
|
|
|
printf("\t\t|* *|\n");
|
|
|
|
|
|
|
|
printf("\t\t|====================================================|\n");
|
|
|
|
|
|
|
|
printf("\n\t\t请输入指令(1-6):");
|
|
|
|
|
|
|
|
scanf("%*c%c",&num);
|
|
|
|
|
|
|
|
if(num < '1' || num > '6')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t错误指令!\n\n");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf("\n\n\t\t请输入修改后的信息:");
|
|
|
|
|
|
|
|
scanf("%s",message);
|
|
|
|
|
|
|
|
printf("\n\n\t\t您确认要修改吗(Y/N):");
|
|
|
|
|
|
|
|
scanf("%*c%c",&c);
|
|
|
|
|
|
|
|
if(c == 'N' || c == 'n') {sz=0;break;}
|
|
|
|
|
|
|
|
switch(num)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case '1' : strcpy(work[number].name,message); break;
|
|
|
|
|
|
|
|
case '2' : strcpy(work[number].edu,message); break;
|
|
|
|
|
|
|
|
case '3' : strcpy(work[number].position,message); break;
|
|
|
|
|
|
|
|
case '4' : strcpy(work[number].wage,message); break;
|
|
|
|
|
|
|
|
case '5' : strcpy(work[number].address,message); break;
|
|
|
|
|
|
|
|
case '6' : strcpy(work[number].tel,message); break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf("\n\n\t\t是否继续修改(Y/N):");
|
|
|
|
|
|
|
|
scanf("%*c%c",&c);
|
|
|
|
|
|
|
|
if(c == 'N' || c == 'n') {if(sz==1) write();break;}
|
|
|
|
|
|
|
|
else {if(sz==1) write();if(sz==0) read();}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//删除信息模块
|
|
|
|
|
|
|
|
void del()//删除职工信息
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char delete_ID[20];//删除职工工号
|
|
|
|
|
|
|
|
int i,j;
|
|
|
|
|
|
|
|
int flag;//标记是否有该职工信息
|
|
|
|
|
|
|
|
char c;
|
|
|
|
|
|
|
|
read();
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
|
|
printf("\t\t请输入需删除职工信息的工号:");
|
|
|
|
|
|
|
|
scanf("%s",delete_ID);
|
|
|
|
|
|
|
|
for(i = 0 ; i < n ; i ++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if( strcmp(work[i].ID,delete_ID) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
n --;
|
|
|
|
|
|
|
|
flag = 1;
|
|
|
|
|
|
|
|
for(j = i ; j < n ; j ++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
work[j] =work[j + 1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!flag) printf("\n\n\t\t无此员工信息!\n\n");
|
|
|
|
|
|
|
|
else printf("\n\n\t\t删除成功!\n");
|
|
|
|
|
|
|
|
printf("\n\n\t\t是否继续删除(Y/N):");
|
|
|
|
|
|
|
|
scanf("%*c%c",&c);
|
|
|
|
|
|
|
|
if(c == 'N' || c == 'n') break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
write();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//菜单模块
|
|
|
|
|
|
|
|
void menu()//菜单
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//printf("\t\t************职工信息管理系统菜单**********\n");
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
|
|
|
printf("\t\t|====================================================|\n");
|
|
|
|
|
|
|
|
printf("\t\t| 学生信息管理系统 |\n");
|
|
|
|
|
|
|
|
printf("\t\t|====================================================|\n");
|
|
|
|
|
|
|
|
printf("\t\t|* *|\n");
|
|
|
|
|
|
|
|
printf("\t\t| 1.录入职工信息 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 2.显示职工信息 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 3.查询职工信息 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 4.修改职工信息 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 5.删除职工信息 |\n");
|
|
|
|
|
|
|
|
printf("\t\t| |\n");
|
|
|
|
|
|
|
|
printf("\t\t| 0.退出 |\n");
|
|
|
|
|
|
|
|
printf("\t\t|* *|\n");
|
|
|
|
|
|
|
|
printf("\t\t|====================================================|\n");
|
|
|
|
|
|
|
|
printf("\t\t\n");
|
|
|
|
|
|
|
|
printf("\t\t请输入指令(0-5): ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int num;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
|
|
|
|
system("color 0B");
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
menu(); //调用菜单
|
|
|
|
|
|
|
|
scanf("%d",&num);
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
switch(num)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1: input(); break;
|
|
|
|
|
|
|
|
case 2: show(); break;
|
|
|
|
|
|
|
|
case 3: que(); break;
|
|
|
|
|
|
|
|
case 4: mod(); break;
|
|
|
|
|
|
|
|
case 5: del(); break;
|
|
|
|
|
|
|
|
case 0: printf("\t\t谢谢使用!\n\n"); return 0;
|
|
|
|
|
|
|
|
default :printf("\n\t\t--->无效的指令!\n\n\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|