mfc界面的图书管理系统.docx

上传人:b****5 文档编号:3599855 上传时间:2022-11-24 格式:DOCX 页数:19 大小:260.79KB
下载 相关 举报
mfc界面的图书管理系统.docx_第1页
第1页 / 共19页
mfc界面的图书管理系统.docx_第2页
第2页 / 共19页
mfc界面的图书管理系统.docx_第3页
第3页 / 共19页
mfc界面的图书管理系统.docx_第4页
第4页 / 共19页
mfc界面的图书管理系统.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

mfc界面的图书管理系统.docx

《mfc界面的图书管理系统.docx》由会员分享,可在线阅读,更多相关《mfc界面的图书管理系统.docx(19页珍藏版)》请在冰豆网上搜索。

mfc界面的图书管理系统.docx

mfc界面的图书管理系统

《数据结构》课程设计

图书管理

1.设计目的

“数据结构”是计算机科学与技术专业一门十分重要的专业技术基础课,计算机科学各领域及有关的应用软件都要使用到各种数据结构。

对于从事计算机科学及其应用的科技工作者来说,数据结构与算法是必须透彻地掌握的重要基础。

学习数据结构与算法的最终目的是解决实际的应用问题,特别是非数值计算类型的应用问题。

课程设计是加强学生实践能力的一个强有力手段。

课程设计所安排的题目,在难度和深度方面都大于平时的上机训练,要求同学在完成设计和编写中小型软件的过程中,深化对数据结构与算法课程中基本概念、理论和方法的理解;训练综合运用所学知识处理实际问题的能力,强化面向对象的程序设计理念;使同学的程序设计与调试水平有一个明显的提高。

课程设计要求学生在完成程序设计的同时能够撰写比较规的设计报告。

严格实施课程设计这一环节,对于学生基本程序设计素养的培养和软件工作者工作作风的训练,将起到显著的促进作用。

2.问题描述

采用VisualC++编程语言开发工具和MFC,设计并实现图书管理系统。

该系统实现了图书管理中的添加,查询,删除,全部查询,退出等功能,以及汇总图书清单,包括对书籍各项信息的汇总。

 

3.需求分析

3.1数据需求

图书信息:

书名,所属类型,作者,定价,出版日期以及ISBN。

3.2基本功能需求

