📄 cclass.cpp
字号:
// CClass.cpp : implementation file
//
#include "stdafx.h"
#include "aoManage.h"
#include "CClass.h"
#include "MainFrm.h"
#include "SearchC.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCClass dialog
CCClass::CCClass(CWnd* pParent /*=NULL*/)
: CParentDlg(CCClass::IDD, pParent)
{
//{{AFX_DATA_INIT(CCClass)
m_strCode = _T("");
m_strName = _T("");
//}}AFX_DATA_INIT
m_pCClass=new CDaoRecordset(&((CMainFrame*)AfxGetMainWnd())->m_db);
}
void CCClass::DoDataExchange(CDataExchange* pDX)
{
CParentDlg::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCClass)
DDX_Text(pDX, IDC_EDIT1, m_strCode);
DDV_MaxChars(pDX, m_strCode, 2);
DDX_Text(pDX, IDC_EDIT2, m_strName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCClass, CParentDlg)
//{{AFX_MSG_MAP(CCClass)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCClass message handlers
BOOL CCClass::OnInitDialog()
{
CParentDlg::OnInitDialog();
m_pCClass->Open(AFX_DAO_USE_DEFAULT_TYPE,"select * from cclass");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCClass::OnButton1()
{
UpdateData(TRUE);
if (!m_strCode.GetLength()||!m_strName.GetLength())
{
MessageBox("分类号和名称不能为空");
return;
}
CString strFilter="code ='"+m_strCode+"' or name='"+m_strName+"'";
if (m_pCClass->FindFirst(strFilter))
{
MessageBox("分类号或名称已存在,请选择另外未注册的");
return;
}
m_pCClass->AddNew();
m_pCClass->SetFieldValue("code",(LPCTSTR)m_strCode);
m_pCClass->SetFieldValue("name",(LPCTSTR)m_strName);
m_pCClass->Update();
MessageBox("已成功添加");
m_strCode="";
m_strName="";
UpdateData(FALSE);
}
void CCClass::OnButton2()
{
OnCancel();
}
void CCClass::OnClose()
{
if (m_pCClass->IsOpen())
m_pCClass->Close();
CParentDlg::OnClose();
}
void CCClass::OnButton5()
{
OnCancel();
CSearchC dlg;
dlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -