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

📄 login.cpp

📁 各个银行
💻 CPP
字号:
// LOGIN.cpp : implementation file
//

#include "stdafx.h"
#include "BankSystem.h"
#include "LOGIN.h"
#include "banksystemdlg.h"
#include "ADOConn.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLOGIN dialog


CLOGIN::CLOGIN(CWnd* pParent /*=NULL*/)
	: CDialog(CLOGIN::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLOGIN)
	m_id = _T("");
	m_pwd = _T("");
	flag=0;
	//}}AFX_DATA_INIT
}


void CLOGIN::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLOGIN)
	DDX_Text(pDX, IDC_ID, m_id);
	DDX_Text(pDX, IDC_PWD, m_pwd);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLOGIN, CDialog)
	//{{AFX_MSG_MAP(CLOGIN)
	ON_BN_CLICKED(IDC_ADMIN, OnAdmin)
	ON_BN_CLICKED(IDC_OPERATOR, OnOperator)
	ON_BN_CLICKED(IDC_User, OnUser)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLOGIN message handlers

BOOL CLOGIN::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//GetDlgItem(IDC_User)->SetCheck(1);
	GetDlgItem(IDC_PWD)->EnableWindow(false);
	GetDlgItem(IDC_ID)->EnableWindow(false);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void CLOGIN::OnAdmin() 
{
GetDlgItem(IDC_NA)->SetWindowText("超级管理员:");
flag=1;
GetDlgItem(IDC_ID)->EnableWindow(true);
GetDlgItem(IDC_PWD)->EnableWindow(true);
GetDlgItem(IDC_ID)->SetFocus();
	
}

void CLOGIN::OnOperator() 
{
GetDlgItem(IDC_NA)->SetWindowText("操作员:");
flag=2;
GetDlgItem(IDC_ID)->EnableWindow(true);
GetDlgItem(IDC_PWD)->EnableWindow(true);
GetDlgItem(IDC_ID)->SetFocus();
	
}

void CLOGIN::OnUser() 
{
GetDlgItem(IDC_NA)->SetWindowText("用户:");
flag=3;
GetDlgItem(IDC_ID)->EnableWindow(true);
GetDlgItem(IDC_PWD)->EnableWindow(false);
GetDlgItem(IDC_ID)->SetFocus();
	
}

void CLOGIN::OnOK() 
{
	ADOConn Conn;
_RecordsetPtr pRst;
CBankSystemApp* pApp=(CBankSystemApp*)AfxGetApp(); 
CBankSystemDlg* pDlg=(CBankSystemDlg*)pApp->m_pMainWnd; 
_bstr_t   sql;
_variant_t v;
	UpdateData(TRUE);
	if(flag==0)
	MessageBox("还没选择");
	
	switch(flag)
	{
		case 1:  
			if(m_id=="")
			 {
				 AfxMessageBox("ID不能为空");
	             GetDlgItem(IDC_ID)->SetFocus();
	             return;
			 }
			  
			if(m_pwd=="")
			 {
				 AfxMessageBox("密码不能为空");
	             GetDlgItem(IDC_PWD)->SetFocus();
	             return;
			 }

			if(m_id=="admin"&&m_pwd=="12345")
			{
				CBankSystemApp* pApp=(CBankSystemApp*)AfxGetApp(); 
                CBankSystemDlg* pDlg=(CBankSystemDlg*)pApp->m_pMainWnd; 
				pDlg->m_bankreg.ShowWindow(SW_SHOW);	
				pDlg->m_bankreg.EnableWindow(true);
                pDlg->m_usereg.ShowWindow(SW_HIDE);	AfxMessageBox("ok");
				pDlg->SetWindowText("超级管理员");
				UpdateData(false);
				pDlg->GetDlgItem(IDC_LOGIN)->EnableWindow(false);
				pDlg->m_outop.ShowWindow(!SW_HIDE);
				//pDlg->GetDlgItem(IDC_LIST1)->ShowWindow(!SW_HIDE);
				pDlg->m_find.EnableWindow(true);
                pDlg->m_print.ShowWindow(true);
				theApp.UserID=m_id;
			}
			else
			{	AfxMessageBox("ID或者密码错误");
			    return;
			}
		        break;
		case 2:
			sql="select * from operator,bankInfo where opId='"+m_id+"'"+"and opPwd='"+m_pwd+"'"+"and Operator.BankId=bankInfo.bankId";
			pRst=Conn.GetRecordset(sql);
			if(pRst->adoEOF)
			{
				AfxMessageBox("failed");return;
			}
            else
			{       AfxMessageBox("ok!");
			        v=pRst->GetCollect("bankId");
					theApp.BANKID=v.bstrVal;
			        v=pRst->GetCollect("bankName");
                    CString Name=v.bstrVal;
				    pDlg->SetWindowText("操作员");
					pDlg->GetDlgItem(IDC_LOGIN)->EnableWindow(false);
					pDlg->m_outop.ShowWindow(!SW_HIDE);
					pDlg->m_find.EnableWindow(true);
					theApp.UserID=m_id;  
					pDlg->m_bankreg.EnableWindow(false);
					pDlg->GetDlgItem(IDC_USERREG)->EnableWindow(false);
					theApp.info="操作员:"+m_id+"所属银行:"+Name;
					pDlg->GetDlgItem(IDC_STATIC)->ShowWindow(!SW_HIDE);
					pDlg->GetDlgItem(IDC_STATIC)->SetWindowText(theApp.info);
			}

			    break;
		case 3:
			sql="select * from userInfo where userID='"+m_id+"'";
		pRst=Conn.GetRecordset(sql);
			if(pRst->adoEOF)
			{	AfxMessageBox("failed");
			return;
			}
            else
			{
				_variant_t v;
				v=pRst->GetCollect("userID");
             theApp.IsonID=v.bstrVal;
                v=pRst->GetCollect("userName").bstrVal;
			 theApp.IsonName=v.bstrVal;
			    v=pRst->GetCollect("userpId").bstrVal;
			 theApp.IsonPID=v.bstrVal;
               v=pRst->GetCollect("userTel").bstrVal;
			 theApp.IsonTel=v.bstrVal;
			    v=pRst->GetCollect("userAddr").bstrVal;
			 theApp.IsonAddr=v.bstrVal;
			AfxMessageBox("ok!");
			pDlg->GetDlgItem(IDC_LOGIN)->EnableWindow(false);
			pDlg->GetDlgItem(IDC_FIND)->EnableWindow(false);
			pDlg->GetDlgItem(IDC_OPERATE)->EnableWindow(true);
			pDlg->GetDlgItem(IDC_USERREG)->SetWindowText("继续开户");
			pDlg->SetWindowText("用户");
			theApp.info="用户"+theApp.IsonName;
            pDlg->GetDlgItem(IDC_STATIC)->ShowWindow(!SW_HIDE);
			pDlg->GetDlgItem(IDC_STATIC)->SetWindowText(theApp.info);
			 pDlg->m_outop.ShowWindow(!SW_HIDE);

			}
			    break;
	}

	//从数据库中找

	CDialog::OnOK();

}

⌨️ 快捷键说明

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