⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notifypwddlg.cpp

📁 一个与金融方面有关的问题
💻 CPP
字号:
/**************************************************
修改账户密码模块
作者:颜永华
***************************************************/
// NotifyPwdDlg.cpp : 实现文件
//

#include "stdafx.h"
#include "BankClient.h"
#include "NotifyPwdDlg.h"
#include ".\notifypwddlg.h"
#include "Sock.h"
#include "Md5.h"
extern CSock sock;

// CNotifyPwdDlg 对话框

IMPLEMENT_DYNAMIC(CNotifyPwdDlg, CDialog)
CNotifyPwdDlg::CNotifyPwdDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CNotifyPwdDlg::IDD, pParent)
{
}

CNotifyPwdDlg::~CNotifyPwdDlg()
{
}

void CNotifyPwdDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT1, m_EditAccount);
	DDX_Control(pDX, IDC_EDIT2, m_EditOldPassword);
	DDX_Control(pDX, IDC_EDIT4, m_EditNewPassword1);
	DDX_Control(pDX, IDC_EDIT3, m_EditNewPassword2);
}


BEGIN_MESSAGE_MAP(CNotifyPwdDlg, CDialog)
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()


// CNotifyPwdDlg 消息处理程序

void CNotifyPwdDlg::OnBnClickedOk()
{//
	//判断输入是否合法
	int errNum=0;CString str,strNewPwd1,strNewPwd2;
	int len=m_EditAccount.GetWindowTextLength();
	if(!len||len!=18)
	{
		str.Format("%d:账号输入有误!\n",++errNum);
		GetDlgItem(IDC_SIGN)->SetWindowText(str);
	}
	m_EditNewPassword1.GetWindowText(strNewPwd1);
	m_EditNewPassword2.GetWindowText(strNewPwd2);
	if(0!=strcmp((char*)strNewPwd1.GetBuffer(),(char*)strNewPwd2.GetBuffer()))
	{
		str.Format("%s%d:两次输入密码不匹配!\n",str,++errNum);
		GetDlgItem(IDC_SIGN)->SetWindowText(str);
	}
	//打包数据
	NOTIFY_PASSWORD_PACKET notifyPacket;
	memset(&notifyPacket,0,sizeof(NOTIFY_PASSWORD_PACKET));
	notifyPacket.wCode=CLIENT_NOTIFY_PASSWORD;
	notifyPacket.wLen=sizeof(NOTIFY_PASSWORD_PACKET);

	m_EditAccount.GetWindowText(notifyPacket.accountId,18);
	m_EditOldPassword.GetWindowText(notifyPacket.accountOldPwd,16);
	m_EditNewPassword1.GetWindowText(notifyPacket.accountNewPwd,16);
	
	//MD5加密密码
	CMD5 md5;
	md5.MD5Update((BYTE*)&notifyPacket.accountOldPwd[0],16);
	md5.MD5Final((BYTE*)&notifyPacket.accountOldPwd[0]);
	
	md5.MD5Update((BYTE*)&notifyPacket.accountNewPwd[0],16);
	md5.MD5Final((BYTE*)&notifyPacket.accountNewPwd[0]);

	if(!errNum)
	{//没有错误 进行发送
		GetDlgItem(IDC_SIGN)->SetWindowText("处理中 ...");
		if(sock.sendPacket((BYTE*)&notifyPacket,sizeof(NOTIFY_PASSWORD_PACKET)))
		{
			int i=sock.RetFlag();
			//显示状态
			if(i==FLAG_SUCCEED)
				GetDlgItem(IDC_SIGN)->SetWindowText("修改成功!");
			else
				GetDlgItem(IDC_SIGN)->SetWindowText("修改失败!");
		}
	}
	
}

BOOL CNotifyPwdDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	//控制输入长度
	m_EditAccount.SetLimitText(18);
	m_EditNewPassword1.SetLimitText(16);
	m_EditNewPassword2.SetLimitText(16);
	m_EditOldPassword.SetLimitText(16);

	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -