在数据库中存取信息

// 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);
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值