📄 modifyuserpassword.cpp
字号:
// ModifyUserPassword.cpp : implementation file
//
#include "stdafx.h"
#include "sms.h"
#include "ModifyUserPassword.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CModifyUserPassword dialog
CModifyUserPassword::CModifyUserPassword(CWnd* pParent /*=NULL*/)
: CDialog(CModifyUserPassword::IDD, pParent)
{
//{{AFX_DATA_INIT(CModifyUserPassword)
m_Authority = _T("");
m_NewPassword = _T("");
m_UserName = _T("");
m_ValidatePassword = _T("");
//}}AFX_DATA_INIT
}
void CModifyUserPassword::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CModifyUserPassword)
DDX_CBString(pDX, IDC_AUTHORITY, m_Authority);
DDX_Text(pDX, IDC_NEW_PASSWORD, m_NewPassword);
DDX_Text(pDX, IDC_USER_NAME, m_UserName);
DDX_Text(pDX, IDC_VALIDATE_PASSWORD, m_ValidatePassword);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CModifyUserPassword, CDialog)
//{{AFX_MSG_MAP(CModifyUserPassword)
ON_BN_CLICKED(IDC_MODIFY_PASSWORD, OnModifyPassword)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CModifyUserPassword::OnModifyPassword()
{
// TODO: Add your control notification handler code here
UpdateData();
if(m_UserName.IsEmpty())
{
MessageBox("用户名不能为空请从列表中选择要修改的用户名");
return;
}
if(m_NewPassword.IsEmpty())
{
MessageBox("新密码不能为空");
GetDlgItem(IDC_NEW_PASSWORD)->SetFocus();
return;
}
if(m_ValidatePassword.IsEmpty())
{
MessageBox("确认密码不能为空");
GetDlgItem(IDC_NEW_PASSWORD)->SetFocus();
return;
}
if(m_NewPassword!=m_ValidatePassword)
{
MessageBox("新密码跟确认密码不一致请重新输入");
return;
}
else
{
//////////////////////////////////////////////////////////////////////////
//休改用户密码
CSMSApp * pCSMSApp=(CSMSApp *)AfxGetApp();//取得App类对象的指针
CSMSADO &Ado=pCSMSApp->m_SMSAdo;
//这里判断数据连接是否连接成功
if(!Ado.IsConnection())
{
MessageBox("连接数据库出错\n请重新设置Oracle相关信息");
return;
}
CString sql;
sql.Format("UPDATE users SET PASSWD='%s' WHERE username='%s'",m_NewPassword,m_UserName);
int isSuccess=Ado.ExecuteWithoutRecordset(sql);
if(!isSuccess)
{
MessageBox("更新数据出错,该用户不存在");
}
else
{
MessageBox("密码修改成功");
}
((CUserManager *)(GetParent()->GetParent()))->ShowUsers();
m_UserName.Empty();
m_NewPassword.Empty();
m_ValidatePassword.Empty();
UpdateData(FALSE);//将变量的内容更新到于之关加的窗口上
}
}
BOOL CModifyUserPassword::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_RETURN) return TRUE;
if (pMsg->wParam == VK_ESCAPE) return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -