/***************************************************
* student manage system *
***************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<time.h>
#include<windows.h>
#define NAME 20
#define SEX 10
#define BIRTH 20
#define ADDR 20
#define POTO 16
#define DAK 7
#define SCHOOL 20
#define STUDENTMAX 100
typedef struct studentinfo
{
char name[NAME];
char sex[SEX];
char birth[BIRTH];
char addr[ADDR];
char poto[POTO];
char dak[DAK];
char school[SCHOOL];
};
typedef struct studentscore
{
char name[NAME];
int ID;
int score[6];
int aver;
int sum;
};
typedef struct allstudentinfo
{
struct studentinfo student1;
struct studentscore student2;
};
/***************************************************
* student info file *
* student score file *
* log student information *
* log student score *
***************************************************/
FILE *infofile=NULL;
FILE *scorefile=NULL;
//char filename1[]="E:\\Studentinfo.dat";
//char filename2[]="E:\\Studentscore.dat";
char filename1[]="Studentinfo.dat";
char filename2[]="Studentscore.dat";
/***************************************************
* checkcode() *
***************************************************/
int checkcode()
{
FILE *fp;
char co[20]={0};
char co1[20]={0};
int i;
if((fp=fopen("stu_code.dat","rb"))==NULL) /*身份验证*/
{
printf("please set your identify\n");
printf("passcode:");
scanf("%s",co);
/*
i=0;
while((co1[i]=getch())!='\r')
{
putchar('*');
i++;
}
co1[i]='\0';
*/
fp=fopen("stu_code.dat","wb+");
for(i=0;i<20;i++)
fwrite(&co[i],sizeof(char),1,fp);
fclose(fp);
return 0;
}
else
{
system("cls");
for(i=0;i<20;i++)
fread(&co[i],sizeof(char),1,fp);
fclose(fp);
printf("\n\n\n\t\t\t请输入你的密码:");
//scanf("%s",co1);
i=0;
while((co1[i]=getch())!='\r')
{
putchar('*');
i++;
}
co1[i]='\0';
if(strcmp(co,co1)!=0) /*密码校验*/
{
return 1;
}
system("cls");
}
return -1;
}
/***************************************************
* 修改密码 *
****************************************************/
void modifycode()
{
FILE *fp;
char co[20]={0};
char co1[20]={0};
char co2[20]={0};
int i;
if((fp=fopen("stu_code.dat","wb+"))==NULL)
{
printf("\a\n\n\n\n\n\n");
printf("\t--------------------------------------------------------------\n");
printf("\t| 请确认磁盘已满或stu_code件没有损坏、且不为空 |\n");
printf("\t--------------------------------------------------------------\n");
getch();
}
else
{
system("cls");
for(i=0;i<20;i++)
fread(&co[i],sizeof(char),1,fp);
printf("\n\n\n\t\t\t请输入你的新密码:");
scanf("%s",co1);
printf("\n\n\n\t\t\t请确认你的密码:");
scanf("%s",co2);
if(strcmp(co1,co2))
{
system("cls");
printf("\a\n\n\n\n\n\n");
printf("\t--------------------------------------------------------------\n");
printf("\t| 两次输入的密码不一样 修改失败 |\n");
printf("\t--------------------------------------------------------------\n");
getch();
fclose(fp);
return ;
}
else
{
for(i=0;i<20;i++)
fwrite(&co1[i],sizeof(char),1,fp);
fclose(fp);
system("cls");
printf("\a\n\n\n\n\n\n");
printf("\t--------------------------------------------------------------\n");
printf("\t| 密 码 修 改 成 功 |\n");
printf("\t--------------------------------------------------------------\n");
getch();
}
}
}
/***************************************************
* password() *
***************************************************/
void password()
{
int sign=0;
time_t start,end;
sign=checkcode(); /*************验证用户名 密码*****************/
if(sign==1)
{
system("cls");
printf("\n\n\n\n\n\n");
printf("\t\t%c-----------------------------------------------%c\n",017,017);
printf("\t\t|-----------------------------------------------|\n");
printf("\t\t|----------- 密码不正确 请重新登陆 -----------|\n");
printf("\t\t|-----------------------------------------------|\n");
printf("\t\t%c-----------------------------------------------%c\n\n\n",016,016);
start=time(NULL);
end=time(NULL);
while(end-start<2)
{
end=time(NULL);
}
exit(0);
}
else
{
system("cls");
printf("\n\n\n\n\n");
printf("\t\t-------------------------------------------------\n");
printf("\t\t|-----------------------------------------------|\n");
printf("\t\t| |\n");
printf("\t\t| 欢迎来到管理系统 |\n");
printf("\t\t| |\n");
printf("\t\t|-----------------------------------------------|\n");
printf("\t\t-------------------------------------------------\n");
printf("\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\t\t请稍等3秒后登陆管理系统主界面");
start=time(NULL);
end=time(NULL);
while(end-start<3)
{
end=time(NULL);
}
}
return ;
}
/***************************************************
* showmenu() *
****************************************************/
int showmenu()
{
int in;
char ch;
printf("\n\n");
system("cls");
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("请您正确选择:");
while(scanf("%d",&in)!=1) /*非数字的判断*/
{
while((ch=getchar())!='\n')
putchar(ch);
return in;
}
fflush(stdin);
return in;
}
/***************************************************
* submeun() *
****************************************************/
int submeun()
{
int in;
system("cls");
printf("\n\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");