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

📄 yhsz.cpp

📁 一个有关人事系统的所有代码和有关文件包括里面小量数据库。
💻 CPP
字号:
// YHSZ.cpp : implementation file
//

#include "stdafx.h"
#include "Rsglxt.h"
#include "YHSZ.h"
#include "DLogin.h"

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

/////////////////////////////////////////////////////////////////////////////
// CYHSZ dialog


CYHSZ::CYHSZ(CWnd* pParent /*=NULL*/)
	: CDialog(CYHSZ::IDD, pParent)
{
	//{{AFX_DATA_INIT(CYHSZ)
	//}}AFX_DATA_INIT
}


void CYHSZ::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CYHSZ)
	DDX_Control(pDX, IDC_BTN_CHANGE, m_BtnChange);
	DDX_Control(pDX, IDC_BTN_SAVE, m_BtnSave);
	DDX_Control(pDX, IDC_BTNEXIT, m_BtnExit);
	DDX_Control(pDX, IDC_BTNUNDO, m_BtnUndo);
	DDX_Control(pDX, IDC_EDTSPWD, m_EdtSPwd);
	DDX_Control(pDX, IDC_EDTPWD, m_EdtPwd);
	DDX_Control(pDX, IDC_EDTNAME, m_EdtName);
	DDX_Control(pDX, IDC_EDTID, m_EdtID);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CYHSZ, CDialog)
	//{{AFX_MSG_MAP(CYHSZ)
	ON_BN_CLICKED(IDC_BTN_CHANGE, OnBtnChange)
	ON_BN_CLICKED(IDC_BTNUNDO, OnBtnundo)
	ON_BN_CLICKED(IDC_BTN_SAVE, OnBtnSave)
	ON_BN_CLICKED(IDC_BTNEXIT, OnBtnexit)
	ON_WM_PAINT()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CYHSZ message handlers

BOOL CYHSZ::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	this->Display(OP);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CYHSZ::Display(CString name)
{
	m_EdtName.SetWindowText(OP);
	RxRecordset brst;
	CString sql;
	sql.Format("select * from 用户视图 where 用户名='%s'",OP);
	brst.Open(sql,adCmdText);
	CString sID,sPwd;
	sID=brst.GetFieldValue("编号");
	sPwd=brst.GetFieldValue("密码");
	m_EdtID.SetWindowText(sID);
	m_EdtPwd.SetWindowText(sPwd);
	m_EdtSPwd.SetWindowText(sPwd);

}

void CYHSZ::Clear()
{
	m_EdtPwd.SetWindowText("");
	m_EdtSPwd.SetWindowText("");
}

void CYHSZ::OnBtnChange() 
{
	// TODO: Add your control notification handler code here
	this->ButtonEnabled(true);
	this->Clear();
	m_EdtPwd.SetFocus();
}

void CYHSZ::ButtonEnabled(bool bEnabled)
{
	m_EdtPwd.EnableWindow(bEnabled);
	m_EdtSPwd.EnableWindow(bEnabled);
	m_BtnUndo.EnableWindow(bEnabled);
	m_BtnSave.EnableWindow(bEnabled);
	m_BtnExit.EnableWindow(!bEnabled);
	m_BtnChange.EnableWindow(!bEnabled);

}

void CYHSZ::OnBtnundo() 
{
	// TODO: Add your control notification handler code here
	if(MessageBox("确定要撤消操作吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
    this->ButtonEnabled(false);
	this->Clear();
	this->Display(OP);
}

void CYHSZ::OnBtnSave() 
{
	// TODO: Add your control notification handler code here
	if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	CString sID,Pwd,sPwd,sName,SQL;
	m_EdtPwd.GetWindowText(Pwd);
	m_EdtSPwd.GetWindowText(sPwd);
	m_EdtName.GetWindowText(sName);
	m_EdtID.GetWindowText(sID);
	if(Pwd.IsEmpty())
	{
		MessageBox("密码不能为空,请输入新密码。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
		m_EdtPwd.SetFocus();
		return;
	}else
	{
		int len;
		len=Pwd.GetLength();
		if(len>15)
		{
			MessageBox("密码不能超过15位,请重新输入。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
			m_EdtPwd.SetFocus();
			return;
		}
		char ch;
		int i;
		for(i=1;i<len;i++)
		{
			ch = Pwd.GetAt(i);
			if(ch==32||ch==8)//||((ch<65||ch>90)&&(ch<97||ch>122))||(ch>47 && ch<58))//32是空格,8是退格键,65_90,97_122是大小写字母,47_58是数字
			{	
				MessageBox("输入密码无效,请输入新的密码。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
				m_EdtPwd.SetFocus();
				return;
			}
			if((ch<48 || ch>57)&&(ch<65||ch>90)&&(ch<97||ch>122))
			{	
				MessageBox("输入密码无效,请输入新的密码。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
				m_EdtPwd.SetFocus();
				return;
			}

		}
	}
	if(sPwd.IsEmpty())
	{
		MessageBox("确认密码不能为空,请输入新的确认密码。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
		m_EdtSPwd.SetFocus();
		return;
	}	
	if (Pwd!=sPwd)
	{
		MessageBox("您两次输入的密码不一致,请确认后重新输入!","系统提示",MB_OK);
		m_EdtPwd.SetWindowText("");
		m_EdtSPwd.SetWindowText("");
		m_EdtPwd.SetFocus();
		return;
	}
	SQL.Format("Update UserInfo set Password='%s' WHERE User_ID=%s",Pwd,sID);
	RxRecordset arst;
	arst.Open(SQL,adCmdText);
	this->ButtonEnabled(false);
	m_BtnChange.SetFocus();
}

void CYHSZ::OnBtnexit() 
{
	// TODO: Add your control notification handler code here
	this->OnCancel();
}

void CYHSZ::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
		CRect rect;
		CBitmap bit;
		CDC memDC;
		this->GetClientRect(&rect);
		bit.LoadBitmap(IDB_BIT_BJ);
		memDC.CreateCompatibleDC(&dc);
		memDC.SelectObject(&bit);
		dc.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
		memDC.DeleteDC();
		::DeleteObject(&bit);	
		CDialog::OnPaint();
	// Do not call CDialog::OnPaint() for painting messages
}

HBRUSH CYHSZ::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	if(nCtlColor==CTLCOLOR_STATIC)
	{
		pDC->SetBkColor(RGB(255,255,255));
		pDC->SetTextColor(RGB(0,0,0));

	}
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

⌨️ 快捷键说明

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