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

📄 user_logindlg.cpp

📁 一个VC编写的寻呼编码测试软件代码
💻 CPP
字号:
// USER_LOGINDlg.cpp : implementation file
//

#include "stdafx.h"
#include "myPager.h"
#include "USER_LOGINDlg.h"
#include "MyPagerDlg.h"

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

extern CMyPagerApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CUSER_LOGINDlg dialog


CUSER_LOGINDlg::CUSER_LOGINDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CUSER_LOGINDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CUSER_LOGINDlg)
	m_sName = _T("");
	m_sPassword = _T("");
	//}}AFX_DATA_INIT
}


void CUSER_LOGINDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUSER_LOGINDlg)
	DDX_Control(pDX, IDC_USER_PASS, m_cPassword);
	DDX_Control(pDX, IDOK, m_cIDOK);
	DDX_Control(pDX, IDC_USER_NAME, m_cName);
	DDX_Text(pDX, IDC_USER_NAME, m_sName);
	DDX_Text(pDX, IDC_USER_PASS, m_sPassword);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUSER_LOGINDlg, CDialog)
	//{{AFX_MSG_MAP(CUSER_LOGINDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUSER_LOGINDlg message handlers

BOOL CUSER_LOGINDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
		{
			CWnd* v_wCtrl=GetFocus();
				if(v_wCtrl==&m_cIDOK)
				{
					OnOK();
					return true;
				}
				CDialog* pwnd=(CDialog*)GetActiveWindow();
				pwnd->NextDlgCtrl();
				return true;
		}
	return CDialog::PreTranslateMessage(pMsg);
}

void CUSER_LOGINDlg::OnOK() 
{
	// TODO: Add extra validation here
	CString v_sName,v_sPassword,v_sNam,v_sPass;
	UpdateData(true);
	v_sName=m_sName;
	v_sName.TrimLeft(" ");
	v_sPassword=m_sPassword;
	v_sPassword.TrimLeft(" ");
	if (v_sName.GetLength()==0)
	{
		MessageBox("请输入登录名!", "信息提示", MB_OK);
		m_cName.SetFocus();
		return;
	}
	theApp.m_strName=v_sName;


	CString v_sVi="SELECT * FROM set_user";//user where zname='"+v_sName+"'";
	try
	{
		v_pRecordset.CreateInstance("ADODB.Recordset");
		v_pRecordset->Open((_bstr_t)v_sVi,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
		if (v_pRecordset->adoEOF)
		{
			MessageBox("  无效员工,请重新输入!  ","信息提示!",MB_OK);
			m_cName.SetFocus();
			return;
		}
		v_sNam = v_pRecordset->GetCollect("zname").bstrVal;
		if(v_pRecordset->Fields->GetItem("zpassword")->ActualSize>0)
			v_sPass = v_pRecordset->GetCollect("zpassword").bstrVal;
		else v_sPass="";
		if (v_sPassword!=v_sPass)
		{
			MessageBox("  密码错误,请重新输入!  ","信息提示!",MB_OK);
			m_cPassword.SetFocus();
			return;
		}
	}
	catch(_com_error e)///捕捉异常
	{
		MessageBox("  读取用户表失败!  ","信息提示!",MB_OK);
	}

	
/*	CString v_sVi="SELECT * FROM user";// where zname='"+v_sName+"'";
	try
	{
		v_pRecordset.CreateInstance("ADODB.Recordset");
		v_pRecordset->Open((_bstr_t)v_sVi,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
		if (v_pRecordset->adoEOF)
		{
			MessageBox("你的用户名不存在,请重新输入!", "信息提示",MB_OK);
			m_cName.SetFocus();
			return;
		}
		v_sNam = v_pRecordset->GetCollect("zname").bstrVal;
		theApp.m_strName=v_sNam;

		if(v_pRecordset->Fields->GetItem("zpassword")->ActualSize>0)
			v_sPass = v_pRecordset->GetCollect("zpassword").bstrVal;
		else v_sPass="";
		if (v_sPassword!=v_sPass)
		{
			MessageBox("  密码错误,请重新输入!  ","信息提示!",MB_OK);
			m_cPassword.SetFocus();
			return;
		}
	}

	catch(_com_error e)///捕捉异常
	{
		MessageBox("  读取用户表失败!  ","信息提示!",MB_OK);
	}
	
*/	CDialog::OnOK();
}

⌨️ 快捷键说明

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