




已阅读5页,还剩20页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
目 录第1章课程设计目的与要求21.1 课程设计目的21.2 课程设计的实验环境21.3 课程设计的预备知识21.4 课程设计要求2第2章课程设计内容32.1 C+语言程序设计图书馆管理系统问题分析32.1.1 功能分析32.1.2 系统分析32.1.3系统流程图42.1.4功能模块说明72.1.5 系统部分代码132.2 课程设计总结24第3章参考文献25第1章 课程设计目的与要求1.1 课程设计目的将理论教学中涉及到的知识点贯穿起来,对不同的数据类型、程序控制结构、数据结构作一比较和总结,结合设计题目进行综合性应用,对所学知识达到融会贯通的程度。通过课程设计,学生在下述各方面的能力应该得到锻炼:(1)进一步巩固、加深学生所学专业课程C+语言教程的基本理论知识,理论联系实际,进一步培养学生综合分析问题,解决问题的能力。(2)对于给定的设计题目,如何进行分析,理清思路,并给出相应的数学模型。 (3)掌握面向对象程序设计的方法。(4)熟练掌握MFC语言的基本语法,灵活运用各种数据类型。(5)进一步掌握在集成环境下如何调试程序(单步调试,设置断点、观察表达式,分块调试)和修改程序。 (6) 在SQL Server 2000环境下建立图书管理信息系统所使用的数据库,利用企业管理器或查询分析器建立各种数据库对象,包括:数据表、视图、约束、存储过程和触发器等;1.2 课程设计的实验环境硬件要求能运行Windows XP 操作系统的微机系统。MFC语言应用程序开发软件使用:VC+ 系统,或其他C+语言应用程序开发软件,SQL2000数据库。1.3 课程设计的预备知识熟悉MFC语言程序设计的基本知识及MFC对话框各控件的使用方法,用DAO实现MFC连接SQL数据库。1.4 课程设计要求1. 仔细分析设计题目,画出程序流程图,编写程序源代码。2. 积极上机调试源程序,增强编程技巧与调程能力。3. 认真书写课程设计预习报告,课程设计说明书。第2章 课程设计内容2.1 C+语言程序设计图书馆管理系统问题分析2.1.1 功能分析设计一个图书馆管理系统,完成图书管理和读者管理的功能,并能对借阅信息进行管理,要求完成以下功能:1. 读者信息管理,可以添加、修改、删除、查询读者信息;2. 图书信息管理,可以添加、修改、删除、查询书籍信息;3. 借书信息管理,可以进行添加借书信息。 4. 还书信息管理,可以进行添加还书信息。程序中所涉及C+语言内容包括:C+语言编译预处理过程、函数、数组、类、继承、封装、多态,重载,面向对象程序设计等相关内容。系统结构图如图2-3所示。2.1.2 系统分析1图书信息包括:图书编号,图书名称,出版社,作者,数量。2学生信息信息包括:学号,用户名,姓名,性别,班级,年龄,电话,系,密码。3. 系统管理员可以登陆图书管理系统,对图书信息进行插入,删除和查询,还可以对学生信息进行插入删除和修改。4. 学生可以凭借学号登陆图书管理系统,进行书籍查询,借书和还书操作,借书后,在借书表中有此学生的借书信息,学生不能重复借同一本书两次,还书以后,书籍记录增加,但是不能马上在窗口显示,另有学生登陆以后,窗口才显示正确的书籍个数。5.管理员登陆以后,不能进行借书还书操作,只能修改各类信息,而学生登陆以后,管理员权限被屏蔽。2.1.3 系统流程图(1)系统结构图图书馆管理系统图书管理学生管理借书还书退出图书添加图书修改图书查询读者添加读者修改读者查询借书操作还书操作(2)main函数流程图进入程序,开始输出提示信息输入选择的功能退出,结束程序4023退出函数读者管理模块图书管理模块还书模块借书模块1判断输入的选项(3)借书模块流程图NYY进入借书模块,开始输入用户名密码输入学号和借阅的图书编号提示错误信息读者是否存在YN图书是否存在提示错误信息提示错误信息图书是否全部借出N保存借书信息提示成功信息退出借书模块,结束(4)图书管理模块流程图0进入图书管理模块,开始输出提示信息输入操作编号判断操作13添加图书信息提示成功信息退出图书管理模块,结束保存图书信息2保存图书信息提示成功信息退出修改图书信息显示图书信息2.1.4 功能模块说明(1)系统登录系统总共分为2类用户,学生和系统管理员,教师模块未实现(2)图书管理界面首页(3)管理员界面管理图书信息插入图书修改图书信息删除图书信息学生信息管理插入学生信息修改学生信息删除学生信息(4)学生登陆界面查询图书有模糊查询和精确查询两种方式,用模糊查询时,随便输入图书的资料(如输入图书名称的首字)就可以查找到所有需要的图书,精确查询时需要输入具体的图书信息借书还书2.1.4 系统部分代码说明模块一 :ADO连接数据库#include stdafx.h#include class123.h#include ado.h#ifdef _DEBUG#undef THIS_FILEstatic char THIS_FILE=_FILE_;#define new DEBUG_NEW#endifCado:Cado() try m_pConnection.CreateInstance(_uuidof(Connection); _bstr_t strConnect=driver=SQL Server;Server=(local);DATABASE=图书馆管理;UID=;PWD=NULL; m_pConnection-Open(strConnect,adModeUnknown); catch(_com_error e) AfxMessageBox(e.Description(); Cado:Cado()void Cado:close() m_pRecordset-Close();m_pConnection-Close(); m_pRecordset=NULL; m_pConnection=NULL;:CoUninitialize(); bool Cado:MovePrevious() try m_pRecordset-MovePrevious(); catch(_com_error e) AfxMessageBox(e.Description(); return false; return TRUE;bool Cado:MoveLast() try m_pRecordset-MoveLast(); catch(_com_error e) AfxMessageBox(e.Description(); return false; return TRUE;bool Cado:MoveNext() try m_pRecordset-MoveNext(); catch(_com_error e) AfxMessageBox(e.Description(); return false; return TRUE;bool Cado:MoveFirst() try m_pRecordset-MoveFirst(); catch(_com_error e) AfxMessageBox(e.Description(); return false; return TRUE;int Cado:GetRecordCount() int nCount; try m_pRecordset-MoveFirst(); catch(_com_error e) return 0; if(m_pRecordset-adoEOF) return 0; while(!m_pRecordset-adoEOF) m_pRecordset-MoveNext(); nCount+; m_pRecordset-MoveFirst(); return nCount;bool Cado:Open(CString srecordset,UINT adCmd) try m_pRecordset=m_pConnection-Execute(_bstr_t)srecordset,NULL,adCmd); catch(_com_error &e) this-GetErrors(e);return false; return true;void Cado:GetErrors(_com_error eErrors) ErrorsPtr pErrors=m_pConnection-GetErrors(); if(pErrors-GetCount()=0) MessageBox(NULL,eErrors.ErrorMessage(),错误,MB_OK|MB_ICONEXCLAMATION); else for(int i=0;iGetCount();i+) _bstr_t desc=pErrors-GetItem(long)i)-GetDescription(); MessageBox(NULL,desc,错误,MB_OK|MB_ICONEXCLAMATION); CString Cado:GetFieldValue(CString Field) _variant_t Thevalue;CString temp;Thevalue=m_pRecordset-GetCollect(_bstr_t)Field);if(Thevalue.vt=VT_EMPTY|Thevalue.vt=VT_NULL) temp=;else temp=(char*)(_bstr_t)Thevalue; temp.TrimLeft(); temp.TrimRight();return temp;bool Cado:Move(int nRecordNum) try if(!m_pRecordset-BOF) m_pRecordset-MoveFirst(); m_pRecordset-Move(nRecordNum); catch(_com_error e) AfxMessageBox(e.Description(); return false; return TRUE;void Cado:ExecuteSQL(CString SQL) try m_pConnection-Execute(_bstr_t)SQL,NULL,adCmdText); catch(_com_error e) AfxMessageBox(e.Description(); void Cado:rstOpen(CString TSQL) try _bstr_t strSQL=TSQL.AllocSysString(); m_pRecordset.CreateInstance(_uuidof(Recordset); m_pRecordset-Open(strSQL,(IDispatch*)m_pConnection,adOpenDynamic,adLockOptimistic,adCmdText); catch(_com_error e) m_pRecordset=m_pConnection-Execute(_bstr_t(TSQL),NULL,adCmdText); void Cado:GetData(CString strSQL,CString UserID) m_pRecordset.CreateInstance(_uuidof(Recordset); m_pRecordset-Open(LPTSTR)strSQL.GetBuffer(130),m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText); if(m_pRecordset-adoEOF) return; else m_UserID=UserID; m_UserPwd=(LPCTSTR)(_bstr_t)m_pRecordset-GetCollect(user_mm); m_UserType=(LPCTSTR)(_bstr_t)m_pRecordset-GetCollect(user_type); 模块二:修改个人信息表#include stdafx.h#include class123.h#include alterpersonal.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endifCalterpersonal:Calterpersonal(CWnd* pParent ): CDialog(Calterpersonal:IDD, pParent)void Calterpersonal:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);BEGIN_MESSAGE_MAP(Calterpersonal, CDialog)void Calterpersonal:OnOK() / TODO: Add extra validation hereCADo CCADO6UpdateData(true);CString SQL,leixing,result;m_alterstyle.GetWindowText(leixing);m_alterresult.GetWindowText(result);CDialog:OnOK();模块三:借书#include stdafx.h#include class123.h#include Borrow.h#include ado.h#include Bquery.h#include Login.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endifCBorrow:CBorrow(CWnd* pParent /*=NULL*/): CDialog(CBorrow:IDD, pParent)void CBorrow:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);BEGIN_MESSAGE_MAP(CBorrow, CDialog)END_MESSAGE_MAP()BOOL CBorrow:OnInitDialog() CDialog:OnInitDialog();CString temp5=图书编号,学号,借书日期,还书日期,剩余天数;for(int i=0;iGetCollect(最大值);str1=var.bstrVal;if(str1.IsEmpty() str1=001;else str1.Format(00%d,atoi(str1.GetBuffer(str1.GetLength()+1);for(int i=0;iBOF)CCADO2.MoveFirst();else return;while(!CCADO2.m_pRecordset-adoEOF) m_blist.InsertItem(index,(LPCTSTR)(_bstr_t)CCADO2.m_pRecordset-GetCollect(图书编号); m_blist.SetItemText(index,1,(LPCTSTR)(_bstr_t)CCADO2.m_pRecordset-GetCollect(图书名称); m_blist.SetItemText(index,2,(LPCTSTR)(_bstr_t)CCADO2.m_pRecordset-GetCollect(作者); m_blist.SetItemText(index,3,(LPCTSTR)(_bstr_t)CCADO2.m_pRecordset-GetCollect(出版社); m_blist.SetItemText(index,4,(LPCTSTR)(_bstr_t)CCADO2.m_pRecordset-GetCollect(数量); CCADO2.MoveNext(); index+;UpdateData(false); BOOL CBquery:OnInitDialog() CDialog:OnInitDialog();CString temp5=图书编号,图书名称,作者,出版社,数量;for(int i=0;iBOF)CCADO1.MoveFirst();else return; while(!CCADO1.m_pRecordset-adoEOF) m_blist.InsertItem(index,(LPCTSTR)(_bstr_t)CCADO1.m_pRecordset-GetCollect(图书编号); m_blist.SetItemText(index,1,(LPCTSTR)(_bstr_t)CCADO1.m_pRecordset-GetCollect(图书名称); m_blist.SetItemText(index,2,(LPCTSTR)(_bstr_t)CCADO1.m_pRecordset-GetCollect(作者); m_blist.SetItemText(index,3,(LPCTSTR)(_bstr_t)CCADO1.m_pRecordset-GetCollect(出版社); m_blist.SetItemText(index,4,(LPCTSTR)(_bstr_t)CCADO1.m_pRecordset-GetCollect(数量); CCADO1.MoveNext(); index+;UpdateData(false); return;case 1: m_blist.DeleteAllItems(); SQL.Format(select * from 图书表 where 图书编号=%s or 图书名称=%s or 作者=%s or 出版社=%s,m_bnumber,m_bname,m_bauthor,m_bpublisher); CCADO1.Open(SQL,adCmdText); if(CCADO1.GetRecordCount()=0) AfxMessageBox(对不起,无记录!); ShowTable(); else if(!CCADO1.m_pRecordset-BOF)CCADO1.MoveFirst();else return; while(!CCADO1.m_pRecordset-adoEOF) m_blist.InsertItem(index,(LPCTSTR)(_bstr_t)CCADO1.m_pRecordset-GetCollect(图书编号); m_blist.SetItemText(index,1,(LPCTSTR)(_bstr_t)CCADO1.m_pRecordset-GetCollect(图书名称); m_blist.SetItemText(index,2,(LPCTSTR)(_bstr_t)CCADO1.m_pRecordset-GetCollect(作者); m_blist.SetItemText(index,3,(LPCTSTR)(_bstr_t)CCADO1.m_pRecordset-GetCollect(出版社); m_blist.SetItemText(index,4,(LPCTSTR)(_bstr_t)CCADO1.m_pRecordset-GetCollect(数量); CCADO1.MoveNext(); index+;UpdateData(false); return;void CBquery:OnCancel() CDialog:OnCancel();void CBquery:OnButton1() CADo CCADO3; UpdateData(true); CString SQL,strNumber,strcount,strSNmuber,strBorrowT,strReturnT; int nlndex; nlndex=m_blist.GetSelectionMark(); if(nlndex=-1) AfxMessageBox(请选择一条数目!); else strNumber=m_blist.GetItemText(nlndex,0); SQL.Format(select 数量 from 图书表 where 图书编号=%s,strNumber); CCADO3.Open(SQL,adCmdText); strcount=(LPCTSTR)(_bstr_t)CCADO3.m_pRecordset-GetCollect(数量); if(strcount=0) MessageBox(对不起此书在馆数为空!); else if(this-thiscount!=1) this-m_cborrow=new CBorrow(); this-m_cborrow-Create(IDD_DIALOG3,this); this-m_cborrow-ShowWindow(SW_SHOW);this-thiscount=1;SQL.Format(select getdate() as 今天);CCADO3.Open(SQL,adCmdText);CString ctoday,cnextday;ctoday=(LPCTSTR)(_bstr_t)CCADO3.m_pRecordset-GetCollect(今天);SQL.Format(select getdate()+30 as 还期);CCADO3.Open(SQL,adCmdText);cnextday=(LPCTSTR)(_bstr_t)CCADO3.m_pRecordset-GetCollect(还期);if(this-bindex=NULL) this-bindex=0;AfxMessageBox(bindex); m_cborrow-m_bblist.InsertItem(this-bindex,strNumber,0);m_cborrow-m_bblist.SetItemText(this-bindex,1,stnumber);m_cborrow-m_bblist.SetItemText(this-bindex,2,ctoday);m_cborrow-m_bblist.SetItemText(this-bindex,3,cnextday);m_cborrow-m_bblist.SetItemText(this-bindex,4,30); this-bindex+;UpdateData(false); void CBquery:OnButton3() UpdateData(true);Clend lend; lend.DoModal(); 模块五:还书#include stdafx.h#include class123.h#include lend.h#include ado.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endifClend:Clend(CWnd* pParent ): CDialog(Clend:IDD, pParent)void Clend:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);BEGIN_MESSAGE_MAP(Clend, CDialog)END_MESSAGE_MAP()BOOL Clend:OnInitDialog() CDialog:OnInitDialog();m_stnumber.SetWindowText(stnumber);return TRUE; void Clend:OnOK() CADo CCADO5;UpdateData(FALSE);CString str,strbmr,strbnm,SQL; m_booknumber.GetWindowText(strbmr);SQL.Format(select getdate() as 今天);CCADO5.Open(SQL,adCmdText);CString ctoday;ctoday=(LPCTSTR)(_bstr_t)CCADO5.m_pRecordset-GetCollect(今天); SQL.Format(select max(还书编号) 最大值 from 还书表); CCADO5.Open(SQL,adCmdText);_variant_t var; var=CCADO5.m_pRecordset-GetCollect(最大值);str=var.bstrVal;if(str.IsEmpty() str=001;else str.Format(00%d,atoi(str.GetBuffer(str.GetLength()+1);SQL.Format(insert 还书表 values(%s,%s,%s,%s),str,strbmr,stnumber,ctoday);CCADO5.ExecuteSQL(SQL);MessageBox(还书成功);CDialog:OnOK();模块六:登陆#include stdafx.h#include class123.h#include Login.h#include ado.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endifCLogin:CLogin(CWnd* pParent /*=NULL*/): CDialog(CLogin:IDD, pParent)void CLogin:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);BEGIN_MESSAGE_MAP(CLogin, CDialog)END_MESSAGE_MAP()void CLogin:OnOK() CADo CCADO;UpdateData(true); CString SQL,name,pwd;switch(m_radio)case 0:user=0;SQL.Format(select * from 用户表);CCADO.Open(SQL,adCmdText);m_name_edit.GetWindowText(name);m_pwd_edit.GetWindowText(pwd);while(!CCADO.m_pRecordset-adoEOF) if(_variant_t)name=CCADO.m_pRecordset-GetCollect(用户名)&(_variant_t)pwd=CCADO.m_pRecordset-GetCollect(密码) CDialog:OnOK();return; CCADO.MoveNext(); AfxMessageBox(用户名不正确,请重新输入); m_name=; m_pwd=; UpdateData(false); m_name_edit.SetFocus(); break;case 1:user=1;SQL.Format(select * from 学生信息表);CCADO.Open(SQL,adCmdText);while(!CCADO.m_pRecordset-adoEOF) if(_variant_t)m_name=CCADO.m_pRecordset-GetCollect(学号)&(_variant_t)m_pwd=CCADO.m_pRecordset-GetCollect(密码) stnumber=(LPCTSTR)(_bstr_t)CCADO.m_pRecordset-GetCollect(学号); CDialog:OnOK();return; CCADO.MoveNext(); AfxMessageBox(用户名或密码不正确,请重新输入); m_name=; m_pwd=; UpdateData(false); m_name_edit.SetFocus(); break;case 2:user=2;break;void CLogin:OnCancel() AfxGetMainWnd()-PostMessage(WM_QUIT);CDialog:OnCancel();BOOL CLogin:OnInitDialog() CDialog:OnInitDialog();m_radio1.GetFocus();return TRUE; 模块七:个人信息#include stdafx.h#include class123.h#include personal.h#include ado.h#include alterpersonal.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endifCpersonal:Cpersonal(CWnd* pParent /*=NULL*/): CDialog(Cpersonal:IDD, pParent)void Cpersonal:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);BEGIN_MESSAGE_MAP(Cpersonal, CDialog)END_MESSAGE_MAP()BOOL Cpersonal:OnInitDialog() CDialog:OnInitDialog();CADo CCADO6;UpdateData(true);CString SQL,yonghuming,xingming,xingbie,banji,nianling,dianhua,mima,xi,xuehao;SQL.Format(select * from 学生信息表 where 学号=%s,stnumber);CCADO6.Open(SQL,adCmdText);xuehao=(LPCTSTR)(_bstr_t)CCADO6.m_pRecordset-GetCollect(学号);yonghuming=(LPCTSTR)(_bstr_t)CCADO6.m_pRecordset-GetCollect(用户名);xingming=(LPCTSTR)(_bstr_t)CCADO6.m_pRecordset-GetCollect(姓名);xingbie=(LPCTSTR)(_bstr_t)CCADO6.m_pRecordset-GetCollect(性别);banji=(LPCTSTR)(_bstr_t)CCADO6.m_pRecordset-GetCollect(班级);nianling=(LPCTSTR)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 改建升旗台合同模板下载(3篇)
- 智能家居环氧地坪漆施工与家居安全协议
- 上海协议离婚协议起草及子女抚养权确定合同
- 离婚协议书起草与财产清算、分割一体化服务合同
- 离婚财产分割协议书及财产分割争议解决机制协议
- 私立幼儿园教师心理健康辅导聘用合同
- 环评技术咨询与环保风险评估合作协议
- 离婚协议签订与执行中财产分割与债务承担合同
- 社保补偿协议书:事业单位员工退休待遇支付细则
- 珠宝定制产品售后维修、保养及增值服务协议
- 数字政府效能评估体系-洞察阐释
- 2025年电力机车钳工(高级)职业技能鉴定理论考试题库(含答案)
- 智联招聘银行试题及答案
- 安置点管理制度
- 麻醉科职责及管理制度
- 教科版五年级上册科学期中测试卷附答案(夺分金卷)
- 药房管理规章制度目录
- 中职第1课 社会主义在中国的确立和探索试题
- 2025年辽宁省交投集团招聘笔试参考题库含答案解析
- 香港 信托合同范本
- 少先队活动课《民族团结一家亲-同心共筑中国梦》课件
评论
0/150
提交评论