更改口令的界面的开发 (VC和数据库应用)
2004-09-09 15:15
369 查看
// ChangePswDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Address.h"
#include "ChangePswDlg.h"
#include "PswdSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChangePswDlg dialog
CChangePswDlg::CChangePswDlg(CWnd* pParent /*=NULL*/)
: CDialog(CChangePswDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CChangePswDlg)
m_oldpassword = _T("");
m_newpassword = _T("");
m_qurenpassword = _T("");
//}}AFX_DATA_INIT
}
void CChangePswDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChangePswDlg)
DDX_Control(pDX, IDC_EDIT1, m_ctrloldpassword);
DDX_Text(pDX, IDC_EDIT1, m_oldpassword);
DDX_Text(pDX, IDC_EDIT2, m_newpassword);
DDX_Text(pDX, IDC_EDIT3, m_qurenpassword);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChangePswDlg, CDialog)
//{{AFX_MSG_MAP(CChangePswDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////
//名称:OnOk
//功能:更改用户口令
////////////////////////////////////////////////////////////////////////
void CChangePswDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);//读入用户输入的密码
CDBVariant varValue;///CDBVariant??? A CDBVariant object represents a variant data type for the MFC ODBC classes. CDBVariant is similar to COleVariant; however, CDBVariant does not use OLE. CDBVariant allows you to store a value without worrying about the value’s data type
CPswdSet m_recordset(&m_database);//记录及类
CString strSQL;
strSQL.Format("select * from password where PASSWORD='%s'",m_oldpassword);
m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
//此处为一种执行SQL语句语法之一,
//int temp=0;
//m_recordset.GetFieldValue(temp,varValue);
//如果输入的密码与数据库中的不一致,则弹出提示框
if(m_recordset.GetRecordCount()==0)//改点特强
//if(m_oldpassword.Compare(varValue.m_pstring->GetBuffer(1))!=0)
{
MessageBox("原密码错误!","提示",MB_OK|MB_ICONINFORMATION);
m_oldpassword.Empty();
m_newpassword.Empty();
m_qurenpassword.Empty();
m_ctrloldpassword.SetFocus();
UpdateData(FALSE);//清空所输入的内容将变化反映到对话框中
}
//如果原密码正确,两次新密码不同
else
{
if(m_newpassword.Compare(m_qurenpassword)!=0)//比较两个字符串是否相同
{
MessageBox("新密码错误!","提示",MB_OK|MB_ICONINFORMATION);
m_oldpassword.Empty();
m_newpassword.Empty();
m_qurenpassword.Empty();
UpdateData(FALSE);//清空所输入的内容
}
else
{
strSQL.Format("update password set PASSWORD='%s' where PASSWORD='%s'",m_newpassword,m_oldpassword);
m_database.ExecuteSQL(strSQL);//该种执行SQL 语句的最佳且最 容易理解的 方法 ,
CDialog::OnOK();
MessageBox("恭喜,口令更改成功!下次登录请使用口令: "+m_newpassword+" ","提示",MB_OK|MB_ICONINFORMATION);
}
}
}
/////////////////////////////////////////////////////////////////////////
//名称:OnInitDialog
//功能:更改口令对话框初始化
////////////////////////////////////////////////////////////////////////
BOOL CChangePswDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_ctrloldpassword.SetFocus();//注意在定义变量时 有一个技巧的,
//那就是,可以一个控件有两种类型的 变量, 因为不同类型的 变量有不同的成员函数
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//
#include "stdafx.h"
#include "Address.h"
#include "ChangePswDlg.h"
#include "PswdSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChangePswDlg dialog
CChangePswDlg::CChangePswDlg(CWnd* pParent /*=NULL*/)
: CDialog(CChangePswDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CChangePswDlg)
m_oldpassword = _T("");
m_newpassword = _T("");
m_qurenpassword = _T("");
//}}AFX_DATA_INIT
}
void CChangePswDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChangePswDlg)
DDX_Control(pDX, IDC_EDIT1, m_ctrloldpassword);
DDX_Text(pDX, IDC_EDIT1, m_oldpassword);
DDX_Text(pDX, IDC_EDIT2, m_newpassword);
DDX_Text(pDX, IDC_EDIT3, m_qurenpassword);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChangePswDlg, CDialog)
//{{AFX_MSG_MAP(CChangePswDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////
//名称:OnOk
//功能:更改用户口令
////////////////////////////////////////////////////////////////////////
void CChangePswDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);//读入用户输入的密码
CDBVariant varValue;///CDBVariant??? A CDBVariant object represents a variant data type for the MFC ODBC classes. CDBVariant is similar to COleVariant; however, CDBVariant does not use OLE. CDBVariant allows you to store a value without worrying about the value’s data type
CPswdSet m_recordset(&m_database);//记录及类
CString strSQL;
strSQL.Format("select * from password where PASSWORD='%s'",m_oldpassword);
m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
//此处为一种执行SQL语句语法之一,
//int temp=0;
//m_recordset.GetFieldValue(temp,varValue);
//如果输入的密码与数据库中的不一致,则弹出提示框
if(m_recordset.GetRecordCount()==0)//改点特强
//if(m_oldpassword.Compare(varValue.m_pstring->GetBuffer(1))!=0)
{
MessageBox("原密码错误!","提示",MB_OK|MB_ICONINFORMATION);
m_oldpassword.Empty();
m_newpassword.Empty();
m_qurenpassword.Empty();
m_ctrloldpassword.SetFocus();
UpdateData(FALSE);//清空所输入的内容将变化反映到对话框中
}
//如果原密码正确,两次新密码不同
else
{
if(m_newpassword.Compare(m_qurenpassword)!=0)//比较两个字符串是否相同
{
MessageBox("新密码错误!","提示",MB_OK|MB_ICONINFORMATION);
m_oldpassword.Empty();
m_newpassword.Empty();
m_qurenpassword.Empty();
UpdateData(FALSE);//清空所输入的内容
}
else
{
strSQL.Format("update password set PASSWORD='%s' where PASSWORD='%s'",m_newpassword,m_oldpassword);
m_database.ExecuteSQL(strSQL);//该种执行SQL 语句的最佳且最 容易理解的 方法 ,
CDialog::OnOK();
MessageBox("恭喜,口令更改成功!下次登录请使用口令: "+m_newpassword+" ","提示",MB_OK|MB_ICONINFORMATION);
}
}
}
/////////////////////////////////////////////////////////////////////////
//名称:OnInitDialog
//功能:更改口令对话框初始化
////////////////////////////////////////////////////////////////////////
BOOL CChangePswDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_ctrloldpassword.SetFocus();//注意在定义变量时 有一个技巧的,
//那就是,可以一个控件有两种类型的 变量, 因为不同类型的 变量有不同的成员函数
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
相关文章推荐
- VC6 和 SQLite开发零配置的数据库应用
- vc++中利用ado和listcontrol控件进行数据库应用开发的一点总结
- VC编程技术点滴(七)简单的数据库应用开发
- vc开发数据库应用中的常用数据转换
- vc++学生选课系统开发 sql语句操作数据库 学生界面模块
- VC++数据库应用开发
- vc ++ 如何做界面开发?
- VC6数据库综合开发资料
- Android应用界面开发09
- netbeans,界面组合框的点击刷新应用和从数据库提取数据添加到列表应用
- 【Android开发基础】应用界面主题Theme使用方法
- Qt Quick应用开发介绍 10-12(动态界面, 实践学习, 总结和扩展)
- VC开发数据库基础之ADO篇 (2)
- SAP应用界面开发:1)SELECT-OPTIONS对象
- 基于C#的MongoDB数据库开发应用(4)--Redis的安装及使用
- Android应用界面开发(一)
- 几种VC++数据库开发技术的比较
- 【C++码农】WMI技术介绍和应用——VC开发WMI应用的基本步骤
- 登入EBS报错:无法完成应用登录。您可能已输入无效的应用口令,或可能存在数据库连接错误
- IBM Data Studio(数据库应用开发)下载!