VC++学生管理信息系统的设计与开发课程设计.docx

上传人:b****5 文档编号:6401110 上传时间:2023-01-06 格式:DOCX 页数:33 大小:91.25KB
下载 相关 举报
VC++学生管理信息系统的设计与开发课程设计.docx_第1页
第1页 / 共33页
VC++学生管理信息系统的设计与开发课程设计.docx_第2页
第2页 / 共33页
VC++学生管理信息系统的设计与开发课程设计.docx_第3页
第3页 / 共33页
VC++学生管理信息系统的设计与开发课程设计.docx_第4页
第4页 / 共33页
VC++学生管理信息系统的设计与开发课程设计.docx_第5页
第5页 / 共33页
点击查看更多>>
下载资源
资源描述

VC++学生管理信息系统的设计与开发课程设计.docx

《VC++学生管理信息系统的设计与开发课程设计.docx》由会员分享,可在线阅读,更多相关《VC++学生管理信息系统的设计与开发课程设计.docx(33页珍藏版)》请在冰豆网上搜索。

VC++学生管理信息系统的设计与开发课程设计.docx

VC++学生管理信息系统的设计与开发课程设计

甘肃政法学院

面向对象程序设计

期末考试

 

题目学生管理信息系统的设计与开发

 

院专业级班

 

学号:

__xxx_

姓名:

_____xx_____

指导教师:

__________

成绩:

_______________

完成时间:

_2011年_7月

 

一、项目说明:

作为用户输入的接口,列表框中可列出用户所需的各种可能的选项,这样一来,用户不需要记住这些项,只需进行选择操作即可,但用户却不能输入列表框中列表项之外的内容。

虽然编辑框能够允许用户输入内容,但却没有列表框的选择操作。

于是很自然地产生这样的想法:

把常用的项列在列表框中以供选择,而同时提供编辑框,允许用户输入列表框中所没有的新项。

组合框正是这样的一种控件,它结合列表框和编辑框的特点,取二者之长,从而完成较为复杂的输入功能。

二、各功能模块的介绍河和源代码介绍:

1、组合框的类型如图一所示:

但本程序用的是下拉式组合框。

2、城市邮政编码和区号对话框添加的空间如图二所示:

图二

3、为各控件增加的成员变量如图三所示:

图三

4、完善的各源代码

、打开MFCClassWizard的MemberVariables页面,看看Classname是否是

CCityZoneDlg,然后选中所需的控件ID标识符,双击鼠标或单击AddVariables

按钮。

依次为下列控件增加成员变量,如图三所示:

、将项目工作区切换到ClassView页面,右击CCityZoneDlg类名,从弹出的快

捷菜单中选择“AddMemberFunction”,弹出AddMemberFunction对话框,在

FunctionType(函数类型)框中输入BOOL,在FunctionDeclaration(函数声明)框

中输入IsValidate,单击[OK]按钮

、在CCityZoneDlg:

:

IsValidate函数输入下列代码:

BOOLCCityZoneDlg:

:

IsValidate()

{

UpdateData();m_strCity.TrimLeft();

if(m_strCity.IsEmpty())

{MessageBox("城市名输入无效!

");returnFALSE;}

m_strZip.TrimLeft();

if(m_strZip.IsEmpty())

{MessageBox("邮政编码输入无效!

");returnFALSE;}

m_strZone.TrimLeft();

if(m_strZone.IsEmpty())

{MessageBox("区号输入无效!

");returnFALSE;}

returnTRUE;

}

打开MFCClassWizard,切换到MesssageMaps页面,为按钮

IDC_BUTTON_ADD添加BN_CLICKED的消息映射,并增加下列代码:

voidCCityZoneDlg:

:

OnButtonAdd()

{

if(!

IsValidate())return;

intnIndex=m_ComboBox.FindStringExact(-1,m_strCity);

if(nIndex!

=CB_ERR)

{MessageBox("该城市已添加!

");return;}

CStringstrData;

strData.Format(“%s,%s”,m_strZip,m_strZone);//将邮政编码和区号合并为

一个字符串

m_ComboBox.SetItemDataPtr(nIndex,newCString(strData));

}

用MFCClassWizard为按钮IDC_BUTTON_CHANGE添加BN_CLICKED的消

息映射,并增加下列代码:

voidCCityZoneDlg:

:

OnButtonChange()

{

if(!

IsValidate())return;

intnIndex=m_ComboBox.FindStringExact(-1,m_strCity);

if(nIndex!

=CB_ERR)

{

delete(CString*)m_ComboBox.GetItemDataPtr(nIndex);

CStringstrData;

strData.Format("%s,%s",m_strZip,m_strZone);

m_ComboBox.SetItemDataPtr(nIndex,newCString(strData));

}

}

、用MFCClassWizard为组合框IDC_COMBO1添加CBN_SELCHANGE(当前

选择项发生改变)的消息映射,并增加下列代码:

voidCCityZoneDlg:

:

OnSelchangeCombo1()

{

intnIndex=m_ComboBox.GetCurSel();

if(nIndex!

=CB_ERR)

{

m_ComboBox.GetLBText(nIndex,m_strCity);

CStringstrData=*(CString*)m_ComboBox.GetItemDataPtr(nIndex);

//分解字符串

intn=strData.Find(',');

m_strZip=strData.Left(n);//前面的n个字符

m_strZone=strData.Mid(n+1);//从中间第n+1字符到未尾的字符串UpdateData(FALSE);

}

}

用MFCClassWizard为对话框添加WM_DESTROY的消息映射,并增加下列

代码:

voidCCityZoneDlg:

:

OnDestroy()//此消息是当对话框关闭时发送的

{

for(intnIndex=m_ComboBox.GetCount()-1;nIndex>=0;nIndex--)

{

//删除所有与列表项相关联的CString数据,并释放内存

delete(CString*)m_ComboBox.GetItemDataPtr(nIndex);

}

CDialog:

:

OnDestroy();

}

5、调用对话框:

(1)打开Ex_CityCode单文档应用程序的菜单资源,添加顶层菜单项“测试(&T)”,

在其下添加一个菜单项“城市邮政编码和区号(&Z)”,ID为ID_TEST_CITYZONE。

(2)用MFCClassWizard为CMainFrame类添加菜单项ID_TEST_CITYZONE的

COMMAND消息映射,取默认的映射函数名,并添加下列代码:

voidCMainFrame:

:

OnTestCityzone()

{

CCityZoneDlgdlg;

dlg.DoModal();

}

(3)在文件MainFrm.cpp的前面添加CCityZoneDlg类的头文件包含:

#include"MainFrm.h"

#include"CityZoneDlg.h"

(1)打开Ex_CityCode单文档应用程序的菜单资源,添加顶层菜单项“测试(&T)”,

在其下添加一个菜单项“城市邮政编码和区号(&Z)”,ID为ID_TEST_CITYZONE。

(2)用MFCClassWizard为CMainFrame类添加菜单项ID_TEST_CITYZONE的

COMMAND消息映射,取默认的映射函数名,并添加下列代码:

voidCMainFrame:

:

OnTestCityzone()

{

(1)打开Ex_CityCode单文档应用程序的菜单资源,添加顶层菜单项“测试(&T)”,

在其下添加一个菜单项“城市邮政编码和区号(&Z)”,ID为ID_TEST_CITYZONE。

(2)用MFCClassWizard为CMainFrame类添加菜单项ID_TEST_CITYZONE的

COMMAND消息映射,取默认的映射函数名,并添加下列代码:

voidCMainFrame:

:

OnTestCityzone()

{

CCityZoneDlgdlg;

dlg.DoModal();

}

(3)在文件MainFrm.cpp的前面添加CCityZoneDlg类的头文件包含:

#include"MainFrm.h"

#include"CityZoneDlg.h"

(4)编译运行并测试

CCityZoneDlgdlg;

dlg.DoModal();

}

(3)在文件MainFrm.cpp的前面添加CCityZoneDlg类的头文件包含:

#include"MainFrm.h"

#include"CityZoneDlg.h"

(4)源程序编码CPP

#include"stdafx.h"

#include"Ex_CityCode.h"

#include"CityZoneDig.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE__;

#endif

//CCityZoneDigdialog

 

CCityZoneDig:

:

CCityZoneDig(CWnd*pParent/*=NULL*/)

:

CDialog(CCityZoneDig:

:

IDD,pParent)

{

//{{AFX_DATA_INIT(CCityZoneDig)

m_strCity=_T("");

m_strZone=_T("");

m_strZip=_T("");

//}}AFX_DATA_INIT

}

 

voidCCityZoneDig:

:

DoDataExchange(CDataExchange*pDX)

{

CDialog:

:

DoDataExchange(pDX);

//{{AFX_DATA_MAP(CCityZoneDig)

DDX_Control(pDX,IDC_COMBO1,m_ComboBox);

DDX_CBString(pDX,IDC_COMBO1,m_strCity);

DDX_Text(pDX,IDC_EDIT_ZONE,m_strZone);

DDX_Text(pDX,IDC_EDIT_ZIP,m_strZip);

//}}AFX_DATA_MAP

}

 

BEGIN_MESSAGE_MAP(CCityZoneDig,CDialog)

//{{AFX_MSG_MAP(CCityZoneDig)

ON_BN_CLICKED(IDC_BUTTON_ADD,OnButtonAdd)

ON_BN_CLICKED(IDC_BUTTON_CHANGE,OnButtonChange)

ON_CBN_SELCHANGE(IDC_COMBO1,OnSelchangeCombo1)

ON_WM_DESTROY()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

//CCityZoneDigmessagehandlers

BOOLCCityZoneDig:

:

IsValidate()

{

UpdateData();m_strCity.TrimLeft();

if(m_strCity.IsEmpty())

{MessageBox("城市名输入无效!

");returnFALSE;}

m_strZip.TrimLeft();

if(m_strZip.IsEmpty())

{MessageBox("邮政编码输入无效!

");returnFALSE;}

m_strZone.TrimLeft();

if(m_strZone.IsEmpty())

{MessageBox("区号输入无效!

");returnFALSE;}

returnTRUE;

}

voidCCityZoneDig:

:

OnButtonAdd()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

if(!

IsValidate())return;

intnIndex=m_ComboBox.FindStringExact(-1,m_strCity);

if(nIndex!

=CB_ERR)

{MessageBox("该城市已添加!

");return;}

CStringstrData;

strData.Format("%s,%s",m_strZip,m_strZone);//将邮政骗码和区号合并为一个字符串

m_ComboBox.SetItemDataPtr(nIndex,newCString(strData));

}

voidCCityZoneDig:

:

OnButtonChange()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

if(!

IsValidate())return;

intnIndex=m_ComboBox.FindStringExact(-1,m_strCity);

If(nIndex!

=CB_ERR)

{

delete(CString*)m_ComboBox.GetItemDataPtr(nIndex);

CStringstrData;

strData.Format("%s,%s",m_strZip,m_strZone);

m_ComboBox.SetItemDataPtr(nIndex,newCString(strData));

}//CCityZoneDigdialog

 

CCityZoneDig:

:

CCityZoneDig(CWnd*pParent/*=NULL*/)

:

CDialog(CCityZoneDig:

:

IDD,pParent)

{

//{{AFX_DATA_INIT(CCityZoneDig)

m_strCity=_T("");

m_strZone=_T("");

m_strZip=_T("");

//}}AFX_DATA_INIT

}

 

voidCCityZoneDig:

:

DoDataExchange(CDataExchange*pDX)

{

CDialog:

:

DoDataExchange(pDX);

//{{AFX_DATA_MAP(CCityZoneDig)

DDX_Control(pDX,IDC_COMBO1,m_ComboBox);

DDX_CBString(pDX,IDC_COMBO1,m_strCity);

DDX_Text(pDX,IDC_EDIT_ZONE,m_strZone);

DDX_Text(pDX,IDC_EDIT_ZIP,m_strZip);

//}}AFX_DATA_MAP

}

 

BEGIN_MESSAGE_MAP(CCityZoneDig,CDialog)

//{{AFX_MSG_MAP(CCityZoneDig)

ON_BN_CLICKED(IDC_BUTTON_ADD,OnButtonAdd)

ON_BN_CLICKED(IDC_BUTTON_CHANGE,OnButtonChange)

ON_CBN_SELCHANGE(IDC_COMBO1,OnSelchangeCombo1)

ON_WM_DESTROY()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

//CCityZoneDigmessagehandlers

BOOLCCityZoneDig:

:

IsValidate()

{

UpdateData();m_strCity.TrimLeft();

if(m_strCity.IsEmpty())

{MessageBox("城市名输入无效!

");returnFALSE;}

m_strZip.TrimLeft();

if(m_strZip.IsEmpty())

{MessageBox("邮政编码输入无效!

");returnFALSE;}

m_strZone.TrimLeft();

if(m_strZone.IsEmpty())

{MessageBox("区号输入无效!

");returnFALSE;}

returnTRUE;

}

voidCCityZoneDig:

:

OnButtonAdd()

{//CCityZoneDigdialog

 

CCityZoneDig:

:

CCityZoneDig(CWnd*pParent/*=NULL*/)

:

CDialog(CCityZoneDig:

:

IDD,pParent)

{

//{{AFX_DATA_INIT(CCityZoneDig)

m_strCity=_T("");

m_strZone=_T("");

m_strZip=_T("");

//}}AFX_DATA_INIT

}

 

voidCCityZoneDig:

:

DoDataExchange(CDataExchange*pDX)

{

CDialog:

:

DoDataExchange(pDX);

//{{AFX_DATA_MAP(CCityZoneDig)

DDX_Control(pDX,IDC_COMBO1,m_ComboBox);

DDX_CBString(pDX,IDC_COMBO1,m_strCity);

DDX_Text(pDX,IDC_EDIT_ZONE,m_strZone);

DDX_Text(pDX,IDC_EDIT_ZIP,m_strZip);

//}}AFX_DATA_MAP

}

 

BEGIN_MESSAGE_MAP(CCityZoneDig,CDialog)

//{{AFX_MSG_MAP(CCityZoneDig)

ON_BN_CLICKED(IDC_BUTTON_ADD,OnButtonAdd)

ON_BN_CLICKED(IDC_BUTTON_CHANGE,OnButtonChange)

ON_CBN_SELCHANGE(IDC_COMBO1,OnSelchangeCombo1)

ON_WM_DESTROY()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

//CCityZoneDigmessagehandlers

BOOLCCityZoneDig:

:

IsValidate()

{

UpdateData();m_strCity.TrimLeft();

if(m_strCity.IsEmpty())

{MessageBox("城市名输入无效!

");returnFALSE;}

m_strZip.TrimLeft();

if(m_strZip.IsEmpty())

{MessageBox("邮政编码输入无效!

");returnFALSE;}

m_strZone.TrimLeft();

if(m_strZone.IsEmpty())

{MessageBox("区号输入无效!

");returnFALSE;}

returnTRUE;

}

voidCCityZoneDig:

:

OnButtonAdd()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

if(!

IsValidate())return;

intnIndex=m_ComboBox.FindStringExact(-1,m_strCity);

if(nIndex!

=CB_ERR)

{MessageBox("该城市已添加!

");return;}

CStringstrData;

strData.Format("%s,%s",m_strZip,m_strZone);//将邮政骗码和区号合并为一个字符串

m_ComboBox.SetItemDataPtr(nIndex,newCString(strData));

}

voidCCityZoneDig:

:

OnButtonChange()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

if(!

IsValidate())return;

intnIndex=m_ComboBox.FindStringExact(-1,m_strCity);

if(nIndex!

=CB_ERR)

{

delete(CString*)m_ComboBox.GetItemDataPtr(nIndex);

CStringstrData;

strData.Format("%s,%s",m_strZip,m_strZone);

m_ComboBox.SetItemDataPtr(nIndex,newCString(strData));

}

}

voidCCityZoneDig:

:

OnSelchangeCombo1()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

intnIndex=m_ComboBox.GetCurSel();

if(nIndex!

=CB_ERR)

{

m_ComboBox.GetLBText(nIndex,m_strCity);

CStringstrData=*(C

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

当前位置:首页 > 高等教育 > 研究生入学考试

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

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