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

📄 setroleunit.cpp

📁 指纹门禁机管理系统
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "SetRoleUnit.h"
#include "EnguardRoleUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "BaseInputUnit"
#pragma resource "*.dfm"
TSetRoleFrm *SetRoleFrm;
//---------------------------------------------------------------------------
__fastcall TSetRoleFrm::TSetRoleFrm(TComponent* Owner)
    : TBaseDataInputFrm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TSetRoleFrm::bbtnRoleClick(TObject *Sender)
{
    TEnguardRoleFrm* pEnguardRoleFrm = new TEnguardRoleFrm(this);
    pEnguardRoleFrm->ShowModal();
    delete pEnguardRoleFrm;
}
//---------------------------------------------------------------------------

char TSetRoleFrm::GetSelectedRole()
{
   //得到门禁规则值
   char lRoleVal;
   char lReturnVal = (int)0;
   for(int i=0;i<5;i++)
   {
     if (RoleCheckBoxList[i]->Checked)
     {
       lRoleVal = RoleCheckBoxList[i]->Tag;
       lReturnVal = lReturnVal |lRoleVal;
     }
   }
   return lReturnVal;
}
//---------------------------------------------------------------------------

void __fastcall TSetRoleFrm::FormCreate(TObject *Sender)
{
  cbNoLimit->Tag = rtNoLimit;
  cbPeriod1->Tag = rtPeriod1;
  cbPeriod2->Tag = rtPeriod2;
  cbWeekend->Tag = rtWeekend;
  cbHoliday->Tag = rtHoliday;

  RoleCheckBoxList[0] = cbNoLimit;
  RoleCheckBoxList[1] = cbPeriod1;
  RoleCheckBoxList[2] = cbPeriod2;
  RoleCheckBoxList[3] = cbWeekend;
  RoleCheckBoxList[4] = cbHoliday;

  for(int i=0;i<5;i++)
  {
    RoleCheckBoxList[i]->OnClick = OnCheckBoxClick;
  }

}
//---------------------------------------------------------------------------
void __fastcall TSetRoleFrm::OnCheckBoxClick(TObject *Sender)
{
   TCheckBox* pCheckBox = (TCheckBox*)Sender;
   int lIndex = pCheckBox->Tag;
   if (pCheckBox->Checked)
   {
      if (lIndex != rtNoLimit)
      {
         RoleCheckBoxList[0]->Checked = false;
      }
      switch(lIndex)
      {
       case rtNoLimit:
       {
          for(int i=1;i<5;i++)
          {
            RoleCheckBoxList[i]->Checked = false;
          }
       }break;
       case rtPeriod1:
       {
           RoleCheckBoxList[2]->Checked = false;
       }break;
       case rtPeriod2:
       {
           RoleCheckBoxList[1]->Checked = false;
       }break;
      }
   }
}
//---------------------------------------------------------------------------

void __fastcall TSetRoleFrm::bbtnOKClick(TObject *Sender)
{
   TBaseDataInputFrm::bbtnOKClick(Sender);

   RoleVal = GetSelectedRole();
   if (RoleVal == 0)
   {
      Application->MessageBoxA("门禁规则不能为空!","提示信息",MB_OK + MB_ICONWARNING);
      return;
   }
   Close();
}
//---------------------------------------------------------------------------
char TSetRoleFrm::GetRoleValue()
{
   return RoleVal;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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