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

📄 deldlg.cpp

📁 MFC做的学生管理系统
💻 CPP
字号:
// DelDlg.cpp : implementation file
//

#include "stdafx.h"


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

/////////////////////////////////////////////////////////////////////////////
// CDelDlg dialog


CDelDlg::CDelDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDelDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDelDlg)
	m_strEditStuNum = _T("");
	//}}AFX_DATA_INIT
}


void CDelDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDelDlg)
	DDX_Text(pDX, IDC_EditStuNum, m_strEditStuNum);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDelDlg, CDialog)
	//{{AFX_MSG_MAP(CDelDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDelDlg message handlers

void CDelDlg::OnOK() 
{
	// TODO: Add extra validation here	
	int n_Status = 0;
	CDialog::OnOK();
	CString sz_StuNum;
	sz_StuNum = this->m_strEditStuNum;  //取出要删除记录的学号

    CMfcDesignDoc* pDoc = theApp.GetDocPointer();

	POSITION pos =pDoc->m_StudentList.GetHeadPosition();
	while (pos != NULL)
	{	
		CStudent* pCStudent = pDoc->m_StudentList.GetAt(pos);
       
		if(pCStudent->m_strStuNum == sz_StuNum)
		{
           pDoc->m_StudentList.RemoveAt(pos); //删除记录
		   n_Status = 1;
		   break;
		}
		else
		{
	    	pDoc->m_StudentList.GetNext(pos);
		}
	}

	if(n_Status == 0)
	{
		MessageBox("删除失败!");
	}
	else
	{
		MessageBox("删除成功!");
	}

}

⌨️ 快捷键说明

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