




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.课 程 设 计 报 告 课程名称:面向对象程序设计C+ 设计题目:店铺电子产品管理系统 专 业:计算机科学与技术 姓 名: 学 号: 指导教师:李 晓 虹2015 年 1 月 10 日1、 需求分析 此程序面向的对象主要是电子产品商铺,针对于客户对电子产品的需求量,店主可以对店铺的产品管理更加方便,更加方便检阅产品的剩余量,以便于准确的给与用户所需产品的准确信息。如此就更加便于产品的销售。2、 总体设计2.1、C+语言编程 利用C+语言编写模板,并利用MFC建立与数据库的连接。图2.1-1图2.1-22.2、数据库后台支持 数据库内建立需要用到的三个表格:dbo.classify、dbo.d
2、epartment、dbo.equipment。(表内内容仅为参考)表dbo.classify:表2.2.1表dbo.department:表2.2.2表dbo.equipment:表2.2.33、 详细设计3.1、查询电子产品型号及库存量图3.1-1具体代码如下:/ Classify.cpp : implementation file/#include "stdafx.h"#include "ems.h"#include "Classify.h"#include "Dialog3.h"#include "
3、;Dialog6.h"#include "Dialog7.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CClassifyIMPLEMENT_DYNCREATE(CClassify, CRecordView)CClassify:CClassify(): CRecordView(CClassify:IDD)/AFX_DATA_INIT(CClassify)m_pSet = NULL;/AFX_DATA_INITCClassify:C
4、Classify()if (m_pSet)delete m_pSet;void CClassify:DoDataExchange(CDataExchange* pDX)CRecordView:DoDataExchange(pDX);/AFX_DATA_MAP(CClassify)DDX_Control(pDX, IDC_LIST1, m_Grid3);DDX_FieldText(pDX, IDC_EDIT_age3, m_pSet->m_Eno, m_pSet);DDX_FieldText(pDX, IDC_EDIT_class3, m_pSet->m_Cclass, m_pSet
5、);DDX_FieldText(pDX, IDC_EDIT_id3, m_pSet->m_Cuseage, m_pSet);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CClassify, CRecordView)/AFX_MSG_MAP(CClassify)ON_BN_CLICKED(IDC_BUTTON_inquire3, OnBUTTONinquire3)ON_BN_CLICKED(IDC_BUTTON_alter3, OnBUTTONalter3)ON_BN_CLICKED(IDC_BUTTON_add3, OnBUTTONadd3)ON_BN_CLICKED(
6、IDC_BUTTON_delete3, OnBUTTONdelete3)ON_BN_CLICKED(IDC_BUTTON_refresh3, OnBUTTONrefresh3)ON_BN_CLICKED(IDC_BUTTON_scan3, OnBUTTONscan3)/AFX_MSG_MAPEND_MESSAGE_MAP()/ CClassify diagnostics#ifdef _DEBUGvoid CClassify:AssertValid() constCRecordView:AssertValid();void CClassify:Dump(CDumpContext& dc)
7、 constCRecordView:Dump(dc);#endif /_DEBUG/ CClassify message handlersCRecordset* CClassify:OnGetRecordset()if (m_pSet != NULL)return m_pSet;m_pSet = new Classify_set(NULL);m_pSet->Open();return m_pSet;Classify_set* CClassify:GetRecordset()Classify_set* pData = (Classify_set*) OnGetRecordset();ASS
8、ERT(pData = NULL | pData->IsKindOf(RUNTIME_CLASS(Classify_set);return pData;void CClassify:OnInitialUpdate()BeginWaitCursor();GetRecordset();CRecordView:OnInitialUpdate();if (m_pSet->IsOpen()CString strTitle = m_pSet->m_pDatabase->GetDatabaseName();CString strTable = m_pSet->GetTableN
9、ame();if (!strTable.IsEmpty()strTitle += _T(":") + strTable;GetDocument()->SetTitle(strTitle);EndWaitCursor();void CClassify:OnBUTTONinquire3() Dialog6 search;/dlg6.DoModal();UpdateData(TRUE);if(search.DoModal()=IDOK)m_pSet->Edit();search.m_11.TrimLeft();/search.m_2.TrimLeft();if(m_p
10、Set->IsOpen()m_pSet->Close();if(!(search.m_11.IsEmpty()m_pSet->m_strFilter.Format("Eno='%s'",search.m_11);/*if(!(search.m_1.IsEmpty()m_pSet->m_strFilter.Format("Sname='%s'",search.m_2);*/m_pSet->Open();if(!m_pSet->IsEOF()m_pSet->Requery();Upda
11、teData(FALSE);OnInitialUpdate();elseMessageBox("没有找到!");void CClassify:OnBUTTONalter3() Dialog7 dlg7;/Dialog6 dlg6;OnBUTTONinquire3();dlg7.m_id111=m_pSet->m_Eno;dlg7.m_class111=m_pSet->m_Cclass;dlg7.m_age111=m_pSet->m_Cuseage;if(dlg7.DoModal()=IDOK)m_pSet->Edit();m_pSet->m_E
12、no=dlg7.m_id111;m_pSet->m_Cclass=dlg7.m_class111;m_pSet->m_Cuseage=dlg7.m_age111;m_pSet->Update();UpdateData(FALSE);m_pSet->m_strFilter.Format("Eno!='0000'");if(!m_pSet->IsEOF()m_pSet->Requery();UpdateData(FALSE);void CClassify:OnBUTTONadd3() Dialog7 dlg;if (dlg.D
13、oModal()=IDOK)/m_pSet->Open();m_pSet->AddNew();m_pSet->m_Eno=dlg.m_id111;m_pSet->m_Cclass=dlg.m_class111;m_pSet->m_Cuseage=dlg.m_age111;m_pSet->Update();m_pSet->Requery();void CClassify:OnBUTTONdelete3() OnBUTTONinquire3();Dialog3 dlg3;if(dlg3.DoModal()=IDOK)CRecordsetStatus sta
14、tus;m_pSet->GetStatus(status);m_pSet->Delete();if (status.m_lCurrentRecord=0)m_pSet->MoveNext();elsem_pSet->MoveFirst();UpdateData(FALSE);void CClassify:OnBUTTONrefresh3() Dialog7 dlg7;dlg7.m_id111=m_pSet->m_Eno;dlg7.m_class111=m_pSet->m_Cclass;dlg7.m_age111=m_pSet->m_Cuseage;if
15、 (dlg7.DoModal()=IDOK)m_pSet->Edit();m_pSet->m_Eno=dlg7.m_id111;m_pSet->m_Cclass=dlg7.m_class111;m_pSet->m_Cuseage=dlg7.m_age111;m_pSet->Update();UpdateData(FALSE);void CClassify:OnBUTTONscan3() CString s1; s1.Format("%f",m_pSet->m_Cuseage);/类型转换 /s2.Format("%d"
16、,m_pSet->m_Esum);while(!m_pSet->IsEOF()m_pSet->MoveNext();m_pSet->GetRecordCount();m_pSet->MoveFirst();int i=0;m_Grid3.DeleteAllItems();m_Grid3.InsertItem(i,"");m_Grid3.SetItemText(i+,0,"设备编号");m_Grid3.InsertItem(i,"");m_Grid3.SetItemText(i+,0,"设备类型&
17、quot;);m_Grid3.InsertItem(i,"");m_Grid3.SetItemText(i+,0,"使用年限");while(!m_pSet->IsEOF()m_Grid3.InsertItem(i,"");m_Grid3.SetItemText(i+,0,m_pSet->m_Eno);m_Grid3.InsertItem(i,"");m_Grid3.SetItemText(i+,0,m_pSet->m_Cclass);m_Grid3.InsertItem(i,"&quo
18、t;);m_Grid3.SetItemText(i+,0,s1);m_pSet->MoveNext();m_pSet->MoveFirst();3.2、查询电子产品具体信息图3.2-1具体代码如下:/ emsView.cpp : implementation of the CEmsView class/#include "stdafx.h"#include "ems.h"#include "emsSet.h"#include "emsDoc.h"#include "emsView.h"
19、; #include "Dialog1.h"#include "Dialog2.h"#include "Dialog3.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CEmsViewIMPLEMENT_DYNCREATE(CEmsView, CRecordView)BEGIN_MESSAGE_MAP(CEmsView, CRecordView)/AFX_MSG_MAP(CEmsView)ON_BN_C
20、LICKED(IDC_BUTTON_scan, OnBUTTONscan)ON_BN_CLICKED(IDC_BUTTON_inquire, OnBUTTONinquire)ON_BN_CLICKED(IDC_BUTTON_alter, OnBUTTONalter)ON_BN_CLICKED(IDC_BUTTON_add, OnBUTTONadd)ON_BN_CLICKED(IDC_BUTTON_delete, OnBUTTONdelete)ON_BN_CLICKED(IDC_BUTTON_refresh, OnBUTTONrefresh)/AFX_MSG_MAP/ Standard prin
21、ting commandsON_COMMAND(ID_FILE_PRINT, CRecordView:OnFilePrint)ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView:OnFilePrint)ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView:OnFilePrintPreview)END_MESSAGE_MAP()/ CEmsView construction/destructionCEmsView:CEmsView(): CRecordView(CEmsView:IDD)/AFX_DATA_INIT(CE
22、msView)m_pSet = NULL;/AFX_DATA_INIT/ TODO: add construction code hereCEmsView:CEmsView()void CEmsView:DoDataExchange(CDataExchange* pDX)CRecordView:DoDataExchange(pDX);/AFX_DATA_MAP(CEmsView)DDX_Control(pDX, IDC_LIST1, m_Grid1);DDX_FieldText(pDX, IDC_EDIT_department, m_pSet->m_Did, m_pSet);DDX_Fi
23、eldText(pDX, IDC_EDIT_name, m_pSet->m_Ename, m_pSet);DDX_FieldText(pDX, IDC_EDIT_no, m_pSet->m_Eno, m_pSet);DDX_FieldText(pDX, IDC_EDIT_outdate, m_pSet->m_Eoutdate, m_pSet);DDX_FieldText(pDX, IDC_EDIT_sum, m_pSet->m_Esum, m_pSet);DDX_FieldText(pDX, IDC_EDIT_price, m_pSet->m_Eprice, m_
24、pSet);/AFX_DATA_MAPBOOL CEmsView:PreCreateWindow(CREATESTRUCT& cs)/ TODO: Modify the Window class or styles here by modifying/ the CREATESTRUCT csreturn CRecordView:PreCreateWindow(cs);void CEmsView:OnInitialUpdate()m_pSet = &GetDocument()->m_emsSet;CRecordView:OnInitialUpdate();ResizePar
25、entToFit();/ CEmsView printingBOOL CEmsView:OnPreparePrinting(CPrintInfo* pInfo)/ default preparationreturn DoPreparePrinting(pInfo);void CEmsView:OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)/ TODO: add extra initialization before printingvoid CEmsView:OnEndPrinting(CDC* /*pDC*/, CPrintInfo*
26、 /*pInfo*/)/ TODO: add cleanup after printing/ CEmsView diagnostics#ifdef _DEBUGvoid CEmsView:AssertValid() constCRecordView:AssertValid();void CEmsView:Dump(CDumpContext& dc) constCRecordView:Dump(dc);CEmsDoc* CEmsView:GetDocument() / non-debug version is inlineASSERT(m_pDocument->IsKindOf(R
27、UNTIME_CLASS(CEmsDoc);return (CEmsDoc*)m_pDocument;#endif /_DEBUG/ CEmsView database supportCRecordset* CEmsView:OnGetRecordset()return m_pSet;/ CEmsView message handlersvoid CEmsView:OnBUTTONscan() CString s1,s2; s1.Format("%f",m_pSet->m_Eprice);/类型转换 s2.Format("%d",m_pSet-&g
28、t;m_Esum);while(!m_pSet->IsEOF()m_pSet->MoveNext();m_pSet->GetRecordCount();m_pSet->MoveFirst();int i=0;m_Grid1.DeleteAllItems();m_Grid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,"设备编号");m_Grid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,"设备名称");m_G
29、rid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,"设备价格");m_Grid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,"设备数量");m_Grid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,"使用部门");m_Grid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,"出厂日
30、期");while(!m_pSet->IsEOF()m_Grid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,m_pSet->m_Eno);m_Grid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,m_pSet->m_Ename);m_Grid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,s1);m_Grid1.InsertItem(i,"");m_Grid1.S
31、etItemText(i+,0,s2); m_Grid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,m_pSet->m_Did);m_Grid1.InsertItem(i,"");m_Grid1.SetItemText(i+,0,m_pSet->m_Eoutdate);m_pSet->MoveNext();m_pSet->MoveFirst();void CEmsView:OnBUTTONinquire() Dialog1 search;/dlg6.DoModal();UpdateData
32、(TRUE);if(search.DoModal()=IDOK)m_pSet->Edit();search.m_id1.TrimLeft();/search.m_2.TrimLeft();if(m_pSet->IsOpen()m_pSet->Close();if(!(search.m_id1.IsEmpty()m_pSet->m_strFilter.Format("Eno='%s'",search.m_id1);/*if(!(search.m_1.IsEmpty()m_pSet->m_strFilter.Format("
33、;Sname='%s'",search.m_2);*/m_pSet->Open();if(!m_pSet->IsEOF()m_pSet->Requery();UpdateData(FALSE);OnInitialUpdate();elseMessageBox("没有找到!");void CEmsView:OnBUTTONalter() Dialog2 dlg2;/Dialog6 dlg6;OnBUTTONinquire();dlg2.m_no11=m_pSet->m_Eno;dlg2.m_name11=m_pSet->
34、m_Ename;dlg2.m_price11=m_pSet->m_Eprice;dlg2.m_sum11=m_pSet->m_Esum;dlg2.m_department11=m_pSet->m_Did;dlg2.m_outdate11=m_pSet->m_Eoutdate;if(dlg2.DoModal()=IDOK)m_pSet->Edit();m_pSet->m_Eno=dlg2.m_no11;m_pSet->m_Ename=dlg2.m_name11;m_pSet->m_Eprice=dlg2.m_price11;m_pSet->m
35、_Esum=dlg2.m_sum11;m_pSet->m_Did=dlg2.m_department11;m_pSet->m_Eoutdate=dlg2.m_outdate11;m_pSet->Update();UpdateData(FALSE);m_pSet->m_strFilter.Format("Eno!='0000'");if(!m_pSet->IsEOF()m_pSet->Requery();UpdateData(FALSE);void CEmsView:OnBUTTONadd() Dialog2 dlg;if
36、(dlg.DoModal()=IDOK)/m_pSet->Open();m_pSet->AddNew();m_pSet->m_Eno=dlg.m_no11;m_pSet->m_Ename=dlg.m_name11;m_pSet->m_Eprice=dlg.m_price11;m_pSet->m_Esum=dlg.m_sum11;m_pSet->m_Did=dlg.m_department11;m_pSet->m_Eoutdate=dlg.m_outdate11;m_pSet->Update();m_pSet->Requery();vo
37、id CEmsView:OnBUTTONdelete() OnBUTTONinquire();Dialog3 dlg3;if(dlg3.DoModal()=IDOK)CRecordsetStatus status;m_pSet->GetStatus(status);m_pSet->Delete();if (status.m_lCurrentRecord=0)m_pSet->MoveNext();elsem_pSet->MoveFirst();UpdateData(FALSE);void CEmsView:OnBUTTONrefresh() Dialog2 dlg2;dl
38、g2.m_no11=m_pSet->m_Eno;dlg2.m_name11=m_pSet->m_Ename;dlg2.m_price11=m_pSet->m_Eprice;dlg2.m_sum11=m_pSet->m_Esum;dlg2.m_department11=m_pSet->m_Did;dlg2.m_outdate11=m_pSet->m_Eoutdate;if (dlg2.DoModal()=IDOK)m_pSet->Edit();m_pSet->m_Eno=dlg2.m_no11;m_pSet->m_Ename=dlg2.m_n
39、ame11;m_pSet->m_Eprice=dlg2.m_price11;m_pSet->m_Esum=dlg2.m_sum11;m_pSet->m_Did=dlg2.m_department11;m_pSet->m_Eoutdate=dlg2.m_outdate11;m_pSet->Update();UpdateData(FALSE);3.3、查询商铺不同负责区的管理人员信息图3.3-1具体代码如下:/ Department1.cpp : implementation file/#include "stdafx.h"#include &qu
40、ot;ems.h"#include "Department1.h"#include "Dialog3.h"#include "Dialog4.h"#include "Dialog5.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ Department1IMPLEMENT_DYNCREATE(Department1, CRecordView)Department1:Depar
41、tment1(): CRecordView(Department1:IDD)/AFX_DATA_INIT(Department1)m_pSet = NULL;/AFX_DATA_INITDepartment1:Department1()if (m_pSet)delete m_pSet;void Department1:DoDataExchange(CDataExchange* pDX)CRecordView:DoDataExchange(pDX);/AFX_DATA_MAP(Department1)DDX_Control(pDX, IDC_LIST1, m_Grid2);DDX_FieldTe
42、xt(pDX, IDC_EDIT_departmentid, m_pSet->m_Did, m_pSet);DDX_FieldText(pDX, IDC_EDIT_departmentname, m_pSet->m_Dname, m_pSet);DDX_FieldText(pDX, IDC_EDIT_principal, m_pSet->m_Dprincipal, m_pSet);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(Department1, CRecordView)/AFX_MSG_MAP(Department1)ON_BN_CLICKED(IDC_
43、BUTTON_alter1, OnBUTTONalter1)ON_BN_CLICKED(IDC_BUTTON_inquire1, OnBUTTONinquire1)ON_BN_CLICKED(IDC_BUTTON_add1, OnBUTTONadd1)ON_BN_CLICKED(IDC_BUTTON_delete1, OnBUTTONdelete1)ON_BN_CLICKED(IDC_BUTTON_refresh1, OnBUTTONrefresh1)ON_BN_CLICKED(IDC_BUTTON_scan1, OnBUTTONscan1)/AFX_MSG_MAPEND_MESSAGE_MA
44、P()/ Department1 diagnostics#ifdef _DEBUGvoid Department1:AssertValid() constCRecordView:AssertValid();void Department1:Dump(CDumpContext& dc) constCRecordView:Dump(dc);#endif /_DEBUG/ Department1 message handlersCRecordset* Department1:OnGetRecordset()if (m_pSet != NULL)return m_pSet;m_pSet = n
45、ew Department_set(NULL);m_pSet->Open();return m_pSet;Department_set* Department1:GetRecordset()Department_set* pData = (Department_set*) OnGetRecordset();ASSERT(pData = NULL | pData->IsKindOf(RUNTIME_CLASS(Department_set);return pData;void Department1:OnInitialUpdate()BeginWaitCursor();GetReco
46、rdset();CRecordView:OnInitialUpdate();if (m_pSet->IsOpen()CString strTitle = m_pSet->m_pDatabase->GetDatabaseName();CString strTable = m_pSet->GetTableName();if (!strTable.IsEmpty()strTitle += _T(":") + strTable;GetDocument()->SetTitle(strTitle);EndWaitCursor();void Departme
47、nt1:OnBUTTONalter1() Dialog4 dlg4;/Dialog6 dlg6;OnBUTTONinquire1();dlg4.m_departmentid11=m_pSet->m_Did;dlg4.m_departmentname11=m_pSet->m_Dname;dlg4.m_principal11=m_pSet->m_Dprincipal;if(dlg4.DoModal()=IDOK)m_pSet->Edit();m_pSet->m_Did=dlg4.m_departmentid11;m_pSet->m_Dname=dlg4.m_de
48、partmentname11;m_pSet->m_Dprincipal=dlg4.m_principal11;m_pSet->Update();UpdateData(FALSE);m_pSet->m_strFilter.Format("Did!='0000'");if(!m_pSet->IsEOF()m_pSet->Requery();UpdateData(FALSE);void Department1:OnBUTTONinquire1() Dialog5 search;/dlg6.DoModal();UpdateData(TR
49、UE);if(search.DoModal()=IDOK)m_pSet->Edit();search.m_findid.TrimLeft();/search.m_2.TrimLeft();if(m_pSet->IsOpen()m_pSet->Close();if(!(search.m_findid.IsEmpty()m_pSet->m_strFilter.Format("Did='%s'",search.m_findid);/*if(!(search.m_1.IsEmpty()m_pSet->m_strFilter.Format
50、("Sname='%s'",search.m_2);*/m_pSet->Open();if(!m_pSet->IsEOF()m_pSet->Requery();UpdateData(FALSE);OnInitialUpdate();elseMessageBox("没有找到!");void Department1:OnBUTTONadd1() Dialog4 dlg;if (dlg.DoModal()=IDOK)/m_pSet->Open();m_pSet->AddNew();m_pSet->m_Did=dlg.m_departmentid11;m_pSet->m_Dname=dlg.m_departmentname11;m_pSet->m_Dprincipal=dlg.m_principal11;m_pSet->Update();m_pSet->Requery();void Department1:OnBUTTONdelete1() OnBUTTONinquire1();Dialog3 dlg3;if(dlg3.DoModal()=IDOK)CRecordsetStatus
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 户外拓展小升初数学试卷
- 市场营销介绍
- 工贸企业职业卫生课件
- 工程预决算课件
- 工程造价课件
- 工程资料制作课件
- 最美的情话1200字(13篇)
- 农副产品网络销售平台合同
- 糖果世界1200字11篇
- 工程结构教学课件
- 出租厂房建筑和设施安全检查表
- 广东湛江市文化广电旅游体育局下属事业单位招考聘用教练员(同步测试)模拟卷及答案
- 安措费使用计划报审表(施工报-监理审-业主批)
- 智慧市政系统解决方案
- 医疗期规定(表格化)
- 切头飞剪设计(含全套CAD图纸)
- GMC核算模型 国际企业管理挑战赛
- RationalDMIS客户培训手册
- 二年级语文看图写话
- Agilent 34970A快速入门指南
- 一次性使用配药用无菌注射针产品技术要求changchuan
评论
0/150
提交评论