⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 工资管理程序view.cpp

📁 工资管理程序 自己做的程序 希望大家喜欢
💻 CPP
字号:
// 工资管理程序View.cpp : implementation of the CMyView class
//

#include "stdafx.h"
#include "工资管理程序.h"

#include "工资管理程序Set.h"
#include "工资管理程序Doc.h"
#include "工资管理程序View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyView

IMPLEMENT_DYNCREATE(CMyView, CRecordView)

BEGIN_MESSAGE_MAP(CMyView, CRecordView)
	//{{AFX_MSG_MAP(CMyView)
	ON_BN_CLICKED(IDC_ADD, OnAdd)
	ON_BN_CLICKED(IDC_DEL, OnDel)
	ON_BN_CLICKED(IDC_REF, OnRef)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CMyView construction/destruction

CMyView::CMyView()
	: CRecordView(CMyView::IDD)
{
	//{{AFX_DATA_INIT(CMyView)
	m_pSet = NULL;
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CMyView::~CMyView()
{
}

void CMyView::DoDataExchange(CDataExchange* pDX)
{
	CRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyView)
	DDX_FieldText(pDX, IDC_EDIT2, m_pSet->m_ID, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT3, m_pSet->m_column1, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT4, m_pSet->m_column2, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT5, m_pSet->m_column3, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT6, m_pSet->m_column4, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT7, m_pSet->m_column5, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT8, m_pSet->m_column6, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT9, m_pSet->m_column7, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT10, m_pSet->m_column8, m_pSet);
	//}}AFX_DATA_MAP
}

BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CRecordView::PreCreateWindow(cs);
}

void CMyView::OnInitialUpdate()
{
	m_pSet = &GetDocument()->m_mySet;
	CRecordView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

}

/////////////////////////////////////////////////////////////////////////////
// CMyView printing

BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMyView diagnostics

#ifdef _DEBUG
void CMyView::AssertValid() const
{
	CRecordView::AssertValid();
}

void CMyView::Dump(CDumpContext& dc) const
{
	CRecordView::Dump(dc);
}

CMyDoc* CMyView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
	return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyView database support
CRecordset* CMyView::OnGetRecordset()
{
	return m_pSet;
}


/////////////////////////////////////////////////////////////////////////////
// CMyView message handlers

void CMyView::OnAdd() 
{
	// TODO: Add your control notification handler code here
	if(m_bAddMode)
		OnMove(ID_RECORD_FIRST);
	m_pSet->AddNew();
	m_bAddMode=true;
	UpdateData(false);
}

void CMyView::OnDel() 
{
	// TODO: Add your control notification handler code here
	TRY
	{
		m_pSet->Delete();
	}
	CATCH(CDBException,e)
	{
		AfxMessageBox(e->m_strError);
		return;
	}
	END_CATCH
	m_pSet->MoveNext();
	if(m_pSet->IsEOF())
		m_pSet->MoveLast();
	if(m_pSet->IsBOF())
		m_pSet->SetFieldNull(NULL);
	UpdateData(false);
}



void CMyView::OnRef() 
{
	// TODO: Add your control notification handler code here
	if(m_bAddMode==TRUE)
	{
		m_pSet->Move(AFX_MOVE_REFRESH);
		m_bAddMode=false;
	}
	UpdateData(false);
}

BOOL CMyView::OnMove(UINT nIDMoveCommand) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(m_bAddMode)
	{
		if(!UpdateData())
			return false;
		TRY
		{
			m_pSet->Update();
		}
		CATCH(CDBException,e)
		{
			AfxMessageBox(e->m_strError);
			return false;
		}
		END_CATCH
		m_pSet->Requery();
		UpdateData(false);
		m_bAddMode=false;
		return true;
	}
	return CRecordView::OnMove(nIDMoveCommand);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -