📄 dialog7.cpp
字号:
// Dialog7.cpp : implementation file
//
#include "stdafx.h"
#include "图书管理系统.h"
#include "Dialog7.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialog7 dialog
extern CMyApp theApp;
CDialog7::CDialog7(CWnd* pParent /*=NULL*/)
: CDialog(CDialog7::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialog7)
m_Name = _T("");
m_OldWord = _T("");
m_NewWord = _T("");
m_RNewWord = _T("");
//}}AFX_DATA_INIT
}
void CDialog7::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialog7)
DDX_Text(pDX, IDC_NAME, m_Name);
DDX_Text(pDX, IDC_PASSWORD, m_OldWord);
DDX_Text(pDX, IDC_PASSWORD1, m_NewWord);
DDX_Text(pDX, IDC_PASSWORD2, m_RNewWord);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialog7, CDialog)
//{{AFX_MSG_MAP(CDialog7)
ON_BN_CLICKED(IDC_BTN_REMOD, OnBtnRemod)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialog7 message handlers
BOOL CDialog7::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
m_pRecordset->Open("SELECT * FROM ADM",theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,adLockOptimistic,adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialog7::OnBtnRemod()
{
// TODO: Add your control notification handler code here
UpdateData();
_variant_t var;
CString strName,strPassWord;
strName=strPassWord="";
if(m_Name =="" || m_OldWord =="")
{
AfxMessageBox("请输入帐号或密码!");
return ;
}
if(m_NewWord=="" && m_RNewWord=="")
{
AfxMessageBox("所设置的密码为空安全系数低!");
}
try
{
if(!m_pRecordset->BOF)
m_pRecordset->MoveFirst();
else
{
AfxMessageBox("还没有读者存在!");
return ;
}
while(!m_pRecordset->adoEOF )
{
var = m_pRecordset->GetCollect("Name");
if(var.vt != VT_NULL)
{
strName = (LPCSTR)_bstr_t(var);
}
var = m_pRecordset->GetCollect("PassWord");
if(var.vt != VT_NULL)
{
strPassWord = (LPCSTR)_bstr_t(var);
}
if(strName==m_Name)
{
if(strPassWord==m_OldWord)
{
if(m_NewWord==m_RNewWord)
{ m_pRecordset->PutCollect("PassWord",_variant_t(m_NewWord));
m_pRecordset->Update();
AfxMessageBox("修改密码成功!");
return;
}
else
{
AfxMessageBox("两次新密码输入错误!");
return;
}
}
else
{
AfxMessageBox("旧密码输入错误");
return;
}
}
else
m_pRecordset->MoveNext();
}
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
AfxMessageBox("用户名不存在");
}
HBRUSH CDialog7::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor==CTLCOLOR_LISTBOX)
{
//pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(233,233,220));
HBRUSH b=CreateSolidBrush(RGB(233,233,220));
return b;
}
else if(nCtlColor==CTLCOLOR_SCROLLBAR)
{
//pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(233,233,220));
HBRUSH b=CreateSolidBrush(RGB(233,233,220));
return b;
}
else if(nCtlColor==CTLCOLOR_EDIT)
{
//pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(233,233,220));
HBRUSH b=CreateSolidBrush(RGB(233,233,220));
return b;
}
else if(nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(160,180,220));
HBRUSH b=CreateSolidBrush(RGB(160,180,220));
return b;
}
else if(nCtlColor==CTLCOLOR_DLG)
{
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(160,180,220));
HBRUSH b=CreateSolidBrush(RGB(160,180,220));
return b;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -