You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.3 KiB
C++
82 lines
2.3 KiB
C++
#pragma once
|
|
#include "GlobalDefine.h"
|
|
#include "module.h"
|
|
|
|
#define ACCOUNT_NO_LOGIN "未登录"
|
|
#define ACCOUNT_USER "操作员"
|
|
#define ACCOUNT_ADMIN "管理员"
|
|
#define ACCOUNT_FACTORY "厂家"
|
|
|
|
enum AUTHORITY_TYPE
|
|
{
|
|
_NO_LOGIN = 0,//未登录
|
|
_USER,//操作员
|
|
_ADMIN,//管理员
|
|
_FACTORY,//厂家
|
|
};
|
|
|
|
//账号
|
|
class CAccount
|
|
{
|
|
public:
|
|
CAccount()
|
|
{
|
|
m_Authority = _NO_LOGIN;
|
|
}
|
|
void Serialize(CArchive& ar)
|
|
{
|
|
if(ar.IsStoring())
|
|
{
|
|
ar<<(int)m_Authority;
|
|
ar<<m_Name;
|
|
ar<<m_PassWord;
|
|
}
|
|
else
|
|
{
|
|
int tmp;
|
|
ar>>tmp;
|
|
m_Authority = (AUTHORITY_TYPE)tmp;
|
|
ar>>m_Name;
|
|
ar>>m_PassWord;
|
|
}
|
|
}
|
|
public:
|
|
AUTHORITY_TYPE m_Authority;//权限
|
|
CString m_Name;//用户名
|
|
CString m_PassWord;//密码
|
|
};
|
|
//权限管理
|
|
class CAuthorityMgr:public CModule
|
|
{
|
|
public:
|
|
CAuthorityMgr(void);
|
|
~CAuthorityMgr(void);
|
|
virtual void Ini();
|
|
virtual MODULE GetModuleType(){return _AUTHORITY_PROP;};
|
|
virtual CMFCPropertyGridProperty *CreatGridProperty();
|
|
|
|
void SetAuthority(AUTHORITY_TYPE authority){m_CurAuthority = authority;};//设置当前权限
|
|
bool CheckAuthority(AUTHORITY_TYPE authority,bool bShowMsgbox = false);//检查当前权限
|
|
AUTHORITY_TYPE GetCurAuthority(){return m_CurAuthority;};
|
|
void AddAccount(CAccount Account);
|
|
bool Login(CString name,CString PassWord);
|
|
CString GetAccountName(AUTHORITY_TYPE authority);
|
|
void SaveOrLoad(bool bSave);
|
|
void InsertToList(CListCtrl &List);
|
|
void DelUser(int idx);
|
|
CString GetCurAccountName();
|
|
CString GetCurUserName(){return m_CurUserName;};
|
|
bool IsAutoFactory(){return m_AutoFactory;};
|
|
void Lock();
|
|
bool IsLogin();
|
|
private:
|
|
void SaveOrLoadExt(CArchive &ar);
|
|
void SortUserVec();
|
|
private:
|
|
AUTHORITY_TYPE m_CurAuthority;//当前权限
|
|
CString m_CurUserName;//当前用户名
|
|
vector<CAccount> m_UserVec;//所有的用户
|
|
bool m_AutoFactory;//打开软件自动升级到管理员权限
|
|
};
|
|
|
|
extern CAuthorityMgr *gAuthorityMgr; |