⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wuhan.cpp

📁 人事管理系统
💻 CPP
字号:

#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<stdio.h>
#include "graphics.h"
#include "conio.h"
#include "dos.h"
#define maxworker 100


FILE *fp;  /*定义全局变量fp,指向数据库文件 worker.txt*/

struct date1{      /*日期的结构,用于存储工人的生日,工作日期等*/
  int year;
  int month;
  int day;
};
struct address {  /*地址的结构, 用于存储工人的地址*/
  char province[10];
  char city[10];
  char street[20];
};
struct WORKER {       /*工人的资料总结构*/
 char name[20];
 enum {male,female}sex;
 struct date1 birthday;
 enum {elesch,middle,high,university,other}rofs;
 struct date1 workday;
 int workeri;
 char position[20];
 struct address addr;
 int workerj;
 char tel[13];
 };


/*从数据库中删除一个工人的资料*/

void del(int *i,struct WORKER *dp){
 char del_name[20],choice;
 int di,dj,mi;
 printf("Enter the worker's name to delete:");scanf("%s",del_name);

  /*调用search函数(在上面已经声明了的),搜索到的话就返回工人的id,没有的话就返回-1*/
 if((mi=search(*i,dp,1,del_name))==-1)return;
 printf("Are you sure to delete this profile?(y/n)");
 choice=getch();
 if(choice=='n')
   return;
 for(di=dj=0;di<*i;di++)
  if(di!=mi)
    dp[dj++]=dp[di];
--*i;
 }


/*下面就是主函数了*/
void main(void)
{
 struct WORKER profile[maxworker];
  int selection;
int GD=DETECT,GM;
  char c;
  int i=0,k=1;
  initgraph(&GD,&GM,"e:\\tc\\bgi");
  setbkcolor(LIGHTBLUE);
 if ((al=fopen("hzk16","rb"))==NULL)
     { printf("Can't open haz16,Please add it");
    getch(); closegraph(); exit(0);
     }
rectangle(20,20,620,460);
rectangle(10,10,630,470);
hz(200,80,40,2,10,"人事管理系统");/*数字依次为横坐标纵坐标字体间距字体大小字体颜色*/
hz(100,150,25,1,11,"长沙理工大学计算机系软件工程课程设计");
hz(100,200,25,1,11,"设计人员:安国兵姚金伶扬寒贺晓玲肖红吴涵");
hz(100,250,25,1,11,"按任意键进入");
getch();
closegraph();
	close(al);


  clrscr();
   initgraph(&GD,&GM,"e:\\tc\\bgi");
  setbkcolor(LIGHTBLUE);
 if ((al=fopen("hzk16","rb"))==NULL)
     { printf("Can't open haz16,Please add it");
    getch(); closegraph(); exit(0);
     }


  data_load(&i,profile);
  do
  { if(k!=1)
    {printf("\nPlease press any key to return to the main meun");
    getch();}
    k++;  

    clrscr();
    initgraph(&GD,&GM,"e:\\tc\\bgi");
    setbkcolor(LIGHTBLUE);
    hz(200,20,40,2,10,"人事管理系统");
    printf("\n\n\n\n\n");
    printf("\t\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
    printf("\t\t\t*1.Add one worker to the file\n");
    printf("\t\t\t*2.Delete one worker from the file\n");
    printf("\t\t\t*3.Search one worker from the file\n");
    printf("\t\t\t*4.Modify one worker's information\n");
    printf("\t\t\t*5.List all the profiles\n");
    printf("\t\t\t*6.Save new data\n");
    printf("\t\t\t*7.Sort the profiles\n");
    printf("\t\t\t*8.Reload data from database file\n");
    printf("\t\t\t*9.Delete all data\n");
    printf("\t\t\t*0.exit without save\n\n\n");
    printf("\t\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
    printf("\t\t\tPlease input your selection number:");

    scanf("%d",&selection);
    switch(selection)

	{
	  case 1:
	    add(&i,profile);
	    printf("\n\nin function main,i=%d",i);
	    break;
	  case 2:
	  del(&i,profile);
	  break;
	  case 3:
	  search(i,profile,1,"");
	  break;
	  case 4:
	  modify(i,profile);
	  break;
	  case 5:
	   list(i,profile);
	   break;
	 case 6:
	   save(i,profile);
	   break;
	 case 7:
	   my_sort(i,profile);
	   break;
	 case 8:
	   data_load(&i,profile);
	   break;
	 case 9:
	   cleardb(&i,profile);
	   break;
	  case 0:
	    printf("Are you sure to exit without save?New data that you enter will be lost!(y/n)");
	    c=getch();
	    if(c=='y'||'Y')exit(0);
	    break;
	  default:

	    printf("please enter the correct selection!");
	    return 0;
	 }
 }while(1);

}
 
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -