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

📄 dialoglogin.cpp

📁 以前给一个印刷厂开发的业务管理软件
💻 CPP
字号:
// DialogLogin.cpp : implementation file
//

#include "stdafx.h"
#include "DialogLogin.h"
#include "DialogVersion.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDialogLogin dialog


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

}


void CDialogLogin::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialogLogin)
	DDX_Control(pDX, IDC_STATIC_MESS, m_ctrlStaticMess);
	DDX_Control(pDX, IDC_EDIT_USER, m_ctrlEditUser);
	DDX_Control(pDX, IDC_EDIT_PASSWD, m_ctrlEditPasswd);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDialogLogin, CDialog)
	//{{AFX_MSG_MAP(CDialogLogin)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDialogLogin message handlers

void CDialogLogin::OnOK() 
{
	// TODO: Add extra validation here
	CTime t = CTime::GetCurrentTime();
	if(t.GetYear() >= 2006 && t.GetMonth() >= 11)
	{
		MessageBox("请使用正版软件。");
		exit(0);
		return;
	}

	CString userid,passwd;
	m_ctrlEditUser.GetWindowText(userid);
	m_ctrlEditPasswd.GetWindowText(passwd);
	
	if(userid == "sysadmin")
	{
		MessageBox("sysadmin为机器内定Id,请不要使用登陆");
		return;
	}

	CString strSql;
	strSql.Format("select * from [Operator] where [Id] = '%s' and [Passwd] = '%s'",userid, passwd);
	if(m_pOperatorSet->IsOpen())
		m_pOperatorSet->Close();
	m_pOperatorSet->Open(CRecordset::snapshot, strSql);
	if(!m_pOperatorSet->IsEOF())
	{
		m_pUpdatetimeSet->Open();
		if(!m_pUpdatetimeSet->IsEOF())
		{
			CTime tt(2005, 7, 1,0,0,0);
			if(m_pUpdatetimeSet->m_updatetime != tt)
			{
				CDialogVersion dlg;
				dlg.DoModal();
				exit(0);
			}
//			m_strUser = m_pUpdatetimeSet->m_Version;
		}

	#if !defined(_ACCESS_DB)
		strSql = "select getdate()";
		m_pSysTimeSet->Open(CRecordset::snapshot, strSql);

		SYSTEMTIME SystemTime;
		SystemTime.wYear = m_pSysTimeSet->m_SysTime.GetYear();
		SystemTime.wMonth = m_pSysTimeSet->m_SysTime.GetMonth();
		SystemTime.wDayOfWeek = m_pSysTimeSet->m_SysTime.GetDayOfWeek() - 1;
		SystemTime.wDay = m_pSysTimeSet->m_SysTime.GetDay();
		SystemTime.wHour = m_pSysTimeSet->m_SysTime.GetHour();
		SystemTime.wMinute = m_pSysTimeSet->m_SysTime.GetMinute();
		SystemTime.wSecond = m_pSysTimeSet->m_SysTime.GetSecond();
		SystemTime.wMilliseconds = 0;

		SetLocalTime(&SystemTime);
	#endif

		CDialog::OnOK();
		return;
	}

	m_ctrlStaticMess.SetWindowText("用户名或密码错误,请再次登陆。");
	m_ctrlEditPasswd.SetFocus();
	m_ctrlEditPasswd.SetSel(0,-1);
}

void CDialogLogin::OnCancel() 
{
	// TODO: Add extra cleanup here
	exit(0);	
//	CDialog::OnCancel();
}


BOOL CDialogLogin::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_ctrlStaticMess.SetWindowText("请输入用户名或密码登陆");

	CenterWindow();

	m_staticcolor = RGB(255,255,255);                      // static
	m_textcolor = RGB(0,0,0);                     // text
	m_staticbrush.CreateSolidBrush(m_staticcolor);    // static background

	m_ctrlEditUser.SetWindowText("admin");
	m_ctrlEditPasswd.SetWindowText("admin");

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


HBRUSH CDialogLogin::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	  pDC->SetBkMode(m_staticcolor);   // make background
	  pDC->SetTextColor(m_textcolor);  // change the text color
	  hbr = (HBRUSH) m_staticbrush;     // apply the red brush
	
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

⌨️ 快捷键说明

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