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

📄 logindlg.cpp

📁 基于SQLSERVER2000的机械工艺数据库系统
💻 CPP
字号:
// LOGINDLG.cpp : implementation file
//

#include "stdafx.h"
#include "KNC_MIS.h"
#include "LOGINDLG.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLOGINDLG dialog


CLOGINDLG::CLOGINDLG(CWnd* pParent /*=NULL*/)
	: CDialog(CLOGINDLG::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLOGINDLG)
	m_sUSER = _T("");
	m_sPWD = _T("");
	//}}AFX_DATA_INIT
}


void CLOGINDLG::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLOGINDLG)
	DDX_Text(pDX, IDC_EDIT1, m_sUSER);
	DDX_Text(pDX, IDC_EDIT2, m_sPWD);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLOGINDLG, CDialog)
	//{{AFX_MSG_MAP(CLOGINDLG)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLOGINDLG message handlers
void CLOGINDLG::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(true);
	
	m_sUSER.TrimRight(" ");

	if ( ""==m_sUSER )
	{
		AfxMessageBox(_T("请填写用户名"), MB_ICONEXCLAMATION);
        return;
	}
		
	_variant_t Holder, strQuery;
    strQuery = "select user_ID, user_PWD from user_Info where user_ID='"+m_sUSER+"'";
	theApp.ADOExecute(theApp.m_pADOSet, strQuery);
	int iCount = theApp.m_pADOSet->GetRecordCount();
	if ( 0==iCount ) 
	{
		theApp.m_iLoginCount++;
		if ( theApp.m_iLoginCount>2 ) 
		{
			AfxMessageBox("没有这个用户\n三次输入均不正确,请核对后再来", MB_ICONEXCLAMATION);	
			CDialog::OnCancel();
		    return;
		}
		AfxMessageBox("没有这个用户,请重新输入用户名", MB_ICONEXCLAMATION);	
	    return;
	}
	
	CString sPWD;
	theApp.m_pADOSet->MoveFirst();
	Holder = theApp.m_pADOSet->GetCollect("user_PWD");
	sPWD = Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder;
	if ( 0!=sPWD.Compare(m_sPWD) )
	{
		theApp.m_iLoginCount++;
		if ( theApp.m_iLoginCount>2 ) 
		{
			AfxMessageBox("输入密码不正确\n三次输入均不正确,请核对后再来", MB_ICONEXCLAMATION);	
			CDialog::OnCancel();
		    return;
		}
		AfxMessageBox("输入密码不正确,请重新输入", MB_ICONEXCLAMATION);	
	    return;
	}
	
	// Get Login User
	theApp.m_sCurrentUser = m_sUSER;
	
	CDialog::OnOK();
}

BOOL CLOGINDLG::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	((CEdit*)GetDlgItem(IDC_EDIT1))->SetLimitText(15);
    ((CEdit*)GetDlgItem(IDC_EDIT2))->SetLimitText(10);
	// Set Caption Font
	//CFont m_Font;
    m_fMyFont.CreatePointFont(140,"华文彩云",NULL);
        
	((CStatic *)GetDlgItem(IDC_Name))->SetFont(&m_fMyFont, true);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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