📄 chpri.cpp
字号:
// ChPri.cpp : implementation file
//
#include "stdafx.h"
#include "aoManage.h"
#include "ChPri.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChPri dialog
CChPri::CChPri(CWnd* pParent /*=NULL*/)
: CParentDlg(CChPri::IDD, pParent)
{
//{{AFX_DATA_INIT(CChPri)
m_strName = _T("");
m_strOldPri = _T("");
m_strNewPri=_T("");
//}}AFX_DATA_INIT
m_pUser=new CDaoRecordset(&((CMainFrame*)AfxGetMainWnd())->m_db);
}
void CChPri::DoDataExchange(CDataExchange* pDX)
{
CParentDlg::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChPri)
DDX_Control(pDX, IDC_COMBO1, m_ctlCombo);
DDX_Text(pDX, IDC_EDIT1, m_strName);
DDX_Text(pDX, IDC_EDIT2, m_strOldPri);
DDX_CBString(pDX, IDC_COMBO1, m_strNewPri);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChPri, CParentDlg)
//{{AFX_MSG_MAP(CChPri)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_EN_KILLFOCUS(IDC_EDIT1, OnKillfocusEdit1)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChPri message handlers
BOOL CChPri::OnInitDialog()
{
CParentDlg::OnInitDialog();
m_pUser->Open(AFX_DAO_USE_DEFAULT_TYPE,"select * from user");
m_ctlCombo.AddString("1");
m_ctlCombo.AddString("2");
m_ctlCombo.AddString("3");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CChPri::OnButton1()
{
UpdateData(TRUE);
if (!m_strName.GetLength())
{
MessageBox("用户名不能为空");
return;
}
if (!m_strOldPri.GetLength())
{
MessageBox("此用户名不存在");
return;
}
if (!m_strNewPri.GetLength())
{
MessageBox("请选择新权限");
return;
}
m_pUser->Edit();
m_pUser->SetFieldValue("priority",(LPCTSTR)m_strNewPri);
m_pUser->Update();
MessageBox("已成功更改");
m_strName="";
m_strOldPri="";
UpdateData(FALSE);
m_ctlCombo.SetCurSel(-1);
}
void CChPri::OnButton2()
{
OnCancel();
}
void CChPri::OnKillfocusEdit1()
{
UpdateData(TRUE);
if (m_strName.GetLength())
{
if (m_pUser->FindFirst("name='"+m_strName+"'"))
{
COleVariant vVal;
m_pUser->GetFieldValue("priority",vVal);
m_strOldPri=(LPCTSTR)vVal.bstrVal;
}
else
m_strOldPri="";
}
else
m_strOldPri="";
UpdateData(FALSE);
}
void CChPri::OnClose()
{
if (m_pUser->IsOpen())
m_pUser->Close();
CParentDlg::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -