📄 login.cpp
字号:
// Login.cpp : implementation file
//
#include "stdafx.h"
#include "SalaryManagement.h"
#include "Login.h"
#include "USkin.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)
//}}AFX_DATA_INIT
m_conn.OnInitADOConn();
}
CLogin::~CLogin()
{
m_conn.ExitConnect();
}
void CLogin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLogin)
DDX_Control(pDX, IDC_SHOCKWAVEFLASH1, m_flash);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLogin, CDialog)
//{{AFX_MSG_MAP(CLogin)
ON_WM_DESTROY()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLogin message handlers
BOOL CLogin::OnInitDialog()
{
CDialog::OnInitDialog();
// USkinInit(NULL,NULL,_T("F:\\实验程序\\SalaryManagement\\5.u3"));//加载皮肤文件
//引入flash控件
// ShowWindow(SW_SHOWMAXIMIZED);
RECT rc;
this->GetClientRect(&rc);
m_flash.MoveWindow( &rc, true );
TCHAR strCurDrt[500];
int nLen = ::GetCurrentDirectory(500,strCurDrt);
if( strCurDrt[nLen]!='\\' )
{
strCurDrt[nLen++] = '\\';
strCurDrt[nLen] = '\0';
}
CString strFileName = strCurDrt;
strFileName += "startup.swf";
m_flash.LoadMovie(0, strFileName);
m_flash.Play();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLogin::OnDestroy()
{
CDialog::OnDestroy();
}
extern CSalaryManagementApp theApp;
//DEL void CLogin::OnOK()
//DEL {
//DEL UpdateData();
//DEL
//DEL if(m_userID=="")
//DEL {
//DEL AfxMessageBox("用户名不能为空");
//DEL return ;
//DEL }
//DEL
//DEL CString sql;
//DEL sql.Format("SELECT * FROM Login WHERE ID='%s' AND Password='%s'",m_userID,m_password);
//DEL _RecordsetPtr m_pRecordset;
//DEL m_pRecordset=m_conn.GetRecordSet((_bstr_t)sql);
//DEL
//DEL if(m_pRecordset->adoEOF)
//DEL {
//DEL AfxMessageBox("用户ID或密码错误!!!");
//DEL return ;
//DEL }
//DEL
//DEL //获得当前用户的用户名
//DEL _variant_t m_user;
//DEL m_user=m_pRecordset->GetCollect("UserName");
//DEL
//DEL theApp.m_username=(LPCTSTR)(_bstr_t)m_user;
//DEL
//DEL CDialog::OnOK();
//DEL }
BEGIN_EVENTSINK_MAP(CLogin, CDialog)
//{{AFX_EVENTSINK_MAP(CLogin)
ON_EVENT(CLogin, IDC_SHOCKWAVEFLASH1, 150 /* FSCommand */, OnFSCommandShockwaveflash1, VTS_BSTR VTS_BSTR)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CLogin::OnFSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args)
{
UpdateData();
if(0==strcmp(command,"m_user"))
{
if(0==strcmp(args,""))
{
AfxMessageBox("用户名不能为空");
return ;
}
else
m_user=args;;
}
if(0==strcmp(command,"m_password"))
{
m_password=args;
try{
CString sql;
sql.Format("SELECT * FROM Login WHERE 用户名='%s' AND 密码='%s'",
m_user,m_password);
_RecordsetPtr m_pRecordset;
m_pRecordset=m_conn.GetRecordSet(sql);
if(m_pRecordset->adoEOF)
{
AfxMessageBox("用户名或密码错误!!!");
return ;
}
theApp.m_username=m_user;
}
catch(_com_error e)
{
AfxMessageBox(e.Description());
}
//1秒后跳转
SetTimer(0,1000,NULL);
}
if(0==strcmp(command,"quit"))
CDialog::OnCancel();
}
void CLogin::OnTimer(UINT nIDEvent)
{
if(nIDEvent==0)
{
KillTimer(0);
AnimateWindow(GetSafeHwnd(),000,AW_HIDE|AW_BLEND|AW_CENTER);
CDialog::OnOK();
// DestroyWindow();
}
CDialog::OnTimer(nIDEvent);
//welcome to salarymanagement
}
BOOL CLogin::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->wParam==VK_ESCAPE||pMsg->wParam==VK_RETURN)
return FALSE;
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -