📄 providerview.cpp
字号:
// PrividerView.cpp : implementation file
//
#include "stdafx.h"
#include "Library.h"
#include "ProviderView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CProviderView
IMPLEMENT_DYNCREATE(CProviderView, CRecordView)
CProviderView::CProviderView()
: CRecordView(CProviderView::IDD)
{
//{{AFX_DATA_INIT(CProviderView)
m_pSet = NULL;
//}}AFX_DATA_INIT
m_bAdding = FALSE;
}
CProviderView::~CProviderView()
{
if (m_pSet)
delete m_pSet;
}
void CProviderView::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProviderView)
DDX_FieldText(pDX, IDC_ADDRESS, m_pSet->m_Address, m_pSet);
DDX_FieldText(pDX, IDC_LINKMAN, m_pSet->m_LinkMan, m_pSet);
DDX_FieldText(pDX, IDC_PHONE, m_pSet->m_Phone, m_pSet);
DDX_FieldText(pDX, IDC_PROVIDERNAME, m_pSet->m_ProviderName, m_pSet);
DDX_FieldText(pDX, IDC_REMARK, m_pSet->m_Remark, m_pSet);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProviderView, CRecordView)
//{{AFX_MSG_MAP(CProviderView)
ON_COMMAND(ID_INSERT_PROVIDER, OnInsertProvider)
ON_COMMAND(ID_DELETE_PROVIDER, OnDeleteProvider)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProviderView diagnostics
#ifdef _DEBUG
void CProviderView::AssertValid() const
{
CRecordView::AssertValid();
}
void CProviderView::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CProviderView message handlers
CRecordset* CProviderView::OnGetRecordset()
{
if (m_pSet != NULL)
return m_pSet;
m_pSet = new CProviderSet(NULL);
m_pSet->Open();
return m_pSet;
}
CProviderSet* CProviderView::GetRecordset()
{
CProviderSet* pData = (CProviderSet*) OnGetRecordset();
ASSERT(pData == NULL || pData->IsKindOf(RUNTIME_CLASS(CProviderSet)));
return pData;
}
void CProviderView::OnInitialUpdate()
{
BeginWaitCursor();
GetRecordset();
CRecordView::OnInitialUpdate();
if (m_pSet->IsOpen())
{
CString strTitle = m_pSet->m_pDatabase->GetDatabaseName();
CString strTable = m_pSet->GetTableName();
if (!strTable.IsEmpty())
strTitle += _T(":") + strTable;
GetDocument()->SetTitle(strTitle);
}
EndWaitCursor();
}
void CProviderView::OnInsertProvider()
{
// 添加新的书目信息
m_pSet->AddNew();
m_bAdding = TRUE;
// 更新显示
UpdateData(FALSE);
}
void CProviderView::OnDeleteProvider()
{
// 删除记录
m_pSet->Delete();
// 滚动到下一条记录
m_pSet->MoveNext();
// 防止越界
if (m_pSet->IsEOF() == TRUE)
m_pSet->MoveLast();
if (m_pSet->IsBOF() == TRUE)
m_pSet->SetFieldNull(NULL);
// 更新显示
UpdateData(FALSE);
}
BOOL CProviderView::OnMove(UINT nIDMoveCommand)
{
if (m_bAdding == TRUE)
{
// 变量复位
m_bAdding = FALSE;
// 更新数据
UpdateData(TRUE);
// 更新数据
if (m_pSet->CanUpdate() == TRUE)
m_pSet->Update();
// 刷新记录
if (m_pSet->CanRestart() == TRUE)
m_pSet->Requery();
// 更新显示
UpdateData(FALSE);
}
else
return CRecordView::OnMove(nIDMoveCommand);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -