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

📄 update.cpp

📁 此程序为EVC编写的MIS系统
💻 CPP
字号:
// 这个类是修改抄表员和抄表管理员的密码
// 创建时间:2004.02.27
// 创建人:苟艳

#include "stdafx.h"
#include "抄表系统.h"
#include "Update.h"
#include "rapi.h"
#include "CreateDB.h"
#include "LogDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//////////////////////////////////////////////////////////////////////////////
//抄表人员记录的字段
#define prop_10  L"抄表员编号"
#define prop_11  L"抄表员名称"
#define prop_12  L"抄表员密码"
//抄表管理员的字段
#define prop_20  L"抄表管理员名称"
#define prop_21	 L"抄表管理员密码"
////////////////////////////////////////////////////////////////////////////
extern CCreateDB  database;
extern CString LogName; 
//extern CLogDlg dlg1;
/////////////////////////////////////////////////////////////////////////////
// CUpdate dialog


CUpdate::CUpdate(CWnd* pParent /*=NULL*/)
	: CDialog(CUpdate::IDD, pParent)
{

	//{{AFX_DATA_INIT(CUpdate)
	m_edit1 = _T("");
	m_edit2 = _T("");
	//}}AFX_DATA_INIT
}


void CUpdate::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUpdate)
	DDX_Control(pDX, IDC_STATIC1, m_static);
	DDX_Control(pDX, IDC_EDIT2, m_code2);
	DDX_Control(pDX, IDC_EDIT1, m_code1);
	DDX_Text(pDX, IDC_EDIT1, m_edit1);
	DDX_Text(pDX, IDC_EDIT2, m_edit2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUpdate, CDialog)
	//{{AFX_MSG_MAP(CUpdate)
	ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
	ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUpdate message handlers

BOOL CUpdate::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//

	if(database.openOperator())
		operDBhandle=database.operhandle;
	//
	m_static.SetWindowText (LogName);
	wcscpy(name,LogName);
	
	
	return TRUE;  
}

void CUpdate::OnChangeEdit1() //新的密码输入
{
	UpdateData(TRUE);
	wcscpy(newpassword,m_edit1);
	
}

void CUpdate::OnChangeEdit2() 
{
	UpdateData(TRUE);
	
	
}

void CUpdate::OnOK() 
{
	CString str="抄表管理员";	
	if(!Judge())
		return;
	if(str.Compare(LogName)==0)   //修改抄表管理员的密码
	{
		CEPROPVAL propval;
		HANDLE managerhandle;
		CEOID findceoid,oid;
		DWORD index;
		propval.propid =MAKELONG(CEVT_LPWSTR,prop_21);
		propval.wFlags =0;
		propval.val .lpwstr =newpassword;
		if(database.CreateManagerDB())
			managerhandle=database.managerhandle;
		findceoid=CeSeekDatabase(managerhandle,CEDB_SEEK_BEGINNING,0,&index);
		oid=CeWriteRecordProps(managerhandle,findceoid,1,&propval);
		if(oid)
		{
			::MessageBox (this->m_hWnd,L"抄表管理员密码修改成功!",L"SUCCESS",MB_OK);
			CloseHandle(managerhandle);
			m_code1.SetWindowText (L"");
			m_code2.SetWindowText (L"");
		}
		
	}
	else
		if(!FindUpdateRec())
			return;

	
	
	CDialog::OnOK();
}

void CUpdate::OnClose() 
{
	
	CloseHandle(operDBhandle);
	CDialog::OnClose();
}

void CUpdate::OnCancel() 
{
	CloseHandle(operDBhandle);
	
	CDialog::OnCancel();
}
///////////////////
BOOL CUpdate::FindUpdateRec()
{
	CEOID findceoid,oid;
	WORD propnumber;
	PCEPROPVAL pRecord=0;
	DWORD cbBuff;
	DWORD index;
	CEPROPVAL Property;

		findceoid=CeSeekDatabase(operDBhandle,CEDB_SEEK_BEGINNING,0,&index);
		Property.propid=MAKELONG(CEVT_LPWSTR,prop_11);
		Property.wFlags =0;
		Property.val .lpwstr =name;
		findceoid=CeSeekDatabase(operDBhandle,CEDB_SEEK_VALUEFIRSTEQUAL,(DWORD)&Property ,&index);  //找到记录
		if(findceoid==0)
			return FALSE;
		Property.propid=MAKELONG(CEVT_LPWSTR,prop_12);
		Property.wFlags =0;
		Property.val .lpwstr =newpassword;
		oid=CeWriteRecordProps(operDBhandle,findceoid,1,&Property);
		if(oid)
		{
			::MessageBox (this->m_hWnd,L"修改密码成功!",L"SUCCESS",MB_OK);
			return TRUE;
		}
	
	return TRUE;

}
/////////
BOOL CUpdate::ComparePassword()
{
	if(m_edit1.Compare(m_edit2)!=0)
	{
		::MessageBox (this->m_hWnd ,L"两次密码输入不符!请重新输入确认密码!",L"ERROR",MB_OK);
		m_code2.SetWindowText (L"");
		m_code2.SetFocus();
		return FALSE;
	}
	return TRUE;
}
////////////////
BOOL CUpdate::Judge()
{
	if(m_edit1=="" || m_edit2=="")
	{
		::MessageBox (this->m_hWnd,L"请用户填入数据!",L"ERROR",MB_OK);
		return FALSE;
	}
	if(!ComparePassword())
		return FALSE;
	return TRUE;
}

⌨️ 快捷键说明

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