目录
序
时间在流去,我们在长大。
嗨,这里是狐狸~~
今天是2022年的一月四日了,元旦小长假也过去了,新年新气象,新年新目标,我们要向前看,不要执意过去了,感谢过去,把握现在,展望未来,这是我们现在应该做的。好了,废话不多说,今天我们分享一个系统,确实也有许久没有分享过系统了,今天就给大家详细讲一下这个图书管理系统吧。
主要内容📝
开发一个图书信息管理系统,图书信息包括:图书编号、书名、作者、出版社、类别、出版时间、价格等基本信息(也可以根据自己情况进行扩充,比如是否借出、库存量等)。使之能提供以下基本功能:
(1)图书信息录入功能(图书信息用文件保存)--输入
(2)图书信息浏览功能--输出
(3)查询功能(至少一种查询方式)、排序功能(至少一种排序方式):
①按书名查询
②按作者名查询 按照价钱排序 按出版时间排序等等
(4)图书信息的删除与修改
扩展功能:可以按照自己的程度进行扩展。比如
(1)简单的权限处理
(2)报表打印功能
(3)甚至根据自己情况,可以加上学生信息,并扩充为图书借阅系统。
(4)模糊查询
(5)综合查询
(6)统计功能 比如统计处某一类别的图书信息 或 筛选出小于指定数量库存的图 书信息等等。
概要设计📝
1 图书录入可以录入图书名,作者,出版社,出版日期,价格!录入图书编号时函数就会判断此 编 号是否存在,若存在不能成功录入!
2 图书浏览可以浏览全部图书!
3 图书查询提供按图书编号模糊查询,按图书名关键字查询,按图书编号精确查询,按图书名精确 查询!模糊查询和关键字查询事通过比价字符串的相似度而实现的!
4 修改删除图书可以通过图书查询来查询操作的图书编号,通过编号操作!函数会提示用户是否调 用图书查询来找到自己想要操作的图书的编号。如果某一本图书已经被借阅那么用户就不能删 除 该图书!
5 借阅图书通过学号和图书编号进行借阅!如果该学号是第一次借阅那么会提示用户输入自己的姓 名,并存入student.txt,方便以后借阅与归还!
6 归还图书先提供学号,然后程序会输出该学号借阅的所有图书,然后再通过编号归还!
7 借阅查询可查询某个学生已借但未归还的图书!
项目源码📝
结构体
先建立结构体,定义结构体成员
typedef struct book/*图书结构体*/
{
char num[10]; /*书号*/
char name[10]; /*书名*/
char auth[10]; /*作者*/
int count;
int sum;
}Book;
typedef struct borrow/*借书结构体*/
{
char id[20];
char user[20];
char book[20];
char bookid[20];
struct borrow *next;
}BBnode,*BBlink;
struct user
{
char num[10];/* 学号 */
char pass[15];
char name[15];
char sex[10];
};
typedef struct unode
{
struct user data;
struct unode *next;
}Unode,*Ulink;
Unode *os;
登录界面函数
int login(Ulink l)
{
/*****************登陆窗口初始化****************************/
while(!flag)
{
char User_id[10],password[10],tmp;
int i=0;
User_id[0]='\0';
password[0]='\0';
textbackground(179);
clrscr();
gotoxy(33,23);
textcolor(YELLOW);
cputs("ESC = EXIT");
textcolor(WHITE);
textbackground(179);
box(1,1,80,24);
h_line(2,3,78);
gotoxy(15,2);
cputs("Login now please input the User__ID and Password");
bar_(30,10,23,5,5);
/******************账号过滤*********************/
while(User_id[0]=='\0')
{
gotoxy(31,11);
textcolor(YELLOW);
textbackground(5);
cputs("User__ID:");
gotoxy(31,13);
cputs("Password:");
textbackground(179);
textcolor(WHITE);
gotoxy(28,7);
cputs("please input the User__ID!");
textbackground(179);
textcolor(YELLOW);
gotoxy(27,11);
putch(272);
gotoxy(27,13);
putch(' ');
gotoxy(40,11);
tmp=getch();
if(tmp==27)
{
flg=27;
return 0;
}
while(tmp!='\r'&&i<=9&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57)))
{
textcolor(YELLOW);
textbackground(5);
putch(tmp);
User_id[i]=tmp;
i++;
tmp=getch();
if(tmp==27)
{
flg=27;
return 0;
}
}
User_id[i]='\0';
}
/**********************密码过滤****************************/
while(password[0]=='\0')
{
gotoxy(28,7);
textbackground(179);
textcolor(WHITE);
cputs(" input the password now ");
textbackground(179);
textcolor(YELLOW);
gotoxy(27,13);
putch(272);
gotoxy(27,11);
putch(' ');
gotoxy(40,13);
i=0;
tmp=getch();
if(tmp==27)
{
flg=27;
return 0;
}
while(tmp!='\r'&&i<=10&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57)))
{
textbackground(5);
putch('*');
password[i]=tmp;
i++;
tmp=getch();
if(tmp==27)
{
flg=27;
return 0;
}
}
password[i]='\0';
}
/*************把账号和密码进行对比验证**************/
if(!strcmp(User_id,"admin")&&!strcmp(password,"admin"))
{
return 2;
}
if(cmps(l,User_id,password))
{
return 1;
}
}
}
选择界面函数
void choose()
{
while(1)
{
textbackground(179);
clrscr();
gotoxy(33,2);
textcolor(WHITE);
cputs("Administrastor");
textcolor(YELLOW);
box(1,1,80,24);
h_line(2,3,78);
gotoxy(3,6);
cputs(">>>-------------------------1.User Management----------------------------<<<");
gotoxy(3,10);
cputs(">>>-------------------------2.Book Management----------------------------<<<");
gotoxy(3,14);
cputs(">>>-------------------------3.Borrow Books-------------------------------<<<");
gotoxy(30,22);
textcolor(RED);
cputs("Please Select!!!");
flg=getch();
if(flg=='2')
bookss();
if(flg=='1')
users();
if(flg=='3')
borrow();
if(flg==27)
{
flg=-1;
return;
}
}
}
void admin()
{
while(1)
{
choose();
if(flg=='1')
bookss();
if(flg=='2')
users();
if(flg=='3')
borrow();
if(flg==27)
{
return;
}
}
}
操作界面函数
void user(Ulink h)
{
int flag;
BBlink l,p,r;/* 连表 */
FILE *fp; /* 文件指针 */
int count=0;
l=(BBnode*)malloc(sizeof(BBnode));
l->next=NULL;
r=l;
fp=fopen(bfile,"rb");
if(fp==NULL)
{
fp=fopen(bfile,"wb");
}
while(!feof(fp))
{
p=(BBnode*)malloc(sizeof(BBnod