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

📄 dlogin.cpp

📁 物流管理系统包括基本信息管理、仓库管理、销售管理、配送管理、运输管理、报关管理、决策管理等模块
💻 CPP
字号:
// DLogin.cpp : implementation file
//

#include "stdafx.h"
#include "MyProject.h"
#include "DLogin.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "DMain.h"
/////////////////////////////////////////////////////////////////////////////
// CDLogin dialog


CDLogin::CDLogin(CWnd* pParent /*=NULL*/)
	: CDialog(CDLogin::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDLogin)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
//	m_hIcon = AfxGetApp()->LoadIcon(IDI_LOG);
	m_nTryTime=1;
}


void CDLogin::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDLogin)
	DDX_Control(pDX, IDC_EDTPASWARD, m_EdtPwd);
	DDX_Control(pDX, IDC_EDTNAME, m_EdtName);
	DDX_Control(pDX, IDC_STATITLE, m_StaTitle);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDLogin, CDialog)
	//{{AFX_MSG_MAP(CDLogin)
	ON_BN_CLICKED(IDC_BUTLOGIN, OnButlogin)
	ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

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

void CDLogin::OnOK() 
{
	// TODO: Add extra validation here
	
	//CDialog::OnOK();
}

BOOL CDLogin::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//判断计算机名与用户名是否相同
	DWORD nSize=MAX_COMPUTERNAME_LENGTH+1;
	char name[MAX_COMPUTERNAME_LENGTH+1];
	memset(name,0,sizeof(name));
	GetComputerName(name,&nSize);
	CString sSQL;
	RxRecordset rst;
	sSQL.Format("SELECT* FROM 操作员信息表 WHERE 用户名='%s'",name);
	rst.Open(sSQL,adCmdText);
	if(rst.GetRecordCount()<1)
	{
		this->SetIcon(m_hIcon,true);
		rst.Open("操作员信息表");
		if(rst.GetRecordCount()<1)	//还没有用户
		{
			this->OnCancel();
			CDMain dlg;
			OP="超级用户";
			dlg.DoModal();		
		}
	}
	else
	{
		this->m_EdtName.EnableWindow(false);
		this->m_EdtName.SetWindowText(name);
		this->m_EdtPwd.SetFocus();
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDLogin::OnButlogin() 
{
	CString sSQL,sPwd,sOldPwd,sUserName;
	m_EdtPwd.GetWindowText(sPwd);
	m_EdtName.GetWindowText(sUserName);
	sOldPwd=ado.FieldToOtherField("操作员信息表","用户名",sUserName,"密码",1);
	if(sOldPwd.IsEmpty())
	{
		if(m_nTryTime>=3)	//确认用户输入用户名或密码的次数
		{
			MessageBox("对不起!您不能登录本系统,请与管理员联系!","系统提示",MB_OK|MB_ICONSTOP);
			this->OnCancel();
			return;
		}
		MessageBox("您输入的用户不存在!请重新的输入!","系统提示",MB_OK|MB_ICONSTOP);
		m_EdtName.SetFocus();
		m_nTryTime=m_nTryTime+1;
		return;
	}
	if(sOldPwd==sPwd)
	{
		this->OnCancel();
		CDMain dlg;
		OP=sUserName;
		dlg.DoModal();		
	}
	else
	{
		if(m_nTryTime>=3)
		{
			MessageBox("对不起!您不能登录本系统,请与管理员联系!","系统提示",MB_OK|MB_ICONSTOP);
			this->OnCancel();
			return;
		}
		MessageBox("您输入的密码不正确!请重试!","系统提示",MB_OK|MB_ICONSTOP);
		m_EdtPwd.SetWindowText("");
		m_EdtPwd.SetFocus();
		m_nTryTime=m_nTryTime+1;

	}		
}

void CDLogin::OnButexit() 
{
	this->OnCancel();	
}

int CDLogin::DoModal() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDialog::DoModal();
}

⌨️ 快捷键说明

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