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.

141 lines
4.4 KiB
C

#pragma once
#include "GlobalDefine.h"
#include "module.h"
#define ACCOUNT_NoLogin "No Login"
#define ACCOUNT_Operator "Operator"
#define ACCOUNT_OperatorAdmin "OperatorAdmin"
#define ACCOUNT_Engineer "Engineer"
#define ACCOUNT_Technics "Technics"
#define ACCOUNT_Factory "Factory"
enum eAuthorityType
{
_Authority_NoLogin = 0,//δ<><CEB4>¼
_Authority_Operator,//<2F><><EFBFBD><EFBFBD>Ա
_Authority_OperatorAdmin,//<2F><><EFBFBD>߹<EFBFBD><DFB9><EFBFBD>Ա
_Authority_Engineer,//<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD>ʦ
_Authority_Technics,//<2F><><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>ʦ
_Authority_Factory,//<2F><><EFBFBD><EFBFBD>
};
//<2F>˺<EFBFBD>
class CAccount
{
public:
CAccount()
{
m_Authority = _Authority_NoLogin;
}
void Serialize(CArchive& ar)
{
if(ar.IsStoring())
{
ar<<(int)m_Authority;
ar<<m_Name;
ar<<m_PassWord;
}
else
{
int tmp;
ar>>tmp;
m_Authority = (eAuthorityType)tmp;
ar>>m_Name;
ar>>m_PassWord;
}
}
public:
eAuthorityType m_Authority;//Ȩ<><C8A8>
CString m_Name;//<2F>û<EFBFBD><C3BB><EFBFBD>
CString m_PassWord;//<2F><><EFBFBD><EFBFBD>
};
class CAuthorityPar
{
public:
CAuthorityPar(void)
{
m_bOperator = false;//<2F><><EFBFBD><EFBFBD>Ա
m_bOperatorAdmin = false;//<2F><><EFBFBD>߹<EFBFBD><DFB9><EFBFBD>Ա
m_bEngineer = false;//<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD>ʦ
m_bTechnics = false;//<2F><><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>ʦ
};
public:
CString m_AuthorityName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CString m_ShowName;//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool m_bOperator;//<2F><><EFBFBD><EFBFBD>Ա
bool m_bOperatorAdmin;//<2F><><EFBFBD>߹<EFBFBD><DFB9><EFBFBD>Ա
bool m_bEngineer;//<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD>ʦ
bool m_bTechnics;//<2F><><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>ʦ
};
enum eUserCtrlType
{
_UserCtrlType_AddUser = 0,//<2F><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
_UserCtrlType_DelUser,//ɾ<><C9BE><EFBFBD>˺<EFBFBD>
_UserCtrlType_login,//<2F><>¼
_UserCtrlType_logout,//<2F>˳<EFBFBD><CBB3><EFBFBD>¼
};
class CUserCtrlPar
{
public:
CUserCtrlPar(void)
{
};
public:
eUserCtrlType m_UserCtrlType;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CString m_UserName;//<2F>û<EFBFBD><C3BB><EFBFBD>
eAuthorityType m_AuthorityType;//Ȩ<><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
};
//Ȩ<>޹<EFBFBD><DEB9><EFBFBD>
class CAuthorityMgr:public CModule
{
public:
CAuthorityMgr(void);
~CAuthorityMgr(void);
virtual void OnAppInitialize();
virtual MODULE GetModuleType(){return _AUTHORITY_PROP;};
virtual CMFCPropertyGridProperty *CreatGridProperty();
void SetAuthority(eAuthorityType authority){m_CurAuthority = authority;};//<2F><><EFBFBD>õ<EFBFBD>ǰȨ<C7B0><C8A8>
bool CheckAuthority(eAuthorityType authority,bool bShowMsgbox = false);//<2F><><EFBFBD>鵱ǰȨ<C7B0><C8A8>
bool CheckAuthorityByName(CString AuthorityName,bool bShowMsgbox);
eAuthorityType GetCurAuthority(){return m_CurAuthority;};
void AddAccount(CAccount Account);
bool Login(CString name,CString PassWord);
CString GetAccountName(eAuthorityType 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();
void InitAuthorityParList(CListCtrl &List);
void InitAuthorityTypeComb(CComboBox &Combo);
void UpdateAuthorityPar(CListCtrl &List,int AuthorityType);
void UpdateAuthorityParList(CListCtrl &List,int AuthorityType);
void SaveAuthorityParaFile();
void SetbLoginDlgOpen(bool b){m_bLoginDlgOpen = b;};
bool IsbLoginDlgOpen(){return m_bLoginDlgOpen;};
private:
void SaveOrLoadExt(CArchive &ar);
void SortUserVec();
void ReadAuthorityParaFile();
void SaveUserCtrlHistory(CUserCtrlPar UserCtrlPar);
private:
eAuthorityType m_CurAuthority;//<2F><>ǰȨ<C7B0><C8A8>
CString m_CurUserName;//<2F><>ǰ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>
vector<CAccount> m_UserVec;//<2F><><EFBFBD>е<EFBFBD><D0B5>û<EFBFBD>
bool m_AutoFactory;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԱȨ<D4B1><C8A8>
bool m_bLoginDlgOpen;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڴ򿪵<DAB4>¼<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>
vector<CAuthorityPar> m_AuthorityParVec;
vector<CAuthorityPar> m_TmpAuthorityParVec;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
};
extern CAuthorityMgr *gAuthorityMgr;