enterdlg.cpp
来自「初学VC,编写的一个机房管理系统,功能基本上完善,但代码可读性不强.」· C++ 代码 · 共 118 行
CPP
118 行
// EnterDlg.cpp : implementation file
//
#include "stdafx.h"
#include "server.h"
#include "EnterDlg.h"
#include "adminSet.h"
#include "admactionSet.h"
#include "time.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString glbname;
extern CString glbpassword;
extern bool tagofhadm;
extern CWnd *phserver;
/////////////////////////////////////////////////////////////////////////////
// CEnterDlg dialog
CEnterDlg::CEnterDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEnterDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEnterDlg)
password = _T("");
id = _T("");
//}}AFX_DATA_INIT
// m_serverdlgWnd=AfxGetApp()->m_pMainWnd;
}
void CEnterDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEnterDlg)
DDX_Text(pDX, IDC_PASSWORD, password);
DDX_Text(pDX, IDC_ID, id);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEnterDlg, CDialog)
//{{AFX_MSG_MAP(CEnterDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEnterDlg message handlers
void CEnterDlg::OnOK()
{
UpdateData(TRUE);
if(id.IsEmpty()||password.IsEmpty())
MessageBox("请输入完整!");
else
{
CAdminSet admin;
bool tag=true;
admin.Open();
while(!admin.IsEOF())
{
if(admin.m_id==id&&admin.m_password==password)
{
tag=false;
glbpassword=admin.m_password;
glbname=admin.m_name;
if(admin.m_tag)
tagofhadm=true;
else
tagofhadm=false;
break;
}
admin.MoveNext();
}
admin.Close();
if(tag)
{ MessageBox("登录失败.请核对!");
id.Empty();
password.Empty();
UpdateData(FALSE);
}
else
{ CAdmactionSet admaction;
admaction.Open();
admaction.AddNew();
admaction.m_name=glbname;
CTime currenttime=CTime::GetCurrentTime();
CString mtime=currenttime.Format("%#Y年%#m月%#d日%#H时%#M分%#S秒");
admaction.m_date=mtime;
admaction.m_action="登录";
admaction.Update();
admaction.Close();
/* currenttime=CTime::GetCurrentTime();
int nowtime=currenttime.GetHour();
nowtime=nowtime/6;
CString wenhou=_T("");
switch(nowtime)
{
case 1: wenhou="上午好!";break;
case 2: wenhou="下午好!";break;
case 3: wenhou="晚上好!";break;
}
CString *msg;
msg=new CString;
msg->Format("%s,%s",wenhou,glbname);
MessageBox(*msg,glbname,MB_OK);
*/
phserver->SendMessage(WM_MYMSG,0,0);
//MessageBox("登录成功!","server",MB_OK);
CDialog::OnOK();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?