清浪冲天 马敬发 QQ: 283989349 E-mail: [email protected]
有问题时,我们可以通过http://www.hustc.mpc.cn 这个论坛,
或 通过QQ 共同学习和讨论
VC开发数据库系统管理员密码修改模块
/ DIALOG_MODPSWD.cpp : implementation file
//
#include "stdafx.h"
#include "train.h"
#include "DIALOG_MODPSWD.h"
#include "LoginSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDIALOG_MODPSWD dialog
CDIALOG_MODPSWD::CDIALOG_MODPSWD(CWnd* pParent /*=NULL*/)
: CDialog(CDIALOG_MODPSWD::IDD, pParent)
{
//{{AFX_DATA_INIT(CDIALOG_MODPSWD)
m_formerps = _T("");
m_newps = _T("");
m_confirmps = _T("");
//}}AFX_DATA_INIT
}
void CDIALOG_MODPSWD::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDIALOG_MODPSWD)
DDX_Text(pDX, IDC_EDIT1, m_formerps);
DDX_Text(pDX, IDC_EDIT2, m_newps);
DDX_Text(pDX, IDC_EDIT3, m_confirmps);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDIALOG_MODPSWD, CDialog)
//{{AFX_MSG_MAP(CDIALOG_MODPSWD)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDIALOG_MODPSWD message handlers
void CDIALOG_MODPSWD::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
CDBVariant varValue;
CLoginSet m_recordset(&m_database);
CString strSQL;
strSQL.Format("select * from USER_PSWD where TMS_USER='%s'",user);
m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
m_recordset.GetFieldValue(1,varValue);
if(m_formerps.Compare(varValue.m_pstring->GetBuffer(1))!=0){
MessageBox("old passward wrong!");
m_formerps.Empty();
m_newps.Empty();
m_confirmps.Empty();
UpdateData(FALSE);
}
else{
if(m_newps.Compare(m_confirmps)!=0){
MessageBox("new passward confirm wrong!");
m_formerps.Empty();
m_newps.Empty();
m_confirmps.Empty();
UpdateData(FALSE);
}
else{
strSQL.Format("delete from USER_PSWD where TMS_USER='%s'",user);
m_database.ExecuteSQL(strSQL);
strSQL.Format("insert into USER_PSWD values(\'%s\',\'%s\')",user,m_newps);
m_database.ExecuteSQL(strSQL);
MessageBox("password modify successful");
CDialog::OnOK();
}
}
}
本文地址:http://com.8s8s.com/it/it27835.htm