在数据库中存取信息

来源:互联网 发布:出货单打印软件 编辑:程序博客网 时间:2024/06/05 02:14
// 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_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CStudent2ViewIMPLEMENT_DYNCREATE(CStudent2View, CView)BEGIN_MESSAGE_MAP(CStudent2View, CView)//{{AFX_MSG_MAP(CStudent2View)ON_WM_LBUTTONDOWN()ON_WM_RBUTTONDOWN()//}}AFX_MSG_MAP// Standard printing commandsON_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/destructionCStudent2View::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 csreturn CView::PreCreateWindow(cs);}/////////////////////////////////////////////////////////////////////////////// CStudent2View drawingvoid CStudent2View::OnDraw(CDC* pDC){CStudent2Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);// TODO: add draw code for native data here}/////////////////////////////////////////////////////////////////////////////// CStudent2View printingBOOL CStudent2View::OnPreparePrinting(CPrintInfo* pInfo){// default preparationreturn 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 _DEBUGvoid 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 handlersvoid CStudent2View::OnLButtonDown(UINT nFlags, CPoint point) {// TODO: Add your message handler code here and/or call defaultCStudentRecordSet 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 defaultCStudentRecordSet 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);}

原创粉丝点击