【VC开源代码栏目提醒】:网学会员为需要VC开源代码的朋友们搜集整理了AdoStudentView.cpp相关资料,希望对各位网友有所帮助!
// AdoStudentView.cpp : CAdoStudentView 类的实现
//
#include "stdafx.h"
#include "AdoStudent.h"
#include "StudentRs.h"
#include "AdoStudentDoc.h"
#include "AdoStudentView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CAdoStudentView
IMPLEMENT_DYNCREATE(CAdoStudentView, CFormView)
BEGIN_MESSAGE_MAP(CAdoStudentView, CFormView)
ON_COMMAND(ID_FIRST_RECORD, OnFirstRecord)
ON_COMMAND(ID_LAST_RECORD, OnLastRecord)
ON_COMMAND(ID_NEXT_RECORD, OnNextRecord)
ON_COMMAND(ID_PREV_RECORD, OnPrevRecord)
ON_COMMAND(ID_RECORD_NEW, OnRecordNew)
ON_COMMAND(ID_RECORD_DELETE, OnRecordDelete)
END_MESSAGE_MAP()
// CAdoStudentView 构造/销毁
CAdoStudentView::CAdoStudentView()
: CFormView(CAdoStudentView::IDD)
, m_lStudentName(_T(""))
, m_lBirthdate(_T(""))
,m_lAddress(_T(""))
{
// TODO: 在此处添加构造代码
}
CAdoStudentView::~CAdoStudentView()
{
}
void CAdoStudentView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
DDX_Text(pDX, IDC_STUDENTID, m_lStudentID);
DDX_Text(pDX, IDC_STUDENTNAME, m_lStudentName);
DDX_Text(pDX, IDC_CLASS, m_lClassID);
DDX_Text(pDX, IDC_ADDRESS, m_lAddress);
DDX_Text(pDX, IDC_BIRTHDATE, m_lBirthdate);
}
BOOL CAdoStudentView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式
return CFormView::PreCreateWindow(cs);
}
void CAdoStudentView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
// CAdoStudentView 诊断
#ifdef _DEBUG
void CAdoStudentView::AssertValid() const
{
CFormView::AssertValid();
}
void CAdoStudentView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CAdoStudentDoc* CAdoStudentView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CAdoStudentDoc)));
return (CAdoStudentDoc*)m_pDocument;
}
#endif //_DEBUG
// CAdoStudentView 消息处理程序
void CAdoStudentView::RefreshBoundData(void)
{
CStudentRs* pRs;
//Get a pointer to the document object.
pRs = GetDocument()->GetRecSet();
//Is the field OK.
if(adFldOK == pRs->lStudentIDStatus)
//Copy the value.
m_lStudentID = pRs->m_lStudentID;
else
//Otherwise,set the value to 0
m_lStudentID = 0;
//Is the field OK.
if(adFldOK == pRs->lStudentNameStatus)
//Copy the value.
m_lStudentName = pRs->m_szStudentName;
else
//Otherwise,set the value to 0.
m_lStudentName = _T("");
//Is the field OK.
if(adFldOK == pRs->lClassIDStatus)
//Copy the value.
m_lClassID = pRs->m_lClassID;
else
//Otherwise,set the value to 0.
m_lClassID = 0;
//Is the field OK.
if(adFldOK == pRs->lAddressStatus)
//Copy the value.
m_lAddress = pRs->m_szAddress;
else
//Otherwise,set the value to 0.
m_lAddress = _T("");
//Is the field OK.
if(adFldOK == pRs->lBirthdateStatus)
//Copy the value.
m_lBirthdate = pRs->m_szBirthdate;
else
//Otherwise,set the value to 0.
m_lBirthdate = _T("");
//Sync the data with the controls
UpdateData(FALSE);
}
void CAdoStudentView::UpdateBoundData(void)
{
CStudentRs* pRs;
//Get a pointer to the document
pRs = GetDocument()->GetRecSet();
//Sync the controls with the variables
UpdateData(TRUE);
//Has the field changed? If so, copy the value back.
if(m_lStudentID != pRs->m_lStudentID)
pRs->m_lStudentID = m_lStudentID;
if(m_lStudentName != pRs->m_szStudentName)
strcpy(pRs->m_szStudentName,(LPCTSTR)m_lStudentName);
if(m_lClassID != pRs->m_lClassID)
pRs->m_lClassID = m_lClassID;
if(m_lAddress != pRs->m_szAddress)
strcpy(pRs->m_szAddress,(LPCTSTR)m_lAddress);