⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mydaoview.cpp

📁 VC编程对ACCESS数据库进行记录读,查询,以及添加.
💻 CPP
字号:
// MyDaoView.cpp : implementation of the CMyDaoView class
//

#include "stdafx.h"
#include "MyDao.h"

#include "MyDaoDoc.h"
#include "MyDaoView.h"
#include "QueryDlg.h"
#include "SortDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyDaoView

IMPLEMENT_DYNCREATE(CMyDaoView, CFormView)

BEGIN_MESSAGE_MAP(CMyDaoView, CFormView)
	//{{AFX_MSG_MAP(CMyDaoView)
	ON_COMMAND(ID_RECORD_SORT, OnRecordSort)
	ON_COMMAND(ID_RECORD_QUERY, OnRecordQuery)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CMyDaoView construction/destruction

CMyDaoView::CMyDaoView()
	: CFormView(CMyDaoView::IDD)
{
	//{{AFX_DATA_INIT(CMyDaoView)
	m_Age = _T("");
	m_Sex = _T("");
	m_Employee = _T("");
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CMyDaoView::~CMyDaoView()
{
}

void CMyDaoView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyDaoView)
	DDX_Control(pDX, IDC_EMPLOYEE, m_ctlEmployee);
	DDX_Text(pDX, IDC_AGE, m_Age);
	DDX_Text(pDX, IDC_SEX, m_Sex);
	DDX_Text(pDX, IDC_EMPLOYEE, m_Employee);
	//}}AFX_DATA_MAP
}

BOOL CMyDaoView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CMyDaoView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

}

/////////////////////////////////////////////////////////////////////////////
// CMyDaoView printing

BOOL CMyDaoView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMyDaoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMyDaoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CMyDaoView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	// TODO: add customized printing code here
}

/////////////////////////////////////////////////////////////////////////////
// CMyDaoView diagnostics

#ifdef _DEBUG
void CMyDaoView::AssertValid() const
{
	CFormView::AssertValid();
}

void CMyDaoView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CMyDaoDoc* CMyDaoView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDaoDoc)));
	return (CMyDaoDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyDaoView message handlers

void CMyDaoView::OnRecordSort() 
{
	// TODO: Add your command handler code here
	CSortDlg psortdlg=new CSortDlg();
	int nResponce=psortdlg.DoModal();
	if(nResponce=IDOK)
	{
		m_pSet->Close();
		m_pSet->m_strSort=psortdlg.m_strSort;
		try
		{
			m_pSet->Open();

		}

		catch(CDaoException *e)
		{
			AfxMessageBox(e->m_pErrorInfo->m_strDescription);
			e->Delete();
		}
		m_pSet->MoveFirst();
		UpdateData(FALSE);
	}
	delete psortdlg;
	
}

void CMyDaoView::OnRecordQuery() 
{
	// TODO: Add your command handler code here
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -