SecretChangeDlg.cpp
上传用户:tyjx315
上传日期:2015-01-18
资源大小:1685k
文件大小:2k
- // SecretChangeDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "SuperMarket.h"
- #include "SecretChangeDlg.h"
- #include "afxdb.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSecretChangeDlg dialog
- CSecretChangeDlg::CSecretChangeDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CSecretChangeDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSecretChangeDlg)
- m_admin = _T("");
- m_old_password = _T("");
- m_new_password = _T("");
- m_affirm_password = _T("");
- //}}AFX_DATA_INIT
- }
- void CSecretChangeDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSecretChangeDlg)
- DDX_Text(pDX, IDC_EDIT1, m_admin);
- DDX_Text(pDX, IDC_EDIT2, m_old_password);
- DDX_Text(pDX, IDC_EDIT3, m_new_password);
- DDX_Text(pDX, IDC_EDIT4, m_affirm_password);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSecretChangeDlg, CDialog)
- //{{AFX_MSG_MAP(CSecretChangeDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSecretChangeDlg message handlers
- void CSecretChangeDlg::OnOK() //修改密码
- {
- // TODO: Add extra validation here
- UpdateData();
- CString strSQL;
- CDatabase dbTemp; //打开数据库
- dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理数据库.mdb;");
- CRecordset rs( &dbTemp);
- rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 登录信息 where usename = '"+m_admin+"' and password ='"+m_old_password+"' " );
- if(rs.IsEOF())
- {
- MessageBox("无效的用户名或密码!");
- }
- else
- {
- // MessageBox("可以修改!");
- if(m_new_password != m_affirm_password)
- {
- MessageBox("两次密码设定不同!");
-
- }
- else
- {
- strSQL = "Update 登录信息 set password = '"+m_new_password+"' where usename ='"+m_admin+"' ";
- dbTemp.ExecuteSQL(strSQL);
- MessageBox("密码修改成功!");
- }
- }
- rs.Close();
- dbTemp.Close();
- // CDialog::OnOK();
- }