?? mydbdoc.cpp
字號:
// mydbDoc.cpp : implementation of the CMydbDoc class
//
#include "stdafx.h"
#include "mydb.h"
#include "DepartNameList.h"
#include "mydbSet.h"
#include "mydbDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMydbDoc
IMPLEMENT_DYNCREATE(CMydbDoc, CDocument)
BEGIN_MESSAGE_MAP(CMydbDoc, CDocument)
//{{AFX_MSG_MAP(CMydbDoc)
ON_COMMAND(ID_RECORD_ADDNEW, OnRecordAddnew)
ON_COMMAND(ID_RECORD_DELETE, OnRecordDelete)
ON_COMMAND(ID_QUERY, OnQuery)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMydbDoc construction/destruction
CMydbDoc::CMydbDoc()
{
// TODO: add one-time construction code here
}
CMydbDoc::~CMydbDoc()
{
}
BOOL CMydbDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
m_SelectedDepartName="ALL";
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
m_bInAdding=FALSE;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMydbDoc diagnostics
#ifdef _DEBUG
void CMydbDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CMydbDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMydbDoc commands
void CMydbDoc::OnRecordAddnew()
{
// TODO: Add your command handler code here
CRecordView*pView;
POSITION pos=GetFirstViewPosition();
pView=(CRecordView*)GetNextView(pos);
if(m_bInAdding)
pView->OnMove(ID_RECORD_FIRST);
if(!m_mydbSet.CanAppend()){
AfxMessageBox("You can't add a newrecord tothis database!");
return;
}
try{
m_mydbSet.AddNew();
}
catch(CDBException*e){
AfxMessageBox(e->m_strError);
}
m_bInAdding=TRUE;
pView->UpdateData(FALSE);
}
void CMydbDoc::OnRecordDelete()
{
// TODO: Add your command handler code here
CRecordView*pView;
POSITION pos=GetFirstViewPosition();
pView=(CRecordView*)GetNextView(pos);
try{
m_mydbSet.Delete();
}
catch(CDBException*e){
AfxMessageBox(e->m_strError);
return;
}
m_mydbSet.MoveNext();
if(m_mydbSet.IsEOF())
m_mydbSet.MoveLast();
if(m_mydbSet.IsBOF())
m_mydbSet.SetFieldNull(NULL);
pView->UpdateData(FALSE);
}
void CMydbDoc::OnQuery()
{
// TODO: Add your command handler code here
CDepartNameList dialog;
if(dialog.DoModal()==IDCANCEL)
return;
m_SelectedDepartName=dialog.m_SelectedDepartName;
UpdateAllViews(NULL,SELECT_NEW_DEPART);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -