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

📄 dlogin.cpp

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

#include "stdafx.h"
#include "Rsglxt.h"
#include "DLogin.h"
#include "DMain.h"
#include "RxRecordset.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDLogin dialog
extern CString Hman;
CString Lever;//权限等级

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


void CDLogin::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDLogin)
	DDX_Control(pDX, IDC_Group, m_Group);
	DDX_Control(pDX, IDC_LOG_BUTEXIT, m_ButExit);
	DDX_Control(pDX, IDC_LOG_BUTLogin, m_ButLogin);
	DDX_Control(pDX, IDC_COMBO_User, m_UserName);
	DDX_Control(pDX, IDC_EDIT_Password, m_EdtPwd);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDLogin, CDialog)
	//{{AFX_MSG_MAP(CDLogin)
	ON_BN_CLICKED(IDC_LOG_BUTLogin, OnLOGBUTLogin)
	ON_BN_CLICKED(IDC_LOG_BUTEXIT, OnLogButexit)
	ON_WM_PAINT()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDLogin message handlers

void CDLogin::OnLOGBUTLogin() 
{
	// TODO: Add your control notification handler code here
	RxRecordset rst;
	CString sUserName,sPwd,sPwd2,sSQL;
	this->m_UserName.GetWindowText(sUserName);
	this->m_EdtPwd.GetWindowText(sPwd);
	sSQL.Format("SELECT * FROM UserInfo WHERE User_name='%s'",sUserName);
	rst.Open(sSQL,adCmdText);
	if(rst.GetRecordCount()<1)
	{
		MessageBox("您输入的用户不存在!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
		m_UserName.SetWindowText("");
		m_UserName.SetFocus();
		nTryTime++;
		goto end;
	}
	else
	{
		Hman=rst.GetFieldValue("User_Stname");
		sPwd2=rst.GetFieldValue("Password");
		if(sPwd==sPwd2)
		{
			OP=sUserName;
			Lever=rst.GetFieldValue("Purview");
			this->OnCancel();
			CDMain dlg;
			dlg.DoModal();
		}
		else
		{
			MessageBox("您输入的密码不正确!请重新输入!","系统提示");//,MB_OK|MB_ICONSTOP);
			m_EdtPwd.SetWindowText("");
			m_EdtPwd.SetFocus();
			nTryTime++;
			goto end;
		}
	}
end: if(nTryTime>3)
	 {
		MessageBox("您已经达到了密码输入的最大次数,请与管理员联系!","系统提示");//,MB_OK|MB_ICONSTOP);
		this->OnCancel();
	 }
}

void CDLogin::OnLogButexit() 
{
	// TODO: Add your control notification handler code here
	 //if(AfxMessageBox("您确定要退出系统登陆吗?",MB_OKCANCEL)==IDCANCEL)
	if(MessageBox("您确定要退出系统登陆吗?","系统提示",MB_OKCANCEL)==IDCANCEL)
 	{
 		return;
 	}			

	this->OnCancel();

}

BOOL CDLogin::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	rst.Open("UserInfo");
	if(rst.GetRecordCount()<1)
	{
		this->OnCancel();
		//OP="无操作员";
		CDMain dlg;
		dlg.DoModal();
	}
	else
		m_UserName.SetRecordset(rst,"User_name");
	///////////////
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDLogin::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 CDLogin::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 + -