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

📄 changkey.cpp

📁 一个人事档案的数据库
💻 CPP
字号:
// CHANGKEY.cpp : implementation file
//

#include "stdafx.h"
#include "dangan.h"
#include "CHANGKEY.h"
#include "AllDlg.h"
#include "fstream.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCHANGKEY dialog


CCHANGKEY::CCHANGKEY(CWnd* pParent /*=NULL*/)
	: CDialog(CCHANGKEY::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCHANGKEY)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CCHANGKEY::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCHANGKEY)
	DDX_Control(pDX, IDC_EDIT_2NEWKEY, m_2newkey);
	DDX_Control(pDX, IDC_EDIT_OKEY, m_oldkey);
	DDX_Control(pDX, IDC_EDIT_NKEY, m_newkey);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCHANGKEY, CDialog)
	//{{AFX_MSG_MAP(CCHANGKEY)
	ON_EN_CHANGE(IDC_EDIT_OKEY, OnChangeEditOkey)
	ON_EN_CHANGE(IDC_EDIT_NKEY, OnChangeEditNkey)
	ON_EN_CHANGE(IDC_EDIT_2NEWKEY, OnChangeEdit2newkey)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCHANGKEY message handlers
CString oldkey;
CString newkey;
CString tnewkey;
void CCHANGKEY::OnChangeEditOkey() 
{
	m_oldkey.GetWindowText(oldkey);
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}

void CCHANGKEY::OnChangeEditNkey() 
{
	m_newkey.GetWindowText(newkey);
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}
CString nchangkey[50];
char nkey[50];
void NInputKey(){
	int i=0;
	ifstream in("key.txt");
	in>>nkey;
//	MessageBox(inkey[50]);
	nchangkey[i]=nkey;
	in.close();
}
//void Output(){
	
void CCHANGKEY::OnOK() 
{
	NInputKey();
	int i=0;
	if(oldkey==nchangkey[i]){
//		CDialog::OnOK();
//		CAllDlg dlg;
//		dlg.DoModal();
		if(newkey==tnewkey){
		ofstream out("key.txt");
		out<<newkey;
		out.close();
		MessageBox("密码修改成功!");
		CDialog::OnOK();
		CAllDlg dlg;
		dlg.DoModal();
		}
		else{
			AfxMessageBox("两次输入的密码不同\n密码修改失败!\n请重新输入!");
			UpdateData(FALSE);
		}
	}
	else{
		AfxMessageBox("您输入的原密码有误,\n请重新输入!");
	//	UpdateWindow(FALSE);
	}
//	CDialog::OnOK();
}

void CCHANGKEY::OnChangeEdit2newkey() 
{
	m_2newkey.GetWindowText(tnewkey);
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}

⌨️ 快捷键说明

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