⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xsdlg.cpp

📁 visual c++编写的简单学生成绩管理系统
💻 CPP
字号:
// XSDlg.cpp : implementation file
//

#include "stdafx.h"
#include "LGH.h"
#include "XSDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CXSDlg dialog


CXSDlg::CXSDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CXSDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CXSDlg)
	m_strName = _T("");
	m_nMod = 0;
	m_nShud = 0;
	m_nYingy = 0;
	m_nGaos = 0;
	//}}AFX_DATA_INIT
}


void CXSDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CXSDlg)
	DDX_Control(pDX, IDC_LISTSTATE, m_ListBx);
	DDX_Text(pDX, IDC_EDITNAME, m_strName);
	DDX_Text(pDX, IDC_EDITMOD, m_nMod);
	DDX_Text(pDX, IDC_EDITSHUD, m_nShud);
	DDX_Text(pDX, IDC_EDITYINGY, m_nYingy);
	DDX_Text(pDX, IDC_EDITGAOS, m_nGaos);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CXSDlg, CDialog)
	//{{AFX_MSG_MAP(CXSDlg)
	ON_BN_CLICKED(IDC_BUTNADD, OnButnadd)
	ON_BN_CLICKED(IDC_BUTNDEL, OnButndel)
	ON_LBN_SELCHANGE(IDC_LISTSTATE, OnSelchangeListstate)
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CXSDlg message handlers

void CXSDlg::OnButnadd() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_strName.IsEmpty())
	{
	MessageBox("姓名不能为空!");
	return;
	}
m_strName.TrimLeft();
m_strName.TrimRight();
if((m_ListBx.FindString(-1,m_strName))!=LB_ERR)
{
MessageBox("列表框中已有该项,不能再添加!");
return;
}
int nIndex=m_ListBx.AddString(m_strName);
SStud stStud;
stStud.strName=m_strName;
stStud.nGaos=m_nGaos;
stStud.nYingy=m_nYingy;
stStud.nMod=m_nMod;
stStud.nShud=m_nShud;
m_ListBx.SetItemDataPtr(nIndex,new SStud(stStud));	
	m_strName="";
	m_nGaos='\0';
	m_nYingy='\0';
	m_nMod='\0';
	m_nShud='\0';
	UpdateData(FALSE);
}

void CXSDlg::OnButndel() 
{
	// TODO: Add your control notification handler code here
	int nIndex=m_ListBx.GetCurSel();
	if(nIndex!=LB_ERR)
	{
		delete (SStud *)m_ListBx.GetItemDataPtr(nIndex);
	m_ListBx.DeleteString(nIndex);
	m_strName="";
	m_nGaos=0;
	m_nYingy=0;
	m_nMod=0;
	m_nShud=0;
	UpdateData(FALSE);
	}
	else 
		MessageBox("没有选择列表项或列表框操作失败!");
}

void CXSDlg::OnSelchangeListstate() 
{
	// TODO: Add your control notification handler code here
	int nIndex=m_ListBx.GetCurSel();
	if(nIndex!=LB_ERR)
	{
	SStud *pstStu=(SStud *)m_ListBx.GetItemDataPtr(nIndex);
	m_strName=pstStu->strName;
	m_nGaos=pstStu->nGaos;
	m_nYingy=pstStu->nYingy;
	m_nMod=pstStu->nMod;
	m_nShud=pstStu->nShud;
	UpdateData(FALSE);
	}
}

void CXSDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	
	// TODO: Add your message handler code here
	for(int nIndex=m_ListBx.GetCount()-1;nIndex>=0;nIndex--)
	{
	delete (SStud *)m_ListBx.GetItemDataPtr(nIndex);
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -