图书管理系统含源代码可以运行
图书馆管理系统源代码

以我给的标题写原创文档,最低1200字,要求以Markdown文本格式输出,不要带图片和AI、人工智能、Markdown、GPT等关键词,标题为:图书馆管理系统源代码# 图书馆管理系统源代码## 一、引言图书馆作为一个重要的知识资源和学术场所,对于学生和研究人员具有重要意义。
为了更好地管理图书馆资源和提供服务,图书馆管理系统应运而生。
本文将介绍图书馆管理系统的源代码设计和实现。
## 二、系统功能需求### 1. 登录功能- 提供管理员和用户登录功能- 管理员可进行图书管理、借阅管理等操作- 用户可查询图书信息、借阅情况等### 2. 图书管理- 添加新书籍信息- 修改或删除现有书籍信息- 查询图书信息,包括书名、作者、出版社等### 3. 借阅管理- 用户借阅图书- 用户归还图书- 管理员监管借阅情况### 4. 查询功能- 用户可以根据条件查询图书信息- 管理员可以查询借阅情况、用户信息等## 三、系统设计### 1. 数据库设计- 数据库包括图书信息表、用户信息表、借阅记录表等- 表之间建立关联,保证数据一致性和完整性### 2. 源代码结构```- books- README.md- book.js- bookRouter.js- users- README.md- user.js- userRouter.js- borrows- README.md- borrow.js- borrowRouter.js- index.js```### 3. 源代码逻辑- 使用Node.js构建后端服务- 使用Express框架处理路由和请求- 使用MongoDB作为数据库存储## 四、系统实现### 1. 登录功能```javascript// 用户登录router.post('/login', (req, res) => {// 处理登录逻辑});// 管理员登录router.post('/admin/login', (req, res) => { // 处理管理员登录逻辑});```### 2. 图书管理```javascript// 添加新书籍router.post('/addBook', (req, res) => {// 处理添加书籍逻辑});// 修改书籍信息router.put('/updateBook/:id', (req, res) => {// 处理修改书籍信息逻辑});// 删除书籍router.delete('/deleteBook/:id', (req, res) => {// 处理删除书籍逻辑});```### 3. 借阅管理```javascript// 用户借阅图书router.post('/borrowBook', (req, res) => {// 处理借阅图书逻辑});// 用户归还图书router.put('/returnBook/:id', (req, res) => {// 处理归还图书逻辑});```## 五、总结通过本文介绍,读者可以了解图书馆管理系统源代码的设计和实现逻辑。
图书管理系统程序代码

