📄 c02view.cpp
字号:
// C02View.cpp : implementation of the CC02View class
//
#include "stdafx.h"
#include "C02.h"
#include "C02Set.h"
#include "C02Doc.h"
#include "C02View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CC02View
IMPLEMENT_DYNCREATE(CC02View, CRecordView)
BEGIN_MESSAGE_MAP(CC02View, CRecordView)
//{{AFX_MSG_MAP(CC02View)
ON_COMMAND(ID_RECORD_FIRST, OnRecordFirst)
ON_COMMAND(ID_RECORD_LAST, OnRecordLast)
ON_COMMAND(ID_RECORD_NEXT, OnRecordNext)
ON_COMMAND(ID_RECORD_PREV, OnRecordPrev)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
ON_BN_CLICKED(IDC_BUTTON_MODIFY, OnButtonModify)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CC02View construction/destruction
CC02View::CC02View()
: CRecordView(CC02View::IDD)
{
//{{AFX_DATA_INIT(CC02View)
m_pSet = NULL;
m_address = _T("");
m_mail = _T("");
m_name = _T("");
m_type = _T("");
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CC02View::~CC02View()
{
}
void CC02View::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CC02View)
DDX_Text(pDX, IDC_EDIT_ADDRESS, m_address);
DDX_Text(pDX, IDC_EDIT_MAIL, m_mail);
DDX_Text(pDX, IDC_EDIT_NAME, m_name);
DDX_Text(pDX, IDC_EDIT_TYPE, m_type);
//}}AFX_DATA_MAP
}
BOOL CC02View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CRecordView::PreCreateWindow(cs);
}
void CC02View::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_c02Set;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
try
{
m_pSet=new CC02Set();
m_pSet->Open();
RefreshData();
}
catch (CDBException* pe)
{
AfxMessageBox(pe->m_strError);
pe->Delete();
}
}
/////////////////////////////////////////////////////////////////////////////
// CC02View diagnostics
#ifdef _DEBUG
void CC02View::AssertValid() const
{
CRecordView::AssertValid();
}
void CC02View::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
CC02Doc* CC02View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CC02Doc)));
return (CC02Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CC02View database support
CRecordset* CC02View::OnGetRecordset()
{
return m_pSet;
}
/////////////////////////////////////////////////////////////////////////////
// CC02View message handlers
void CC02View::OnRecordFirst()
{
// TODO: Add your command handler code here
m_pSet->MoveFirst();
RefreshData();
}
void CC02View::OnRecordLast()
{
// TODO: Add your command handler code here
m_pSet->MoveLast();
RefreshData();
}
void CC02View::OnRecordNext()
{
// TODO: Add your command handler code here
m_pSet->MoveNext();
RefreshData();
}
void CC02View::OnRecordPrev()
{
// TODO: Add your command handler code here
m_pSet->MovePrev();
RefreshData();
}
void CC02View::OnButtonAdd()
{
// TODO: Add your control notification handler code here
try
{
m_pSet->AddNew();
UpdateData(TRUE);
m_pSet->m_column1=m_name;
m_pSet->m_column2=m_type;
m_pSet->m_column3=m_address;
m_pSet->m_column4=m_mail;
m_pSet->Update();
m_pSet->Requery();
}
catch (CDBException* pe)
{
AfxMessageBox(pe->m_strError);
pe->Delete();
}
}
void CC02View::OnButtonDelete()
{
// TODO: Add your control notification handler code here
try
{
m_pSet->Delete();
m_pSet->Requery();
RefreshData();
}
catch (CDBException* pe)
{
AfxMessageBox(pe->m_strError);
pe->Delete();
}
}
void CC02View::OnButtonModify()
{
// TODO: Add your control notification handler code here
try
{
m_pSet->Edit();
UpdateData(TRUE);
m_pSet->m_column1=m_name;
m_pSet->m_column2=m_type;
m_pSet->m_column3=m_address;
m_pSet->m_column4=m_mail;
m_pSet->Update();
}
catch (CDBException* pe)
{
AfxMessageBox(pe->m_strError);
pe->Delete();
}
}
void CC02View::RefreshData()
{
m_name=m_pSet->m_column1;
m_type=m_pSet->m_column2;
m_address=m_pSet->m_column3;
m_mail=m_pSet->m_column4;
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -