📄 enguardmainunit.cpp
字号:
//显示界面
if (lEventType == etNormalEvent) //为正常门禁事件
{
AddNormalEventLog(aLogInfo);
lEventCount++;
}
else
{
if (lEventType <= etDeviceError && lEventType >= etWarningEvent) //为警告事件
{
AddWaringEventLog(aLogInfo);
lWarningEventCount++;
}
}
//保存数据库
lRV = aDBAccess.InsertLog(aLogInfo);
if (lRV != OK)
{
Application->MessageBoxA("保存日志信息失败!","提示信息",MB_OK + MB_ICONERROR);
}
sbInfo->Panels->Items[2]->Text = "共监控到门禁事件:" + AnsiString(lWarningEventCount+lEventCount) + " 起,其中报警:"+AnsiString(lWarningEventCount)+" 起";
}
sbInfo->Panels->Items[3]->Text = " 当前系统时间:" + Now().DateTimeString();
}
//---------------------------------------------------------------------------
void TEnguardMainFrm::AddNormalEventLog(LogInfoBase_T iLogInfo)
{
if (lvRecordInfo->Items->Count >= aSystemConfigInfo.ViewConfig.ShowMaxCount)
{
lvRecordInfo->Items->Delete(0);
}
UserSimpleInfo_T aEmpSimpleInfo;
aDBAccess.GetUserSimpleInfo(iLogInfo.MainEmpID,aEmpSimpleInfo);
TListItem *ListItem;
ListItem = lvRecordInfo->Items->Add();
ListItem->Caption = iLogInfo.DeviceLogID;
ListItem->SubItems->Add(iLogInfo.MainEmpID);
ListItem->SubItems->Add(aEmpSimpleInfo.EmpName);
ListItem->SubItems->Add(aEmpSimpleInfo.DeptName);
DeviceInfo_T aDeviceInfo;
pEventEngine->GetDeviceInfo(iLogInfo.DeviceID,&aDeviceInfo);
ListItem->SubItems->Add(aDeviceInfo.DeviceName);
AnsiString lTimeStr = SystemTimeToDateTime(iLogInfo.EventTime).FormatString("MM-DD HH:MM:SS");
ListItem->SubItems->Add(lTimeStr);
ListItem->SubItems->Add(aConv.GetEventName((EventType_T)iLogInfo.OpType));
}
//---------------------------------------------------------------------------
void TEnguardMainFrm::AddWaringEventLog(LogInfoBase_T iLogInfo)
{
if (lvWaringEvent->Items->Count >= aSystemConfigInfo.ViewConfig.ShowMaxCount)
{
lvWaringEvent->Items->Delete(0);
}
TListItem *ListItem;
ListItem = lvWaringEvent->Items->Add();
ListItem->Caption = iLogInfo.DeviceLogID;
DeviceInfo_T aDeviceInfo;
pEventEngine->GetDeviceInfo(iLogInfo.DeviceID,&aDeviceInfo);
ListItem->SubItems->Add(aDeviceInfo.DeviceName);
AnsiString lTimeStr = SystemTimeToDateTime(iLogInfo.EventTime).FormatString("MM-DD HH:MM:SS");
ListItem->SubItems->Add(lTimeStr);
ListItem->SubItems->Add(aConv.GetEventName((EventType_T)iLogInfo.OpType));
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::SpeedButton4Click(TObject *Sender)
{
TEmployeeViewFrm* pTEmployeeViewFrm = new TEmployeeViewFrm(this);
pTEmployeeViewFrm->ShowModal();
delete pTEmployeeViewFrm;
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::aCloseExecute(TObject *Sender)
{
//退出系统
/*
TSystemLoginFrm* pSystemLoginFrm = new TSystemLoginFrm(this);
pSystemLoginFrm->ShowModal();
delete pSystemLoginFrm;
*/
if (Application->MessageBoxA("您确认要退出系统吗?","提示信息",MB_YESNO+MB_ICONQUESTION) == ID_YES)
{
Application->Terminate();
}
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::aLogAnalyseExecute(TObject *Sender)
{
TLogAnalyseFrm* pLogAnalyseFrm = new TLogAnalyseFrm(this);
pLogAnalyseFrm->ShowModal();
delete pLogAnalyseFrm;
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::aEngineStatusExecute(TObject *Sender)
{
//停止或开启门禁监控
if (pEventEngine->IsActive()) //已经开启
{
if(Application->MessageBoxA("您确认要停止门禁监控吗?","提示信息",MB_YESNO + MB_ICONQUESTION) == ID_YES)
{
if(sbInfo->Panels->Items[0]->Text != "登录员工:未登录")
{
SystemLoginFrm->ShowModal();
if(SystemLoginFrm->IsCanceled())
return;
AnsiString lStatus = "登录员工:";
if(aDBAccess.GetUserMaxID() == 0)
{
lStatus = lStatus + "未登录";
sbInfo->Panels->Items[0]->Text = lStatus;
}
else
{
int lEmpID = SystemLoginFrm->edtEmpID->Text.Trim().ToInt();
aDBAccess.GetUserInfo(lEmpID,CurUserInfo);
lStatus = lStatus + CurUserInfo.BaseUserInfo.EmpName;
sbInfo->Panels->Items[0]->Text = lStatus;
}
}
pEventEngine->StopEngine();
}
else
{
pEventEngine->StartEngine();
}
int lCount,lActiveCount;
pEventEngine->GetDeviceCount(lCount,lActiveCount);
sbInfo->Panels->Items[1]->Text = " 设备总数:" + AnsiString(lCount)+ " | 启用监控设备个数:" + AnsiString(lActiveCount);;
}
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::aLoginExecute(TObject *Sender)
{
SystemLoginFrm->ShowModal();
AnsiString lStatus = "登录员工:";
if(SystemLoginFrm->IsCanceled())
return;
if(aDBAccess.GetUserMaxID() == 0)
{
lStatus = lStatus + "未登录";
sbInfo->Panels->Items[0]->Text = lStatus;
}
else
{
int lEmpID = SystemLoginFrm->edtEmpID->Text.Trim().ToInt();
aDBAccess.GetUserInfo(lEmpID,CurUserInfo);
lStatus = lStatus + CurUserInfo.BaseUserInfo.EmpName;
sbInfo->Panels->Items[0]->Text = lStatus;
}
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::aChangePasswordExecute(TObject *Sender)
{
//修改登录密码
TChangePasswordFrm* pChangePasswordFrm = new TChangePasswordFrm(this);
pChangePasswordFrm->CurEmpID = CurUserInfo.BaseUserInfo.UserID;
pChangePasswordFrm->ShowModal();
delete pChangePasswordFrm;
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::aShowInitPanelExecute(TObject *Sender)
{
SetInitPanelVisible(!plInitPanel->Visible);
}
//---------------------------------------------------------------------------
void TEnguardMainFrm::SetInitPanelVisible(bool iVisible)
{
plInitPanel->Visible = iVisible;
if (iVisible)
{
aShowInitPanel->Caption = "隐藏初始化面板 &I";
spbnInitPanelShow->Caption = "<";
}
else
{
aShowInitPanel->Caption = "显示初始化面板 &I";
spbnInitPanelShow->Caption = ">";
}
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::aRefreshExecute(TObject *Sender)
{
pEventEngine->RestartEngine();
int lCount,lActiveCount;
pEventEngine->GetDeviceCount(lCount,lActiveCount);
sbInfo->Panels->Items[1]->Text = " 设备总数:" + AnsiString(lCount)+ " | 启用监控设备个数:" + AnsiString(lActiveCount);;
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::aHelpExecute(TObject *Sender)
{
//
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::lvWaringEventCustomDrawItem(
TCustomListView *Sender, TListItem *Item, TCustomDrawState State,
bool &DefaultDraw)
{
AnsiString lEventName = Item->SubItems->Strings[2].Trim();
if(lEventName == "非法进入或开门按扭")
{
Sender->Canvas->Font->Color = (TColor)aSystemConfigInfo.ViewConfig.fvWarningEventColor;
}
else if(lEventName == "胁迫事件")
{
Sender->Canvas->Font->Color = (TColor)aSystemConfigInfo.ViewConfig.fvDangerEventColor;
}
else if(lEventName == "门未关好")
{
Sender->Canvas->Font->Color = (TColor)aSystemConfigInfo.ViewConfig.fvUncloseEventColor;
}
else if(lEventName == "设备异常")
{
Sender->Canvas->Font->Color = (TColor)aSystemConfigInfo.ViewConfig.fvDeviceErrorColor;
}
else
{
Sender->Canvas->Font->Color = (TColor)aSystemConfigInfo.ViewConfig.fvOtherColor;
}
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::aClearEventListExecute(TObject *Sender)
{
lvRecordInfo->Clear();
lvWaringEvent->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::aSystemConfigSetExecute(TObject *Sender)
{
TSystemConfigSetFrm* pSystemConfigSetFrm = new TSystemConfigSetFrm(this);
pSystemConfigSetFrm->ShowModal();
if (!pSystemConfigSetFrm->IsCanceled())
{
TConfigInfoXML aConfigInfoXML(ConfigFile);
if (!aConfigInfoXML.GetConfigInfo(aSystemConfigInfo))
{
aConfigInfoXML.GetDefaultConfigInfo(aSystemConfigInfo);
}
SetWarningPanelSytle(aSystemConfigInfo.ViewConfig.WarningPanelStyle);
}
delete pSystemConfigSetFrm;
}
//---------------------------------------------------------------------------
void __fastcall TEnguardMainFrm::FormClose(TObject *Sender,
TCloseAction &Action)
{
if (Application->MessageBoxA("您确认要退出系统吗?","提示信息",MB_YESNO+MB_ICONQUESTION) == ID_YES)
Application->Terminate();
else
Action = caNone;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -