一个很好的教职工管理系统
源代码在线查看: 教职工人事管理系统view.cpp
// 教职工人事管理系统View.cpp : implementation of the CMyView class
//
#include "stdafx.h"
#include "教职工人事管理系统.h"
#include "教职工人事管理系统Set.h"
#include "教职工人事管理系统Doc.h"
#include "教职工人事管理系统View.h"
#include "DlgQuery.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_BUTTONUPDATE, OnButtonupdate)
ON_BN_CLICKED(IDC_ADDRECO, OnButtonaddnew)
ON_BN_CLICKED(IDC_RECODELE, OnButtondelete)
ON_BN_CLICKED(IDC_BUTTONQUERY, OnButtonquery)
//}}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_EDITJL, m_pSet->m_JL, m_pSet);
DDX_FieldText(pDX, IDC_EDITJLI, m_pSet->m_JLI, m_pSet);
DDX_FieldText(pDX, IDC_EDITJSBH, m_pSet->m_JSBH, m_pSet);
DDX_FieldText(pDX, IDC_EDITJSNL, m_pSet->m_JSNL, m_pSet);
DDX_FieldText(pDX, IDC_EDITJSXB, m_pSet->m_JSXB, m_pSet);
DDX_FieldText(pDX, IDC_EDITJSXM, m_pSet->m_JSXM, m_pSet);
DDX_FieldText(pDX, IDC_EDITSZBM, m_pSet->m_SZBM, m_pSet);
DDX_FieldText(pDX, IDC_EDITZC, m_pSet->m_ZC, m_pSet);
DDX_FieldText(pDX, IDC_EDITZW, m_pSet->m_ZW, 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::OnButtonupdate()
{
// TODO: Add your control notification handler code here
//m_pSet->Edit();
UpdateData();
m_pSet->Update();
m_pSet->Requery();
//m_pSet->CancelUpdate();
}
void CMyView::OnButtonaddnew()
{
// TODO: Add your control notification handler code here
m_pSet->AddNew();
UpdateData(FALSE);
}
void CMyView::OnButtondelete()
{
// TODO: Add your control notification 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 CMyView::OnButtonquery()
{
// TODO: Add your control notification handler code here
CDlgQuery Dlgquery;
Dlgquery.DoModal();
CString value;
if(Dlgquery.DoModal()==IDOK)
{
value="教师编号=+"+Dlgquery.m_query+"";
m_pSet->m_strFilter=value;
m_pSet->Requery();
UpdateData(FALSE);
}
}