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

📄 logiondlg.cpp

📁 一套人事管理系统
💻 CPP
字号:
// LOGIONDLG.cpp : implementation file
//

#include "stdafx.h"
#include "zhurui_jk02_人事管理.h"
#include "LOGIONDLG.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLOGIONDLG dialog


CLOGIONDLG::CLOGIONDLG(CWnd* pParent /*=NULL*/)
	: CDialog(CLOGIONDLG::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLOGIONDLG)
	m_YHM = _T("");
	m_MIMA = _T("");
	//}}AFX_DATA_INIT
}


void CLOGIONDLG::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLOGIONDLG)
	DDX_Control(pDX, IDOK, m_ok);
	DDX_Control(pDX, IDCANCEL, m_cancle);
	DDX_Control(pDX, IDC_YHM, m_ctrYHM);
	DDX_Control(pDX, IDC_STATIC2, m_ctr2);
	DDX_Control(pDX, IDC_STATIC1, m_ctr1);
	DDX_Control(pDX, IDC_STATIC0, m_ctr0);
	DDX_Control(pDX, IDC_MIMA, m_ctrMIMA);
	DDX_Text(pDX, IDC_YHM, m_YHM);
	DDX_Text(pDX, IDC_MIMA, m_MIMA);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLOGIONDLG, CDialog)
	//{{AFX_MSG_MAP(CLOGIONDLG)
	ON_WM_CTLCOLOR()
	ON_WM_LBUTTONDOWN()
	ON_WM_TIMER()
	ON_WM_NCLBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLOGIONDLG message handlers

/*
void CLOGIONDLG::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
	CRect rc_window,rc_min,rc_close;
	GetWindowRect(&rc_window);
	
	rc_close.left=rc_window.right-45;
	rc_close.right=rc_window.right-7;
	rc_close.top=rc_window.top;
	rc_close.bottom=rc_window.top+21;
	
	
	if(rc_close.PtInRect(point))
	{
		SendMessage(WM_CLOSE);
	}
	else
	{
		Default();
	}
	
}

void CLOGIONDLG::OnNcMouseMove(UINT nHitTest, CPoint point)
{
	CRect rc;
	this->GetWindowRect(&rc);
	CDC* dc;
	dc=GetWindowDC();
	CDC memdc;
	memdc.CreateCompatibleDC(dc);
	CRect rc_window,rc_min,rc_close;
	GetWindowRect(&rc_window);

	rc_min.left=rc_window.right-90;
	rc_min.right=rc_window.right-65;
	rc_min.top=rc_window.top;
	rc_min.bottom=rc_window.top+21;

	rc_close.left=rc_window.right-45;
	rc_close.right=rc_window.right-7;
	rc_close.top=rc_window.top;
	rc_close.bottom=rc_window.top+18;
	
	
	CBitmap bmp,bmp1,*oldbmp;
	if(rc_close.PtInRect(point))
	{
		bmp.LoadBitmap("IDB_CLOSE");
		
	}
	else
	{
		bmp.LoadBitmap("IDB_NORMAL");
	}
	oldbmp=memdc.SelectObject(&bmp);
	dc->BitBlt(rc.Width()-93,0,93,30,&memdc,0,0,SRCCOPY);
	
	bmp1.LoadBitmap("IDB_TOP");
	memdc.SelectObject(&bmp1);
	dc->BitBlt(0,0,rc.Width()-93,30,&memdc,0,0,SRCCOPY);
	memdc.SelectObject(oldbmp);
	bmp1.DeleteObject();
	bmp.DeleteObject();
	ReleaseDC(&memdc);
	ReleaseDC(dc);
	
	
	memdc.DeleteDC();
	
//	dc->DeleteDC();


}
*/
HBRUSH CLOGIONDLG::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_DLG)   
	{   
        //返回对话框的颜色   
		hbr=(HBRUSH)::CreateSolidBrush(RGB(0,255,255));     
	}  
	
	HBRUSH hbr0=(HBRUSH)::GetStockObject(NULL_BRUSH); 
	if(nCtlColor==CTLCOLOR_STATIC)   
	{   
		//让静态文本框透明   
		pDC->SetBkMode(TRANSPARENT);   
		pDC->SetTextColor(RGB(0,255,255));   //设置字体颜色天蓝色   
		HBRUSH hbr0=(HBRUSH)::GetStockObject(NULL_BRUSH);  
		return hbr0 ;
	}   
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

void CLOGIONDLG::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	SendMessage(WM_NCLBUTTONDOWN,HTCAPTION); //拖动没有标题栏的对话框
	CDialog::OnLButtonDown(nFlags, point);
}
int i=17,j=1;
BOOL CLOGIONDLG::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	if(j==1)
	{
		m_ctr0.ShowWindow(FALSE);
		m_ctr1.ShowWindow(FALSE);
		m_ctrYHM.ShowWindow(FALSE);
		m_ctrMIMA.ShowWindow(FALSE);
		m_ok.ShowWindow(FALSE);
		m_cancle.ShowWindow(FALSE);
		SetTimer(1,3000,NULL);
		SetTimer(2,100,NULL);
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CLOGIONDLG::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if(nIDEvent==1)
	{
		m_ctr0.ShowWindow(TRUE);
		m_ctr1.ShowWindow(TRUE);
		m_ctrYHM.ShowWindow(TRUE);
		m_ctrMIMA.ShowWindow(TRUE);
		m_ok.ShowWindow(TRUE);
		m_cancle.ShowWindow(TRUE);
		m_ctr2.ShowWindow(FALSE);
		m_ctrYHM.SetFocus();
		this->KillTimer(1);
	}
	if(nIDEvent==2 && j==1)
	{
		static CString strtmp="系统载入中,请稍候. . . . . . . . . .";
		m_ctr2.SetWindowText(strtmp.Mid(0,i));
		i++;
		if(i>30)
		{
			j=0;
			this->KillTimer(2);
		}
	}
	CDialog::OnTimer(nIDEvent);
}
int count=0;
void CLOGIONDLG::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();
	m_LOGION=0;
	if(m_YHM=="")
	{
		AfxMessageBox("请输入用户名!");
		m_ctrYHM.SetFocus();
		CDatabase dbtmp;
	}
	else
	{
		CDatabase db;
		CRecordset rs(&db);
		db.Open("sam人事管理");
		rs.Open(CRecordset::forwardOnly,"select * from 员工 where ID ='"+m_YHM +"' and PASSWORD='"+ m_MIMA  +"' ");
		if(!rs.IsEOF())
		{
			m_LOGION=1;
			rs.Close();
			db.Close();
			CDialog::OnOK();
		}
		else
		{
			count++;
			AfxMessageBox("用户名或密码输入错误!");
			m_ctrYHM.SendMessage(EM_SETSEL,0,-1);
			m_ctrYHM.SetFocus();
			m_LOGION=0;
		}
		
		if(count==3)
		{
			AfxMessageBox("对不起,错误次数已达上限!");
			m_LOGION=0;
			count=0;
			CDialog::OnOK();
		}
		
		
	}
}

⌨️ 快捷键说明

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