C++学籍管理系统课程设计报告(共39页).doc
精选优质文档-倾情为你奉上摘要:学籍管理信息系统是高校管理的重要组成部分,为老师、同学提供存档、查询等手段。根据教学安排,我们有两周的时间进行学籍管理信息系统课程设计,我们小组团结一心,分工明确,积极讨论,终于在组员的努力下及老师的指导帮助下,我们顺利完成了本次课程设计,系统包括学生资料设置,成绩设置,成绩、排名查询,修改资料关键字: 系统 查询 课程设计 论文 管理目录第一章 绪论-(1)1.1 课程设计背景11.2 课程设计目的11.3 课程设计思路1第二章 系统总体规划-(2)2.1 前期准备22.2系统功能2第三章 系统分析设计-(3)3.1 建立MFC主界面及代码设计33.2 学生资料设置及代码设计103.3学生成绩设置及代码设计193.4查询功能及代码设计283.5修改密码功能及代码设计303.6删除功能及代码设计343.7修改功能及代码设计36第四章 界面设计与实现-(37)4.1 学生信息管理系统374.2 学生资料设置374.3 成绩设置384.4 学生资料显示384.5 成绩显示394.6 修改密码39总结-(40)工作安排-(43)参考文献-(44)第一章 绪论1.1 课程设计背景经过一个学期对C+程序设计的学习,学习到了基本的理论知识,了解到了C+语言程序设计的思想,现在把这些知识运用到实际中来。学籍管理信息系统是高校管理的重要组成部分,它能够为用户提供充足的信息和快捷的查询手段。使用计算机对学生资料、成绩信息进行管理,能够极大的提高学生管理的效率,节约教育经费,这也是适应学校信息化建设发展趋势的重要因素。因此我们有必要开发学籍管理信息系统。1.2 课程设计目的 全面系统的学习面向对象程序设计的基本概念、基本语法和编程方法。正确理解掌握C+面向对象程序设计的基本特性:类、对象、继承与派生、多态、虚函数、模板、流类库等。遵循软件过程的各个环节进行系统分析、设计、实现、集成、测试,并相应给出软件规格说明书等制品。了解当前常用的软件开发工具(Visual C+),要求熟练掌握基于MFC的程序设计,培养解决实际问题的能力。1.3 课程设计思路实现学生基本情况的录入、修改、删除等基本操作;能实现学生成绩的录入、修改、删除等基本操作;能方便的对学生的各个学期成绩进行统计;能具有成绩统计、排名等功能;可行性分析由于本系统管理的对象单一,都是在校学生,且每个数据内容具有较强的关联性,涉及的计算过程不是很复杂。第二章 系统总体规划2.1 前期准备学习C+6.0课本理论知识,查找、搜集相关资料,讨论出具体思路、方法,在整个过程中周老师给了我们必不可少的许多指导,使我们能够顺利地完成前期各项工作。2.2系统功能基于系统需求分析,该系统具有以下基本功能:用户管理:管理系统操作人员,设置操作人员账号、密码、用户资料等。用户资料:学生通过登录,可以查询到自己的资料、成绩、排名,同时可以修改密码。成绩管理:管理员根据学生成绩保存到系统中,同时可计算出综合排名、平均分等信息。基础数据管理:维护学生资料,主要包括院系、专业设置,联系方式、学号等个人信息设置等。管理员登陆注册用户资料登录系统设置成绩功能图查询成绩排名平均分查询用户资料修改密码学生登录第三章 系统分析设计3.1 建立MFC主界面及代码设计#include "stdafx.h" /头文件#include "学生信息管理系统.h"#include "学生信息管理系统Dlg.h"#include "xueshengziliao2.h"#include "xueshengziliao1.h"#include "stu.h"#include "fstream.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endifclass CAboutDlg : public CDialog /定义类CAboutDlg及数据和方法public:CAboutDlg();enum IDD = IDD_ABOUTBOX ;protected:virtual void DoDataExchange(CDataExchange* pDX); protected:DECLARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD)void CAboutDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX);BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)END_MESSAGE_MAP()CMyDlg:CMyDlg(CWnd* pParent ) /构造函数: CDialog(CMyDlg:IDD, pParent)m_xuehao2 = 0.0f; m_mima = 0.0f;m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);void CMyDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX);DDX_Text(pDX, IDC_EDIT1, m_xuehao2);DDX_Text(pDX, IDC_EDIT2, m_mima);BEGIN_MESSAGE_MAP(CMyDlg, CDialog) /窗口链接函数的实现ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_guanliyuandenglu, Onguanliyuandenglu)ON_BN_CLICKED(IDC_xueshengdenglu, Onxueshengdenglu)ON_BN_CLICKED(IDC_guanbi, Onguanbi)END_MESSAGE_MAP()BOOL CMyDlg:OnInitDialog() /布尔函数的实现CDialog:OnInitDialog(); ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX < 0xF000);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);SetIcon(m_hIcon, TRUE);SetIcon(m_hIcon, FALSE);return TRUE; void CMyDlg:OnSysCommand(UINT nID, LPARAM lParam) if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal();elseCDialog:OnSysCommand(nID, lParam);void CMyDlg:OnPaint() /添加背景图片if (IsIconic()CPaintDC dc(this); SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);int 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;dc.DrawIcon(x, y, m_hIcon); else /CDialog:OnPaint(); /要禁止这个调用 CPaintDC dc(this); CRect rect; GetClientRect(&rect); CDC dcMem; dcMem.CreateCompatibleDC(&dc); CBitmap bmpBackground; bmpBackground.LoadBitmap(IDB_BITMAP1); BITMAP bitmap; bmpBackground.GetBitmap(&bitmap); CBitmap *pbmpOld=dcMem.SelectObject(&bmpBackground); dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0, bitmap.bmWidth,bitmap.bmHeight,SRCCOPY); HCURSOR CMyDlg:OnQueryDragIcon() /最小化窗口return (HCURSOR) m_hIcon;void CMyDlg:Onguanliyuandenglu() /管理员登录this->UpdateData(true);if(m_mima=123&&m_xuehao2=321) xueshengziliao2 a; this->OnCancel(); /跳出此窗口时关闭此窗口 a.DoModal(); /跳转到另一窗口else this->MessageBox("管理员的学号或密码输入错误!");Void CMyDlg:Onxueshengdenglu() /学生登录 struct stu stu;bool num=false;bool code=false;int find=0; this->UpdateData(true);ifstreamii("data.txt"); /读取数据 while(ii.eof()=0)ii.read(char *)&stu,sizeof(stu);if(stu.xuehao=m_xuehao2) find=1;break; ii.close(); if(find=0)this->MessageBox("该学号尚未注册!");else num=true;if(stu.mima=m_mima)code=true;elsethis->MessageBox("密码错误!"); if(num=true&&code=true) xueshengziliao1 aa;this->UpdateData(true); aa.m_dianhua1=stu.dianhua; /更新关联变量 aa.m_dizhi1=stu.dizhi; aa.m_mima1=stu.mima; aa.m_nianbanji1=stu.nianbanji; aa.m_xingbie1=stu.xingbie; aa.m_xingming1=stu.xingming; aa.m_xuehao1=stu.xuehao; aa.m_xueyuan1=stu.xueyuan; aa.m_zhuanye1=stu.zhuanye;aa.m_jiguan1=stu.jiguan;this->UpdateData(false);this->OnCancel(); aa.DoModal(); /跳转窗口voidCMyDlg:Onguanbi() /关闭此窗口this->OnOK();3.2 学生资料设置及代码设计#include "stdafx.h"#include "学生信息管理系统.h"#include "学生信息管理系统Dlg.h"#include "xueshengziliao2.h"#include "chengji2.h"#include "fstream.h"#include "stu.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endifxueshengziliao2:xueshengziliao2(CWnd* pParent /*=NULL*/): CDialog(xueshengziliao2:IDD, pParent)m_zhuanye2 = _T("");m_xueyuan2 = _T("");m_xuehao2 = 0.0f;m_xingming2 = _T("");m_xingbie2 = _T("");m_nianbanji2 = _T("");m_mima2 = 0.0f;m_jiguan2 = _T("");m_dizhi2 = _T("");m_dianhua2 = 0.0f;void xueshengziliao2:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);DDX_Text(pDX, IDD_zhuanye2, m_zhuanye2);DDX_Text(pDX, IDD_xueyuan2, m_xueyuan2);DDX_Text(pDX, IDD_xuehao2, m_xuehao2);DDX_Text(pDX, IDD_xingming2, m_xingming2);DDX_Text(pDX, IDD_xingbie2, m_xingbie2);DDX_Text(pDX, IDD_nianbanji2, m_nianbanji2);DDX_Text(pDX, IDD_mima2, m_mima2);DDX_Text(pDX, IDD_jiguan2, m_jiguan2);DDX_Text(pDX, IDD_dizhi2, m_dizhi2);DDX_Text(pDX, IDD_dianhua2, m_dianhua2);BEGIN_MESSAGE_MAP(xueshengziliao2, CDialog)ON_BN_CLICKED(IDC_chaxun2, Onchaxun2)ON_BN_CLICKED(IDC_fanhui2, Onfanhui2)ON_BN_CLICKED(IDC_guanbi2, Onguanbi2)ON_BN_CLICKED(IDC_queren2, Onqueren2)ON_BN_CLICKED(IDC_shanchu2, Onshanchu2)ON_BN_CLICKED(IDC_shezhichengji2, Onshezhichengji2)ON_BN_CLICKED(IDC_xiugai2, Onxiugai2)END_MESSAGE_MAP()Void xueshengziliao2:Onfanhui2() /关闭此窗口并返回this->OnCancel();CMyDlg a;a.DoModal();Void xueshengziliao2:Onguanbi2() /关闭此窗口this->OnOK();Void xueshengziliao2:Onchaxun2() /查询用户资料int findFlag=0; this->UpdateData(true);struct stu stu; ifstream is("data.txt");while(is.eof()=0)is.read(char *)&stu,sizeof(stu);if(m_xuehao2=stu.xuehao) findFlag=1;break; is.close(); if(findFlag=1) m_xingming2=stu.xingming; m_mima2=stu.mima; m_xuehao2=stu.xuehao; m_dianhua2=stu.dianhua; m_dizhi2=stu.dizhi; m_nianbanji2=stu.nianbanji; m_xingbie2=stu.xingbie; m_xueyuan2=stu.xueyuan; m_zhuanye2=stu.zhuanye; m_jiguan2=stu.jiguan; else this->MessageBox("此学号用户不存在!"); m_xingming2="" m_mima2=0; m_xuehao2=0; m_dianhua2=0; m_dizhi2="" m_nianbanji2="" m_xingbie2="" m_xueyuan2="" m_zhuanye2="" m_jiguan2="" this->UpdateData(false);void xueshengziliao2:Onxiugai2() /修改用户资料unsigned long position = NULL;int findFlag=0; this->UpdateData(true);struct stu stu;ifstream is("data.txt");while(is.eof()=0)position = is.tellg();is.read(char *)&stu,sizeof(stu); if(stu.xuehao=m_xuehao2) findFlag=1;break;is.close();if(findFlag=0) this->MessageBox("此学号用户不存在!"); return; ofstream os("data.txt", ios:ate);os.seekp(position);strcpy(stu.xingming,m_xingming2); stu.mima=m_mima2; stu.xuehao=m_xuehao2; stu.dianhua=m_dianhua2; strcpy(stu.dizhi,m_dizhi2); strcpy(stu.nianbanji,m_nianbanji2); strcpy(stu.xingbie,m_xingbie2); strcpy(stu.xueyuan,m_xueyuan2); strcpy(stu.zhuanye,m_zhuanye2); strcpy(stu.jiguan,m_jiguan2);os.write(char *)&stu,sizeof(stu);os.close(); this->MessageBox("修改成功");void xueshengziliao2:Onqueren2() /用户注册stu stu,stu1; this->UpdateData(true); strcpy(stu.xingming,m_xingming2); stu.mima=m_mima2; stu.xuehao=m_xuehao2; stu.dianhua=m_dianhua2; strcpy(stu.dizhi,m_dizhi2); strcpy(stu.nianbanji,m_nianbanji2); strcpy(stu.xingbie,m_xingbie2); strcpy(stu.xueyuan,m_xueyuan2); strcpy(stu.zhuanye,m_zhuanye2); strcpy(stu.jiguan,m_jiguan2); ifstream is("data.txt"); int i=0; while(is.eof()=0)is.read(char *)&stu1,sizeof(stu1);if(stu1.xuehao=m_xuehao2) i=1; this->MessageBox("此学号用户已登记!");break; is.close(); if(i=0) ofstream os("data.txt",ios:app); os.write(char *)&stu,sizeof(stu); os.close(); MessageBox("此学号用户注册成功!"); Void xueshengziliao2:Onshanchu2() /删除用户资料unsigned long position = NULL;struct stu stu;int findFlag=0; this->UpdateData(true); ifstream is("data.txt");while(is.eof()=0)position = is.tellg();is.read(char *)&stu,sizeof(stu); if(stu.xuehao=m_xuehao2) findFlag=1;break;is.close();if(findFlag=0) this->MessageBox("此学号用户不存在,删除失败!"); return; ofstream os("data.txt", ios:ate);os.seekp(position); strcpy(stu.xingming,""); stu.mima=0; stu.xuehao=0; stu.dianhua=0; strcpy(stu.dizhi,""); strcpy(stu.nianbanji,""); strcpy(stu.xingbie,""); strcpy(stu.xueyuan,""); strcpy(stu.zhuanye,""); strcpy(stu.jiguan,"");os.write(char *)&stu,sizeof(stu);os.close(); m_xingming2="" m_mima2=0; m_xuehao2=0; m_dianhua2=0; m_dizhi2="" m_nianbanji2="" m_xingbie2="" m_xueyuan2="" m_zhuanye2="" m_jiguan2="" this->MessageBox("删除成功");this->UpdateData(false);Void xueshengziliao2:Onshezhichengji2() /判断学生资料存在与否和跳到学生资料窗口chengji2 a;a.DoModal();3.3 学生成绩设置及代码设计/ chengji2.cpp : implementation file#include "stdafx.h"#include "学生信息管理系统.h"#include "chengji2.h"#include "fstream.h"#include "fen.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endifchengji2:chengji2(CWnd* pParent ): CDialog(chengji2:IDD, pParent)m_c1 = 0.0f;m_changweifen1 = 0.0f;m_makesiyuanli1 = 0.0f;m_pingjunfen1 = 0.0f;m_shufen1 = 0.0f;m_tiyu1 = 0.0f;m_wuli1 = 0.0f;m_wulishiyan1 = 0.0f;m_yingyu1 = 0.0f;m_zongfen1 = 0.0f;m_paiming1 = 0.0f;m_xuehao1 = 0.0f;void chengji2:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);DDX_Text(pDX, IDD_c1, m_c1);DDX_Text(pDX, IDD_changweifen1, m_changweifen1);DDX_Text(pDX, IDD_makesiyuanli1, m_makesiyuanli1);DDX_Text(pDX, IDD_pingjunfen1, m_pingjunfen1);DDX_Text(pDX, IDD_shufen1, m_shufen1);DDX_Text(pDX, IDD_tiyu1, m_tiyu1);DDX_Text(pDX, IDD_wuli1, m_wuli1);DDX_Text(pDX, IDD_wulishiyan1, m_wulishiyan1);DDX_Text(pDX, IDD_yingyu1, m_yingyu1);DDX_Text(pDX, IDD_zongfen1, m_zongfen1);DDX_Text(pDX, IDC_paiming11, m_paiming1);DDX_Text(pDX, IDC_xuehao21, m_xuehao1);BEGIN_MESSAGE_MAP(chengji2, CDialog)ON_BN_CLICKED(IDC_queren2, Onqueren2)ON_BN_CLICKED(IDC_fanhui2, Onfanhui2)ON_BN_CLICKED(IDC_guanbi2, Onguanbi2)ON_BN_CLICKED(IDC_shanchu2, Onshanchu2)ON_BN_CLICKED(IDC_xiugai2, Onxiugai2)ON_BN_CLICKED(IDC_chaxun2, Onchaxun2)END_MESSAGE_MAP()void chengji2:Onqueren2() /登记小学生成绩fen fen,fen1; this->UpdateData(true); fen.c=m_c1; fen.changweifen=m_changweifen1; fen.makesiyuanli=m_makesiyuanli1; fen.shufen=m_shufen1; fen.tiyu=m_tiyu1; fen.wuli=m_wuli1; fen.wulishiyan=m_wulishiyan1; fen.yingyu=m_yingyu1; fen.xuehao=m