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

📄 amendpwd.cpp

📁 个人理财系统(管理股票信息)
💻 CPP
字号:
// AmendPwd.cpp : implementation file
//

#include "stdafx.h"
#include "StockSystem.h"
#include "AmendPwd.h"
#include "PersonFrame.h"
#include "Sqlitter_Wnd.h"
#include "AccountTreeView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAmendPwd dialog


CAmendPwd::CAmendPwd(CWnd* pParent /*=NULL*/)
	: CDialog(CAmendPwd::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAmendPwd)
	m_oldpwd = _T("");
	m_newpwd1 = _T("");
	m_newpwd2 = _T("");
	m_user = _T("");
	//}}AFX_DATA_INIT
}


void CAmendPwd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAmendPwd)
	DDX_Text(pDX, IDC_OLD_PWD, m_oldpwd);
	DDX_Text(pDX, IDC_NEWPWD1, m_newpwd1);
	DDX_Text(pDX, IDC_NEWPWD2, m_newpwd2);
	DDX_Text(pDX, IDC_USER, m_user);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAmendPwd, CDialog)
	//{{AFX_MSG_MAP(CAmendPwd)
	ON_BN_CLICKED(IDB_OK_BTN, OnOkBtn)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAmendPwd message handlers

void CAmendPwd::OnOK() 
{
	// TODO: Add extra validation here
	
//	CDialog::OnOK();
}
//修改密码
void CAmendPwd::OnOkBtn() 
{
	UpdateData();
	CStockSystemApp *pApp = (CStockSystemApp *)AfxGetApp();

	if (pApp->m_pConnection.IsThePwd(m_user, m_oldpwd) == 0)
	{
		MessageBox("密码错误,","错误");
		m_newpwd1.Empty();
		m_newpwd2.Empty();
		m_oldpwd.Empty();
		UpdateData(FALSE);
		return;
	}
	if (m_newpwd1 != m_newpwd2)
	{
		MessageBox("2次输入的密码不一样,","错误");
		m_newpwd1.Empty();
		m_newpwd2.Empty();
		m_oldpwd.Empty();
		UpdateData(FALSE);
		return;
	}
	if (pApp->m_pConnection.AmendPwd(m_user, m_newpwd1))
	{
		int len = pApp->UserInfoVect.size();
		for (int i=0; i<len; i++)
		{
			if (pApp->UserInfoVect[i].username == m_user)
			{
				pApp->UserInfoVect[i].userpwd = m_newpwd1;
			}
		}
		m_newpwd1.Empty();
		m_newpwd2.Empty();
		m_oldpwd.Empty();
		UpdateData(FALSE);
		CDialog::OnOK();
	}
}

BOOL CAmendPwd::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CPersonFrame *pframe = (CPersonFrame *)GetParent();
	CAccountTreeView *mytree =(CAccountTreeView *)(pframe->m_splitterwnd.GetPane(0,0));
	mytree->GetCurrentUser(m_user);
	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CAmendPwd::OnCancel() 
{	
	m_newpwd1.Empty();
	m_newpwd2.Empty();
	m_oldpwd.Empty();
	UpdateData(FALSE);
	CDialog::OnCancel();
}

⌨️ 快捷键说明

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