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

📄 logondialog.cpp

📁 一个资产管理软件
💻 CPP
字号:
// LogonDialog.cpp : implementation file
//

#include "stdafx.h"
#include "PropertyManager.h"
#include "LogonDialog.h"

#include "MainFrm.h"

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


/////////////////////////////////////////////////////////////////////////////
// CLogonDialog dialog

extern CPropertyManagerApp theApp;

CLogonDialog::CLogonDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CLogonDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLogonDialog)
	m_save = FALSE;
	//}}AFX_DATA_INIT
}


void CLogonDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLogonDialog)
	DDX_Control(pDX, IDC_PWD, m_pwd);
	DDX_Control(pDX, IDC_USER, m_user);
	DDX_Check(pDX, IDC_CHECK1, m_save);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CLogonDialog message handlers

BOOL CLogonDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	//SetWindowText("校产处管理软件  登录框");
	CFile file;
	CFileStatus status;
	if( file.GetStatus("userlist.txt", status))
	{
		file.Open("userlist.txt",CFile::modeRead,NULL);
		CString temp,str;
		char *buf = new char(int(file.GetLength()+1));
		file.Read( buf,file.GetLength());
		*(buf+file.GetLength())='\0';
		temp.Format("%s", buf);
		buf = NULL;
		delete buf;
		file.Close();
		do{
			str = temp.Left(temp.Find("\r\n",0));
			if(str.IsEmpty())
				break;
			m_user.InsertString(0, str);
			temp.TrimLeft( str);
			temp.TrimLeft("\r\n");
		}while( temp.Find( "\r\n", 0) >= 0);
		if( !str.IsEmpty())
		{
			SetDlgItemText( IDC_USER, str);
			GetDlgItem(IDC_PWD)->SetFocus();
			UpdateData(false);
		}
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CLogonDialog::OnOK() 
{
	// TODO: Add extra validation here
	CString user,pwd;
	GetDlgItemText(IDC_USER,user);
	GetDlgItemText(IDC_PWD,pwd);
	if( theApp.CheckUser( user, pwd)==FALSE)
	{
		theApp.m_userinfo.user = user;
		theApp.m_userinfo.pwd = pwd;
		theApp.m_userinfo.time = 0;
		((CMainFrame*)AfxGetMainWnd())->SetStatusBarText(1,"");
		((CMainFrame*)AfxGetMainWnd())->ChangeMenu(1);
		UpdateData();
		if(m_save)
		{
			CFile file;
			CFileStatus status;
			if( !file.GetStatus("userlist.txt", status))
			{
				file.Open("userlist.txt",CFile::modeCreate,NULL);
				file.Close();
			}
			CString temp,str;
			file.Open("userlist.txt",CFile::modeRead,NULL);
			char *buf = new char(int(file.GetLength()+1));
			file.Read(buf,file.GetLength());
			*(buf+file.GetLength())='\0';
			temp.Format("%s",buf);
			file.Close();
			if( temp.Find(user) < 0)
			{
				str.Format("%s%s\r\n",temp,user);
				file.Open("userlist.txt",CFile::modeWrite,NULL);
				file.Write(str,str.GetLength());
				file.Close();
			}
		}
		CDialog::OnOK();
	}
	else
		AfxMessageBox("ERROR");
}

void CLogonDialog::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

⌨️ 快捷键说明

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