1.汇总图书清单,包括对书籍各项信息的汇总;(各项信息包括书名,所属类型,作者,定价,出版日期以及ISBN。

2.对书籍信息的增、删、查、全部查询等功能。

其中删除功能主要依靠第一无二的ISBN,查询功能可以依靠任何一种图书信息(即书名,所属类型,作者,定价,出版日期以及ISBN任意一种)。

3.3非功能性需求

用户界面需求:

简洁、易用、易懂、友好的用户界面。

硬件要求:

装有VisualC++6.0的计算机。

可靠性需求:

保证用户在正常使用本系统时,用户的操作或误操作不会产生数据的丢失。

 

4.概要设计

4.1数据结构

用结构struct定义图书信息,用链表实现对图书信息的存储及维护。

以文件的形式保存图书信息到硬盘。

 

4.2系统包含的函数

函数原型:

voidCAddDlg:

:

OnButtonAdd()

功能:

在链表结尾添加一个结点并将链表信息存入文件“图书管理.txt”

函数原型:

voidCChaxunDlg:

:

OnButtonChaxun()

功能:

完成查找用户信息的功能并在编辑框和用户列表中显示出来

函数原型:

voidCDelDlg:

:

OnButton1()

功能:

删除链表和用户列表的当前结点

函数原型:

voidCLookDlg:

:

OnButtonDialog()

功能:

在编辑框和用户列表中显示全部书籍出来

 

4.3函数间的关系

1.进入程序调用booklist()从硬盘读取数据,并将信息放入链表中。

2.用函数CDelDlg:

:

OnButton1()删除链表和用户列表的当前结点。

3.可用函数CAddDlg:

:

OnButtonAdd()在链表结尾添加一个结点并在用户列表中显示

4.CChaxunDlg:

:

OnButtonChaxun()可实现按不同方式进行图书查询。

5.CLookDlg:

:

OnButtonDialog()在编辑框和用户列表中显示全部书籍出来。

 

4.4系统功能模块图

 

图4-1系统功能模块图

5.详细设计

5.1结构体的详细定义

classbooklist

{

public:

CStringbookname;//书名

CStringcongshuname;//丛书种类

CStringwriter;//作者

CStringprice;//价格

CStringdateyear;//出版年份

CStringdatemonth;//出版月份

CStringISBN;

booklist*next;

};

5.2系统函数详细介绍

增加书籍:

voidCAddDlg:

:

OnButtonAdd()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

UpdateData();

externbooklist*head_book;

if(m_bookname==""||m_congshuname==""||m_isbn==""||m_month==""||m_price==""||m_writer==""||m_year=="")

MessageBox("请填写完整图书信息");

else

{

booklist*p=head_book;

booklist*Book=newbooklist;

Book->next=NULL;

Book->bookname=m_bookname;

Book->congshuname=m_congshuname;

Book->datemonth=m_month;

Book->dateyear=m_year;

Book->ISBN=m_isbn;

Book->price=m_price;

Book->writer=m_writer;

if(head_book==NULL)

head_book=Book;

else

{

if(p->ISBN>m_isbn)

{

Book->next=head_book;

head_book=Book;

}

else

{

while(p->next)

{

if(p->next->ISBN>m_isbn)

{

Book->next=p->next;

p->next=Book;

break;

}

p=p->next;

}

}

if(p->next==NULL)

p->next=Book;

}

MessageBox("添加成功");

char*pszFileName=".\\data.txt";

CStdioFilemyFile;

CFileExceptionfileException;

CStringstr;

if(!

myFile.Open(pszFileName,CFile:

:

modeCreate|CFile:

:

modeReadWrite,&fileException))

{

MessageBox("打开失败");

TRACE("Cannotopenfile%s,error=%u\n",pszFileName,fileException.m_cause);

}

myFile.SeekToEnd();

myFile.WriteString("书名,丛书名,作者,定价(元),出版年月,ISBN");

myFile.WriteString("\n");

//externbooklist*head_book;

for(p=head_book;p;p=p->next)

{

str.Format("%s,%s,%s,%s,%s.%s,%s",p->bookname,p->congshuname,p->writer,p->price,p->dateyear,p->datemonth,p->ISBN);

myFile.SeekToEnd();

myFile.WriteString(str);

myFile.WriteString("\n");

}

//DestroyWindow(this);

CDialog:

:

OnCancel();

}

}

BOOLCAddDlg:

:

OnInitDialog()

{

CDialog:

:

OnInitDialog();

//TODO:

Addextrainitializationhere

m_isbn="978-7-115-";

UpdateData(FALSE);

returnTRUE;//returnTRUEunlessyousetthefocusto//acontrol

//EXCEPTION:

OCXPropertyPagesshould//returnFALSE

}

voidCAddDlg:

:

OnCancel2()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

m_bookname=="";

m_congshuname=="";

m_isbn=="";

m_month=="";

m_price=="";

m_writer=="";

m_year=="";

UpdateData(FALSE);

}

查询书籍:

BOOLCChaxunDlg:

:

OnInitDialog()

