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

📄 viewmodifypassword.cpp

📁 用户管理系统
💻 CPP
字号:
// ViewModifyPassword.cpp : implementation file
//

#include "stdafx.h"
#include "Kvip.h"
#include "ViewModifyPassword.h"
#include "MainFrm.H"

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

/////////////////////////////////////////////////////////////////////////////
// CViewModifyPassword

IMPLEMENT_DYNCREATE(CViewModifyPassword, CFormView)

CViewModifyPassword::CViewModifyPassword()
	: CFormView(CViewModifyPassword::IDD)
{
	//{{AFX_DATA_INIT(CViewModifyPassword)
	m_strPassword1 = _T("");
	m_strPassword2 = _T("");
	m_strPassword3 = _T("");
	//}}AFX_DATA_INIT
	m_pApp = NULL;
}

CViewModifyPassword::~CViewModifyPassword()
{
}

void CViewModifyPassword::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CViewModifyPassword)
	DDX_Text(pDX, IDC_PASSWORD1, m_strPassword1);
	DDX_Text(pDX, IDC_PASSWORD2, m_strPassword2);
	DDX_Text(pDX, IDC_PASSWORD3, m_strPassword3);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CViewModifyPassword, CFormView)
	//{{AFX_MSG_MAP(CViewModifyPassword)
	ON_BN_CLICKED(IDC_OK, OnOK)
	ON_BN_CLICKED(IDC_CANCEL, OnCancel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CViewModifyPassword diagnostics

#ifdef _DEBUG
void CViewModifyPassword::AssertValid() const
{
	CFormView::AssertValid();
}

void CViewModifyPassword::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CViewModifyPassword message handlers

void CViewModifyPassword::OnOK() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	CString strSQL, strUser;
	COleDateTime tNow;
//整理输入数据
	m_strPassword1.MakeUpper();
	m_strPassword1.TrimLeft();
	m_strPassword1.TrimRight();
	m_strPassword2.MakeUpper();
	m_strPassword2.TrimLeft();
	m_strPassword2.TrimRight();
	m_strPassword3.MakeUpper();
	m_strPassword3.TrimLeft();
	m_strPassword3.TrimRight();

	if (m_strPassword2 != m_strPassword3)
	{
      MessageBox("错误:新用户密码与新密码确认不一至, 请重新输入!", 
		         "系统提示", MB_OK|MB_ICONEXCLAMATION);
	  return ;
	}
	strSQL.Format("Select * From kv_user Where us_code = '%s' AND us_password = '%s' AND us_enabled = true",
				   m_pApp->m_strCode, m_strPassword1);
//检测用户
//    m_RecordSet.SetCursorLocation();          //作者例程,不知有什么用 
    if (!m_RecordSet.Open(strSQL,adCmdText,    //SQL为TXT
		                  adOpenStatic,       //静态游标
			              adLockOptimistic) || 
        m_RecordSet.IsBOF() ||
		m_RecordSet.IsEOF())
	{//错误提示	
      MessageBox("错误:原用户密码不正确!", "系统提示", MB_OK|MB_ICONEXCLAMATION);
	  return ;
	}
//修改
	tNow.GetCurrentTime();
	m_RecordSet.PutCollect("us_password", m_strPassword2);
	m_RecordSet.PutCollect("us_date", tNow);
	if (!m_RecordSet.Update())
	{
      MessageBox("错误:MPW-000002修改数据失败!", "系统提示", MB_OK|MB_ICONEXCLAMATION);
      return ;
	}
 MessageBox("密码已经成功修改!", "系统提示", MB_OK|MB_USERICON);
// GetParent()->PostMessage(WM_CLOSE);
	
}

void CViewModifyPassword::OnCancel() 
{
	// TODO: Add your control notification handler code here
	GetParent()->PostMessage(WM_CLOSE);
}

void CViewModifyPassword::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	m_pApp = (CKvipApp *)AfxGetApp();
    if(!m_Connection.ConnectDefault())
	{
      MessageBox("错误:MPW-000001连接数据库出错!", "系统提示", MB_OK|MB_ICONEXCLAMATION);
	  GetParent()->PostMessage(WM_CLOSE);
	}
    m_RecordSet.SetAdoConnection(&m_Connection); //连结数据库
}

BOOL CViewModifyPassword::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	m_RecordSet.Close();
	m_Connection.Close();
	return CFormView::DestroyWindow();
}

⌨️ 快捷键说明

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