📄 daodoc.cpp
字号:
// DaoDoc.cpp : implementation of the CMSDIDaoDoc class
//
#include "stdafx.h"
#include "MSDIApp.h"
#include "MSDIDao.h"
#include "DaoBmp.h"
#include "DaoSet.h"
#include "CategSet.h"
#include "CustSet.h"
#include "DaoDoc.h"
#include "TblView.h"
#include "CategTbl.h"
#include "CustTbl.h"
#include "CategVw.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// helpers
static BOOL FileExist(LPCSTR lpszFileName)
{
OFSTRUCT OpenBuffer;
OpenFile(lpszFileName, &OpenBuffer, OF_EXIST);
return (OpenBuffer.nErrCode == 0x0000) ? TRUE: FALSE;
}
int DaoMessageBox(CDaoException* e, UINT nType, UINT nIDHelp)
{
return AfxMessageBox(e->m_pErrorInfo->m_strDescription, nType|MB_ICONEXCLAMATION, nIDHelp);
}
/////////////////////////////////////////////////////////////////////////////
// CMSDIDaoDoc
IMPLEMENT_DYNCREATE(CMSDIDaoDoc, CDocument)
BEGIN_MESSAGE_MAP(CMSDIDaoDoc, CDocument)
//{{AFX_MSG_MAP(CMSDIDaoDoc)
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave)
ON_COMMAND(ID_TABLE_CATEG, OnTableCategories)
ON_COMMAND(ID_TABLE_CUSTOM, OnTableCustomers)
ON_COMMAND(ID_FORM_CATEG, OnFormCateg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMSDIDaoDoc construction/destruction
CMSDIDaoDoc::CMSDIDaoDoc()
{
m_pCategoriesSet = NULL;
m_pCustomersSet = NULL;
// ... ADDALL
}
CMSDIDaoDoc::~CMSDIDaoDoc()
{
}
BOOL CMSDIDaoDoc::OnNewDocument()
{
ASSERT(!m_db.IsOpen());
if (!CDocument::OnNewDocument())
return FALSE;
// MSDIDAO: prompt for a file name to create a new document
return DoSave(NULL);
}
void CMSDIDaoDoc::OnCloseDocument()
{
// database is closed in the DeleteContents
CDocument::OnCloseDocument();
}
BOOL CMSDIDaoDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
// MSDIDAO: OnOpenNewDocument()
try
{
m_db.Open(lpszPathName);
}
catch (CDaoException* e)
{
DaoMessageBox(e);
e->Delete();
return FALSE;
}
DeleteContents();
SetModifiedFlag(FALSE); // start with unmodified
return TRUE;
}
BOOL CMSDIDaoDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
// MSDIDAO: OnSaveDocument()
CString strPathName = GetPathName();
// if pathname is empty, create
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -