📄 工资管理系统.txt
字号:
#include <dos.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#include<conio.h>
struct award{
char reason[20]; /*该奖金的原因*/
float amount; /*该奖金的数目*/
struct award *p; /*指向下一个奖金的指针*/
};
struct salary{
long num3; /*该月奖金类别的数目*/
char month[10]; /*月份名称*/
short zcbh; /*职称编号*/
char title[20]; /*职称*/
float jbgz; /*该月基本工资*/
float zwgz; /*该月职务工资*/
float subsidy; /*该月补助*/
struct salary *p5; /*指向下一个月工资的指针*/
struct award *p6; /*指向奖金链表的指针*/
};
struct employee{
long num2; /*该员工发的工资的月数*/
char name[30]; /*该员工的名字*/
long gzkh; /*该员工的工资卡号*/
char ID[20]; /*该员工的身份证号*/
char sex; /*该员工的性别*/
short age; /*该员工的年龄*/
short standing; /*该员工的工龄*/
char tel[13]; /*该员工的电话号码*/
char mobile[12]; /*该员工的手机号码*/
char jszc[20]; /*该员工的技术职称*/
short zcbh; /*该员工的职称编号*/
struct employee *p3; /*指向下一个工人的指针*/
struct salary *p4; /*指向工资链表的指针*/
};
struct department{
long num1; /*该部门中的员工人数*/
char name[24]; /*部门的名称*/
struct department *p1; /*指向下一个部门的指针*/
struct employee *p2; /*指向工人链表的指针*/
};
struct department1{
long num1; /*该部门中的员工人数*/
char name[24]; /*部门的名称*/
};
struct employee1{
long num2; /*该员工发的工资的月数*/
char name[30]; /*该员工的名字*/
long gzkh; /*该员工的工资卡号*/
char ID[20]; /*该员工的身份证号*/
char sex; /*该员工的性别*/
short age; /*该员工的年龄*/
short standing; /*该员工的工龄*/
char tel[13]; /*该员工的电话号码*/
char mobile[12]; /*该员工的手机号码*/
char jszc[20]; /*该员工的技术职称*/
short zcbh; /*该员工的职称编号*/
};
struct salary1{
long num3; /*该月奖金类别的数目*/
char month[10]; /*月份名称*/
short zcbh; /*职称编号*/
char title[20]; /*职称*/
float jbgz; /*该月基本工资*/
float zwgz; /*该月职务工资*/
float subsidy; /*该月补助*/
};
struct award1{
char reason[20]; /*该奖金的原因*/
float amount; /*该奖金的数目*/
};
struct department *new(void); /*新建*/
struct department *open(void); /*打开*/
void save(struct department *); /*保存*/
struct department *de(struct department *ph); /*修改部门信息*/
struct department *em(struct department *ph); /*修改工人信息*/
struct department *sa(struct department *ph); /*修改工资信息*/
struct department *aw(struct department *ph); /*修改奖金信息*/
struct department *dep(struct department *ph); /*插入部门信息*/
struct department *emp(struct department *ph); /*插入工人信息*/
struct department *sal(struct department *ph); /*插入工资信息*/
struct department *awa(struct department *ph); /*插入奖金信息*/
void stage(struct department *ph); /*按年龄统计*/
void stsalary(struct department *ph); /*按工资统计*/
void stpaixu(struct department *ph); /*对工人排序*/
struct department *depa(struct department *ph); /*删除一个部门的信息*/
struct department *empl(struct department *ph); /*删除一个工人的信息*/
struct department *sala(struct department *ph); /*删除一个月的工资的信息*/
struct department *awar(struct department *ph); /*删除一类奖金的信息*/
void zhch(struct department *ph); /*按职称查询*/
void gongzi(struct department *ph); /*按工资查询*/
void worker(struct department *ph); /*查询某个工人的信息*/
FILE * fp;
void screen(int dx,int dy,int m, char *p[]) ; /*界面*/
int key0,key1,key,test,dx,dy,y,i;
char buf[30*10*2],buf1[30*2];
char *chp[]={"file","statistic","insert","modify","delete","query"};
char *file[]={"new","open","save","quit"};
char *mod[]={"department","employee","salary","award"};
char *ins[]={"department","employee","salary","award"};
char *del[]={"department","employee","salary","award"};
char *que[]={"title","salary","worker"};
char *sta[]={"age","salary","paixu"};
void main(){ /*主函数*/
char c;
struct department *phead,**ph=&phead;
inx:
textbackground(1);
clrscr( );
window(1,1,80,1);
textbackground(WHITE);
textcolor(BLACK);
clrscr( );
window(1,1,80,2);
for(i=0;i<6;i++)
cprintf(" %s",chp[i]);
while(1)
{
key=0;
while(bioskey(1)==0);
key=bioskey(0);
key=key&0xff?0:key>>8;
if(key==45) exit(0); /*pressalt+x*/
if(key==33) /*pressalt+f*/
{
dx=0,dy=4;
screen(dx,dy,0,file);
if(key0==45) exit(0);
if(key0==13)
switch(test)
{
case 1:phead=new(); goto inx;
case 2:phead=open();goto inx;
case 3: save(*ph);goto inx;
default: break;
}
else
goto inx;
}
if(key==31)
{
dy=3;
dx=7;
screen(dx,dy,1,sta);
if(key0==45) exit(0);
if(key0==13)
switch(test)
{
case 1:stage(*ph);goto inx;
case 2:stsalary(*ph);goto inx;
case 3:stpaixu(*ph);goto inx;
default:
cprintf("\nInput error!");
break;
}
else /* esc key */
goto inx;
}
if(key==23) /* alt+i */
{ dx=19;
dy=4;
screen(dx,dy,2,ins);
if(key0==45) exit(0);
if(key0==13)
switch(test)
{
case 1:phead=dep(*ph);goto inx;
case 2:phead=emp(*ph);goto inx;
case 3:phead=sal(*ph);goto inx;
case 4:phead=awa(*ph);goto inx;
default: break;
}
else /* esc key */
goto inx;
}
if(key==50) /*alt+m*/ /*print alt+m*/
{ dx=28;
dy=4;
screen(dx,dy,3,mod);
if(key0==45) exit(0);
if(key0==13)
switch(test)
{
case 1:phead=de(*ph);goto inx;
case 2:phead=em(*ph);goto inx;
case 3:phead=sa(*ph);goto inx;
case 4:phead=aw(*ph);goto inx;
default:break;
}
else /* esc key */
goto inx;
}
if(key==32) /* alt+d */
{ dx=37;
dy=4;
screen(dx,dy,4,del);
if(key0==45) exit(0);
if(key0==13)
switch(test)
{
case 1:phead=depa(*ph);goto inx;
case 2:phead=empl(*ph);goto inx;
case 3:phead=sala(*ph);goto inx;
case 4:phead=awar(*ph);goto inx;
default:break;
}
else /* esc key */
goto inx;
}
if(key==16) /* alt+q*/
{ dx=46;
dy=3;
screen(dx,dy,5,que);
if(key0==45) exit(0);
if(key0==13)
switch(test)
{
case 1:zhch(*ph);goto inx;
case 2:gongzi(*ph);goto inx;
case 3:worker(*ph);goto inx;
default:break;
}
else /* esc key */
goto inx;
}
}
}
void screen(int dx,int dy,int m, char *p[]) /*打印屏幕*/
{
textbackground(BLACK);
textcolor(WHITE);
gotoxy(4+dx,1);
cprintf("%s",chp[m]);
gettext(4+dx,2,15+dx,dy+3,buf); /* save the content */
window(4+dx,2,15+dx,dy+3);
textbackground(WHITE);
textcolor(BLACK);
clrscr( );
window(4+dx,2,15+dx,dy+4);
gotoxy(1,1);
putch(0xda);
for(i=2;i<12;i++) putch(0xc4); /*print '-'*/
putch(0xbf);
for(i=2;i<dy+2;i++)
{
gotoxy(1,i);putch(0xb3); /*print '|'*/
gotoxy(12,i);putch(0xb3);
}
gotoxy(1,dy+2);
putch(0xc0);
for(i=2;i<12;i++) putch(0xc4); /*print '-'*/
putch(0xd9);
for(i=2;i<dy+2;i++)
{
gotoxy(2,i);
cprintf("%s",p[i-2]);
}
gettext(2+dx,2,14+dx,3,buf1);
textbackground(RED);
textcolor(YELLOW);
gotoxy(2,2);
cprintf("%s",p[0]);
y=2;
key0=key1=0;
while(key0!=27&&key1!=45&&key0!=13)
{
while(bioskey(1)==0);
key0=key1=bioskey(0);
key0=key0&0xff;
key1=key1&0xff?0:key1>>8;
if(key1==72||key1==80)
{
puttext(2+dx,y,14+dx,y+1,buf1); /* 上下移动 */
if(key1==72) y=y==2?dy+1:y-1;
if(key1==80) y=y==dy+1?2:y+1;
gettext(2+dx,y,14+dx,y+1,buf1);
textbackground(RED);
textcolor(YELLOW);
gotoxy(2,y);
cprintf("%s",p[y-2]);
}
test=y-1;
}
if(key0==13)
{ window(1,1,80,2);
puttext(4+dx,2,15+dx,dy+3,buf);
textbackground(WHITE);
textcolor(BLACK);
gotoxy(4+dx,1);
cprintf("%s",chp[m]);
window(1,2,80,22);
textbackground(LIGHTBLUE);
textcolor(YELLOW);
clrscr();
gotoxy(1,1);
}
}
struct department *new(void) /*新建一个文件*/
{
struct department *head=NULL,*pa;
struct employee *pb;
struct salary *pc;
struct award *pd;
char ch;
short flag=1;
long i=0;
printf("\nNow,input informations of departments\n");
while(flag)
{
pa=malloc(sizeof(struct department));
printf("\nPlease input the name of the department:\n");
scanf("%s",pa->name);
pa->p1=head;
head=pa;
printf("Continue or not ?[n or y](add department)\n");
scanf("%1s",&ch);
if(ch=='n'||ch=='N')
flag=0;
else flag=1;
}
printf("\nNow,input informations of workers!");
pa=head;
while(pa!=NULL)
{
i=0;
flag=1;
pa->p2=NULL;
while(flag){
printf("\nInput information of workers in department %s.\n",pa->name);
pb=malloc(sizeof(struct employee));
pb->p3=pa->p2;
pa->p2=pb;
printf("\nPlease input Name of worker:");
scanf("%s",pb->name);
printf("\nPlease input ID of worker:");
scanf("%s",pb->ID);
printf("\nPlease input telephone number of worker:");
scanf("%s",pb->tel);
printf("\nPlease input mobile number of worker:");
scanf("%s",pb->mobile);
printf("\nPlease input title of worker (jishuzhicheng):");
scanf("%s",pb->jszc);
printf("\nPlease input :\n"
"Gongzikahao,Sex,Age,Standing(Gongling),Zhichengbianhao\n");
scanf("%ld,%c,%hd,%hd,%hd",&pb->gzkh,&pb->sex,&pb->age,&pb->standing,&pb->zcbh);
printf("Continue or not?[n or y](add workers)\n");
while(isspace(ch=getchar())) ;
if(ch=='n'||ch=='N')
{
flag=0;
pa->num1=i+1;
}
else
{
flag=1;
i++;
}
}
pa=pa->p1;
}
printf("\Now,input informations of workers' salary\n");
pa=head;
i=0;
while(pa!=NULL){
printf("\nInput salary informations of workers in department %s\n",pa->name);
pb=pa->p2;
while(pb!=NULL){
printf("\nInput salary informations of worker %s\n",(pa->p2)->name);
flag=1;
pb->p4=NULL;
while(flag){
pc=malloc(sizeof(struct salary));
pc->p5=pb->p4;
pb->p4=pc;
printf("\nPlease input the month:");
scanf("%s",pc->month);
printf("\nPlease input the title of the worker:");
scanf("%s",pc->title);
printf("\nPlease input:\n"
"zhichengbianhao,Jibengongzi,Zhiwugongzi,Subsidy(buzhu):\n");
scanf("%hd,%f,%f,%f",&pc->zcbh,&pc->jbgz,&pc->zwgz,&pc->subsidy);
i++;
printf("Continue or not ?[n or y](add salary)\n");
scanf("%1s",&ch);
if(ch=='n'||ch=='N')
{
flag=0;
pb->num2=i;
}
else flag=1;
}
pb=pb->p3;
i=0;
}
pa=pa->p1;
}
printf("\nNow,input informations of award of workers!\n");
pa=head;
i=0;
while(pa!=NULL){
printf("\nInput informations of award of workers in department %s:\n",pa->name);
pb=pa->p2;
while(pb!=NULL){
printf("\nInput informations of award of worker %s\n",pb->name);
pc=pb->p4;
while(pc!=NULL){
printf("\nInput informations of award in month %s\n",pc->month);
pc->p6=NULL;
flag=1;
while(flag)
{
pd=malloc(sizeof(struct award));
pd->p=pc->p6;
pc->p6=pd;
printf("\nPlease input Reason:\n");
scanf("%s",pd->reason);
printf("\nPlease input Amount:\n");
scanf("%f",&pd->amount);
i++;
printf("\nContinue or not ?[n or y](add award)\n");
scanf("%1s",&ch);
if(ch=='n'||ch=='N')
{
flag=0;
pc->num3=i;
}
else flag=1;
}
pc=pc->p5;
}
pb=pb->p3;
}
pa=pa->p1;
}
return (head);
}
struct department *open(void) /*打开一个文件*/
{
struct department *head=NULL,*pa,*taila;
struct employee *pb,*tailb;
struct salary *pc,*tailc;
struct award *pd,*taild;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -