VC大作业分析报告学生信息管理系统.docx
《VC大作业分析报告学生信息管理系统.docx》由会员分享,可在线阅读,更多相关《VC大作业分析报告学生信息管理系统.docx(12页珍藏版)》请在冰豆网上搜索。
VC大作业分析报告学生信息管理系统
VC大作业报告(学生信息管理系统)
————————————————————————————————作者:
————————————————————————————————日期:
高级程序设计项目训练报告
指导教师:
黄欢
时间2012年7月27日
专业年级:
姓名:
学号:
报告分
程序功能:
1)学生基本信息录入功能
2)学生信息查询功能
3)学生信息的删除
学生信息包括:
姓名、性别、学号、班级、出生年月、手机号码、已经获得学分等
输入输出数据的说明:
输入学生信息点击确定,在“学生信息查询”中输入姓名,就可以在“查询结果”中输出相应信息。
报告内容
一、分析
设计的是一个基于MFC对话框的C++应用程序,创建了一个主对话框,和一些必要的子对话框。
在主对话框中添加列表控件用来显示学生的基本信息。
主要用到了在MFC中运用编辑框的只是,还有插入位图。
二、操作
运行后点击“学生信息录入”显示:
输入相关信息在确定。
在选中信息点击删除,可进行删除操作。
点击“学生信息查询”显示:
输入名字,若有信息储存,则在查询结果中显示,若无信息储存则显示:
主代码:
//zxyDlg.cpp:
implementationfile
//
#include"stdafx.h"
#include"zxy.h"
#include"zxyDlg.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CAboutDlgdialogusedforAppAbout
classCAboutDlg:
publicCDialog
{
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:
:
CAboutDlg():
CDialog(CAboutDlg:
:
IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
voidCAboutDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CZxyDlgdialog
CZxyDlg:
:
CZxyDlg(CWnd*pParent/*=NULL*/)
:
CDialog(CZxyDlg:
:
IDD,pParent)
{
//{{AFX_DATA_INIT(CZxyDlg)
//NOTE:
theClassWizardwilladdmemberinitializationhere
//}}AFX_DATA_INIT
//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32
m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
voidCZxyDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZxyDlg)
DDX_Control(pDX,IDC_BUTTON3,m_button_change);
DDX_Control(pDX,IDC_BUTTON2,m_button_del);
DDX_Control(pDX,IDC_BUTTON1,m_button_enter);
DDX_Control(pDX,IDC_LIST4,m_list_ctrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZxyDlg,CDialog)
//{{AFX_MSG_MAP(CZxyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1,OnButton1)
ON_BN_CLICKED(IDC_BUTTON2,OnButton2)
ON_BN_CLICKED(IDC_BUTTON3,OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CZxyDlgmessagehandlers
BOOLCZxyDlg:
:
OnInitDialog()
{
CDialog:
:
OnInitDialog();
//Add"About..."menuitemtosystemmenu.
//IDM_ABOUTBOXmustbeinthesystemcommandrange.
ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX<0xF000);
CMenu*pSysMenu=GetSystemMenu(FALSE);
if(pSysMenu!
=NULL)
{
CStringstrAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if(!
strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);
}
}
//Settheiconforthisdialog.Theframeworkdoesthisautomatically
//whentheapplication'smainwindowisnotadialog
SetIcon(m_hIcon,TRUE);//Setbigicon
SetIcon(m_hIcon,FALSE);//Setsmallicon
//TODO:
Addextrainitializationhere
m_list_ctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT);
CRectrect;
m_list_ctrl.GetClientRect(&rect);
intnColInterval=rect.Width()/16;
m_list_ctrl.InsertColumn(0,_T("学号"),LVCFMT_LEFT,nColInterval*3);
m_list_ctrl.InsertColumn(1,_T("姓名"),LVCFMT_LEFT,nColInterval*2);
m_list_ctrl.InsertColumn(2,_T("性别"),LVCFMT_CENTER,nColInterval*1+5);
m_list_ctrl.InsertColumn(3,_T("班级"),LVCFMT_LEFT,nColInterval*2);
m_list_ctrl.InsertColumn(4,_T("出生日期"),LVCFMT_LEFT,nColInterval*3);
m_list_ctrl.InsertColumn(5,_T("电话号码"),LVCFMT_LEFT,nColInterval*3);
m_list_ctrl.InsertColumn(6,_T("已获学分"),LVCFMT_LEFT,nColInterval*2);
returnTRUE;//returnTRUEunlessyousetthefocustoacontrol
}
voidCZxyDlg:
:
OnSysCommand(UINTnID,LPARAMlParam)
{
if((nID&0xFFF0)==IDM_ABOUTBOX)
{
CAboutDlgdlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog:
:
OnSysCommand(nID,lParam);
}
}
//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow
//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,
//thisisautomaticallydoneforyoubytheframework.
voidCZxyDlg:
:
OnPaint()
{
if(IsIconic())
{
CPaintDCdc(this);//devicecontextforpainting
SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);
//Centericoninclientrectangle
intcxIcon=GetSystemMetrics(SM_CXICON);
intcyIcon=GetSystemMetrics(SM_CYICON);
CRectrect;
GetClientRect(&rect);
intx=(rect.Width()-cxIcon+1)/2;
inty=(rect.Height()-cyIcon+1)/2;
//Drawtheicon
dc.DrawIcon(x,y,m_hIcon);
}
else
{
CDialog:
:
OnPaint();
}
}
//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags
//theminimizedwindow.
HCURSORCZxyDlg:
:
OnQueryDragIcon()
{
return(HCURSOR)m_hIcon;
}
#include"MyDialog_enter.h"
voidCZxyDlg:
:
OnButton1()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
CMyDialog_enter*pwd=newCMyDialog_enter(this);
pwd->Create(IDD_DIALOG1,this);
pwd->ShowWindow
(1);
}
#include"student.h"
voidCZxyDlg:
:
List_Show(void)
{
m_list_ctrl.DeleteAllItems();
intnItem=m_list_ctrl.GetItemCount();
for(inti=0;i{
m_list_ctrl.InsertItem(nItem,people[i].sno);
m_list_ctrl.SetItemText(nItem,1,people[i].sname);
m_list_ctrl.SetItemText(nItem,2,people[i].sex);
m_list_ctrl.SetItemText(nItem,3,people[i].inst);
m_list_ctrl.SetItemText(nItem,4,people[i].brondata);
m_list_ctrl.SetItemText(nItem,5,people[i].phone);
m_list_ctrl.SetItemText(nItem,6,people[i].grade);
}
}
voidCZxyDlg:
:
OnButton2()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
intnItem=m_list_ctrl.GetSelectionMark();
//AfxMessageBox(people[nItem].sname,MB_OK);
if(nItem==-1)
{
AfxMessageBox("您未选择任何内容!
",MB_OK);
}
else
{
if(AfxMessageBox("确认删除学生"+people[nItem].sname+"的信息?
",MB_YESNO)==IDYES)
{
for(;nItem{
people[nItem].All_Copy(people[nItem+1]);
}
people[0].AllNumber--;
List_Show();
}
}
}
#include"MyDialog_2.h"
voidCZxyDlg:
:
OnButton3()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
CMyDialog_2*pwnd=newCMyDialog_2(this);
pwnd->Create(IDD_DIALOG2,this);
pwnd->ShowWindow
(1);
}
BOOLCZxyDlg:
:
PreTranslateMessage(MSG*pMsg)//屏蔽回车和ESC按键
{
//TODO:
在此添加专用代码和/或调用基类
{
//屏蔽回车和ESC键
//屏蔽ESC键退出
if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==0x1b)
returnTRUE;
//回车
if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==0x0d)
returnTRUE;
}
returnCDialog:
:
PreTranslateMessage(pMsg);
}
遇到的问题及解决方法(编译错误提示及如何解决)
1、主要遇到了一些成员变量添加错误的问题,在通过Ctrl+W操作显示窗口中重新添加后得以改正,是缺少成员变量的问题。
2、还有做作业的过程中多次遇到缺少定义的现象,在同学的帮助下找到并添加改正。
3、在执行时出现“计算机中缺少.DLL文件,无法运行”的问题在工程的常规中在了连接方式后运行。