{

CDialog:

:

OnInitDialog();

LONGlStyle;

lStyle=GetWindowLong(m_list.m_hWnd,GWL_STYLE);//获//取当前窗口style

lStyle&=~LVS_TYPEMASK;//清除显示方式位

lStyle|=LVS_REPORT;//设置style

SetWindowLong(m_list.m_hWnd,GWL_STYLE,lStyle);//设置//style

DWORDdwStyle=m_list.GetExtendedStyle();

dwStyle|=LVS_EX_FULLROWSELECT;//选中某行使整行高亮//(只适用与report风格的listctrl)

dwStyle|=LVS_EX_GRIDLINES;//网格线(只适用与report//风格的listctrl)

//dwStyle|=LVS_EX_CHECKBOXES;//item前生成checkbox控件

m_list.SetExtendedStyle(dwStyle);//设置扩展风格

m_list.InsertColumn(0,"书名",LVCFMT_LEFT,190);//插入列

m_list.InsertColumn(1,"丛书名",LVCFMT_LEFT,100);

m_list.InsertColumn(2,"作者",LVCFMT_LEFT,120);

m_list.InsertColumn(3,"定价",LVCFMT_LEFT,50);

m_list.InsertColumn(4,"出版日期",LVCFMT_LEFT,80);

m_list.InsertColumn(5,"ISBN",LVCFMT_LEFT,140);

//TODO:

Addextrainitializationhere

m_bookname="不限";

m_isbn="不限";

m_price="不限";

m_year="不限";

m_month="不限";

m_writer="不限";

m_congshuname="不限";

UpdateData(FALSE);

returnTRUE;//returnTRUEunlessyousetthefocus//toacontrol

//EXCEPTION:

OCXPropertyPagesshouldreturnFALSE

}

voidCChaxunDlg:

:

OnButtonChaxun()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

m_list.DeleteAllItems();

inti=0;//标记查找到的本数

CStringstr;

externbooklist*head_book;

//m_ListBox.ResetContent();

UpdateData();

intnRow;

for(booklist*p=head_book;p;p=p->next)

{if(m_bookname==""||m_bookname=="不限"||m_bookname==p->bookname)

if(m_congshuname==""||m_congshuname=="不限"||m_congshuname==p->congshuname)

if(m_writer==""||m_writer=="不限"||m_writer==p->writer)

if(m_price==""||m_price=="不限"||m_price==p->price)

if(m_isbn==""||m_isbn=="不限"||m_isbn==p->ISBN)

if(m_year==""||m_year=="不限"||m_year==p->dateyear)

if(m_month==""||m_month=="不限"||m_month==p->datemonth||m_month==p->datemonth.Left

(2)||(m_month==p->datemonth.Left

(1)&&p->datemonth.Mid(1,1)=='('))

{

str.Format("%s",p->bookname);

m_ListBox.AddString(str);

str.Format("%s.%s",p->dateyear,p->datemonth);

nRow=m_list.InsertItem(0,p->bookname);//插入行

nRow=m_list.InsertItem(0,"sb");//插入行

m_list.SetItemText(nRow,1,p->congshuname);//设置数据

m_list.SetItemText(nRow,2,p->writer);//设置数据

m_list.SetItemText(nRow,3,p->price);//设置数据

m_list.SetItemText(nRow,4,str);//设置数据

m_list.SetItemText(nRow,5,p->ISBN);//设置数据

i++;

}

}

if(i==0)

MessageBox("无此书");

}

删除书籍:

voidCDelDlg:

:

OnButton1()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

UpdateData();

intdelbooknum=0;

CStringstr;

externbooklist*head_book;

booklist*q,*p=head_book;

//MessageBox(head_book->ISBN);

while(p->ISBN==m_isbn)

{

q=p;

p=p->next;

head_book=p;

delbooknum++;

deleteq;

}

CStringstr1;

if(head_book->next!

=NULL)

