|
|
#include "admin.h"
|
|
|
#include <string.h>
|
|
|
|
|
|
void admin_BOOK_menu(int choice)
|
|
|
{
|
|
|
system("cls");
|
|
|
showtitle();
|
|
|
Settitle("|学生选课系统|管理员功能菜单|");
|
|
|
in_BOOK();
|
|
|
char o[8][30] = {"浏 览 现 有 课 程 信 息","选 课 与 退 课","修 改 课 程 信 息","删 除 课 程","新 增 课 程","全部用户信息","修改用户密码","修改当前密码"};
|
|
|
int i,j = 0;
|
|
|
for(i = 0; i < 8;i++)
|
|
|
{
|
|
|
if(choice == i)
|
|
|
setcolor(0,15);
|
|
|
setposition(LB+21,START+i);
|
|
|
printf("%s",o[j++]);
|
|
|
setcolor(11,0);
|
|
|
}
|
|
|
if(choice == 8)
|
|
|
setcolor(0,15);
|
|
|
setposition(LB+50,START+i-1);
|
|
|
printf("退出登陆");
|
|
|
setcolor(11,0);
|
|
|
strcpy(book1,ADMIN.book1);
|
|
|
strcpy(book2,ADMIN.book2);
|
|
|
strcpy(book3,ADMIN.book3);
|
|
|
booknum = ADMIN.booknum;
|
|
|
if(strcmp(book1,"o") == 0) book1[0] = 0;
|
|
|
if(strcmp(book2,"o") == 0) book2[0] = 0;
|
|
|
if(strcmp(book3,"o") == 0) book3[0] = 0;
|
|
|
setposition(LB,INFO+1);
|
|
|
printf("已选课程:%s %s %s",book1,book2,book3);
|
|
|
setposition(LB,INFO+2);
|
|
|
printf("(%d/3)",ADMIN.booknum);
|
|
|
}
|
|
|
|
|
|
void admin_BOOK_choice()
|
|
|
{
|
|
|
system("cls");
|
|
|
showtitle();
|
|
|
int choice = 0;
|
|
|
while(1)
|
|
|
{
|
|
|
admin_BOOK_menu(choice);
|
|
|
setposition(19,12);
|
|
|
printf("输入“↑”、“↓”“←”“→”,回车键确认");
|
|
|
HideCursor();
|
|
|
char a,b;
|
|
|
b = getch();
|
|
|
if(b==-32)
|
|
|
a = getch();
|
|
|
fflush(stdin);
|
|
|
if(a == UP && b == -32)
|
|
|
{
|
|
|
choice--;
|
|
|
}
|
|
|
else if(a == DOWN && b == -32)
|
|
|
{
|
|
|
choice++;
|
|
|
}
|
|
|
else if(a == LEFT && b == -32 && choice == 8)
|
|
|
{
|
|
|
choice--;
|
|
|
}
|
|
|
else if(a == LEFT && b == -32 && choice != 8)
|
|
|
{
|
|
|
choice = 8;
|
|
|
}
|
|
|
else if(a == RIGHT && b == -32 && choice == 8)
|
|
|
{
|
|
|
choice = 7;
|
|
|
}
|
|
|
else if(a == RIGHT && b == -32 && choice != 8)
|
|
|
{
|
|
|
choice = 8;
|
|
|
}
|
|
|
else if(b==13)
|
|
|
{
|
|
|
in();
|
|
|
if(choice == 0) conshow_BOOK_choice(1);
|
|
|
if(choice == 1) borrowandreturn_BOOK_choice(1);
|
|
|
if(choice == 2) alter_BOOK();
|
|
|
if(choice == 3) del_BOOK();
|
|
|
if(choice == 4) newone_BOOK();
|
|
|
if(choice == 5) showall();
|
|
|
if(choice == 6) change_user_all();
|
|
|
if(choice == 7) change_admin_password();
|
|
|
if(choice == 8) login1();
|
|
|
break;
|
|
|
}
|
|
|
else{
|
|
|
setposition(19,12);
|
|
|
printf("输入“↑”或“↓”,回车键确认");
|
|
|
}
|
|
|
if(choice<0) choice = 8;
|
|
|
if(choice>8) choice = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void admin_BOOK_info()
|
|
|
{
|
|
|
Settitle("|学生选课系统|管理员功能菜单|");
|
|
|
system("cls");
|
|
|
showtitle();
|
|
|
setposition(LB+5,START+1);
|
|
|
printf("管 理 员 功 能 提 示 :");
|
|
|
setposition(LB+5,START+2);
|
|
|
printf("输入所有信息长度超过20字符将自动省略超过部分");
|
|
|
setposition(LB+5,START+3);
|
|
|
printf("录入任何信息若包含空格将自动省略第一个空格及其后面部分");
|
|
|
setposition(LB+5,START+4);
|
|
|
printf("一次只能新增一门课,若要修改数量请使用修改功能");
|
|
|
setposition(LB+5,START+5);
|
|
|
printf("最多选三门课");
|
|
|
}
|
|
|
|
|
|
void admin_save()
|
|
|
{
|
|
|
if((FP_ADMIN = fopen(ADMIN.id,"w"))==NULL)
|
|
|
{
|
|
|
system("cls");
|
|
|
printf("\n\n\t未知错误");
|
|
|
system("pause");
|
|
|
exit(0);
|
|
|
}
|
|
|
fprintf(FP_ADMIN,"%s %s %s %s %d ",ADMIN.pass,ADMIN.book1,ADMIN.book2,ADMIN.book3,ADMIN.booknum);
|
|
|
if(fclose(FP_ADMIN))
|
|
|
{
|
|
|
system("cls");
|
|
|
printf("\n\t*————*");
|
|
|
printf("\n\t*未知错误*");
|
|
|
printf("\n\t*————*");
|
|
|
system("pause");
|
|
|
exit(0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void change_admin_password()
|
|
|
{
|
|
|
admin_menu_info();
|
|
|
Settitle("|学生选课系统|管理员功能|修改管理员密码|");
|
|
|
setposition(LB,INFO);
|
|
|
printf("原密码:");
|
|
|
char pass[20];
|
|
|
fflush(stdin);
|
|
|
scanf("%s",pass);
|
|
|
fflush(stdin);
|
|
|
setposition(LB,INFO+1);
|
|
|
if(strcmp(pass,ADMIN.pass) == 0)
|
|
|
{
|
|
|
printf("输入新密码:");
|
|
|
scanf("%s",pass);
|
|
|
char apass[20];
|
|
|
setposition(LB,INFO+2);
|
|
|
printf("确认新密码:");
|
|
|
scanf("%s",apass);
|
|
|
setposition(LB,INFO+3);
|
|
|
if(strcmp(apass,pass) == 0)
|
|
|
{
|
|
|
strcpy(ADMIN.pass,pass);
|
|
|
printf("修改成功!");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("两次输入的密码不一致!");
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
printf("原密码错误!");
|
|
|
}
|
|
|
admin_save();
|
|
|
admin_BOOK_choice();
|
|
|
}
|
|
|
void change_user_all()
|
|
|
{
|
|
|
admin_menu_info();
|
|
|
Settitle("|学生选课系统|管理员功能|修改用户密码|");
|
|
|
ID();
|
|
|
setposition(LB,INFO+3);
|
|
|
printf("输入新密码:");
|
|
|
char pass[20];
|
|
|
scanf("%s",pass);
|
|
|
if(strlen(pass) < 6)
|
|
|
{
|
|
|
setposition(LB,INFO+2+2);
|
|
|
printf("密码长度过短!");
|
|
|
setposition(LB,INFO+3+2);
|
|
|
system("pause");
|
|
|
admin_BOOK_choice();
|
|
|
}
|
|
|
char apass[20];
|
|
|
setposition(LB,INFO+2+2);
|
|
|
printf("确认新密码:");
|
|
|
scanf("%s",apass);
|
|
|
setposition(LB,INFO+3+2);
|
|
|
if(strcmp(apass,pass) == 0)
|
|
|
{
|
|
|
strcpy(change->pass,pass);
|
|
|
printf("修改成功!");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("两次输入的密码不一致!");
|
|
|
}
|
|
|
save();
|
|
|
admin_BOOK_choice();
|
|
|
}
|
|
|
|
|
|
void admin_menu_info()
|
|
|
{
|
|
|
Settitle("|学生选课系统|管理员功能菜单|修改功能|");
|
|
|
system("cls");
|
|
|
showtitle();
|
|
|
setposition(LB+5,START+1);
|
|
|
printf("管 理 员 修 改 功 能 提 示 :");
|
|
|
setposition(LB+5,START+2);
|
|
|
printf("输入所有信息长度超过20字符将自动省略超过部分");
|
|
|
setposition(LB+5,START+3);
|
|
|
printf("录入任何信息若包含空格将自动省略第一个空格及其后面部分");
|
|
|
setposition(LB+5,START+4);
|
|
|
printf("管理员密码不能为空,用户密码不能少于6位");
|
|
|
}
|