charISBN[40];
floatprice;
intcount;
intlendnum;
}bbasic;
*
图书资料基本信息:
中图法分类号、图书编号、书名、作者(要考虑多个作者情况)、出版社、出版日期、ISBN、版次、定价、馆藏数、借阅数等。
*
typedefstructbook2*图书采购信息结构体*
{
charname[20];
charwriter[20];
chartime[15];
intnum;
floatprice;
floatmoney;
charbill[30];
}bpurchase;
*
图书采购信息:
书名、作者、采购日期、采购数量、采购单价、采购金额、发票号码、图书编号等。
*
typedefstructbook3*图书借阅信息结构体*
{
***************需要输入的信息*********
charname[20];
charperson[20];
charcompany[20];
charnum[20];*借书证号*
charbtime[15];
**************运算可得信息************
charrtime[15];
charfine[20];
}blend;
*
图书借阅信息:
借阅人、借阅人所在单位、借书证号、所借书名、借阅日期、归还日期、逾期罚款等。
借阅期限为一个月,逾期1天,罚款1角。
*
structlinklist
{
bbasicbinfo;
structlinklist*next;
};
intkey();
voidmenu();
void_window();
voidwords();
voidbox(int,int,int,int);
int_choose(intbot,inttop);
voidplay(int);
intreadsum();
voidadd();
voidaddbook();
voidaddbuy();
voidaddborrow();
voidmanage();
structlinklist*create();
voidmodify();
voiddelete();
voidinsert();
voidsearch();
voidsearchname();
voidsearchwriter();
voidorderw(bbasicbinfo[100]);
voidorderw(bbasicbinfo[100]);
int(intsum,bbasicbinfo[100],char*find);
int(void)
{
menu();
}
voidmenu()
{
inty;
_window();*显示窗口*
words();*显示菜单文字*
y=choose(7,19);*光标*
play(y);*根据键盘值操作*
}
void_window()*窗口初始化*
{
textbackground(BLUE);
textcolor(WHITE);
clrscr();
box();
}
voidwords()*显示菜单文字*
{
textcolor(WHITE);
gotoxy(30,7);
textbackground(RED);
cprintf("AddBookinfo");
textbackground(BLUE);
gotoxy(30,10);
cprintf("ManageBook");
gotoxy(30,13);
cprintf("SearchBook");
gotoxy(30,16);
cprintf("BookStatistic");
gotoxy(30,19);
cprintf("Exit");
gotoxy(35,22);
textcolor(LIGHTGRAY);
textbackground(BLUE);
cprintf("MainMenu");
gotoxy(25,2);
textcolor(RED);
REGSrg;
rg.rg.y;
}
upbar(inty)*光标上移*
{
inti;
typedefstructtexel_struct
{
unsignedcharch;
unsignedcharattr;
}texel;
texelt;
for(i=30;i<=48;i++)
{
gettext(i,y,i,y,&t);
t.attr=0x1f;
puttext(i,y,i,y,&t);
gettext(i,y-3,i,y-3,&t);
t.attr=0x4f;
puttext(i,y-3,i,y-3,&t);
};
gotoxy(30,y-3);
return;
}
downbar(inty)*光标下移*
{
inti;
typedefstructtexel_struct
{
unsignedcharch;
unsignedcharattr;
}texel;
texelt;
for(i=30;i<=48;i++)
{
gettext(i,y,i,y,&t);
t.attr=0x1f;
puttext(i,y,i,y,&t);
gettext(i,y+3,i,y+3,&t);
t.attr=0x4f;
puttext(i,y+3,i,y+3,&t);
};
gotoxy(30,y+3);
return;
}
voidplay(inty)*根据y的值选择操作*
{
switch(y)
{
case7:
add();
break;
case10:
manage();
break;
case13:
search();
break;
case16:
sta();
break;
case19:
exit
(1);
default:
printf("Error");exit(0);
}
}
voidadd()*显示"选择增加那种类型的信息"的窗口*
{
inty;
_window();
gotoxy(30,7);
textbackground(RED);
cprintf("AddBasicinfo");
textbackground(BLUE);
gotoxy(30,10);
cprintf("AddPurchaseinfo");
gotoxy(30,13);
cprintf("AddBorrowinfo");
gotoxy(30,16);
cprintf("Back");
gotoxy(25,2);
textcolor(RED);
("e:
\\sum.dat","rb"))!
=NULL)*读取图书基本信息数量sum*
{
fread(&sum,2,1,fp);
}
fclose(fp);
if((fp=fopen("e:
\\addbook.dat","ab"))==NULL)
{
printf("cannotwritetheaddbook.dat");
}
do
{
clrscr();
gotoxy(2,2);
cprintf("Pleaseinputtheclassficationofchineselibraryclassification:
");
scanf("%s",&binfo.type);
getchar();
gotoxy(2,4);
cprintf("Pleaseinputthebook'snumber:
");
scanf("%s",&binfo.num);
getchar();
gotoxy(2,6);
cprintf("Pleaseinputthebook'sname:
");
scanf("%s",&binfo.name);
getchar();
gotoxy(2,8);
cprintf("Pleaseinputthebook'swriter:
");
scanf("%s",&binfo.writer);
getchar();
gotoxy(2,10);
cprintf("Pleaseinputthethebook'spress:
");
scanf("%s",&binfo.press);
getchar();
gotoxy(2,12);
cprintf("Pleaseinputthebook'sedition:
");
scanf("%s",&binfo.edition);
getchar();
gotoxy(2,14);
cprintf("Pleaseinputthebook'spublishtime:
");
scanf("%s",&binfo.time);
getchar();
gotoxy(2,16);
cprintf("Pleaseinputtheprice:
");
scanf("%f",&binfo.price);
getchar();
gotoxy(2,18);
cprintf("PleaseinputtheISBNofthebook:
");
scanf("%s",&binfo.ISBN);
getchar();
gotoxy(2,20);
cprintf("Pleaseinputthecountofbooks:
");
scanf("%d",&binfo.count);
getchar();
gotoxy(2,22);
cprintf("Pleaseinputthelendnumberofthebook:
");
scanf("%d",&binfo.lendnum);
getchar();
gotoxy(10,25);
cprintf("PressN(n)tofinishaddbookorPressanykeytoaddmorebook.");
ky=key();
sum++;
if(fwrite(&binfo,sizeof(bbasic),1,fp)!
=1)
{
clrscr();
printf("cannotsavethedata.");
}
}while(ky!
=Key_N);
fclose(fp);
if((fp=fopen("e:
\\sum.dat","wb"))==NULL)
{
printf("cannotsavethesumofthebook.");
getch();
exit(0);
}
if(fwrite(&sum,2,1,fp)!
=1)
{
printf("failtowritethesum.dat.");
getch();
exit(0);
};
fclose(fp);
menu();
}
*中图法分类号、(要考虑多个作者情况)、出版社、出版日期、ISBN、版次、定价、馆藏数、借阅数等。
*
voidaddbuy()*增加图书购买信息*
{
intky;
FILE*fp;
bpurchasepinfo;
textbackground(BLUE);
textcolor(WHITE);
clrscr();
if((fp=fopen("e:
\\addbuy.dat","ab"))==NULL)
{
printf("cannotopentheaddbuydata.");
exit(0);
}
do
{
clrscr();
gotoxy(2,2);
cprintf("Pleaseinputthebook'sname:
");
scanf("%s",&pinfo.name);
gotoxy(2,4);
cprintf("Pleaseinputthebook'swriter:
");
scanf("%s",&pinfo.writer);
gotoxy(2,6);
cprintf("Pleaseinputthebook'sbuytime:
");
scanf("%s",&pinfo.writer);
gotoxy(2,8);
cprintf("Pleaseinputthenumberofthebookbuy:
");
scanf("%d",&pinfo.num);
gotoxy(2,10);
cprintf("Pleaseinputtheprice:
");
scanf("%f",&pinfo.price);
gotoxy(2,12);
cprintf("Pleaseinputtherealmoneyofbuythebook:
");
scanf("%f",&pinfo.money);
gotoxy(2,14);
cprintf("Pleaseinputthebillnumber:
");
scanf("%s",&pinfo.bill);
gotoxy(10,20);
cprintf("PressN(n)tofinishaddbookorPressanykeytoaddmorebook.");
ky=key();
if(fwrite(&pinfo,sizeof(pinfo),1,fp)!
=1)
{
clrscr();
printf("cannotsavethedata.");
}
}while(ky!
=Key_N);
fclose(fp);
menu();
}
voidaddborrow()*增加图书借阅信息*
{
intky;
FILE*fp;
blendlinfo;
textbackground(BLUE);
textcolor(WHITE);
clrscr();
if((fp=fopen("e:
\\addborrow.dat","ab"))==NULL)
{
printf("cannotopentheaddborrowdata.");
exit(0);
}
do
{
clrscr();
gotoxy(2,2);
cprintf("Pleaseinputthelendbook'sname:
");
scanf("%s",&linfo.name);
gotoxy(2,4);
cprintf("Pleaseinputtheborrower'sname:
");
scanf("%s",&linfo.person);
gotoxy(2,6);
cprintf("Pleaseinputthecompanyoftheborrower:
");
scanf("%s",&linfopany);
gotoxy(2,8);
cprintf("Pleaseinputtheborrower'scard:
");
scanf("%s",&linfo.num);
gotoxy(2,10);
cprintf("Pleaseinputtheborrowtime(ex.20100126):
");
scanf("%s",&linfo.btime);
gotoxy(2,12);
cprintf("Pleaseinputthereturntime(ex.20100508):
");
scanf("%s",&linfo.rtime);
gotoxy(10,20);
cprintf("PressN(n)tofinishaddbookorPressanykeytoaddmorebook.");
ky=key();
if(fwrite(&linfo,sizeof(linfo),1,fp)!
=1)
{
clrscr();
printf("cannotsavethedata.");
}
}while(ky!
=Key_N);
fclose(fp);
menu();
}
structlinklist*create()*创建链表*
{
inti,sum;
structlinklist*("e:
\\addbook.dat","rb"))==NULL)
{
printf("cannotopenthefile.");
}
for(i=0;i{
p2=p1;
p1=(structlinklist*)malloc(LEN);
p2->next=p1;
if(fread(&(p2->binfo),sizeof(bbasic),1,fp)!
=1)
{
printf("cannotsavethedata.");
}
}
p2->next=NULL;
fclose(fp);
returnofchineselibraryclassification:
");
scanf("%s",&(p->binfo.type));
getchar();
gotoxy(2,4);
cprintf("Pleaseinputthebook'snumber:
");
scanf("%s",&(p->binfo.num));
getchar();
gotoxy(2,6);
cprintf("Pleaseinputthebook'sname:
");
scanf("%s",&(p->binfo.name));
getchar();
gotoxy(2,8);
cprintf("Pleaseinputthebook'swriter:
");
scanf("%s",&(p->binfo.writer));
getchar();
gotoxy(2,10);
cprintf("Pleaseinputthethebook'spress:
");
scanf("%s",&(p->binfo.press));
getchar();
gotoxy(2,12);
cprintf("Pleaseinputthebook'sedition:
");
scanf("%s",&(p->binfo.edition));
getchar();
gotoxy(2,14);
cprintf("Pleaseinputthebook'spublishtime:
");
scanf("%s",&(p->binfo.time));
getchar();
gotoxy(2,16);
cprintf("Pleaseinputtheprice:
");
scanf("%f",&(p->binfo.price));
getchar();
gotoxy(2,18);
cprintf("PleaseinputtheISBNofthebook:
");
scanf("%s",&(p->binfo.ISBN));
getchar();