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

📄 inputpwd.cpp

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

#include "stdafx.h"
#include "stocksystem.h"
#include "InputPwd.h"
#include "MainFrm.h"
#include "AdoConnect.h"
#include "AccountTreeView.h"
#include "AdoRecordSet.h"

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


/////////////////////////////////////////////////////////////////////////////
// CInputPwd dialog


CInputPwd::CInputPwd(CWnd* pParent /*=NULL*/)
	: CDialog(CInputPwd::IDD, pParent)
{
	//{{AFX_DATA_INIT(CInputPwd)
	m_inputpwd = _T("");
	//}}AFX_DATA_INIT
}


void CInputPwd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CInputPwd)
	DDX_Text(pDX, IDC_PWD, m_inputpwd);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CInputPwd, CDialog)
	//{{AFX_MSG_MAP(CInputPwd)
	ON_BN_CLICKED(IDC_LOGIN, OnLogin)
	ON_WM_CLOSE()
	ON_BN_CLICKED(IDB_LOGIN, OnLogin)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CInputPwd::OnCancel() 
{
	m_inputpwd.Empty();
	UpdateData(FALSE);
	CDialog::OnCancel();
}

void CInputPwd::OnLogin() 
{
	UpdateData();
	if (m_inputpwd.GetLength() == 0)
	{
		MessageBox("密码不能为空","提示");
		return;
	}
	CAdoRecordSet				record;
	CString						command;
	CString						username;
	CString						user_pwd;
	CStockSystemApp *pApp = (CStockSystemApp *)AfxGetApp();	
	command.Format("select password from tb_account where name='%s'",current_user);
	if(pApp->m_pConnection.IsThePwd(current_user , m_inputpwd) == 0)
  	{
			MessageBox("密码错误,请重新输入","提示");
			m_inputpwd.Empty();
			UpdateData(FALSE);
			return;			
	}
	else
	{	
		CString	str = "更新窗口";
		CSplitterWnd &psplwnd = ((CPersonFrame *)m_pParentWnd)->m_splitterwnd;
		CInputPwd *inputpwd	  = (CInputPwd *)psplwnd.GetPane(0,0);
		inputpwd->SendMessage(WM_UPDATETREE, (WPARAM)&str, NULL);
		//在结构体中把这个用户的状态设置为1,表示用户已经登陆了
		UserInfo		user_info;
		int len = pApp->UserInfoVect.size();
		for (int i=0; i<len; i++)
		{
			user_info = pApp->UserInfoVect[i];
			//找到正确的用户名,设置状态码为1
			if (user_info.username == current_user)
			{
				pApp->UserInfoVect[i].loginstate = "1";
			}
		}
		//密码正确,关闭对话框
		CDialog::OnOK();	 
  	}
}


void CInputPwd::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	CDialog::OnCancel();
	CDialog::OnClose();
}

void CInputPwd::SetDlgTitle(CString &name)
{
	current_user = name;
	m_title.Format("请输入%s的密码", name);
}

BOOL CInputPwd::OnInitDialog() 
{
	CDialog::OnInitDialog();
	SetWindowText(m_title);
	return TRUE;
}

void CInputPwd::OnOK() 
{
	// TODO: Add extra validation here
	
//	CDialog::OnOK();
}

⌨️ 快捷键说明

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