?? change_pro.cpp
字號:
// change_pro.cpp : implementation file
//
#include "stdafx.h"
#include "LMTS.h"
#include "change_pro.h"
#include "odbcinst.h"
#include "user.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// change_pro dialog
change_pro::change_pro(CWnd* pParent /*=NULL*/)
: CDialog(change_pro::IDD, pParent)
{
//{{AFX_DATA_INIT(change_pro)
old_psw=_T("");
new_psw=_T("");
new_psw2=_T("");
id=_T("");// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void change_pro::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(change_pro)
DDX_Text(pDX, IDC_EDIT1, old_psw);
DDX_Text(pDX, IDC_EDIT2, new_psw);
DDX_Text(pDX, IDC_EDIT3, new_psw2);
DDX_Text(pDX,IDC_EDIT4,id);
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(change_pro, CDialog)
//{{AFX_MSG_MAP(change_pro)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// change_pro message handlers
void change_pro::OnOK()
{
AfxEnableControlContainer();
//MessageBox("原密碼錯誤 !");
// TODO: Add extra validation here
UpdateData(TRUE);//讀入用戶輸入的密碼
CDBVariant varValue;
user m_recordset(&m_database);
CString strSQL,get_old_psw,get_new_psw,get_new_psw2,get_id;
GetDlgItem(IDC_EDIT1)->GetWindowText(get_old_psw);
GetDlgItem(IDC_EDIT2)->GetWindowText(get_new_psw);
GetDlgItem(IDC_EDIT3)->GetWindowText(get_new_psw2);
GetDlgItem(IDC_EDIT4)->GetWindowText(get_id);
strSQL.Format("select * from user where password='%s' and id='%s'",get_old_psw,get_id);
m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
//int temp=0;
//m_recordset.GetFieldValue(temp,varValue);
//如果輸入的密碼與數(shù)據(jù)庫中的不一致,則彈出提示框
if(m_recordset.GetRecordCount()==0)
//if(m_oldpassword.Compare(varValue.m_pstring->GetBuffer(1))!=0)
{
MessageBox("原密碼錯誤!","提示",MB_OK|MB_ICONINFORMATION);
old_psw.Empty();
new_psw.Empty();
new_psw2.Empty();
UpdateData(FALSE);//清空所輸入的內(nèi)容
}
//如果原密碼正確,兩次新密碼不同
else
{
if(get_new_psw.Compare(get_new_psw2)!=0)
{
MessageBox("新密碼錯誤!","提示",MB_OK|MB_ICONINFORMATION);
new_psw.Empty();
new_psw2.Empty();
UpdateData(FALSE);//清空所輸入的內(nèi)容
}
else
{
int i=10;
//strSQL.Format("insert into user values(%d,'%s','%s','%s','%s','%s')",i,"lala","lala","student",get_new_psw,"no");
strSQL.Format("update user set password='%s' where password='%s'",get_new_psw,get_old_psw);
m_database.ExecuteSQL(strSQL);
CDialog::OnOK();
MessageBox("恭喜,口令更改成功!");//下次登錄請使用口令: "+new_psw+" ","提示",MB_OK|MB_ICONINFORMATION);
}
}
CDialog::OnOK();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -