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

📄 change_pro.cpp

📁 LTMS软件说明 软件名称:LTMS(Luinse Teaching Management System)
💻 CPP
字号:
// change_pro.cpp : implementation file
//

#include "stdafx.h"
#include "LMTS.h"
#include "change_pro.h"
#include "odbcinst.h"
#include "user.h"

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

/////////////////////////////////////////////////////////////////////////////
// change_pro dialog


change_pro::change_pro(CWnd* pParent /*=NULL*/)
	: CDialog(change_pro::IDD, pParent)
{
	//{{AFX_DATA_INIT(change_pro)
	old_psw=_T("");
	new_psw=_T("");
	new_psw2=_T("");
	id=_T("");// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void change_pro::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(change_pro)
	DDX_Text(pDX, IDC_EDIT1, old_psw);
	DDX_Text(pDX, IDC_EDIT2, new_psw);
	DDX_Text(pDX, IDC_EDIT3, new_psw2);
	DDX_Text(pDX,IDC_EDIT4,id);
	// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// change_pro message handlers

void change_pro::OnOK() 
{
	AfxEnableControlContainer();
	//MessageBox("原密码错误                     !");
	// TODO: Add extra validation here
	UpdateData(TRUE);//读入用户输入的密码
	CDBVariant varValue;
	user m_recordset(&m_database);
	CString strSQL,get_old_psw,get_new_psw,get_new_psw2,get_id;
	GetDlgItem(IDC_EDIT1)->GetWindowText(get_old_psw);
	GetDlgItem(IDC_EDIT2)->GetWindowText(get_new_psw);
	GetDlgItem(IDC_EDIT3)->GetWindowText(get_new_psw2);
	GetDlgItem(IDC_EDIT4)->GetWindowText(get_id);
	strSQL.Format("select * from user where password='%s' and id='%s'",get_old_psw,get_id);

	m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);

	//int temp=0;
	//m_recordset.GetFieldValue(temp,varValue);
	//如果输入的密码与数据库中的不一致,则弹出提示框

	if(m_recordset.GetRecordCount()==0)
	//if(m_oldpassword.Compare(varValue.m_pstring->GetBuffer(1))!=0)
	{
		MessageBox("原密码错误!","提示",MB_OK|MB_ICONINFORMATION);
		old_psw.Empty();
		new_psw.Empty();
		new_psw2.Empty();
		UpdateData(FALSE);//清空所输入的内容
	}
	//如果原密码正确,两次新密码不同
	else
	{
		if(get_new_psw.Compare(get_new_psw2)!=0)
		{
			MessageBox("新密码错误!","提示",MB_OK|MB_ICONINFORMATION);
			new_psw.Empty();
			new_psw2.Empty();
			UpdateData(FALSE);//清空所输入的内容
		}
		else
		{
			int i=10;
			//strSQL.Format("insert into user values(%d,'%s','%s','%s','%s','%s')",i,"lala","lala","student",get_new_psw,"no");
			strSQL.Format("update user set password='%s' where password='%s'",get_new_psw,get_old_psw); 
			m_database.ExecuteSQL(strSQL);
			CDialog::OnOK();
			MessageBox("恭喜,口令更改成功!");//下次登录请使用口令: "+new_psw+"  ","提示",MB_OK|MB_ICONINFORMATION);
		}
	}


	CDialog::OnOK();
}

⌨️ 快捷键说明

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