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

📄 update_mimadlg.cpp

📁 是我大学事情开发的一个很经典的案例
💻 CPP
字号:
// update_mimaDlg.cpp : implementation file
//

#include "stdafx.h"
#include "pmz.h"
#include "pmzDlg.h"
#include "update_mimaDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// update_mimaDlg dialog


update_mimaDlg::update_mimaDlg(CWnd* pParent /*=NULL*/)
	: CDialog(update_mimaDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(update_mimaDlg)
	m_old_mima = _T("");
	m_new_mima1 = _T("");
	m_new_mima2 = _T("");
	//}}AFX_DATA_INIT
	m_pdb=new CDatabase;          
	m_pdb->Open( NULL, FALSE, FALSE,mydb);
}

update_mimaDlg::~update_mimaDlg()
{
	m_pdb->Close();
	delete m_pdb;
}
void update_mimaDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(update_mimaDlg)
	DDX_Text(pDX, IDC_EDIT1, m_old_mima);
	DDX_Text(pDX, IDC_EDIT2, m_new_mima1);
	DDX_Text(pDX, IDC_EDIT3, m_new_mima2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(update_mimaDlg, CDialog)
	//{{AFX_MSG_MAP(update_mimaDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// update_mimaDlg message handlers

void update_mimaDlg::OnOK() 
{
	
	UpdateData(TRUE);
   
	  
	m_old_mima.TrimLeft();
	m_old_mima.TrimRight();
	if(	m_old_mima.GetLength()<1) 
	{
		AfxMessageBox("旧密码不能为空!");
		return;
	}
	m_new_mima1.TrimLeft();
	m_new_mima1.TrimRight();
	if(	m_new_mima1.GetLength()<1) 
	{
		AfxMessageBox("新密码不能为空!");
		return;
	}
	m_new_mima2.TrimLeft();
	m_new_mima2.TrimRight();
	if(	m_new_mima2.GetLength()<1) 
	{
		AfxMessageBox("新密码不能为空!");
		return;
	}
	if(	m_new_mima1!=m_new_mima2) 
	{
		AfxMessageBox("两次密码输入不一样,请重新输入!");
		this->GetDlgItem(IDC_EDIT2)->SetWindowText("");
	    this->GetDlgItem(IDC_EDIT3)->SetWindowText("");
		return;
	}
	if(	m_old_mima!=admin_old_mima) 
	{
		AfxMessageBox("旧密码输入错误!");
		this->GetDlgItem(IDC_EDIT1)->SetWindowText("");
		return;
	}
	AfxMessageBox("管理员密码将被修改,继续吗?");

	CString str,str0,str1,str2,str4;
	str=admin_ID;
	str0=m_old_mima;
	str1=m_new_mima1;
	str2=m_new_mima2;
    
	m_precordset=new admin_infodb(m_pdb);
	str4="update admin_info set  admin_mima='"+str1+"'where admin_ID='"+str+"' ";
	m_pdb->ExecuteSQL(str4);
	AfxMessageBox("修改成功!");
	delete m_precordset;	
	this->GetDlgItem(IDC_EDIT1)->SetWindowText("");
	this->GetDlgItem(IDC_EDIT2)->SetWindowText("");
	this->GetDlgItem(IDC_EDIT3)->SetWindowText("");  
}

void update_mimaDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

⌨️ 快捷键说明

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