图书信息管理系统C结构体

随着高校图书数量的增长,图书借阅管理面临挑战。本文介绍了一套利用C#开发的图书信息管理系统,旨在简化学生借书流程,减轻图书馆管理人员工作负担,实现图书借阅信息的高效集中管理。
摘要由CSDN通过智能技术生成

1.目的

随着计算机的普及和信息技术的发展,人们的生活发生了日新月异的变化,各类计算机软件逐渐渗透到了社会的每个角落,大大地改善了人们的生活质量,提高了人们的工作效率。在高校中,图书借阅是学生获取知识的一个很重要的途径,如何既能方便学生借书,又能减轻图书馆管理人员的工作负担,高效地完成图书借阅管理工作,是一件非常重要的事情。

近几年来,随着生源的不断扩大,图书馆的规模也随之扩大,图书数量也相应地打量增加,有关图书借阅的各种信息成倍增加。面对如此巨大的信息量,图书馆管理人员很难支撑,因此,决定建立一套合理实用的图书借阅管理系统软件,以对图书借阅信息进行统一、集中的管理。

#include <stdio.h>
#include <stdlib.h>



/*头文件区*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <conio.h>

/*宏定义区*/
#define  ADMIN_password "123456" /*管理员登录密码*/

/*结构体声明区*/
typedef struct bookinfo/*系统图书信息 */
{
    char number[15];/*图书编号*/
    char name[30];/*图书名称*/
    char author[20];/*作者*/
    char press[30];/*出版社*/
    char category[20]; /*类别*/
    float price;/*单价*/
    int  quantity;/*馆藏量*/
 	int  time;/*借书次数*/
}BOOKINFO;

typedef struct bookgrasp/*会员借出的书籍信息*/
{
	char number[15];/*图书编号*/
    char name[30];/*图书名称*/
    char author[20];/*作者*/
    char press[30];/*出版社*/
    char category[20]; /*类别*/
    float price;/*单价*/
 	char account[30];/*借书者ID*/
}BOOKGRASP;

typedef struct member/*会员个人信息 */
{
	char name[30];
	char ID[20];
	char password[30];
	char sex[15];
	char password_key[30];
}MEMBER;

/*菜单函数区*/
void menu1();
void menu2();
void menu3();

/*工具函数区*/
int compare_password(char password[20]);/*密码比对函数 */
void clock_delay(); /*时间延时函数*/
void password_circle();/*密码框装饰函数*/
void find_account_circle();/*找回帐户弹出框函数*/

/*会员信息系统层级函数区*/
int user_account(char account[20]);/*个人账户信息*/
void member_log_up();/*会员注册函数*/
int member_log_in(char account[20]);/*会员登录函数*/
void ADMIN_watch_member();/*查看会员信息函数*/
void display_memberbook();/*查看所有图书借阅信息函数*/
int check_repeat_ID(char id_account[20]);/*检查账户重复性函数*/
void find_account();/*账户找回函数*/

/*图书信息系统层级函数区*/
void add_book();/*输入新进的图书信息*/
void delete_book();/*根据图书名称对图书信息进行删除*/
void modify_book();/*修改图书信息*/
void display_book();/*显示全部图书信息*/
void search_book();/*根据图书名称显示图书的信息*/
void borrow_book(char account[20]);/*借书*/
void return_book(char account[20]);/*还书*/
void display_price_lower();/*根据价格列出图书信息*/
void dispaly_popular();/*图书受欢迎度排行榜*/
int check_repeat_book(char number[30]);/*查重书籍编号*/

