📄 odbcsnapview.cpp
字号:
// OdbcSnapView.cpp : implementation of the COdbcSnapView class
//
#include "stdafx.h"
#include "OdbcSnap.h"
#include "OdbcSnapSet.h"
#include "OdbcSnapDoc.h"
#include "OdbcSnapView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COdbcSnapView
IMPLEMENT_DYNCREATE(COdbcSnapView, CRecordView)
BEGIN_MESSAGE_MAP(COdbcSnapView, CRecordView)
//{{AFX_MSG_MAP(COdbcSnapView)
ON_COMMAND(ID_RECORD_ADD, OnRecordAdd)
ON_COMMAND(ID_RECORD_DELETE, OnRecordDelete)
ON_COMMAND(ID_RECORD_REFRESH, OnRecordRefresh)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COdbcSnapView construction/destruction
COdbcSnapView::COdbcSnapView()
: CRecordView(COdbcSnapView::IDD)
{
//{{AFX_DATA_INIT(COdbcSnapView)
m_pSet = NULL;
//}}AFX_DATA_INIT
// TODO: add construction code here
m_bAddMode=FALSE;
}
COdbcSnapView::~COdbcSnapView()
{
}
void COdbcSnapView::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COdbcSnapView)
DDX_Control(pDX, IDC_EDIT6, m_ctlSection);
DDX_FieldText(pDX, IDC_EDIT1, m_pSet->m_Capacity, m_pSet);
DDX_FieldText(pDX, IDC_EDIT2, m_pSet->m_CourseID, m_pSet);
DDX_FieldText(pDX, IDC_EDIT3, m_pSet->m_InstructorID, m_pSet);
DDX_FieldText(pDX, IDC_EDIT4, m_pSet->m_RoomNo, m_pSet);
DDX_FieldText(pDX, IDC_EDIT5, m_pSet->m_Schedule, m_pSet);
DDX_FieldText(pDX, IDC_EDIT6, m_pSet->m_SectionNo, m_pSet);
//}}AFX_DATA_MAP
}
BOOL COdbcSnapView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CRecordView::PreCreateWindow(cs);
}
void COdbcSnapView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_odbcSnapSet;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
/////////////////////////////////////////////////////////////////////////////
// COdbcSnapView printing
BOOL COdbcSnapView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void COdbcSnapView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void COdbcSnapView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// COdbcSnapView diagnostics
#ifdef _DEBUG
void COdbcSnapView::AssertValid() const
{
CRecordView::AssertValid();
}
void COdbcSnapView::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
COdbcSnapDoc* COdbcSnapView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COdbcSnapDoc)));
return (COdbcSnapDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COdbcSnapView database support
CRecordset* COdbcSnapView::OnGetRecordset()
{
return m_pSet;
}
/////////////////////////////////////////////////////////////////////////////
// COdbcSnapView message handlers
//●:
void COdbcSnapView::OnRecordAdd()
{
// TODO: Add your command handler code here
if(m_bAddMode)
{
OnMove(ID_RECORD_FIRST);
}
m_pSet->AddNew();
m_bAddMode=TRUE;
UpdateData(FALSE);
}
void COdbcSnapView::OnRecordDelete()
{
// TODO: Add your command handler code here
m_pSet->Delete();
m_pSet->MoveNext();
if(m_pSet->IsEOF())
{
m_pSet->MoveLast();
}
if(m_pSet->IsBOF())
{
m_pSet->SetFieldNull(NULL);
}
UpdateData(FALSE);
}
void COdbcSnapView::OnRecordRefresh()
{
// TODO: Add your command handler code here
if(m_bAddMode)
{
m_pSet->Move(0);
m_bAddMode=FALSE;
}
UpdateData(FALSE);
}
BOOL COdbcSnapView::OnMove(UINT nIDMoveCommand)
{
// TODO: Add your specialized code here and/or call the base class
if(m_bAddMode)
{
if(!UpdateData())
{
return FALSE;
}
m_pSet->Update();
m_pSet->Requery();
UpdateData(FALSE);
m_bAddMode=FALSE;
return TRUE;
}
return CRecordView::OnMove(nIDMoveCommand);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -