【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,Ex11_3View.cpp,希望对大家有所帮助!
// Ex11_3View.cpp : implementation of the CEx11_3View class
//
#include "stdafx.h"
#include "Ex11_3.h"
#include "Ex11_3Doc.h"
#include "Ex11_3View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx11_3View
IMPLEMENT_DYNCREATE(CEx11_3View, CFormView)
BEGIN_MESSAGE_MAP(CEx11_3View, CFormView)
//{{AFX_MSG_MAP(CEx11_3View)
ON_COMMAND(ID_RECORD_FIRST, OnRecordFirst)
ON_COMMAND(ID_RECORD_PREV, OnRecordPrev)
ON_COMMAND(ID_RECORD_NEXT, OnRecordNext)
ON_COMMAND(ID_RECORD_LAST, OnRecordLast)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEx11_3View construction/destruction
CEx11_3View::CEx11_3View()
: CFormView(CEx11_3View::IDD)
{
//{{AFX_DATA_INIT(CEx11_3View)
m_strStuID = _T("");
m_strStuName = _T("");
m_strStuNativePlace = _T("");
m_strStuClass = _T("");
m_strStuCollege = _T("");
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CEx11_3View::~CEx11_3View()
{
}
void CEx11_3View::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEx11_3View)
DDX_Text(pDX, IDC_STUID, m_strStuID);
DDX_Text(pDX, IDC_STUNAME, m_strStuName);
DDX_Text(pDX, IDC_STUNATIVEPLACE, m_strStuNativePlace);
DDX_Text(pDX, IDC_STUCLASS, m_strStuClass);
DDX_Text(pDX, IDC_STUCOLLEGE, m_strStuCollege);
//}}AFX_DATA_MAP
}
BOOL CEx11_3View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CEx11_3View::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
ShowTable();//显示数据库数据表
}
/////////////////////////////////////////////////////////////////////////////
// CEx11_3View printing
BOOL CEx11_3View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CEx11_3View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CEx11_3View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CEx11_3View::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CEx11_3View diagnostics
#ifdef _DEBUG
void CEx11_3View::AssertValid() const
{
CFormView::AssertValid();
}
void CEx11_3View::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CEx11_3Doc* CEx11_3View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx11_3Doc)));
return (CEx11_3Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx11_3View message handlers
void CEx11_3View::ShowTable()//显示表中的数据
{
_variant_t vstrSQL;
vstrSQL="Select * from studenttab";
theApp.ADOExecute(theApp.m_pADOSet,vstrSQL);
theApp.m_pADOSet->MoveFirst();
m_strStuID=theApp.VariantToCString(theApp.m_pADOSet->GetCollect("StuID"));
m_strStuName=theApp.VariantToCString(theApp.m_pADOSet->GetCollect("StuName"));
m_strStuNativePlace=theApp.VariantToCString(theApp.m_pADOSet->GetCollect("StuNativePlace"));
m_strStuClass=theApp.VariantToCString(theApp.m_pADOSet->GetCollect("StuClass"));
m_strStuCollege=theApp.VariantToCString(theApp.m_pADOSet->GetCollect("StuCollege"));
UpdateData(false);
}
void CEx11_3View::OnRecordFirst()
{
// TODO: Add your command handler code here
theApp.m_pADOSet->MoveFirst();
try
{
m_strStuID=theApp.VariantToCString(theApp.m_pADOSet->GetCollect("StuID"));
m_strStuName=theApp.VariantToCString(theApp.m_pADOSet->GetCollect("StuName"));
m_strStuNativePlace=theApp.VariantToCString(theApp.m_pA