int main()
{
	int flag1=1,flag2=1,flag3=1;/* flag是判断条件,flag为 1 时为真,为 0 时为假 */
	char choice1,choice2,choice3;
	FILE *p1,*p2,*p3;

	system("title tyy");

    if((p1=fopen("library.txt","r"))==NULL)/*p1是图书管理系统的书籍信息文件指针*/
    {
      	p1=fopen("library.txt","w");/*不存在就新建*/
      	fclose(p1);
    }
	if((p2=fopen("infomember.txt","r"))==NULL)/*p2是图书管理系统的会员个人信息文件指针*/
	{
		p2=fopen("infomember.txt","w");
		fclose(p2);
	}
	if( (p3=fopen("memberbook.txt","r"))==NULL)/*p3是图书管理系统的会员书籍信息文件指针*/
	{
		p3=fopen("memberbook.txt","w");
		fclose(p3);
	}

	while(flag1)
	{
		system("cls");
		menu1();/*调出主菜单 */

  		printf("\n");
  		printf("请您选择(1-4):");
  		choice1=getch();
  		while(choice1!='1'&&choice1!='2'&&choice1!='3'&&choice1!='4')
  			choice1=getch();/*读取回车进行缓冲*/
  		printf("%c",choice1);/*能够显示出所选的选项*/
  		fflush(stdin);/*清空输入缓冲区,以便下一次数据的读取*/

  		if(choice1=='1')/*会员登录*/
		{
			int flag=0;
			char account1[20],account_choice;
			system("cls");
			password_circle();
			fflush(stdin);
			gets(account1);
			flag=member_log_in(account1);/*账户登录函数*/
			if(flag==2)
			{
				system("cls");
				password_circle();
				fflush(stdin);
				gets(account1);
				flag=member_log_in(account1);/*账户登录函数*/
			}
			if(flag==1)
			{
    		while(flag2&&flag3){
    		system("cls");
			menu2();
    		printf("\n");
    		printf("请您选择(1-8):");
    		choice2=getch();
    		while(choice2!='1'&&choice2!='2'&&choice2!='3'&&choice2!='4'&&choice2!='5'&&choice2!='6'&&choice2!='7'&&choice2!='8')
  				choice2=getch();
  			printf("%c",choice2);

   			switch(choice2)
    		{
    			case '1':search_book(); break;
    			case '2':borrow_book(account1); break;
    			case '3':return_book(account1); break;
    			case '4':display_book(); break;
    			case '5':display_price_lower();break;
    			case '6':dispaly_popular();break;
    			case '7':if(user_account(account1))
    						{
								printf("\n\n\t\t\t登录信息改变,请重新登录...");
       		       	  	 		clock_delay();
       		       	  	 		flag3=0;
							}
						 break;
    			case '8':flag2=0;
					     printf("\n\n\t\t\t正在退出用户界面...");
       		       	  	 clock_delay();
						 break;
				default:break;/*虽然压根不会读到default情况,但是怕后来开发者漏掉新加的case的while处理,所以加上*/
    				}
				}
			}else{
				system("cls");
				find_account_circle();/*装饰弹出框函数*/
				fflush(stdin);
				account_choice=getch();
				while(account_choice!='Y'&&account_choice!='y'&&account_choice!='N'&&account_choice!='n')
      	    		account_choice=getch();
      			printf("%c",account_choice);
				printf("\n");
				if(account_choice=='Y'||account_choice=='y')
					find_account();/*账户找回函数*/
			}
			flag2=1,flag3=1;
		}

		else if(choice1=='2')/*会员注册*/
		{
			system("cls");
			printf("\n\n\n\t\t\t正在进入用户注册界面...");
			clock_delay();
     	   member_log_up();
		}

		else if(choice1=='3')/*管理员登录*/
		{
			if(compare_password(ADMIN_password))
			{
				printf("\n\n\t\t\t\t  --输入密码正确!--\n\n\t\t\t\t==正在进入管理员界面==\n");
     	  	 	clock_delay();
				while(flag2){
				system("cls");
				menu3();
				printf("\n");
				printf("请您选择(1-8):");
				choice3=getch();
				while(choice3!='1'&&choice3!='2'&&choice3!='3'&&choice3!='4'&&choice3!='5'&&choice3!='6'&&choice3!='7'&&choice3!='8')
  					choice3=getch();
  				printf("%c",choice3);

 				switch(choice3)
				{
					case '1':add_book(); break;
					case '2':delete_book(); break;
   					case '3':modify_book(); break;
   					case '4':search_book(); break;
   					case '5':display_book(); break;
   					case '6':ADMIN_watch_member();break;
   					case '7':display_memberbook();break;
   					case '8':flag2=0;
					     	 printf("\n\n\t\t\t正在退出管理员界面...");
         	     	  		 clock_delay();
							 break;
   					default:break;/*虽然压根不会读到default情况,但是怕后来开发者漏掉新加的case的while处理,所以加上*/
   					}
  				}
  			}
  			else{
  				printf("\n\n\t\t\t\t  --输入密码错误!--\n");
     		   	clock_delay();
			}
			flag2=1;
 		}



 		else if(choice1=='4')/*退出系统*/
 		{
 			flag1=0;
		}
	}
	fflush(stdin);
	system("cls");
	printf("你已经安全退出系统!(按任意键关闭界面)\n\n\t欢迎您的再次使用!\n\n\n");
	getch();
	return 0;
}

void menu1()
{
	system("color f4");
	printf("\n\n");
	printf("\t\t\t *=======================================*\n");
	printf("\t\t\t|  * - * - - *  Welcome图书馆 * - * - - * |\n");
	printf("\t\t\t| *                                     * |\n");
	printf("\t\t\t| |  [1]   会员登录                     | |\n");
	printf("\t\t\t| *                                     * |\n");
	printf("\t\t\t| |  [2]   会员注册                     | |\n");
	printf("\t\t\t| *                                     * |\n");
	printf("\t\t\t| |  [3]   管理员登录                   | |\n");
	printf("\t\t\t| *                                     * |\n");
	printf("\t\t\t| |  [4]   退出系统                     | |\n");
	printf("\t\t\t| *                                     * |\n");
	printf("\t\t\t|  * - * - * - * - * - * - * - * - * - *  |\n");
	printf("\t\t\t *=======================================*\n");
}
void menu2()
{
	system("color f4");
	printf("\n\n");
	printf("\t\t\t *=====================================*\n");
    printf("\t\t\t| | * - * - * -会-员-界-面- * - * - * | |\n");
    printf("\t\t\t| *                                   * |\n");
    printf("\t\t\t| |  [1]   查找图书信息               | |\n");
    printf("\t\t\t| *  [2]   借阅图书                   * |\n");
    printf("\t\t\t| |  [3]   归还图书                   | |\n");
    printf("\t\t\t| *  [4]   书库所有图书信息           * |\n");
    printf("\t\t\t| |  [5]   价位书籍推荐               | |\n");
    printf("\t\t\t| *  [6]   图书受欢迎度排行榜         * |\n");
    printf("\t\t\t| |  [7]   您的账户信息               | |\n");
    printf("\t\t\t| *  [8]   退出用户界面               * |\n");
    printf("\t\t\t| |                                   | |\n");
    printf("\t\t\t| * - * - * - * - * - * - * - * - * - * |\n");
	printf("\t\t\t *=====================================*\n");
}
void menu3()
{
	system("color f4");
	printf("\n\n");
	printf("\t\t\t *======================
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值