




已阅读5页,还剩27页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
目 录一、需求与功能分析 1二、系统总体框架 1三、模块设计与分析 1四、类的设计与分析 2五、特色算法分析 6六、功能测试 6七、存在的不足与对策 14八、程序源代码 15一 需求与功能分析本系统为了更好地实现对考试相关信息管理。本系统主要功能是对文件进行读取,修改和删除等。系统由MFC编写,有友好的操作界面,设计简单明朗也是一大特色,能够很方便管理员进行操作,其中实现功能如下:输入:考生相关信息:考生姓名,考号,性别,班别,监考老师。功能:对学生资料的查询,修改,删除,添加。二系统总体框架 考试管理系统用户基本操作查询部分考生信息添加考生信息修改考生信息删除部分考生信息三模块设计与分析1.查询考生信息当按下这个按钮,会弹出一个窗口,用户可以输入需要查询的考生考号,然后该考生的信息就会显示在下面的列表上.2.添加考生信息当按下这个按钮,会弹出一个窗口,然后再把需要添加的资料添在相应的信息栏上.这样该考生资料就会添加在名为db1数据库的表1上。3.修改考生信息当按下这个按钮,会弹出一个窗口,用户可以输入需要修改的考生考号,然后再把需要修改的资料添在相应的信息栏上.4删除部分考生信息在主窗口的列表中,点选需要删除的一栏或多栏,按下删除按钮,弹出一个对话框,按确定,该资料就会从数据库中删除掉。四 类的设计与分析添加考生信息的类:class add_student : public CDialog /主对话框类/ Constructionpublic:add_student(CWnd* pParent = NULL); enum IDD = IDD_DIALOG1 ;CStringm_class1;CStringm_name;CStringm_num;CStringm_sex;CStringm_teacher;protected:virtual void DoDataExchange(CDataExchange* pDX); protected:virtual void OnOK();DECLARE_MESSAGE_MAP();查询考生信息的类:class find : public CDialogpublic:CBrush br;CBitmap h;_RecordsetPtr m_pSet;find(CWnd* pParent = NULL); enum IDD = IDD_DIALOG3 ;CListCtrlm_bank1;CStringm_num;protected:virtual void DoDataExchange(CDataExchange* pDX); protected:afx_msg void OnButton1();virtual BOOL OnInitDialog();afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);DECLARE_MESSAGE_MAP()private:_bstr_t var;修改信息的类:class name2 : public CDialogpublic:CBitmap b;CBrush br;name2(CWnd* pParent = NULL); enum IDD = IDD_DIALOG2 ;CStringm_chass1;CStringm_change;CStringm_name;CStringm_num;CStringm_sex;CStringm_teacher;CStringm_oldnum;protected:virtual void DoDataExchange(CDataExchange* pDX); protected:virtual void OnOK();virtual BOOL OnInitDialog();afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);DECLARE_MESSAGE_MAP();主对话框类:class CAboutDlg : public CDialogpublic:CAboutDlg();enum IDD = IDD_ABOUTBOX ;protected:virtual void DoDataExchange(CDataExchange* pDX); protected:DECLARE_MESSAGE_MAP();class CMuzi2App : public CWinApppublic:CMuzi2App();public:virtual BOOL InitInstance();DECLARE_MESSAGE_MAP();class CMuzi2Dlg : public CDialogpublic:CBrush br;CBitmap b;void zhao();_RecordsetPtr tea;CMuzi2Dlg(CWnd* pParent = NULL);_RecordsetPtr m_stu;_ConnectionPtr m_pConnection;enum IDD = IDD_MUZI2_DIALOG ;CStaticm_test;CListCtrlm_bank;protected:virtual void DoDataExchange(CDataExchange* pDX);protected:HICON m_hIcon;virtual BOOL OnInitDialog();afx_msg void OnSysCommand(UINT nID, LPARAM lParam);afx_msg void OnPaint();afx_msg HCURSOR OnQueryDragIcon();afx_msg void OnButton1();afx_msg void OnButton5();afx_msg void OnClose();afx_msg void OnButton8();afx_msg void OnButton6();afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);DECLARE_MESSAGE_MAP()private:_variant_t var;五、特色算法分析在设计的开始阶段我就有一个疑惑,就是删除数据的问题怎么处理,当你删除一条数据时,下面的数据会怎么样?怎么才能使下一条的数据完完全全地代替刚删除的数据?我想了很多方法及上网查阅了很多资料都没有办法解决,因为即使你删除了,你该行的数据会变成一个空字符串,但也会相当于一条数据,这样就会使读文件时常出错。开始,我想另外开一个窗口,填入要删除的考生号,然后进行删除,后来觉得实操起来有点繁琐,所以在列表种点选需要删除的一项或多项,再按删除按钮进行删除,这样比较方便快捷。六、功能测试1进入考试管理系统:2.按下“查询部分考生信息”按钮:输入要查询的考生号:3.删除考生信息:点选需要删除的一栏或两栏:按下“删除”按钮:4.按下“添加考生信息”按钮:填入要添加的考生资料:OK:5.按下“修改考生信息”按钮:填入要修改的考生号和要修改成的资料:OK:七存在的不足与对策由于设计者的编程水平有限,并且在不熟悉的MFC环境下编写,所以难免出现不少的问题。考试系统的功能不多,有最基本的查询,添加,修改删除。1,开始,我只会用MFC来做窗口,后来,经过老师和同学的教导,实现了窗口之间的连接,数据库的连接,和功能的实现。2.简单的程序基本完成了,就开始了美化的工作,为每个窗口添加了背景,和插图。起初,导入图片时,经常出现说导入的图片,但无法显示的对话框,我以为导入失败了,所以试了很多次,后来才发现其实是导入成功了。八、程序源代码/ muzi2Dlg.cpp : implementation file#include stdafx.h#include muzi2.h#include muzi2Dlg.h#include add_student.h#include find.h#include name2.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialogpublic:CAboutDlg();/ Dialog Data/AFX_DATA(CAboutDlg)enum IDD = IDD_ABOUTBOX ;protected:virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support/ Implementationprotected:DECLARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD)/AFX_DATA_INIT(CAboutDlg)/AFX_DATA_INITvoid CAboutDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CAboutDlg)BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)/AFX_MSG_MAP(CAboutDlg)/ No message handlersEND_MESSAGE_MAP()/ CMuzi2Dlg dialogCMuzi2Dlg:CMuzi2Dlg(CWnd* pParent /*=NULL*/): CDialog(CMuzi2Dlg:IDD, pParent)m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME);void CMuzi2Dlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CMuzi2Dlg)DDX_Control(pDX, IDC_F, m_test);DDX_Control(pDX, IDC_LIST1, m_bank);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CMuzi2Dlg, CDialog)/AFX_MSG_MAP(CMuzi2Dlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_BUTTON1, OnButton1)ON_BN_CLICKED(IDC_BUTTON5, OnButton5)ON_WM_CLOSE()ON_BN_CLICKED(IDC_BUTTON8, OnButton8)ON_BN_CLICKED(IDC_BUTTON6, OnButton6)ON_WM_CTLCOLOR()ON_WM_CREATE()/AFX_MSG_MAPEND_MESSAGE_MAP()/ CMuzi2Dlg message handlersBOOL CMuzi2Dlg:OnInitDialog()CDialog:OnInitDialog();/ Add About. menu item to system menu./ IDM_ABOUTBOX must be in the system command range.ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX Open(Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db3.mdb,adModeUnknown); catch(_com_error e) MessageBox(数据库连接失败,确认数据库phonebook.mdb是否在当前路径下!);this-CloseWindow();return FALSE; /表1连接m_stu.CreateInstance(_uuidof(Recordset);try m_stu-Open(SELECT * FROM 表1, m_pConnection.GetInterfacePtr(), / 获取库接库的IDispatch指针 adOpenDynamic, adLockOptimistic, adCmdText); catch(_com_error *e) /AfxMessageBox(e-ErrorMessage(); MessageBox(e-ErrorMessage(); zhao();CMenu* pSysMenu = GetSystemMenu(FALSE);if (pSysMenu != NULL)CString strAboutMenu;strAboutMenu.LoadString(IDS_ABOUTBOX);if (!strAboutMenu.IsEmpty()pSysMenu-AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);/ Set the icon for this dialog. The framework does this automatically/ when the applications main window is not a dialogSetIcon(m_hIcon, TRUE);/ Set big iconSetIcon(m_hIcon, FALSE);/ Set small icon/ TODO: Add extra initialization herereturn TRUE; / return TRUE unless you set the focus to a controlvoid CMuzi2Dlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal();elseCDialog:OnSysCommand(nID, lParam);/ If you add a minimize button to your dialog, you will need the code below/ to draw the icon. For MFC applications using the document/view model,/ this is automatically done for you by the framework.void CMuzi2Dlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(&rect);int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CMuzi2Dlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CMuzi2Dlg:OnButton1() / TODO: Add your control notification handler code hereadd_student as;if(IDOK=as.DoModal()m_stu-AddNew();m_stu-PutCollect(studentname,(_bstr_t)as.m_name);m_stu-PutCollect(number,(_bstr_t)as.m_num);m_stu-PutCollect(sex,(_bstr_t)as.m_sex);m_stu-PutCollect(class1,(_bstr_t)as.m_class1);m_stu-PutCollect(teacher,(_bstr_t)as.m_teacher);m_stu-Update();m_bank.DeleteAllItems();zhao();void CMuzi2Dlg:OnButton5() / TODO: Add your control notification handler code herefind qq;qq.m_pSet=m_stu;qq.DoModal();CString num;void CMuzi2Dlg:OnClose() / TODO: Add your message handler code here and/or call defaultm_stu-Close();m_pConnection-Close();CDialog:OnClose();void CMuzi2Dlg:OnButton8() name2 ac;CString num;if(IDOK=ac.DoModal()if(!m_stu-BOF) /判断指针状态是否正常m_stu-MoveFirst();while(!m_stu-adoEOF)var=m_stu-GetCollect(number);num.Format(_com_util:ConvertBSTRToString(_bstr_t)var);if(num=ac.m_oldnum)m_stu-PutCollect(number,(_bstr_t)ac.m_num);m_stu-PutCollect(studentname,(_bstr_t)ac.m_name);m_stu-PutCollect(sex,(_bstr_t)ac.m_sex);m_stu-PutCollect(class1,(_bstr_t)ac.m_chass1);m_stu-PutCollect(teacher,(_bstr_t)ac.m_teacher);m_stu-Update();m_stu-MoveNext();m_bank.DeleteAllItems();int i=0;CString name,name2;if(!m_stu-BOF) /判断指针状态是否正常m_stu-MoveFirst(); /指针移动到第一条记录while(!m_stu-adoEOF) /判断指针是否已到达记录末尾var=m_stu-GetCollect(studentname);name.Format(_com_util:ConvertBSTRToString(_bstr_t)var);m_bank.InsertItem(i,(LPCTSTR)(_bstr_t)m_stu-GetCollect(studentname);m_bank.SetItemText(i, 1, (LPCTSTR)(_bstr_t)m_stu-GetCollect(number);m_bank.SetItemText(i, 2, (LPCTSTR)(_bstr_t)m_stu-GetCollect(sex);m_bank.SetItemText(i, 3, (LPCTSTR)(_bstr_t)m_stu-GetCollect(class1); m_bank.SetItemText(i, 4, (LPCTSTR)(_bstr_t)m_stu-GetCollect(teacher);i+;m_stu-MoveNext(); / TODO: Add your control notification handler code herevoid CMuzi2Dlg:OnButton6() / TODO: Add your control notification handler code here CString name,sn;int nItem;POSITION pos = m_bank.GetFirstSelectedItemPosition(); if (pos = NULL) MessageBox(操作失败!);return; elseCString str;str.Format(确定要删除这%d项?,m_bank.GetSelectedCount();if(IDYES=AfxMessageBox(str,MB_YESNO)while (pos)nItem = m_bank.GetNextSelectedItem(pos);name=m_bank.GetItemText(nItem,0);if(!m_stu-BOF) /判断指针状态是否正常m_stu-MoveFirst();while(!m_stu-adoEOF)var=m_stu-GetCollect(studentname);sn.Format(_com_util:ConvertBSTRToString(_bstr_t)var);if(sn=name)m_stu-Delete(adAffectCurrent);m_stu-Update();break;m_stu-MoveNext();elseMessageBox(数据出错!);m_bank.DeleteAllItems();zhao();void CMuzi2Dlg:zhao()int i=0;CString name,name2;if(!m_stu-BOF) /判断指针状态是否正常m_stu-MoveFirst(); /指针移动到第一条记录while(!m_stu-adoEOF) /判断指针是否已到达记录末尾var=m_stu-GetCollect(studentname);name.Format(_com_util:ConvertBSTRToString(_bstr_t)var);m_bank.InsertItem(i,(LPCTSTR)(_bstr_t)m_stu-GetCollect(studentname);m_bank.SetItemText(i, 1, (LPCTSTR)(_bstr_t)m_stu-GetCollect(number);m_bank.SetItemText(i, 2, (LPCTSTR)(_bstr_t)m_stu-GetCollect(sex);m_bank.SetItemText(i, 3, (LPCTSTR)(_bstr_t)m_stu-GetCollect(class1); m_bank.SetItemText(i, 4, (LPCTSTR)(_bstr_t)m_stu-GetCollect(teacher);i+;m_stu-MoveNext(); HBRUSH CMuzi2Dlg:OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) HBRUSH hbr = CDialog:OnCtlColor(pDC, pWnd, nCtlColor);/ TODO: Change any attributes of the DC herereturn br;/ TODO: Return a different brush if the default is not desiredreturn hbr;int CMuzi2Dlg:OnCreate(LPCREATESTRUCT lpCreateStruct) if (CDialog:OnCreate(lpCreateStruct) = -1)return -1;/ TODO: Add your specialized creation code herereturn 0;#if !defined(AFX_MUZI2_H_475DF2B0_BE58_4899_93BA_9B58D344218C_INCLUDED_)#define AFX_MUZI2_H_475DF2B0_BE58_4899_93BA_9B58D344218C_INCLUDED_#if _MSC_VER 1000#pragma once#endif / _MSC_VER 1000#ifndef _AFXWIN_H_#error include stdafx.h before including this file for PCH#endif#include resource.h/ main symbols/ CMuzi2App:/ See muzi2.cpp for the implementation of this classclass CMuzi2App : public CWinApppublic:CMuzi2App();/ Overrides/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CMuzi2App)public:virtual BOOL InitInstance();/ Implementation/AFX_MSG(CMuzi2App)/ NOTE - the ClassWizard will add and remove member functions here./ DO NOT EDIT what you see in these blocks of generated code !/AFX_MSGDECLARE_MESSAGE_MAP();/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediately before the previous line.#endif / !defined(AFX_MUZI2_H_475DF2B0_BE58_4899_93BA_9B58D344218C_INCLUDED_)/ muzi2Dlg.h : header file#if !defined(AFX_MUZI2DLG_H_D9768330_F3F0_403F_A139_8992861BA92C_INCLUDED_)#define AFX_MUZI2DLG_H_D9768330_F3F0_403F_A139_8992861BA92C_INCLUDED_#if _MSC_VER 1000#pragma once#endif / _MSC_VER 1000#import msado15.dll no_namespace rename (EOF, adoEOF) / CMuzi2Dlg dialogclass CMuzi2Dlg : public CDialog/ Constructionpublic:CBrush br;CBitmap b;void zhao();_RecordsetPtr tea;CMuzi2Dlg(CWnd* pParent = NULL);/ standard constructor_RecordsetPtr m_stu;_ConnectionPtr m_pConnection;/ Dialog Data/AFX_DATA(CMuzi2Dlg)enum IDD = IDD_MUZI2_DIALOG ;CStaticm_test;CListCtrlm_bank;/AFX_DATA/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CMuzi2Dlg)protected:virtual void DoDataExchange(CDataExchange* pDX);/ DDX/DDV support/AFX_VIRTUAL/ Implementationprotected:HICON m_hIcon;/ Generated message map functions/AFX_MSG(CMuzi2Dlg)virtual BOOL OnInitDialog();afx_msg void OnSysCommand(UINT nID, LPARAM lParam);afx_msg void OnPaint();afx_msg HCURSOR OnQueryDragIcon();afx_msg void OnButton1();afx_msg void OnButton5();afx_msg void OnClose();afx_msg void OnButton8();afx_msg void OnButton6();afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);/AFX_MSGDECLARE_MESSAGE_MAP()private:_variant_t var;/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediately before the previous line.#endif / !defined(AFX_MUZI2DLG_H_D9768330_F3F0_403F_A139_8992861BA92C_INCLUDED_)添加考生信息:class add_student : public CDialog/ Constructionpublic:CBitmap b;CBrush br;add_student(CWnd* pParent = NULL); / standard constructor/ Dialog Data/AFX_DATA(add_student)enum IDD = IDD_DIALOG1 ;CStringm_class1;CStringm_name;CStringm_num;CStringm_sex;CStringm_teacher;/AFX_DATA/ Overrides/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(add_student)protected:virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support/AFX_VIRTUAL/ Implementationprotected:/ Generated message map functions/AFX_MSG(add_student)virtual void OnOK();virtual BOOL OnInitDialog();afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);/AFX_MSGDECLARE_MESSAGE_MAP();/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediately before the previous line.#endif / !defined(AFX_ADD_STUDENT_H_6B192ACB_34A0_49D3_A57B_17C8F3000A5D_INCLUDED_)#include stdafx.h#include muzi2.h#include add_student.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ add_student dialogadd_student:add_student(CWnd* pParent /*=NULL*/): CDialog(add_student:IDD, pParent)/AFX_DATA_INIT(add_student)m_class1 = _T();m_name = _T();m_num = _T();m_sex = _T();m_teacher = _T();/AFX_DATA_INITvoid add_student:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(add_student)DDX_Text(pDX, IDC_CLASS1, m_class1);DDX_Text(pDX, IDC_NAME, m_name);DDX_Text(pDX, IDC_NUM, m_num);DDX_Text(pDX, IDC_SEX, m_sex);DDX_Text(pDX, IDC_TE
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB 46032-2025储粮化学药剂管理与使用规范
- 2025年建筑工地抹灰安全题库解析集
- 2025年康复训练面试高频题
- 2025年机械工程师初级面试模拟题及答案全解
- 2025年AI主播入门初级题库解析
- 2025年卡丁车教练员考试通关秘籍模拟题集与答题技巧
- 2025年化学初级工无机题解
- 2025年市委党校教师招聘面试问题解答
- 2025年高压电工模拟题及答案
- 2025年AI智能语音技术实战指南及考试题库
- JG/T 503-2016承插型盘扣式钢管支架构件
- 落户防离职协议书
- T/SFABA 5-2024食品配料天然度检测
- 铁路团体车票协议书
- 2025新人教版英语八上单词默写单(先鸟版)
- 养老护理移乘技能课件
- 物业服务接待课件
- 2025年度专业技术人员继续教育公需科目考试题(附答案)
- 广东2025年03月珠海市市直机关事业单位公开招考合同制职员笔试历年参考题库考点剖析附解题思路及答案详解
- 供应商有效管理方案
- 铝合金门窗安装与质量控制
评论
0/150
提交评论