#include <stdio.h>#include <string.h>#include <stdlib.h>#define SIZE (struct booklist *)malloc(sizeof(struct booklist))//建立已借阅图书信息结构体struct borrow{char borbook_num[10];char borbook_name[22];char return_time[15];char stu_num[15];char stu_name[15];struct borrow *next;};//建立预借图书信息结构体struct prebor_stu{char prebook_num[10];char prestu_num[15];struct prebor_stu *next;};//建立图书结构体struct booklist{char num[10];char name[22];char zuozhe[15];char leibie[10];char pub_time[10];char price[10];char condition[10];struct booklist *next;};struct booklist *create(void); /*创建图书信息链表*/struct borrow *borrow_creat(struct booklist *head); //创建已借阅图书信息链表int pre_creat(struct booklist *head); //学生登录系统预借图书并将信息存入文件prebor_stulist.txtstruct prebor_stu *prebor_creat(void); //创建预借阅图书信息链表void printf1_(struct booklist *); //输出单个基本图书的数据void store(struct booklist *head); /*保存链表中的图书信息到文件booklist.txt*/void printfb1_(struct borrow *); //输出单个借出图书的部分数据void printfb_(struct borrow *p); //输出单个借出图书的数据void printfp1_(struct prebor_stu *); //输出单个被预借出图书的部分数据void printfp_(struct prebor_stu *); //输出单个被预借出图书的数据void printf_(struct booklist *,struct borrow *,struct prebor_stu *); /*2---输出链表中的图书信息*/struct booklist *load(void); //5---从文件读入图书信息struct booklist *num_paixu(struct booklist *); //4---按编号排序struct booklist *price_paixu(struct booklist *); //3---按价格顺序排序int kcnum(struct booklist *head); //6---统计库存数void chaxun1_(struct booklist *,struct borrow *,struct prebor_stu *); //7---查询图书的编号图书的信息,并输出void chaxun2_(struct booklist *,struct prebor_stu *,struct borrow *);//7---按作者查询信息并输出void chaxun3_(struct booklist *,struct prebor_stu *,struct borrow *); //7---查询某类别图书信息并自动输出void chaxun4_(struct borrow *,prebor_stu *,struct booklist *); //7---按学号查询借阅信息struct booklist *shanchu(struct booklist *,struct borrow *,struct prebor_stu *); //9---删除数据struct borrow *shanchu2_(struct borrow *,struct borrow *); //删除一个 struct borrow 结构体的数据struct prebor_stu *shanchu3_(struct prebor_stu *,struct prebor_stu *); //删除一个 struct prebor_stu 结构体的数据void xiugai(struct booklist *,struct borrow *,struct prebor_stu *); //10---修改数据void borstore(struct borrow *borrow_head); //保存已借阅图书信息到文件borrowlist.txt//重新保存修改后的预借阅信息到文件 prebor_stulist.txt (全部覆盖)void prestore(struct prebor_stu *pre_head);struct borrow *borload(void); //从文件提取信息创建已借阅图书源信息链表struct booklist *charu(struct booklist *head,struct borrow *borrow_head); //8---将图书的数据到顺序排放的链表中.且插入后也是顺序排放的struct booklist *scanf1_(void); // 输入单个图书源数据void exchange(struct booklist *,struct booklist *) ;//交换两个结构体内的内容struct borrow *tianjia1_(struct borrow *borrow_head,struct booklist *p); //添加一个 struct borrow 结构体的数据int main(void){int n, n1, x , k = 0, flag, flag1, x1;char ch;struct booklist *head = NULL; //图书信息链表头指针struct borrow *borrow_head = NULL ; //已借阅图书信息链表头指针struct prebor_stu *pre_head = NULL ; //预借图书信息链表头指针flag1 = 0; x = x1 = 1;while(x){system("cls");printf("***************************************************************************\n");printf("* >>>>>>>>>>>>>欢迎使用君宁图书管理系统<<<<<<<<<<<<<<< *\n");printf("* 0---退出系统 5---从文件录入数据 *\n");printf("* 1---录入数据 6---统计库存数 *\n");printf("* 2---输出信息 10---修改数据 7---查询功能 *\n");printf("* 3---按价格排序 8---增加数据 *\n");printf("* 4---按编号排序 9---删除数据 *\n");printf("***************************************************************************\n");printf("请选择功能:");scanf("%d", &n);getchar();switch(n){case 0: //0---退出系统{x = 0;printf("*******谢谢使用君宁图书管理系统!******\n");printf("****** 欢迎下次使用! ******\n");break;}case 1: //1---录入数据{while(x1){system("cls");printf("*******欢迎使用君宁图书信息录入系统*******\n");printf("*** 0---放弃录入 ****\n");printf("** 1---录入图书源信息 **\n");printf("* 2---录入借出图书信息 *\n");printf("** 3---录入预借图书信息 **\n");printf("******** 祝您使用愉快 ********\n");printf("请选择功能:");scanf("%d", &n1);getchar();switch(n1){case 0:{x1 = 0;break;}case 1:{head = create( ); /*创建图书信息链表*/printf("是否将源图书信息保存到文件booklist.txt!...(Y/N) :");ch = getchar();if(ch == 'y' || ch == 'Y')store(head);getchar();break;}case 2:{if(head == NULL ){printf("请先录入图书源信息!\n");getchar();break;}else{borrow_head = borrow_creat(head); //创建已借阅图书信息链表printf("是否将源图书信息保存到文件borrowlist.txt!...(Y/N) :" );ch = getchar();if(ch == 'y' || ch == 'Y')borstore(borrow_head);getchar();break;}}case 3:{if(head == NULL ){printf("请先录入图书源信息!\n");getchar();break;}else{flag = pre_creat(head);if(flag == 1)printf("没有录入预借图书信息!\n\n");if(flag == 2)pre_head = prebor_creat(); //创建预借阅图书信息链表getchar();break;}}default :{printf("输入错误指示!\n\n");break;}}}}case 2: //2---输出信息{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{printf_(head,borrow_head,pre_head);break;}}case 3: //3---按价格排序{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{head = price_paixu(head);printf("是否将排序后的源图书信息保存到文件booklist.txt!...(Y/N) :");ch = getchar();if(ch == 'y' || ch == 'Y')store(head);getchar();break;}}case 4: //4---按编号排序{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{head = num_paixu(head);printf("是否将排序后的源图书信息保存到文件booklist.txt!...(Y/N) :");ch = getchar();if(ch == 'y' || ch == 'Y')store(head);getchar();break;}}case 5: //11---从文件读取数据{head = load();if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{borrow_head = borload(); //从文件提取信息创建已借阅图书源信息链表pre_head = prebor_creat(); //创建预借阅图书信息链表getchar();break;}}case 6: //6---统计库存数{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{k = kcnum(head);printf("总共有%3d本图书!\n\n", k);getchar();break;}}case 7: //7---查询信息{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{while(x1){system("cls");printf("*******欢迎使用君宁图书信息查询系统*******\n");printf("****** 0---退出查询******\n");printf("***** 1---按编号*****\n");printf("**** 2---按作者****\n");printf("***** 3---按类别*****\n");printf("****** 4---按学号******\n");printf("******** 祝您使用愉快********\n");printf("******************\n");printf("********************\n");printf("请选择功能:");scanf("%d", &n1);getchar();switch(n1){case 0:{x1 = 0;break;}case 1:{chaxun1_(head,borrow_head,pre_head);getchar();break;}case 2:{chaxun2_(head,pre_head,borrow_head);getchar();break;}case 3:{chaxun3_(head,pre_head,borrow_head);getchar();break;}case 4:{chaxun4_(borrow_head,pre_head,head);getchar();break;}default :{printf("输入指示有误!\n\n");break;}}}}x1 = 1;break;}case 8:{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{head = charu(head,borrow_head);printf("是否将源图书信息保存到文件booklist.txt!...(Y/N) :");ch = getchar();if(ch == 'y' || ch == 'Y')store(head);getchar();break;}}case 9: //9---删除数据{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{head = shanchu(head,borrow_head,pre_head);borrow_head = borload();pre_head = prebor_creat();break;}}case 10: //10---修改数据{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{xiugai(head,borrow_head,pre_head);borrow_head = borload();getchar();break;}}default :{printf("输入错误指示.请重新输入!");getchar();break;}}}return 0;}/*创建图书源信息信息链表*/struct booklist *create(void){struct booklist *head, *tail, *p;char num[10],name[22], zuozhe[15], leibie[10], pub_time[10], price[10],condition[10];head = tail = p = NULL;printf("当输入图书编号为0时结束信息输入\n");printf("请输入图书编号:");gets(num);while(strcmp(num,"0") != 0){p = SIZE;printf("请输入书名:");gets(name);printf("请输入作者:");gets(zuozhe);printf("请输入类别:");gets(leibie);printf("请输入出版时间:");gets(pub_time);printf("请输入价格:");gets(price);printf("请输入借阅情况:");gets(condition);printf("\n");strcpy(p -> num, num);strcpy(p -> name, name);strcpy(p -> zuozhe, zuozhe);strcpy(p -> leibie, leibie);strcpy(p -> pub_time, pub_time);strcpy(p -> price, price);strcpy(p -> condition, condition);p -> next = NULL;if(head == NULL)head = p;elsetail -> next = p;tail = p;printf("请输入图书编号:");gets(num);}printf("图书源信息已建立链条!\n");return head;}//创建已借阅图书源信息链表struct borrow *borrow_creat(struct booklist *head) {struct booklist *p;struct borrow *borrow_head , *p1, *tail;borrow_head = p1 = tail = NULL;for(p = head; p != NULL; p = p -> next){p1 = (struct borrow *)malloc(sizeof(struct borrow));if(strcmp(p -> condition,"借出") == 0){printf("创建借出信息:\n");strcpy(p1 -> borbook_num ,p -> num);strcpy(p1 -> borbook_name ,p -> name);getchar();printf("借阅编号为%s的图书的借阅信息:\n",p -> num);printf("请输入应归还时间:");gets(p1 -> return_time);printf("请输入学生学号:");gets(p1 -> stu_num);printf("请输入学生姓名:");gets(p1 -> stu_name);printf("\n");p1 -> next = NULL;if(borrow_head == NULL)borrow_head = p1;elsetail -> next = p1;tail = p1;}}printf("成功创建已借出信息链表!\n\n");getchar();return borrow_head;}//保存已借阅图书信息到文件 borrowlist.txtvoid borstore(struct borrow *borrow_head){FILE *fp;struct borrow *p;if((fp = fopen("borrowlist.txt","w")) == NULL){printf("File open error! \n");exit(0);}p = borrow_head;while(p != NULL){fprintf(fp,"%16s%26s%16s%16s%16s\n",p -> borbook_num, p -> borbook_name, p -> return_time,p -> stu_num, p -> stu_name);p = p -> next;}fclose(fp);printf("文件成功保存到 borrowlist.txt 中!\n");getchar();}//从文件提取信息创建已借阅图书源信息链表struct borrow *borload(void){struct borrow *p, *tail, *head;FILE *fp;head = p = tail = NULL;if((fp = fopen("borrowlist.txt","r")) == NULL){printf("文件 borrowlist.txt 打开失败!\n");getchar();exit(0);}while(!feof(fp)){p = (struct borrow *)malloc(sizeof(struct borrow));fscanf(fp,"%16s%26s%16s%16s%16s\n",p -> borbook_num, p -> borbook_name, p -> return_time,p -> stu_num, p -> stu_name);if(head == NULL)head = p;elsetail -> next = p;tail = p;}tail -> next = NULL;fclose(fp);printf("已成功从文件 borrowlist.txt 提取信息创建已借阅图书源信息!\n");return head;}//录入预借图书信息并将信息存入文件 prebor_stulist.txtint pre_creat(struct booklist *head){struct booklist *b;struct prebor_stu *p;char a[10], c[15];int n, x = 1, flag = 1;FILE *fp;b = head;p = (struct prebor_stu *)malloc(sizeof(struct prebor_stu));printf("进入预借图书!(按回车键继续、、、)\n");getchar();while(x){printf("请输入要预借阅的图书编号:");gets(a);while((strcmp(b -> num ,a) != 0) && b -> next != NULL){b = b -> next;}if(strcmp(b -> num ,a) != 0){printf("没有找到编号为%s的图书!\n", a);printf("输入--0 结束录入!(输入其他数字继续录入...)\n\n");printf("请选择功能:");scanf("%d", &n);getchar();if(n == 0){x = 0;}getchar();}else{printf("请输入学号:");gets(c);strcpy(p -> prebook_num, a);strcpy(p -> prestu_num, c);if((fp = fopen("prebor_stulist.txt","a+")) == NULL){printf("File open error! \n");exit(0);}fprintf(fp,"%16s%16s\n",p -> prebook_num, p -> prestu_num);fclose(fp);flag = 2;printf("输入--0 结束录入!(输入其他数字继续录入...)\n\n");printf("请选择功能:");scanf("%d", &n);getchar();if(n == 0){x = 0;getchar();}}}return flag;}//重新保存修改后的预借阅信息到文件 prebor_stulist.txt (全部覆盖)void prestore(struct prebor_stu *pre_head){struct prebor_stu *p;FILE *fp;p = pre_head;if((fp = fopen("prebor_stulist.txt","w")) == NULL){printf("File open error! \n");exit(0);}while(p != NULL){fprintf(fp,"%16s%16s\n",p -> prebook_num, p -> prestu_num); p = p -> next;}fclose(fp);printf("文件成功保存到 prebor_stulist.txt 中!\n");getchar();}//从文件 prebor_stulist.txt创建预借阅图书信息链表struct prebor_stu *prebor_creat(void){struct prebor_stu *p, *tail, *head;FILE *fp;head = p = tail = NULL;if((fp = fopen("prebor_stulist.txt","r")) == NULL){printf("文件 prebor_stulist.txt 打开失败!\n");getchar();}while(!feof(fp)){p = (struct prebor_stu *)malloc(sizeof(struct prebor_stu));fscanf(fp,"%16s%16s\n",p -> prebook_num, p -> prestu_num);if(head == NULL)head = p;elsetail -> next = p;tail = p;}tail -> next = NULL;fclose(fp);printf("已从文件 prebor_stulist.txt 成功读取并建立预借阅图书信息!\n");getchar();return head;}/*2---保存链表中的图书信息到文件booklist.txt*/void store(struct booklist *head){FILE *fp;struct booklist *p;if((fp = fopen("booklist.txt","w")) == NULL){printf("File open error! \n");exit(0);}p = head;while(p != NULL){fprintf(fp,"%16s%26s%16s%16s%16s%16s%16s\n",p -> num, p -> name, p -> zuozhe, p -> leibie,p -> pub_time, p -> price, p -> condition);p = p -> next;}fclose(fp);printf("文件成功保存到 booklist.txt 中!\n");getchar();}// 输入单个图书源数据struct booklist *scanf1_(void) {struct booklist *p;p = SIZE;printf("请输入图书编号:");gets(p -> num);printf("请输入书名:");gets(p -> name);printf("请输入作者:");gets(p -> zuozhe);printf("请输入类别:");gets(p -> leibie);printf("请输入出版时间:");gets(p -> pub_time);printf("请输入价格:");gets(p -> price);printf("请输入借阅情况:");gets(p -> condition);return p;}//输出单个图书的数据void printf1_(struct booklist *p) {printf("编号:");puts(p -> num);printf("书名:");puts(p -> name);printf("作者:");puts(p -> zuozhe);printf("类别:");puts(p -> leibie);printf("出版时间:");puts(p -> pub_time);printf("价格:");puts(p -> price);printf("借阅情况:");}//输出单个借出图书的部分数据void printfb1_(struct borrow *p) {printf("应归还时间:");puts(p -> return_time);printf("借阅学生学号:");puts(p -> stu_num);printf("借阅学生姓名:");puts(p -> stu_name);}//输出单个借出图书的数据void printfb_(struct borrow *p) {printf("图书编号:");puts(p -> borbook_num);printf("书名:");puts(p -> borbook_name);printf("应归还时间:");puts(p -> return_time);printf("借阅学生学号:");puts(p -> stu_num);printf("借阅学生姓名:");puts(p -> stu_name);}//输出单个被预借出图书的部分数据void printfp1_(struct prebor_stu *p) {printf("预借图书的学生学号:"); puts(p -> prestu_num);}//输出单个被预借出图书的数据void printfp_(struct prebor_stu *p) {printf("图书编号:");printf("预借阅图书的学生学号:");puts(p -> prestu_num);}/*3---输出链表中的图书信息*/void printf_(struct booklist *head, struct borrow *borrow_head,struct prebor_stu *pre_head){struct booklist *p;struct borrow *b;struct prebor_stu *pre;int x = 1, n;p = head; b = borrow_head; pre = pre_head;while(x == 1){system("cls");printf("*******欢迎使用君宁图书信息输出系统*******\n");printf("* 0---退出 *\n");printf("* 1---输出图书源信息 *\n");printf("* 2---输出借出图书信息 *\n");printf("* 3---输出预借借图书信息 *\n");printf("******** 祝您使用愉快 ********\n");printf("请选择功能:");scanf("%d", &n);getchar();switch(n){case 0:{x = 0;break;}case 1:{if(head != NULL){printf("图书源信息如下:\n");do{printf1_(p);printf("\n\n");p = p -> next;}while(p != NULL);}getchar();break;}case 2:{if(borrow_head == NULL){printf("没有借出图书信息(按回车键继续、、、)!\n");getchar();break;}else{printf("借出图书信息如下:\n");do{printfb_(b);printf("\n\n");b = b -> next;}while(b != NULL);}printf("按回车键继续、、\n");getchar();break;}case 3:{if(pre_head == NULL){printf("没有预借图书信息(按回车键继续、、、)!\n");getchar();getchar();break;}else{printf("预借借图书信息如下:\n");do{printfp_(pre);printf("\n\n");pre = pre -> next;}while(pre != NULL);}printf("按回车键继续、、\n");getchar();break;}default :{printf("输入错误(按回车键继续、、、)!\n");getchar();break;}}}}//11---从文件读入图书信息struct booklist *load(void){struct booklist *p, *tail, *head;FILE *fp;head = p = tail = NULL;if((fp = fopen("booklist.txt","r")) == NULL){printf("文件 booklist.txt 打开失败!\n");getchar();exit(0);}while(!feof(fp)){p = SIZE;fscanf(fp,"%16s%26s%16s%16s%16s%16s%16s\n",p -> num, p -> name, p -> zuozhe, p -> leibie,p -> pub_time, p -> price,p -> condition);if(head == NULL)head = p;elsetail -> next = p;tail = p;}tail -> next = NULL;fclose(fp);printf("已成功读取文件 booklist.txt ,建立源图书信息链表!\n");return head;}//4---按编号排序并输出struct booklist *num_paixu(struct booklist *head){struct booklist *p, *p1, *tail;p1 = NULL;tail = SIZE;for(p = head;p -> next != NULL; p = p -> next){for(p1 = p ->next; p1 != NULL; p1 = p1 ->next){if(strcmp(p -> num,p1 -> num) > 0){exchange(tail,p1);exchange(p1,p);exchange(p,tail);}}}printf("图书已按编号排序成功,具体信息如下:\n");for(p = head; p != NULL; p = p -> next){printf1_(p);printf("\n");}return head;}//3---按价格排序struct booklist *price_paixu(struct booklist *head) {struct booklist *p, *p1, *tail;p1 = NULL;tail = SIZE;for(p = head;p -> next != NULL; p = p -> next){for(p1 = p ->next; p1 != NULL; p1 = p1 ->next){if(strcmp(p -> price,p1 -> price) > 0){exchange(tail,p1);exchange(p1,p);exchange(p,tail);}}}printf("图书已按价格排序成功,具体信息如下:\n");for(p = head; p != NULL; p = p -> next){printf1_(p);printf("\n");}return head;}//6---统计库存数int kcnum(struct booklist *head){int i = 0;struct booklist *p;for(p = head;p != NULL; p = p -> next)i++;return i;}//7---按编号查询信息并输出void chaxun1_(struct booklist *head,struct borrow *borrow_head,struct prebor_stu *pre_head){char a[10];struct booklist *p;struct borrow *b;struct prebor_stu *p1;int x1, x2;p = head; x1 = x2 = 0;printf("请输入要查询的图书编号:");gets(a);while((strcmp(p -> num ,a) != 0) && p -> next != NULL){p = p -> next;}if(strcmp(p -> num ,a) != 0)printf("没有找到编号为%s的图书!\n", a);else{for(b = borrow_head;b != NULL; b = b -> next){if(strcmp(b -> borbook_num ,a) == 0){x1 = 1;printf("您要查询的书已借出,其具体信息如下:\n");printfb1_(b); //输出单个借出图书的数据printf1_(p);}}for(p1 = pre_head;p1 != NULL; p1 = p1 -> next){if(strcmp(p1 -> prebook_num ,a) == 0){ x2 = 1;printf("您要查询的书已预借,其具体信息如下:\n");printfp1_(p1); //输出单个被预借出图书的数据printf1_(p);}}if(x1 == 0 && x2 == 0){printf("此书未被预借!\n\n");printf("您要查询的图书信息如下:\n");printf1_(p);}}}//7---按作者查询信息void chaxun2_(struct booklist *head,struct prebor_stu *pre_head,struct borrow *borrow_head){char a[10];struct booklist *p;struct borrow *b;struct prebor_stu *pre;int flag = 1, x1 ;printf("请输入要查询的图书的作者:");gets(a);for(p = head;p != NULL; p = p -> next){if(strcmp(p -> zuozhe,a) == 0){if(flag == 1){printf("您查询的%s的所有图书信息如下:\n\n",a);flag = -1;}printf1_(p);for(b = borrow_head;b != NULL; b = b -> next){if(strcmp(b -> borbook_num ,p -> num) == 0){printfb1_(b);}}x1 = 0;for(pre = pre_head; pre != NULL; pre = pre -> next){if(strcmp(pre -> prebook_num, p -> num) == 0){printf("此书已被%s学号的学生预借!\n",pre -> prestu_num );x1 = 1;}}if(x1 == 0){printf("此书未被预借!\n");x1 = 1;}printf("\n\n");}}if(flag == 1)printf("没有找到您要查询的的图书信息!\n\n");}//7---查询某类别图书信息并自动输出void chaxun3_(struct booklist *head,struct prebor_stu *pre_head,struct borrow *borrow_head){char a[10];struct booklist *p;struct prebor_stu *pre;struct borrow *b;int flag = 1 , x1;printf("请输入要查询的图书的类别:");gets(a);for(p = head;p != NULL; p = p -> next){if(strcmp(p -> leibie,a) == 0){if(flag == 1){printf("您查询的%s的所有图书信息如下:\n\n",a);flag = -1;}printf1_(p);for(b = borrow_head;b != NULL; b = b -> next){if(strcmp(b -> borbook_num ,p -> num) == 0){printfb1_(b);}}x1 = 0;for(pre = pre_head; pre != NULL; pre = pre -> next){if(strcmp(pre -> prebook_num, p -> num) == 0){printf("此书已被%s学号的学生预借!\n",pre -> prestu_num );x1 = 1;}}if(x1 == 0){printf("此书未被预借!\n");x1 = 1;}printf("\n\n");}}if(flag == 1)printf("没有找到您要查询的的图书信息!\n\n");}//7---按学号查询图书借阅信息并自动输出void chaxun4_(struct borrow *borrow_head,struct prebor_stu *pre_head,struct booklist *head){//建立图书编号结构体struct book_num{char booknum[10];struct book_num *next;};struct prebor_stu *p ;struct borrow *b;struct booklist *p2;char a[15];int i, j;i = j = 0;struct book_num *bnumhead1, *bnumhead2, *tail, *p1;bnumhead1 = bnumhead2 = tail = p1 = NULL;printf("请输入学生学号:");gets(a);for(p = pre_head; p != NULL; p = p -> next){if(strcmp(p -> prestu_num,a) ==0){i++;p1 = (struct book_num *)malloc(sizeof(struct book_num)); strcpy( p1 -> booknum, p ->prebook_num);if(bnumhead1 == NULL)bnumhead1 = p1;elsetail -> next = p1;tail = p1;p1 -> next = NULL;}}for(b = borrow_head;b != NULL; b = b -> next){if(strcmp(b -> stu_num,a) ==0){j++;p1 = (struct book_num *)malloc(sizeof(struct book_num)); strcpy( p1 -> booknum, b ->borbook_num);if(bnumhead2 == NULL)bnumhead2 = p1;elsetail -> next = p1;tail = p1;p1 -> next = NULL;}}if(i == 0 && j == 0)printf("没有您要查询学生的借阅信息!");else{if( j != 0){printf("该生一共借了%d本书,其借阅书的信息如下:\n", j);for( p1 = bnumhead2; p1 != NULL; p1 = p1 -> next){for(p2 = head; p2 != NULL; p2 = p2 -> next){if(strcmp(p1 -> booknum, p2 -> num) == 0){printf1_(p2);if(strcmp(p2 -> condition,"借出") ==0){for(b = borrow_head;b != NULL; b = b -> next)if(strcmp(b -> borbook_num,p2 -> num) ==0)printfb1_(b);}printf("\n");}}}}if( i != 0){printf("该生一共预借借了%d本书,其借阅书的信息如下:\n", i);for( p1 = bnumhead1; p1 != NULL; p1 = p1 -> next){for(p2 = head; p2 != NULL; p2 = p2 -> next){if(strcmp(p1 -> booknum, p2 -> num) == 0){printf1_(p2);if(strcmp(p2 -> condition,"借出") ==0){for(b = borrow_head;b != NULL; b = b -> next)if(strcmp(b -> borbook_num,p2 -> num) ==0)printfb1_(b);}printf("\n");}}}}}}//9---删除数据struct booklist *shanchu(struct booklist *head,struct borrow *borrow_head,struct prebor_stu *pre_head){struct booklist *p1 , *p2;struct borrow *b;struct prebor_stu *p;char a[10];p1 = p2 = head;printf("请输入要删除的图书编号:");gets(a);while((strcmp(p1 -> num ,a) != 0) && p1 -> next != NULL) {p2 = p1;p1 = p1 -> next;}if(strcmp(p1 -> num ,a) != 0)printf("没有找到要删除的图书信息!\n");else if(p1 == head){head = p1 -> next;printf("删除成功!\n");store(head);for(b = borrow_head; b != NULL; b = b -> next){if(strcmp(b -> borbook_num,a) == 0)borrow_head = shanchu2_(borrow_head,b);}for(p = pre_head; p != NULL; p = p -> next){if(strcmp(p -> prebook_num,a) == 0)pre_head = shanchu3_(pre_head,p);}}else{p2 -> next = p1 -> next;printf("删除成功!\n");store(head);for(b = borrow_head; b != NULL; b = b -> next){if(strcmp(b -> borbook_num,a) == 0)borrow_head = shanchu2_(borrow_head,b);}for(p = pre_head; p != NULL; p = p -> next){if(strcmp(p -> prebook_num,a) == 0)pre_head = shanchu3_(pre_head,p);}}return head;}//删除一个 struct borrow 结构体的数据struct borrow *shanchu2_(struct borrow *borrow_head,struct borrow *p) {struct borrow *p1 , *p2;p1 = p2 = borrow_head;while(strcmp(p1 -> borbook_num ,p -> borbook_num) != 0) {p2 = p1;p1 = p1 -> next;}if(p1 == borrow_head){borrow_head = p1 -> next;borstore(borrow_head);}else{p2 -> next = p1 -> next;borstore(borrow_head);}getchar();return borrow_head;}//添加一个 struct borrow 结构体的数据。
图书馆管理系统源代码

源程序清单1、文件名 login(login.frm)功能说明:整个系统的登陆界面,需要输入用户名和登陆密码才能进入到系统中,进行借阅等操作。
源代码:Option ExplicitDim cnt As IntegerPrivate Sub Command1_Click()Dim sql As StringDim rs_login As New ADODB.RecordsetIf Trim(Combo1.Text) = "" ThenMsgBox "没有这个用户", vbOKOnly + vbExclamation, ""Combo1.SetFocusElsesql = "select * from 系统管理 where 用户名='" & Combo1.Text & "'" rs_login.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_login.EOF = True ThenMsgBox "没有这个用户", vbOKOnly + vbExclamation, ""Combo1.SetFocusElseIf Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) ThenuserID = Combo1.Textrs_login.CloseUnload Meform1.ShowElseMsgBox "密码不正确", vbOKOnly + vbExclamation, ""txtpwd.SetFocusEnd IfEnd Ifcnt = cnt + 1If cnt = 3 ThenUnload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim connectionstring As Stringconnectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _"data source=book.mdb"conn.Open connectionstringcnt = 0End SubPrivate Sub txtuser_Change()End Sub2、文件名 form1(form1.frm)功能说明:整个系统的主界面,其中包括图书管理、读者管理、图书借阅管理、系统管理、关于,以及在这下面的子菜单。
RFID图书管理系统程序源代码

登陆界面using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Labrary{public partial class FormLogin : Form{public FormLogin(){InitializeComponent();}页脚内容1///<summary>///验¨¦证¡è控?件t///</summary>///<returns></returns>private bool ValidControl(){if (this.tbID.Text == ""){MessageBox.Show("请填写用户名!ê?");this.tbID.Focus();return false;}if (this.tbID.Text != "admin"){if (!UserManage.ObjUser.IsHasID(All.dbo, this.tbID.Text)){页脚内容2MessageBox.Show("不存在此用户!ê?");this.tbID.Text = "";this.tbID.Focus();return false;}}if (this.tbID.Text != "admin"){UserManage.ObjUser user= new UserManage.ObjUser(this.tbID.Text, All.dbo);if (user.PWD != this.tbPWD.Text){MessageBox.Show("密码错误!ê?");this.tbPWD.Text = "";this.tbPWD.Focus();return false;}页脚内容3}else{if (this.tbPWD.Text != "123456"){MessageBox.Show("密码错误!");this.tbPWD.Text = "";this.tbPWD.Focus();return false;}}return true;}private void gbtnCancel_Click(object sender, EventArgs e) {页脚内容4this.Close();}private void gbtnOK_Click(object sender, EventArgs e){//如¨?果?验¨¦证¡è控?件t通ª¡§过yif (ValidControl()){if (this.tbID.Text != "admin"){erLogin = new UserManage.ObjUser(this.tbID.Text, All.dbo);}else{erLogin = new UserManage.ObjUser(All.dbo);erLogin.ID = "admin"; = "管理员";页脚内容5}this.DialogResult = DialogResult.OK;this.Close();}}}}主界面using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;页脚内容6namespace Labrary{public partial class FormMain : Form{public const int WM_USER = 0x0400;public const int WM_GETBUFFER_LOOP = WM_USER + 2;private RFID_dll.Reader rdr;private RFID_dll.RFID rfid;List<string> rfids = new List<string>();int directionFlag = 0;//1进;出?FormInAndOut fiao = new FormInAndOut();public FormMain(){InitializeComponent();页脚内容7this.rdr = new RFID_dll.Reader();//this.rfid = new RFID_dll.RFID(rdr);}private void FormMain_Load(object sender, EventArgs e) {Init();}///<summary>///初始化///</summary>private void Init(){fiao.StartPosition = FormStartPosition.Manual;//多窗体在不同时间显示Screen[] screens = Screen.AllScreens;页脚内容8if (screens.Length == 2){List<Screen> listScreen = new List<Screen>();foreach (Screen screen in Screen.AllScreens){if (screen.Primary == false){listScreen.Add(screen);}}fiao.Location = listScreen[0].WorkingArea.Location;}SetMenJin("PicIn");fiao.Show();//toolStripStatusLabel2显示登陆用户名? toolStripStatusLabel2.Text = ;页脚内容9this.panel1.BackgroundImage = null;//菜单栏全部显示º?this.用®?户¡ì管¨¹理¤¨ªToolStripMenuItem.Visible = true; this.系¦Ì统ª3初?始º?化¡¥CToolStripMenuItem.Visible = true;this.应®|用®?模¡ê式º?ToolStripMenuItem.Visible = true;this.图ª?书º¨¦管¨¹理¤¨ªToolStripMenuItem.Visible = true; this.退ª?办㨬卡¡§ToolStripMenuItem.Visible = true; this.借¨¨阅?ToolStripMenuItem.Visible = true;this.门?禁?ToolStripMenuItem.Visible = true;SetPurview();this.toolStrip1.Visible = false;this.toolStrip2.Visible = false;this.toolStrip3.Visible = false;页脚内容10//rfid.OpenSerial();////是º?否¤?找¨°到Ì?门?禁?设¦¨¨备À?//if (rfid.ChangeWorkModel(2))//{// rfid.StartInventory(this.Handle.ToInt32(),2);//}}///<summary>///权限设置///</summary>private void SetPurview(){if (erLogin.ID == "admin"){this.应®|用®?模¡ê式º?ToolStripMenuItem.Visible = false;页脚内容11}else{this.用户管理¨ªToolStripMenuItem.Visible = false;this.系统初始化¡¥CToolStripMenuItem.Visible = false;this.读书管理¨ªToolStripMenuItem.Visible = false;this.退办卡¡§ToolStripMenuItem.Visible = false;this.借阅ToolStripMenuItem.Visible = false;this.门禁?ToolStripMenuItem.Visible = false;for (int i = 0; i < erLogin.Purview.Count; i++){string purview = erLogin.Purview[i];if (purview == "1"){this.图书管理¨ªToolStripMenuItem.Visible = true;}页脚内容12else if (purview == "2"){this.办退卡¡§ToolStripMenuItem.Visible = true;}else if (purview == "3"){this.借阅?ToolStripMenuItem.Visible = true;}else if (purview == "4"){this.门禁ToolStripMenuItem.Visible = true;}}}}private void用户管理¨ªToolStripMenuItem_Click(object sender, EventArgs e)页脚内容13{UserManage.FormUserList ful = new UserManage.FormUserList(All.conn);ful.ShowDialog();}private void修改密码?ToolStripMenuItem_Click(object sender, EventArgs e){UserManage.FormUserPwd fup = new UserManage.FormUserPwd(All.conn, erLogin);fup.ShowDialog();}private void tsbtnBookType_Click(object sender, EventArgs e){FormBookTypeList fbtl = new FormBookTypeList();fbtl.ShowDialog();}private void tsbtnBookAdd_Click(object sender, EventArgs e)页脚内容14{FormBookAdd fba = new FormBookAdd();fba.ShowDialog();}private void tsbtnBookManage_Click(object sender, EventArgs e){FormBookInfoList fbil = new FormBookInfoList();fbil.ShowDialog();}private void tsbtnBookStatistics_Click(object sender, EventArgs e){FormBookStatistics fbs = new FormBookStatistics();fbs.ShowDialog();}private void退ª?出?XToolStripMenuItem_Click(object sender, EventArgs e)页脚内容15{this.Close();}private void tsbtnCardAdd_Click(object sender, EventArgs e){FormCardInfo fci = new FormCardInfo(1, new ObjCardInfo());fci.ShowDialog();}private void tsbtnCardManage_Click(object sender, EventArgs e) {FormCardList fcl = new FormCardList();fcl.ShowDialog();}private void tsbtnAddTime_Click(object sender, EventArgs e){页脚内容16string rfid = RfidOperate.GetCard();if (rfid == ""){MessageBox.Show("请把借阅卡放到桌面读写器上!"); }else{if (ObjCardInfo.IsHas(rfid)){ObjCardInfo oci = new ObjCardInfo(rfid);FormCardInfo fci = new FormCardInfo(5, oci);fci.ShowDialog();}else{MessageBox.Show("没有此借阅卡信息");}页脚内容17}}private void tsbtnCardDelete_Click(object sender, EventArgs e) {string rfid = RfidOperate.GetCard();if (rfid == ""){MessageBox.Show("请把借阅卡到读写器上?");}else{if (ObjCardInfo.IsHas(rfid)){ObjCardInfo oci = new ObjCardInfo(rfid);int count = oci.NotReturnCount();页脚内容18if (count == 0){if (MessageBox.Show("是否决定退卡!ê?", "", MessageBoxButtons.YesNo) == DialogResult.Yes){oci.Delete();MessageBox.Show("退卡成功|!ê?");}}else{MessageBox.Show( + "还有一本" + count.ToString() + " 本书未归还不能退卡?");}}else{MessageBox.Show("没有此借阅信息?");页脚内容19}}}private void tsbtnJie_Click(object sender, EventArgs e){FormBookJie fbj = new FormBookJie(1);fbj.ShowDialog();}private void tsbtnHuan_Click(object sender, EventArgs e){FormBookHuan fbh = new FormBookHuan();fbh.ShowDialog();}private void图ª?书º¨¦管¨¹理¤¨ªToolStripMenuItem_Click(object sender, EventArgs e) {页脚内容20this.toolStrip1.Visible = true;this.toolStrip2.Visible = false;this.toolStrip3.Visible = false;this.panel1.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\pic\\1.jpg");}private void退ª?办㨬卡¡§ToolStripMenuItem_Click(object sender, EventArgs e){this.toolStrip1.Visible = false;this.toolStrip2.Visible = true;this.toolStrip3.Visible = false;this.panel1.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\pic\\2.jpg");}private void借¨¨阅?ToolStripMenuItem_Click(object sender, EventArgs e){页脚内容21this.toolStrip1.Visible = false;this.toolStrip2.Visible = false;this.toolStrip3.Visible = true;this.panel1.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\pic\\3.jpg");}private void门?禁?ToolStripMenuItem_Click(object sender, EventArgs e){//MenJinInit();//this.toolStrip1.Visible = false;//this.toolStrip2.Visible = false;//this.toolStrip3.Visible = false;//this.panel1.BackgroundImage = null;//rfid.OpenSerial();页脚内容22////是否找到门禁设备?//if (rfid.IsOpen)//{// rfid.StartInventory(this.Handle.ToInt32());//}}private void注销²ToolStripMenuItem_Click(object sender, EventArgs e) {erLogin = null;FormLogin fl = new FormLogin();if (fl.ShowDialog() != DialogResult.OK){this.Close();}else{页脚内容23Init();}}private void帮助¨²ToolStripMenuItem1_Click(object sender, EventArgs e){}private void系统初始化¡¥CToolStripMenuItem_Click(object sender, EventArgs e){if (MessageBox.Show("是否初始化数据库?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) {All.dbo.excuteSql("delete from lendtable");All.dbo.excuteSql("delete from bookinfo");All.dbo.excuteSql("delete from booktype");All.dbo.excuteSql("delete from librarycard");All.dbo.excuteSql("delete from usertable");页脚内容24MessageBox.Show("初始化完成?");}}private void关于ToolStripMenuItem_Click(object sender, EventArgs e){FormAbout fa = new FormAbout();fa.ShowDialog();}protected override void DefWndProc(ref System.Windows.Forms.Message m) {if (m.Msg == WM_GETBUFFER_LOOP){//启动if (this.timer1.Tag.ToString() == "0")页脚内容25{this.timer1.Start();this.timer1.Tag = "1";}string uid = "";string direction = "";bool personWithMultCard = false;rdr.GetLoopGetBufferData(m, ref uid, ref direction, ref personWithMultCard); if (uid != "0000000000000000"){//进if (direction == "In"){this.directionFlag = 1;this.rfids.Add(uid);}页脚内容26//出if (direction == "Out"){this.directionFlag = 2;this.rfids.Add(uid);}if (uid == "FFFFFFFFFFFFFFFF"){}}}base.DefWndProc(ref m);}页脚内容27private void timer1_Tick(object sender, EventArgs e){if (this.directionFlag == 1){for (int i = 0; i < this.rfids.Count; i++){if (ObjCardInfo.IsHas(this.rfids[i])){ObjCardInfo oci = new ObjCardInfo(this.rfids[i]);if (oci.IsOverTime()){SetMenJin("PicInOutTime");MenJinInit();return;}else页脚内容28{SetMenJin("PicIn");MenJinInit();return;}}}SetMenJin("PicInNoCard");MenJinInit();}else if (this.directionFlag == 2){for (int i = 0; i < this.rfids.Count; i++){if (ObjBookInfo.IsHas(this.rfids[i])){页脚内容29ObjBookInfo obi = new ObjBookInfo(this.rfids[i]);if (obi.LendStatus == "为借出?"){this.rdr.WarningOutput(false, false, true, false, false);SetMenJin("PicOut");MenJinInit();return;}}}MenJinInit();}}///<summary>///门禁初始化///</summary>页脚内容30private void MenJinInit(){this.rfids.Clear();this.directionFlag = 0;this.timer1.Tag = "0";this.timer1.Stop();}private void SetMenJin(string message){this.fiao.Controls.Clear();UserControlMenJin ucmj = new UserControlMenJin(message);ucmj.Dock = DockStyle.Fill;this.fiao.Controls.Add(ucmj);}页脚内容31private void FormMain_FormClosing(object sender, FormClosingEventArgs e) {//this.rfid.StopInventory();//this.rfid.CloseSerial();}}}图书统计using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;页脚内容32namespace Labrary{public partial class FormBookStatistics : Form{private int boolShelf;public FormBookStatistics(){InitializeComponent();BindTreeView();this.boolShelf = 0;BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo");this.cboBookLendStatus.SelectedIndex = 0;}页脚内容33private void BindTreeView(){this.treeView1.Nodes.Clear();TreeNode nodeRoot = new TreeNode();nodeRoot.Text = "全部书架¹";this.treeView1.Nodes.Add(nodeRoot);for (int i = 0; i < 4; i++){TreeNode nodeChild = new TreeNode();if (i == 0){nodeChild.Text = "第一书架¹";}if (i == 1){nodeChild.Text = "第二书架¨¹";页脚内容34}if (i == 2){nodeChild.Text = "第三书架¨¹";}if (i == 3){nodeChild.Text = "第四书架¨¹";}nodeRoot.Nodes.Add(nodeChild);}nodeRoot.Expand();}private void BindListView(string sql){this.listView1.Items.Clear();页脚内容35this.listView1.Columns.Clear();string[] headerText = new string[] { "标签,100", "所属分类¤¨¤,100", "书名,150", "作者,80", "借阅状态,80", "所在书架,80" };for (int i = 0; i < headerText.Length; i++){ColumnHeader header = new ColumnHeader();string headerName = headerText[i].Split(',')[0];int headerWidth = Convert.ToInt32(headerText[i].Split(',')[1]);header.Text = headerName;header.Width = headerWidth;this.listView1.Columns.Add(header);}DataTable dtb = All.dbo.getDataTable(sql);页脚内容36for (int i = 0; i < dtb.Rows.Count; i++){ObjBookInfo bookInfo = new ObjBookInfo(dtb.Rows[i]["RFID"].ToString());ListViewItem item = new ListViewItem(new string[] { bookInfo.RFID, , , bookInfo.Author, bookInfo.LendStatus, bookInfo.BookShelf });this.listView1.Items.Add(item);}ListViewItem itemCount = new ListViewItem(new string[] { "统ª3计?", "", "", "", "",dtb.Rows.Count.ToString() + "本À?" });this.listView1.Items.Add(itemCount);}private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e){if (e.Node.Text == "全部书架¨¹")页脚内容37{this.boolShelf = 0;BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo"));}if (e.Node.Text == "第一书架¨¹"){this.boolShelf = 1;BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='1'"));}if (e.Node.Text == "第二书架¨¹"){this.boolShelf = 2;BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='2'"));}if (e.Node.Text == "第三书架¨¹")页脚内容38{this.boolShelf = 3;BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='3'"));}if (e.Node.Text == "第四书架¨¹"){this.boolShelf = 4;BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='4'"));}}private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e){if (this.boolShelf == 0){if (this.cboBookLendStatus.SelectedIndex == 0)页脚内容39{BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo"));}if (this.cboBookLendStatus.SelectedIndex == 1){BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where LendStatus='1'"));}if (this.cboBookLendStatus.SelectedIndex == 2){BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where LendStatus='0'"));}}if (this.boolShelf > 0){if (this.cboBookLendStatus.SelectedIndex == 0)页脚内容40{BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='{0}'", this.boolShelf.ToString()));}if (this.cboBookLendStatus.SelectedIndex == 1){BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='{0}' and LendStatus='1'", this.boolShelf.ToString()));}if (this.cboBookLendStatus.SelectedIndex == 2){BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='{0}' and LendStatus='0'", this.boolShelf.ToString()));}}}}}页脚内容41借阅卡管理using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Labrary{public partial class FormCardList : Form{public FormCardList(){InitializeComponent();SetListView();页脚内容42}private void SetListView(){this.listView1.Items.Clear();List<ObjCardInfo> listCard = ObjCardInfo.GetAllCard();for (int i = 0; i < listCard.Count; i++){ObjCardInfo oci = listCard[i];ListViewItem item = new ListViewItem(oci.Rfid);item.Tag = oci;ListViewItem.ListViewSubItem subitem1 = new ListViewItem.ListViewSubItem();subitem1.Text = ;item.SubItems.Add(subitem1);页脚内容43ListViewItem.ListViewSubItem subitem2 = new ListViewItem.ListViewSubItem(); subitem2.Text = oci.Sex;item.SubItems.Add(subitem2);ListViewItem.ListViewSubItem subitem3 = new ListViewItem.ListViewSubItem(); subitem3.Text = oci.Brithday.ToString("yyyy年¨ºMM月?dd日¨?");item.SubItems.Add(subitem3);ListViewItem.ListViewSubItem subitem4 = new ListViewItem.ListViewSubItem(); subitem4.Text = oci.SID;item.SubItems.Add(subitem4);ListViewItem.ListViewSubItem subitem5 = new ListViewItem.ListViewSubItem(); subitem5.Text = oci.StartTime.ToString();item.SubItems.Add(subitem5);ListViewItem.ListViewSubItem subitem6 = new ListViewItem.ListViewSubItem(); subitem6.Text = oci.EndTime.ToString();页脚内容44item.SubItems.Add(subitem6);ListViewItem.ListViewSubItem subitem7 = new ListViewItem.ListViewSubItem();subitem7.Text = ;item.SubItems.Add(subitem7);this.listView1.Items.Add(item);}}private void SetListView(List<ObjCardInfo> listCard){this.listView1.Items.Clear();for (int i = 0; i < listCard.Count; i++){ObjCardInfo oci = listCard[i];页脚内容45ListViewItem item = new ListViewItem(oci.Rfid);item.Tag = oci;ListViewItem.ListViewSubItem subitem1 = new ListViewItem.ListViewSubItem(); subitem1.Text = ;item.SubItems.Add(subitem1);ListViewItem.ListViewSubItem subitem2 = new ListViewItem.ListViewSubItem(); subitem2.Text = oci.Sex;item.SubItems.Add(subitem2);ListViewItem.ListViewSubItem subitem3 = new ListViewItem.ListViewSubItem(); subitem3.Text = oci.Brithday.ToString("yyyy年¨ºMM月?dd日¨?");item.SubItems.Add(subitem3);ListViewItem.ListViewSubItem subitem4 = new ListViewItem.ListViewSubItem(); subitem4.Text = oci.SID;item.SubItems.Add(subitem4);页脚内容46ListViewItem.ListViewSubItem subitem5 = new ListViewItem.ListViewSubItem();subitem5.Text = oci.StartTime.ToString();item.SubItems.Add(subitem5);ListViewItem.ListViewSubItem subitem6 = new ListViewItem.ListViewSubItem();subitem6.Text = oci.EndTime.ToString();item.SubItems.Add(subitem6);ListViewItem.ListViewSubItem subitem7 = new ListViewItem.ListViewSubItem();subitem7.Text = ;item.SubItems.Add(subitem7);this.listView1.Items.Add(item);}}private void tsbtnExit_Click(object sender, EventArgs e)页脚内容47{this.Close();}private void tsbtnInsert_Click(object sender, EventArgs e){FormCardInfo fci = new FormCardInfo(1, new ObjCardInfo());if (fci.ShowDialog() == DialogResult.OK){SetListView();IsEnabled(false);}}private void IsEnabled(bool Enabled){//this.tsbtnAddTime.Enabled = Enabled;this.tsbtnUpdate.Enabled = Enabled;页脚内容48this.tsbtnDelete.Enabled = Enabled;this.tsbtnRecord.Enabled = Enabled;}private void listView1_SelectedIndexChanged(object sender, EventArgs e) {if (this.listView1.SelectedItems.Count > 0){IsEnabled(true);}else{IsEnabled(false);}}private void tsbtnAddTime_Click(object sender, EventArgs e){页脚内容49if (this.listView1.SelectedItems.Count > 0){ObjCardInfo oci = this.listView1.SelectedItems[0].Tag as ObjCardInfo;FormCardInfo fci = new FormCardInfo(5, oci);if (fci.ShowDialog() == DialogResult.OK){SetListView();IsEnabled(false);}}}private void tsbtnUpdate_Click(object sender, EventArgs e){if (this.listView1.SelectedItems.Count > 0){ObjCardInfo oci = this.listView1.SelectedItems[0].Tag as ObjCardInfo;页脚内容50。
图书借阅管理系统代码图书管理系统源代码

#include<stdio。
h>#include 〈stdlib。
h>#include <string.h>#define num 7 //全局定义void showmain() //显示菜单{printf("\n\n 欢迎使用图书借阅管理系统\n\n");printf(" 1、查询所有图书\n\n");printf(" 2、归还现有图书\n\n");printf(" 3、租借现有图书\n\n”);printf(”0、退出借书系统\n\n");printf(”请输入您所需的服务编号:”);}void viewbooks(int score[num],char name[num][100],char writter[num][100],double yajin[num],int free[num],double jiage[num],int flag[num]){int i;int j;for(i=1;i〈7;i++)//设置编号score[i]=i;yajin[1]=26.00;//将原图书的各项值保存yajin[2]=28.50;yajin[3]=98。
00;yajin[4]=79.80;yajin[5]=49。
00;yajin[6]=15.00;for(i=1;i<7;i++)//将原图书的各项值保存{free[i]=30;jiage[i]=0.5;}flag[1]=0; //flag为0代表已借出,为1代表未借出flag[2]=1;flag[3]=1;flag[4]=0;flag[5]=1;flag[6]=1;printf("编号\t|书名\t |作者\t|押金\t|免费天数\t|收费价格\t|出租状态\n"); //制表同时输出printf(”—--——-—---——-------—--——-————-——-———-—-—————--—————-—--——-——————-—-—---——-—\n”);for(i=1;i<7;i++){printf(”%d\t|%s\t|%s\t|%。
图书管理系统源代码

char tsname[60];
char tsbh[6];
char xm[10];
char tel[13];
char sfc[20];
int tssl;
int tsyj;
}js[n];
void main()
{
load();
help: //帮助系统
system("time /t");
system("color 2f");
printf("\t\t ");
printf("\n\t\t\t欢迎使用本系统: << %s >> ",user1);
system("time /t");
printf("\n");
printf("\t\t\t◢※※※※※※※※※※※※※※※◣\n");
printf("\t\t\t※※※※※※※※※※※※※※※※※\n");
printf("\t\t\t※ ※\n");
printf("\t\t\t※ ◎ (1) 图 书 查 询 ★ ※\n"); //有没有书名和书的总量
first1 = time(NULL); /* Gets system time */
system("cls");
system("date /t");
system("time /t");
system("color 47");
printf("\n");
原创c语言图书馆管理系统源代码

原创C语言图书馆管理系统源代码介绍图书馆作为一个重要的知识储备和学习场所,必须进行有效的管理和组织。
使用C语言编写的图书馆管理系统可以帮助图书馆实现自动化的借阅、归还和管理功能。
本文将介绍一个原创的C语言图书馆管理系统的源代码。
功能概述这个图书馆管理系统具有以下核心功能: - 图书管理:包括添加图书、删除图书、查询图书等操作。
- 借阅管理:可以进行借阅操作,记录借阅者和借阅时间。
- 归还管理:可以进行归还操作,并更新图书的可借状态。
- 用户管理:管理借阅者的信息,包括添加用户、删除用户、查询用户等操作。
数据结构设计该图书馆管理系统使用了以下几种数据结构: 1. 图书(Book)结构体:包含图书的ID、书名、作者、可借状态等字段。
2. 用户(User)结构体:包含用户的ID、姓名、地址等字段。
3. 借阅记录(BorrowRecord)结构体:包含借阅者ID、图书ID、借阅时间等字段。
系统流程整个系统的流程可以分为以下几个步骤: 1. 用户打开系统,进入主菜单。
2. 用户选择不同的功能选项(如图书管理、借阅管理、用户管理等)。
3. 根据用户选择的功能,进入相应的功能界面。
4. 用户可以根据提示,输入相应的信息进行图书管理、借阅管理或用户管理操作。
5. 用户完成操作后,可以选择返回主菜单或退出系统。
代码实现以下是一个简化版的C语言图书馆管理系统的源代码:```c #include <stdio.h>// 定义结构体 struct Book { int id; char name[50]; char author[50]; int isAvailable; };struct User { int id; char name[50]; char address[100]; };struct BorrowRecord { int userId; int bookId; char borrowDate[20]; };// 函数声明 void addBook(); void deleteBook(); void searchBook(); void borrowBook(); void returnBook(); void addUser(); void deleteUser(); void searchUser();int main() { int choice;do {// 显示主菜单printf(\。
图书信息管理系统设计源代码

头函数名:#include<stdio.h>#include<stdlib.h>#include<string.h>/*********图书信息结构体*********//***包括登录号,书名,作者名,分类号,出版单位,出版时间,价格等***/ struct bookinf{ int num; ******************************************************登录号char bname[20];***************************************书名char wname[10];***************************************作者名char clanum[14];***************************************分类号char pubcom[10];***************************************出版单位char pubtime[10];***************************************出版时间float price;*********************************************价格};一管理员登录系统模块:(1)来到图书信息管理系统页面void index(){char input; 注释:运行时printf("\n\n\t\t\t*****************************\n"); 直接进入printf("\t\t\t 图书信息管理系统\n"); 这个页面printf("\t\t\t*****************************\n\n\n");printf(" ------------------------------------------------------------------------------\n");printf("\t<按任意键进入>\n\t");input=getchar();}(2)管理员登陆进入功能菜单页面FILE *fp;struct manage pswd;if ((fp=fopen("password.txt","r"))==NULL) {printf("\n\n\n\tCannot open file!\n\t");}else{do{printf("\n\n\t请输入管理员帐号:");scanf("%s",name);printf("\n\n\t请输入管理员密码:");scanf("%s",password);fp=fopen("password.txt","r");fread(&pswd,sizeof(struct manage),1,fp);fclose(fp);w=strcmp(pswd.manage_name,name);k=strcmp(pswd.password,password);adm_servelist();}while (w!=0||k!=0);adm_servelist();}}(3)来到功能菜单页面{void book_add();void book_view();void change();void del();void book_search();void login();void pwchange();int in; 注释:菜单列出的服务种类char input; 从1,2,3,4,5,6 do 所对应的功能进行选择{printf("\n\n\n\t--欢迎使用信息管理系统--");printf("\n\n\t1.图书信息录入\n");printf("\t2.图书信息浏览\n");printf("\t3.图书信息查询\n");printf("\t4.图书信息删除\n");printf("\t5.图书信息修改\n");printf("\t6.退出管理模式\n");printf("\n\t请选择服务种类:");scanf("%d",&in);if (in!=1&&in!=2&&in!=3&&in!=4&&in!=5&&in!=6){printf("\n\t没有这项服务~\n");printf("\t按任意键重新选择");input=getchar();}}while (in!=1&&in!=2&&in!=3&&in!=4&&in!=5&&in!=6);switch (in){case 1: book_add(); break; 注释:选择自己所需要case 2: book_view(); break; 后摁下数字键则case 3: book_search(); break; 则进入此功能页面case 4: del(); break;case 5: change();break;case 6: login(); break;}}(3)图书信息录入功能模块void book_add(){void book_add();int i=0,j;FILE *fp;char input; 注释:输入的图书信息struct bookinf books; 是通过文件进行struct bookinf book_taxis[30]; 保存的printf("\n\n\n\t---请输入图书信息---\n\n");printf("\t登录号:");scanf("%d",&books.num);printf("\n\t书名:");scanf("%s",books.bname);printf("\n\t作者名:");scanf("%s",books.wname);printf("\n\t分类号:");scanf("%s",books.clanum);printf("\n\t出版单位:");scanf("%s",books.pubcom);printf("\n\t出版时间:");scanf("%s",books.pubtime);printf("\n\t价格:");scanf("%f",&books.price);if ((fp=fopen("book.txt","r"))!=NULL){do{fread(&book_taxis[i],sizeof(struct bookinf),1,fp);i=i+1;}while(!feof(fp));fclose(fp);for (j=0;j<=i;j++)if (books.num==book_taxis[j].num){printf("\n\n\n\t对不起,这个编号已经使用过了~\n");printf("\t按任意键返回管理菜单~");input=getchar();adm_servelist();break;}}if ((fp=fopen("book.txt","r"))==NULL){fp=fopen("book.txt","w");}else{fclose(fp);fp=fopen("book.txt","a");}fwrite(&books,sizeof(struct bookinf),1,fp);fclose(fp);printf("\n\n\n\t信息输入完毕~按任意键继续\n");input=getchar();adm_servelist();}(4)图书信息浏览功能模块void book_view(){void adm_servelist();void book_view();int inp,i=0,n=0;FILE *fp;char input;struct bookinf bookview[20];if ((fp=fopen("book.txt","r"))==NULL){printf("\n\n\n\t数据尚未初始化~~\n\n\t请在管理菜单中增加图书信息~~~\n"); printf("\n\t<按任意键返回管理菜单>\n\t");input=getchar();adm_servelist();}else{do{fread(&bookview[i],sizeof(struct bookinf),1,fp);i=i+1;}while (!feof(fp));fclose(fp);do{printf("\n\t--------共有%d条记录--------",i-1);printf("\n\n\t登录号: %d\n",bookview[n].num);printf("\n\t书名: %s\n",bookview[n].bname);printf("\n\t作者名: %s\n",bookview[n].wname);printf("\n\t分类号: %s\n",bookview[n].clanum);printf("\n\t出版单位: %s\n",bookview[n].pubcom);printf("\n\t出版时间: %s\n",bookview[n].pubtime);printf("\n\t价格: %f\n",bookview[n].price);printf("\n\n\t1.上一页\t2.下一页\t3.回目录\n");printf("\n\t请选择:");scanf("%d",&inp);switch (inp){case 1:{if (n==0){printf("\n\t已到达首页\n\t按任意键重新选择");input=getchar();}else n=n-1; break;}case 2:{if (n==i-2){printf("\n\t已到达最末页\n\t按任意键重新选择");input=getchar();}else n=n+1; break;}case 3:{adm_servelist();break;}default:{printf("\n\t没有这项服务\n\t按任意键重新选择");input=getchar();}}}while (inp!=3);}}(5)图书信息修改与删除功能模块修改:void change(int x){int inp,i=0,j;void book_search();FILE *fp,*fp1;char input;struct bookinf books,book_taxis[20];do{printf("\n\n\n\t注意:您确定要修改该记录吗?\n"); printf("\n\t1.是\t2.否\n");printf("\n\t请输入:");scanf("%d",&inp);if (inp!=1&&inp!=2){printf("\n\t对不起~没有这项服务~\n");printf("\t按任意键重新选择\n\t");input=getchar();}}while (inp!=1&&inp!=2);if (inp==2)book_search();if (inp==1){printf("\n\n\n\t---请输入图书信息---\n\n");printf("\t登录号:");scanf("%d",&books.num);printf("\n\t书名:");scanf("%s",books.bname);printf("\n\t作者名:");scanf("%s",books.wname);printf("\n\t分类号:");scanf("%s",books.clanum);printf("\n\t出版单位:");scanf("%s",books.pubcom);printf("\n\t出版时间:");scanf("%s",books.pubtime);printf("\n\t价格:");scanf("%f",&books.price);if ((fp1=fopen("book.txt","r"))!=NULL){do{fread(&book_taxis[i],sizeof(struct bookinf),1,fp1);i=i+1;}while(!feof(fp1));fclose(fp1);for (j=0;j<x;j++)if (books.num==book_taxis[j].num){printf("\n\n\n\t对不起,这个编号已经使用过了~\n");printf("\t按任意键返回管理菜单~");printf("0");input=getchar();book_search();break;}for (j=x+1;j<i-2;j++)if (books.num==book_taxis[j].num){printf("\n\n\n\t对不起,这个编号已经使用过了~\n");printf("1");printf("\t按任意键返回管理菜单~");input=getchar();book_search();break;}}book_taxis[x]=books;fp=fopen("book.txt","w");for (j=0;j<i-1;j++)fwrite(&book_taxis[j],sizeof(struct bookinf),1,fp);fclose(fp);printf("\n\n\t信息修改完成!按任意键返回");input=getchar();book_search();}}S删除:void del(int y){char input;FILE *fp;int inp,i=0,j;struct bookinf book_taxis[20];void book_search();void adm_servelist();do{printf("\n\n\n\t注意:您确定要删除该记录吗?\n"); printf("\n\t1.是\t2.否\n");printf("\n\t请输入:");scanf("%d",&inp);if (inp!=1&&inp!=2){printf("\n\t对不起~没有这项服务~\n");printf("\t按任意键重新选择\n\t");input=getchar();}}while (inp!=1&&inp!=2);if (inp==2)book_search();if (inp==1){if ((fp=fopen("book.txt","r"))!=NULL){do{fread(&book_taxis[i],sizeof(struct bookinf),1,fp);i=i+1;}while(!feof(fp));fclose(fp);}if (i>2){fp=fopen("book.txt","w");for (j=0;j<y;j++)fwrite(&book_taxis[j],sizeof(struct bookinf),1,fp);fclose(fp);fp=fopen("book.txt","a");for (j=y+1;j<i-1;j++)fwrite(&book_taxis[j],sizeof(struct bookinf),1,fp);fclose(fp);}else{remove("book.txt");}printf("\n\n\t记录已删除!\n\n\t按任意键返回\n\t");input=getchar();adm_servelist();}}(6)图书信息查询功能模块void book_search(){void adm_servelist();void id_search();void wr_search();void bn_search();char input;FILE *fp;int inp;if ((fp=fopen("book.txt","r"))==NULL){printf("\n\n\n\t数据尚未初始化~~\n\n\t请在管理菜单中增加图书信息~~~\n"); printf("\n\t<按任意键返回管理菜单>\n\t");input=getchar();adm_servelist();}else{do{printf("\n\n\n\t1.按图书登录号查询\n");printf("\n\t2.按图书作者查询\n");printf("\n\t3.按图书名查询\n");printf("\n\t4.回到主菜单\n");printf("\n\n\t请选择查询类别:");scanf("%d",&inp);if (inp!=1&&inp!=2&&inp!=3&&inp!=4){printf("\n\n\t没有这项服务~\n\t按任意键重新选择~");input=getchar();}}while (inp!=1&&inp!=2&&inp!=3&&inp!=4);fclose(fp);switch (inp){case 1: id_search(); break;case 2: wr_search(); break;case 3: bn_search(); break;case 4: adm_servelist(); break;}}}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
第一章需求分析1.1设计内容利用c++的文件操作能力设计开发一个小型的图书管信息管理系统,至少具有如下功能:查寻所有图书信息、通过输入图书编号来完成查找某一本图书信息、添加图书信息、删除图书信息以及通过学生学号实现图书借阅功能。
操作界面要符合用户的一般习惯,界面易于读者明白理解,图形或文本界面都可以。
1.2 设计任务要求:明确课程设计的目的,能根据课程设计的要求,查阅相关文献,为完成设计准备必要的知识;提高学生用高级语言进行程序设计的能力,重点提高用C++进行文件操作和绘图应用的编程技术水平;初步了解软件开发的一般方法和步骤;提高撰写技术文档的能力。
掌握模块化编程的基本方法与步骤;巩固和加深学生对C++课程基本知识的理解与掌握,培养学生利用C++进行软件操作的能力和技巧。
1.3 基本要求(1)通过提示菜单选择可以进行的操作。
(2)将图书的信息存入文件中,并命名为BookInfo.txt。
(3)将图书借阅情况信息存入文件中,并命名为SendInfo.txt。
(4)在本系统中可以进行管理系统包含的基本操作,其中包括:a)查看所有图书的信息。
b)输入一本图书的图书编号,从当前图书中进行查找,如果找到则显示该图书的相关信息,如果没有找到则给出提示信息。
c)添加一本图书的基本信息,通过输入图书编号,首先查找是否存在该图书编号的图书,如果存在则提示重新输入,否则将该图书按照顺序插入到相应位置。
d)删除一本图书的基本信息,通过输入图书编号,首先查找是否存在该图书编号的图书,如果存在则将该图书删除,否则给出提示信息,提示该图书不存在。
e)借阅一本图书,需要给出学号和图书编号,如果图书编号不存在则重新输入,直到输入正确为止,并将学号和相应的图书编号存入SendInfo.txt文件中。
(5)图书基本信息包括图书编号、书名、作者、出版社和价钱这些简单信息。
(6)图书信息文件中每一行存放一本图书的信息。
(7)借阅信息文件中每一行存放一本书的借阅情况。
(8)对老师.学生的信息进行登记处理,包括姓名、学号教师编号、学院班级等。
(9)对图书的金额进出管理,对一丢失的图书进行处罚、对超期归还的图书进行赔偿金额计算。
第二章系统功能设计2.1系统功能图1 系统功能图图书管理在生活中运用非常广泛,因此需要用许多的程序来对它们进行管理。
此程序包含了图书信息的录入、图书信息的浏览、图书的查询和排序、图书信息的删除与修改,借书,还书,统计等。
通过编译一个C++函数,其中包含一个主函数,多个子函数,主函数调用其余的子函数实现人们能够简易、快捷的了解并找到自己所学要的信息的功能。
1、查询所有图书信息:将所有图书信息包括编号、书名、出版社、作者、价格等显示在屏幕上。
2、查找一本图书的信息:通过输入图书编号完成图书信息的查找,并在屏幕上显示。
3、修改图书信息:通过输入编号,判断此图书是否存在,若不存在则提示用户重新输入图书编号。
4、删除图书信息:通过输入编号,判断此图书是否存在,若存在,则提示用户是否显示删除后的信息,若不存在则提示用户重新输入图书编号。
5、借书:通过输入图书编号,判断此图书是否存在,若不存在则提示用户重新输入图书编号,若图书已借出则提示用户是否继续借书,若没借出则将此图书的编号和学生的学号存入图书借阅文件中。
6、图书丢失:若图书丢失,对已丢失图书进行删除处理,并通过金额赔偿系统进行图书的金额赔偿管理。
7、金额赔偿:通过输入一丢失图书的编号对以丢失的图书的金额进行显示在屏幕上。
8、老师信息:通过选择读者信息中的老师信息可以对老师的信息进行添加.删除和修改。
最后通过输入老师的编号可以对老师的信息进行查询。
9、学生信息:通过选者读者信息中的学生信息可以对学生的信息进行添加,删除和下该。
最后通过输入学生的学号可以对学生的信息进行查询。
10、退出系统:返回主页面。
2.2 各个模块之间的主要关系图书信息管理系统可划分为7个模块:查询所有图书模块、查找一本图书信息模块、修改图书信息模块、删除图书信息模块、借阅图书模块、图书丢失模块、金额赔偿模块。
各模块之间均有着或多或少的联系,比如:查找一本图书信息模块、修改信息模块、删除信息模块、借阅图书模块都需要先判断该图书是否存在,然后再进行其它操作。
图书丢失后对已丢失图书的信息进行删除,删除后显示出图书的价格病进行金额赔偿。
理解了各模块之间的主要关系有利于程序的设计与完成,使程序的层次结构清晰,便于程序的编写、阅读和调试。
第三章详细设计3.1系统的总体流程图2 系统流程图系统的整体流程如上图所示,开始后显示输出菜单选择进入读者信息模块或者图书管理模块,读者信息中是对教师和学生的信息进行编辑如信息的添加、删除和修改。
主要是针对如果图书丢失或者超期归还时计算赔偿金额用的。
教师的归还图书期限为60天,学生为30天。
图书管理模块式针对图书进行管理,如显示出全部图书.即显示出未被借出的图书、添加一本图书信息、删除一本图书信息、显示一本图书信息产看一本图书是否被借、借阅图书功能、图书丢失功能、查看图书的价格对图书进行赔偿、金额管理管理计算出丢失图书的赔偿金额和超期归还图书的金额。
主要根据当前系统时间模块进行计算。
3.2 main() 函数模块根据图书馆信息管理系统的要求,可设计一个主函数,及定义多个用户自定义函数。
在主函数中定义全局变量,即是在函数外部定义的变量,其不属于某一个函数,而属于一个源程序文件,在整个程序内可以多次被引用。
通过将switch语句与break语句联合使用来实现多分支选择结构程序的设计。
运用fscanf语句在主函数中将文件中的内容赋给结构体变量,便于在自定义函数中对结构体的调用。
具体如下:在主函数中定义一个存放图书信息的结构体struct list{char num[20] ; /*图书编号*/char name[40] ; /*书名*/char author[40] ; /*作者*/char publish [40]; /*出版社*/ouble price; /*价格*/};以及各函数的申明void search_allinformation(struct list b[]) ; /*查看全部图书信息*/void check_bookinformation (struct list b[] );/*查找图书信息*/void add_bookinformation (struct list b[] ); /*添加图书信息*/double delete_bookinformation (struct list b[] );/*删除图书信息*/void borrow_book (struct list b[] ) ; /*借阅图书*/void lost_book(struct list b[]); /*图书丢失*/double cash_manage(); /*金额赔偿*/通过将switch语句与break语句联合使用来实现多分支选择结构程序的设计。
switch (choice1){ case 1 : search_allinformation (b);break ;case 2 : check_bookinformation( b );break ;case 3 : add_bookinformation (b );break ;case 4 : delete_bookinformation( b);break ;case 5 : borrow_book( b);break ;case 6 : lost_book( b);break ;case 7 : cash_manage();break ;case 0 : break ;}3.3 查询所有图书信息函数模块void search_allinformation (struct list b[])通过printf()语句将所有的图书信息包括包括编号、书名、出版社、作者、价格等信息显示在屏幕上。
运用for语句加printf()实现图书信息的循环输出显示。
3.4 查询一本图书信息函数模块void check_bookinformation(struct list b[] )用户先输入图书编号后,先用strcmp(s1, s2)函数进行比较两个字符串数组的大小,从而查找出该图书是否存在,若不存在则提示用户是否要继续查找,运用switch语句,若继续则再次调用函数本身进行第二次查找,直到找到为止,若否则结束循环,不再进行查找。
通过将switch语句与break语句联合使用来实现多分支选择结构程序的设计。
运用fscanf语句在主函数中将文件中的内容赋给结构体。
图3 查询一本图书函数功能模块图3.5添加图书信息函数模块void add_bookinformation(struct list b[] )输入图书的基本信息包括编号、书名、出版社、作者、价格,由于原有的图书信息是按照编号的大小顺序排列的,所以只需运用for循环和strcmp函数找出输入的图书应该插入的位置,再将所添加的图书信息插入即可。
图4 添加图书信息函数功能模块图3.6 删除图书信息函数模块void delete_bookinformation (struct list b[] )用户输入所要删除的图书编号,先查找该图书编号是否存在,若存在,这提示用户是否要显示删除后的信息,若不存在则提示重新输入。
图5 删除图书信息函数功能模块图3.7借阅图书模块void borrow_book(struct list b[] )用户先输入所借图书的编号,调用函数查找该图书有没有借出,若已借出,则提示用户该图书已借出,并提示用户是否继续借阅其他书籍。
若继续,则继续进行新的查找。
图6 借阅图书函数功能模块图3.8 图书丢失模块用户先输入以丢失图书的编号,调用函数删除图书的相关信息,并显示出图书的金额。
3.9 金额赔偿模块用户对以丢失的图书进行赔偿。
对以超期归还的图书用当前系统统时间系统进行计算正确的罚款数额。
3.10 老师学生信息管理系统对老师和学生的信息进行储存,其中有添加,删除和修改功能。
第四章调试及测试4.1 主菜单运行界面运行程序可进入系统菜单栏,可选择如图功能进行下一步的操作。
图7 主菜单运行界面图4.2 查询所有图书信息模块运行界面按1操作查询所有未被借出的图书信息,如图所示,选择下一步操作可对图书进行下一步操作。
图8 查询所有图书信息模块界面4.3 查找某一本图书信息模块运行界面按2选择按书名查询某一本图书信息,若图书编号存在则界面如下:图9 图书编号查询图书界面若图书不存在这显示该图书不存在。
4.4 添加图书信息模块运行界面按3选择,输入编号,界面如下:图10 按图书编号添加图书界面输入图书的编号.书名.作者出版社.和价格。