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

📄 classmateview.cpp

📁 一个简易通讯录
💻 CPP
字号:
// classmateView.cpp : implementation of the CClassmateView class
//

#include "stdafx.h"
#include "classmate.h"

#include "classmateDoc.h"
#include "classmateView.h"
//#include "classmateSet.h"

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

/////////////////////////////////////////////////////////////////////////////
// CClassmateView

IMPLEMENT_DYNCREATE(CClassmateView, CRecordView)

BEGIN_MESSAGE_MAP(CClassmateView, CRecordView)
	//{{AFX_MSG_MAP(CClassmateView)
	ON_COMMAND(ID_addrecord, Onaddrecord)
	ON_COMMAND(ID_clearrecord, Onclearrecord)
	ON_COMMAND(ID_delrecord, Ondelrecord)
	ON_COMMAND(ID_update, Onupdate)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CClassmateView construction/destruction

CClassmateView::CClassmateView()
	: CRecordView(CClassmateView::IDD)
{
	//{{AFX_DATA_INIT(CClassmateView)
	m_pSet = NULL;
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CClassmateView::~CClassmateView()
{
}

void CClassmateView::DoDataExchange(CDataExchange* pDX)
{
	CRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CClassmateView)
	DDX_FieldText(pDX, IDC_address, m_pSet->m_column7, m_pSet);
	DDX_FieldText(pDX, IDC_ID, m_pSet->m_column1, m_pSet);
	DDX_FieldText(pDX, IDC_name, m_pSet->m_column3, m_pSet);
	DDX_FieldText(pDX, IDC_sex, m_pSet->m_column5, m_pSet);
	DDX_FieldText(pDX, IDC_tel, m_pSet->m_column4, m_pSet);
	DDX_FieldText(pDX, IDC_telphone, m_pSet->m_column6, m_pSet);
	DDX_FieldText(pDX, IDC_work, m_pSet->m_column2, m_pSet);
	//}}AFX_DATA_MAP
}

BOOL CClassmateView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CRecordView::PreCreateWindow(cs);
}

void CClassmateView::OnInitialUpdate()
{
	m_pSet = &GetDocument()->m_classmateSet;
	CRecordView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

}

/////////////////////////////////////////////////////////////////////////////
// CClassmateView printing

BOOL CClassmateView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CClassmateView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CClassmateView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CClassmateView diagnostics

#ifdef _DEBUG
void CClassmateView::AssertValid() const
{
	CRecordView::AssertValid();
}

void CClassmateView::Dump(CDumpContext& dc) const
{
	CRecordView::Dump(dc);
}

CClassmateDoc* CClassmateView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CClassmateDoc)));
	return (CClassmateDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CClassmateView database support
CRecordset* CClassmateView::OnGetRecordset()
{
	return m_pSet;
}


/////////////////////////////////////////////////////////////////////////////
// CClassmateView message handlers

void CClassmateView::Onaddrecord() 
{
	// TODO: Add your command handler code here
	
}

void CClassmateView::Onclearrecord() 
{
	m_pSet->SetFieldNull (NULL);
	UpdateData(FALSE);
	// TODO: Add your command handler code here
	
}

void CClassmateView::Ondelrecord() 

{
	try
	{m_pSet->Delete();
	}
	catch(CDBException*e)
	{AfxMessageBox(e->m_strError);
	e->Delete();
	m_pSet->MoveFirst();
	UpdateData(FALSE);
	return;
	}
	if (m_pSet->IsEOF())
		m_pSet->MoveLast();
	if (m_pSet->IsBOF())
		m_pSet->SetFieldNull(NULL);
	UpdateData(FALSE);

	// TODO: Add your command handler code here
	
}

void CClassmateView::Onupdate() 
{
	m_pSet->Edit();
	UpdateData(TRUE);
	if (m_pSet->CanUpdate())
	{m_pSet->Update();
	}

	// TODO: Add your command handler code here
	
}

⌨️ 快捷键说明

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