?? wuhan.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;
};
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 + -