{

for(booklist*p=head_book;p;p=p->next)

{

if(p->next!

=NULL&&p->next->ISBN==m_isbn)

{str1.Format("书名:

%s\nISBN:

%s\n",p->next->bookname,p->next->ISBN);

p->next=p->next->next;

delbooknum++;

}

}

}

if(delbooknum==0)

MessageBox("无此书","警告");

else

{

str.Format("%s%d%s","已删除",delbooknum,"本");

MessageBox(str1+str);

char*pszFileName=".\\data.txt";

CStdioFilemyFile;

CFileExceptionfileException;

if(!

myFile.Open(pszFileName,CFile:

:

modeCreate|CFile:

:

modeReadWrite,&fileException))

{

MessageBox("打开失败");

TRACE("Cannotopenfile%s,error=%u\n",pszFileName,fileException.m_cause);

}

myFile.SeekToEnd();

myFile.WriteString("书名,丛书名,作者,定价(元),出版年月,ISBN");

myFile.WriteString("\n");

//externbooklist*head_book;

for(booklist*p=head_book;p;p=p->next)

{str.Format("%s,%s,%s,%s,%s.%s,%s",p->bookname,p->congshuname,p->writer,p->price,p->dateyear,p->datemonth,p->ISBN);

myFile.SeekToEnd();

myFile.WriteString(str);

myFile.WriteString("\n");

}

CDialog:

:

OnCancel();

}

}

voidCDelDlg:

:

OnCancel()

{

//TODO:

Addextracleanuphere

CDialog:

:

OnCancel();

}

BOOLCDelDlg:

:

OnInitDialog()

{

CDialog:

:

OnInitDialog();

//TODO:

Addextrainitializationhere

m_isbn="978-7-115-";

UpdateData(FALSE);

returnTRUE;//returnTRUEunlessyousetthefocustoacontrol

//EXCEPTION:

OCXPropertyPagesshould//returnFALSE

}

查询全部书籍:

BOOLCLookDlg:

:

OnInitDialog()

{

CDialog:

:

OnInitDialog();

LONGlStyle;

lStyle=GetWindowLong(m_list.m_hWnd,GWL_STYLE);//获取当前窗口style

lStyle&=~LVS_TYPEMASK;//清除显示方式位

lStyle|=LVS_REPORT;//设置style

SetWindowLong(m_list.m_hWnd,GWL_STYLE,lStyle);//设置style

DWORDdwStyle=m_list.GetExtendedStyle();

dwStyle|=LVS_EX_FULLROWSELECT;//选中某行使整行高//亮(只适用与report风格的listctrl)

dwStyle|=LVS_EX_GRIDLINES;//网格线(只适用与//report风格的listctrl)

//dwStyle|=LVS_EX_CHECKBOXES;

//item前生成checkbox控件

m_list.SetExtendedStyle(dwStyle);//设置扩展风格

//TODO:

Addextrainitializationhere

externbooklist*head_book;

intbooknum=0;

externlength;

CStringstr;

m_list.InsertColumn(0,"书名",LVCFMT_LEFT,190);//插入列

m_list.InsertColumn(1,"丛书名",LVCFMT_LEFT,100);

m_list.InsertColumn(2,"作者",LVCFMT_LEFT,120);

m_list.InsertColumn(3,"定价",LVCFMT_LEFT,50);

m_list.InsertColumn(4,"出版日期",LVCFMT_LEFT,90);

m_list.InsertColumn(5,"ISBN",LVCFMT_LEFT,);

intnRow;

for(booklist*q=head_book;q;q=q->next)

{

str.Format("%s.%s",q->dateyear,q->datemonth);

nRow=m_list.InsertItem(0,q->bookname);

//插入行

//nRow=m_list.InsertItem(0,"sb");//插入行

m_list.SetItemText(nRow,1,q->congshuname);

//设置数据

m_list.SetItemText(nRow,2,q->writer);

//设置数据

m_list.SetItemText(nRow,3,q->price);//设置数据

m_list.SetItemText(nRow,4,str);//设置数据

m_list.SetItemText(nRow,5,q->ISBN);//设置数据

booknum++;

}

length=booknum;

m_booknum=length;

UpdateData(FALSE);

returnTRUE;//returnTRUEunlessyousetthefocusto//acontrol

//EXCEPTION:

OCXPropertyPagesshould//returnFALSE

}

voidCLookDlg:

:

OnButton1()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

CDelDlgdlg;

dlg.DoModal();

}

 

5.3

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 小升初

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1