// student2View.cpp : implementation of the CStudent2View class
//
#include "stdafx.h"
#include "student2.h"
#include "student2Doc.h"
#include "student2View.h"
#include "StudentRecordSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CStudent2View
IMPLEMENT_DYNCREATE(CStudent2View, CView)
BEGIN_MESSAGE_MAP(CStudent2View, CView)
//{{AFX_MSG_MAP(CStudent2View)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/
// CStudent2View construction/destruction
CStudent2View::CStudent2View()
{
// TODO: add construction code here
}
CStudent2View::~CStudent2View()
{
}
BOOL CStudent2View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/
// CStudent2View drawing
void CStudent2View::OnDraw(CDC* pDC)
{
CStudent2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/
// CStudent2View printing
BOOL CStudent2View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CStudent2View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CStudent2View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/
// CStudent2View diagnostics
#ifdef _DEBUG
void CStudent2View::AssertValid() const
{
CView::AssertValid();
}
void CStudent2View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CStudent2Doc* CStudent2View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CStudent2Doc)));
return (CStudent2Doc*)m_pDocument;
}
#endif //_DEBUG
/
// CStudent2View message handlers
void CStudent2View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CStudentRecordSet rs;
rs.Open();
rs.AddNew();
rs.m_ID="001";
rs.m_Name="张三";
rs.m_english=90;
rs.Update();
if(!rs.Update())
{
MessageBox("error");
}
rs.Close();
CView::OnLButtonDown(nFlags, point);
}
void CStudent2View::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CStudentRecordSet rs;
CClientDC dc(this);
int y = 20;
rs.Open();
CString str;
while (!rs.IsEOF())
{
str.Format("ID:%s, Name:%s, english:%d",rs.m_ID, rs.m_Name, rs.m_english);
rs.MoveNext();
dc.TextOut(20, y, str);
y += 20;
}
rs.Update();
rs.Close();
CView::OnRButtonDown(nFlags, point);
}