Esempio n. 1
0
        private void btnGet_Click(object sender, EventArgs e)
        {
            uint dwCommand = 0;

            string[] strCommand            = { "NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50", "NET_DVR_GET_VERIFY_WEEK_PLAN", "NET_DVR_GET_WEEK_PLAN_CFG" };
            int      weekPlanNumberWPIndex = 0;

            uint   dwReturned = 0;
            string strTemp    = null;
            uint   dwSize     = (uint)Marshal.SizeOf(m_struPlanCfg);

            m_struPlanCfg.dwSize = dwSize;
            IntPtr ptrPlanCfg = Marshal.AllocHGlobal((int)dwSize);

            Marshal.StructureToPtr(m_struPlanCfg, ptrPlanCfg, false);
            switch (cbDeviceType.SelectedIndex)
            {
            case 0:
                dwCommand = (uint)CHCNetSDK.NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50;
                uint dwConSize = (uint)Marshal.SizeOf(m_struPlanCond);
                m_struPlanCond.dwSize = dwConSize;
                uint.TryParse(textBoxWPNumber.Text, out m_struPlanCond.dwWeekPlanNumber);
                ushort.TryParse(textBoxLCID.Text, out m_struPlanCond.wLocalControllerID);

                IntPtr ptrPlanCon = Marshal.AllocHGlobal((int)dwConSize);
                Marshal.StructureToPtr(m_struPlanCond, ptrPlanCon, false);
                IntPtr ptrDwReturned = Marshal.AllocHGlobal(4);

                if (!CHCNetSDK.NET_DVR_GetDeviceConfig(m_lUserID, dwCommand, 1, ptrPlanCon, dwConSize, ptrDwReturned, ptrPlanCfg, dwSize))
                {
                    Marshal.FreeHGlobal(ptrPlanCfg);
                    Marshal.FreeHGlobal(ptrPlanCon);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[cbDeviceType.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    dwReturned = (uint)Marshal.ReadInt32(ptrDwReturned);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    Marshal.FreeHGlobal(ptrPlanCon);
                    strTemp = string.Format("{0} Succ", strCommand[cbDeviceType.SelectedIndex]);
                    MessageBox.Show(strTemp);
                }
                break;

            case 1:
                dwCommand = (uint)CHCNetSDK.NET_DVR_GET_VERIFY_WEEK_PLAN;
                int.TryParse(textBoxWPNumber.Text, out weekPlanNumberWPIndex);

                if (!CHCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, dwCommand, weekPlanNumberWPIndex, ptrPlanCfg, dwSize, ref dwReturned))
                {
                    Marshal.FreeHGlobal(ptrPlanCfg);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[cbDeviceType.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    strTemp = string.Format("{0} Succ", strCommand[cbDeviceType.SelectedIndex]);
                    MessageBox.Show(strTemp);
                }
                break;

            case 2:
                dwCommand = (uint)CHCNetSDK.NET_DVR_GET_WEEK_PLAN_CFG;
                int.TryParse(textBoxWPNumber.Text, out weekPlanNumberWPIndex);

                if (!CHCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, dwCommand, weekPlanNumberWPIndex, ptrPlanCfg, dwSize, ref dwReturned))
                {
                    Marshal.FreeHGlobal(ptrPlanCfg);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[cbDeviceType.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    strTemp = string.Format("{0} Succ", strCommand[cbDeviceType.SelectedIndex]);
                    MessageBox.Show(strTemp);
                }
                break;

            default:
                Marshal.FreeHGlobal(ptrPlanCfg);
                MessageBox.Show("unknown command");
                return;
            }
            m_struPlanCfg        = (CHCNetSDK.NET_DVR_WEEK_PLAN_CFG)Marshal.PtrToStructure(ptrPlanCfg, typeof(CHCNetSDK.NET_DVR_WEEK_PLAN_CFG));
            cbDate.SelectedIndex = 0;
            UpdateList();

            if (1 == m_struPlanCfg.byEnable)
            {
                checkBoxEnableWP.Checked = true;
            }
            else
            {
                checkBoxEnableWP.Checked = false;
            }

            Marshal.FreeHGlobal(ptrPlanCfg);
        }
Esempio n. 2
0
        private void buttonGetTemplate_Click(object sender, EventArgs e)
        {
            uint dwCommand = 0;

            string[] strCommand = { "NET_DVR_GET_DOOR_STATUS_PLAN_TEMPLATE", "NET_DVR_GET_VERIFY_PLAN_TEMPLATE", "NET_DVR_GET_CARD_RIGHT_PLAN_TEMPLATE_V50" };

            uint   dwReturned = 0;
            string strTemp    = null;
            uint   dwSize     = (uint)Marshal.SizeOf(m_struTemplateCfg);
            IntPtr ptrPlanCfg = Marshal.AllocHGlobal((int)dwSize);

            Marshal.StructureToPtr(m_struTemplateCfg, ptrPlanCfg, false);

            switch (comboBoxDeviceTypeHG.SelectedIndex)
            {
            case 0:
            case 1:
                if (comboBoxDeviceTypeHG.SelectedIndex == 0)
                {
                    dwCommand = (uint)CHCNetSDK.NET_DVR_GET_DOOR_STATUS_PLAN_TEMPLATE;
                }
                else
                {
                    dwCommand = (uint)CHCNetSDK.NET_DVR_GET_VERIFY_PLAN_TEMPLATE;
                }

                int templateNumberIndex;
                int.TryParse(textBoxTemplateNumber.Text, out templateNumberIndex);

                if (!CHCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, dwCommand, templateNumberIndex, ptrPlanCfg, dwSize, ref dwReturned))
                {
                    Marshal.FreeHGlobal(ptrPlanCfg);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[comboBoxDeviceTypeHG.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    strTemp = string.Format("{0}", strCommand[comboBoxDeviceTypeHG.SelectedIndex]);
                    g_formList.AddLog(m_lUserID, AcsDemoPublic.OPERATION_SUCC_T, strTemp);
                }
                break;

            case 2:
                dwCommand = (uint)CHCNetSDK.NET_DVR_GET_CARD_RIGHT_PLAN_TEMPLATE_V50;
                uint dwConSize = (uint)Marshal.SizeOf(m_struTemplateCond);
                m_struTemplateCond.dwSize = dwConSize;

                // limited input data guarantee parse success
                uint.TryParse(textBoxTemplateNumber.Text, out m_struTemplateCond.dwPlanTemplateNumber);
                ushort.TryParse(textBoxLocalControllerID.Text, out m_struTemplateCond.wLocalControllerID);

                IntPtr ptrPlanCon = Marshal.AllocHGlobal((int)dwConSize);
                Marshal.StructureToPtr(m_struTemplateCond, ptrPlanCon, false);
                IntPtr ptrDwReturned = Marshal.AllocHGlobal(4);

                if (!CHCNetSDK.NET_DVR_GetDeviceConfig(m_lUserID, dwCommand, 1, ptrPlanCon, dwConSize, ptrDwReturned, ptrPlanCfg, dwSize))
                {
                    Marshal.FreeHGlobal(ptrPlanCfg);
                    Marshal.FreeHGlobal(ptrPlanCon);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[comboBoxDeviceTypeHG.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    dwReturned = (uint)Marshal.ReadInt32(ptrDwReturned);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    Marshal.FreeHGlobal(ptrPlanCon);
                    strTemp = string.Format("{0}", strCommand[comboBoxDeviceTypeHG.SelectedIndex]);
                    g_formList.AddLog(m_lUserID, AcsDemoPublic.OPERATION_SUCC_T, strTemp);
                }

                break;

            default:
                Marshal.FreeHGlobal(ptrPlanCfg);
                MessageBox.Show("unknown command");
                return;
            }

            m_struTemplateCfg = (CHCNetSDK.NET_DVR_PLAN_TEMPLATE)Marshal.PtrToStructure(ptrPlanCfg, typeof(CHCNetSDK.NET_DVR_PLAN_TEMPLATE));

            if (1 == m_struTemplateCfg.byEnable)
            {
                checkBoxEnableHG.Checked = true;
            }
            else
            {
                checkBoxEnableHG.Checked = false;
            }

            if (m_iEncodeType == 6)
            {
                textBoxTemplateName.Text = System.Text.Encoding.UTF8.GetString(m_struTemplateCfg.byTemplateName);
            }
            else
            {
                Encoding ec = System.Text.Encoding.GetEncoding("gb2312");
                textBoxTemplateName.Text = ec.GetString(m_struTemplateCfg.byTemplateName);
            }

            textBoxWeekPlanNo.Text = m_struTemplateCfg.dwWeekPlanNo.ToString();
            UpdateLstGroupNoP();

            Marshal.FreeHGlobal(ptrPlanCfg);
        }
Esempio n. 3
0
        private void buttonGet_Click(object sender, EventArgs e)
        {
            uint dwCommand = 0;

            string[] strCommand = { "NET_DVR_GET_DOOR_STATUS_HOLIDAY_PLAN", "NET_DVR_GET_VERIFY_HOLIDAY_PLAN", "NET_DVR_GET_CARD_RIGHT_HOLIDAY_PLAN_V50" };

            uint   dwReturned = 0;
            string strTemp    = null;
            uint   dwSize     = (uint)Marshal.SizeOf(m_struPlanCfgH);

            m_struPlanCfgH.dwSize = dwSize;
            IntPtr ptrPlanCfgH = Marshal.AllocHGlobal((int)dwSize);

            Marshal.StructureToPtr(m_struPlanCfgH, ptrPlanCfgH, false);

            switch (comboBoxDeviceType.SelectedIndex)
            {
            case 0:
            case 1:
                if (comboBoxDeviceType.SelectedIndex == 0)
                {
                    dwCommand = (uint)CHCNetSDK.NET_DVR_GET_DOOR_STATUS_HOLIDAY_PLAN;
                }
                else
                {
                    dwCommand = (uint)CHCNetSDK.NET_DVR_GET_VERIFY_HOLIDAY_PLAN;
                }

                int holidayPlanNumberIndex;
                int.TryParse(textBoxHolidayPlanNumber.Text, out holidayPlanNumberIndex);

                if (!CHCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, dwCommand, holidayPlanNumberIndex, ptrPlanCfgH, dwSize, ref dwReturned))
                {
                    Marshal.FreeHGlobal(ptrPlanCfgH);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[comboBoxDeviceType.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    strTemp = string.Format("{0}", strCommand[comboBoxDeviceType.SelectedIndex]);
                    g_formList.AddLog(m_lUserID, AcsDemoPublic.OPERATION_SUCC_T, strTemp);
                }

                break;

            case 2:
                dwCommand = (uint)CHCNetSDK.NET_DVR_GET_CARD_RIGHT_HOLIDAY_PLAN_V50;
                uint dwConSize = (uint)Marshal.SizeOf(m_struPlanCond);
                m_struPlanCond.dwSize = dwConSize;
                IntPtr ptrPlanCon = Marshal.AllocHGlobal((int)dwConSize);
                Marshal.StructureToPtr(m_struPlanCond, ptrPlanCon, false);
                IntPtr ptrDwReturned = Marshal.AllocHGlobal(4);

                // limited input data guarantee parse success
                uint.TryParse(textBoxHolidayPlanNumber.Text, out m_struPlanCond.dwHolidayPlanNumber);
                ushort.TryParse(textBoxLocalControllerID.Text, out m_struPlanCond.wLocalControllerID);


                if (!CHCNetSDK.NET_DVR_GetDeviceConfig(m_lUserID, dwCommand, 1, ptrPlanCon, dwConSize, ptrDwReturned, ptrPlanCfgH, dwSize))
                {
                    Marshal.FreeHGlobal(ptrPlanCfgH);
                    Marshal.FreeHGlobal(ptrPlanCon);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[comboBoxDeviceType.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    dwReturned = (uint)Marshal.ReadInt32(ptrDwReturned);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    Marshal.FreeHGlobal(ptrPlanCon);
                    strTemp = string.Format("{0}", strCommand[comboBoxDeviceType.SelectedIndex]);
                    g_formList.AddLog(m_lUserID, AcsDemoPublic.OPERATION_SUCC_T, strTemp);
                }

                break;

            default:
                Marshal.FreeHGlobal(ptrPlanCfgH);
                MessageBox.Show("unknown command");
                return;
            }

            m_struPlanCfgH = (CHCNetSDK.NET_DVR_HOLIDAY_PLAN_CFG)Marshal.PtrToStructure(ptrPlanCfgH, typeof(CHCNetSDK.NET_DVR_HOLIDAY_PLAN_CFG));

            UpdateList();

            if (1 == m_struPlanCfgH.byEnable)
            {
                checkBoxEnablePlan.Checked = true;
            }
            else
            {
                checkBoxEnablePlan.Checked = false;
            }

            if (!AcsDemoPublic.CheckState(m_struPlanCfgH.struBeginDate) || !AcsDemoPublic.CheckState(m_struPlanCfgH.struEndDate))
            {
                Marshal.FreeHGlobal(ptrPlanCfgH);
                return;
            }

            // set the date
            dateTimePickerStartDateHP.Value = new System.DateTime(m_struPlanCfgH.struBeginDate.wYear, m_struPlanCfgH.struBeginDate.byMonth, m_struPlanCfgH.struBeginDate.byDay);
            dateTimePickerEndDateHP.Value   = new System.DateTime(m_struPlanCfgH.struEndDate.wYear, m_struPlanCfgH.struEndDate.byMonth, m_struPlanCfgH.struEndDate.byDay);

            Marshal.FreeHGlobal(ptrPlanCfgH);
        }
Esempio n. 4
0
        private void buttonGet_Click(object sender, EventArgs e)
        {
            uint dwSize = (uint)Marshal.SizeOf(m_struEventCardLinkageCond);

            m_struEventCardLinkageCond.dwSize = dwSize;
            uint.TryParse(textBoxEventNo.Text, out m_struEventCardLinkageCond.dwEventID);
            ushort.TryParse(textBoxLocalConID.Text, out m_struEventCardLinkageCond.wLocalControllerID);

            IntPtr ptrStruCond = Marshal.AllocHGlobal((int)dwSize);

            Marshal.StructureToPtr(m_struEventCardLinkageCond, ptrStruCond, false);
            IntPtr ptrDwReturned = Marshal.AllocHGlobal(4);

            uint dwSizeCfg = (uint)Marshal.SizeOf(m_struEventCardLinkageCfgV50);

            m_struEventCardLinkageCfgV50.dwSize = dwSizeCfg;
            IntPtr ptrStruCfg = Marshal.AllocHGlobal((int)dwSize);

            Marshal.StructureToPtr(m_struEventCardLinkageCfgV50, ptrStruCfg, false);

            if (!CHCNetSDK.NET_DVR_GetDeviceConfig(m_lUserID, CHCNetSDK.NET_DVR_GET_EVENT_CARD_LINKAGE_CFG_V50, 1, ptrStruCond, dwSize, ptrDwReturned, ptrStruCfg, dwSizeCfg))
            {
                g_formList.AddLog(m_iDeviceIndex, AcsDemoPublic.OPERATION_FAIL_T, "NET_DVR_GET_EVENT_CARD_LINKAGE_CFG_V50 Failed");
                MessageBox.Show("Get event card linkage cfg failed");
            }
            else
            {
                uint dwStatus = (uint)Marshal.ReadInt32(ptrDwReturned);
                if (dwStatus != CHCNetSDK.NET_DVR_NOERROR)
                {
                    string strTemp = null;
                    strTemp = string.Format("NET_DVR_GET_EVENT_CARD_LINKAGE_CFG_V50 Error Status{0}", dwStatus);
                    MessageBox.Show(strTemp);
                    Marshal.FreeHGlobal(ptrStruCond);
                    Marshal.FreeHGlobal(ptrStruCfg);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    return;
                }

                //get data from unmanaged memory
                m_struEventCardLinkageCfgV50 = (CHCNetSDK.NET_DVR_EVENT_CARD_LINKAGE_CFG_V50)Marshal.PtrToStructure(ptrStruCfg, typeof(CHCNetSDK.NET_DVR_EVENT_CARD_LINKAGE_CFG_V50));

                g_formList.AddLog(m_iDeviceIndex, AcsDemoPublic.OPERATION_SUCC_T, "NET_DVR_GET_EVENT_CARD_LINKAGE_CFG_V50 SUCC");
                if (m_struEventCardLinkageCfgV50.byProMode == 1)
                {
                    m_byProMode = true;
                    checkBoxCardNoLinkage.Checked = true;
                }
                if (m_struEventCardLinkageCfgV50.byProMode == 2)
                {
                    m_byMacAddr = true;
                    checkBoxMacAddressLinkage.Checked = true;
                }
                textBoxEventSourceID.Text        = m_struEventCardLinkageCfgV50.dwEventSourceID.ToString();
                checkBoxBuzzer.Checked           = (m_struEventCardLinkageCfgV50.byMainDevBuzzer == 1) ? true : false;
                checkBoxSnapshortLinkage.Checked = (m_struEventCardLinkageCfgV50.byCapturePic == 1) ? true : false;
                checkBoxRecordLinkage.Checked    = (m_struEventCardLinkageCfgV50.byRecordVideo == 1) ? true : false;

                if (m_byProMode)
                {
                    textBoxCardNo.Text = string.Format("{0}", m_struEventCardLinkageCfgV50.uLinkageInfo.byCardNo);
                }
                if (m_byMacAddr)
                {
                    textBoxMacAddress.Text = string.Format("{0:x2}:{0:x2}:{0:x2}:{0:x2}:{0:x2}:{0:x2}", m_struEventCardLinkageCfgV50.uLinkageInfo.byMACAddr[0], m_struEventCardLinkageCfgV50.uLinkageInfo.byMACAddr[1],
                                                           m_struEventCardLinkageCfgV50.uLinkageInfo.byMACAddr[2], m_struEventCardLinkageCfgV50.uLinkageInfo.byMACAddr[3], m_struEventCardLinkageCfgV50.uLinkageInfo.byMACAddr[4],
                                                           m_struEventCardLinkageCfgV50.uLinkageInfo.byMACAddr[5]);
                }
                if (m_byProMode == false && m_byMacAddr == false)
                {
                    comboBoxMajorEventType.SelectedIndex = m_struEventCardLinkageCfgV50.uLinkageInfo.struEventLinkage.wMainEventType;

                    int dwMainEventType = comboBoxMajorEventType.SelectedIndex;
                    if (dwMainEventType == 0)
                    {
                        SubEventTypeDev();
                    }
                    else if (dwMainEventType == 1)
                    {
                        SubEventTypeAlarm();
                    }
                    else if (dwMainEventType == 2)
                    {
                        SubEventTypeDoor();
                    }
                    else if (dwMainEventType == 3)
                    {
                        SubEventTypeCardReader();
                    }

                    comboBoxMinorEventType.SelectedIndex = m_struEventCardLinkageCfgV50.uLinkageInfo.struEventLinkage.wSubEventType;
                }
                CreateChecklistBox();
            }

            Marshal.FreeHGlobal(ptrStruCond);
            Marshal.FreeHGlobal(ptrStruCfg);
            Marshal.FreeHGlobal(ptrDwReturned);
        }
Esempio n. 5
0
        private void buttonGet_Click(object sender, EventArgs e)
        {
            if ("" == textBoxCardNumber.Text)
            {
                MessageBox.Show("Please input the card number!");
                return;
            }
            byte[] byTempCardNo = System.Text.Encoding.UTF8.GetBytes(textBoxCardNumber.Text);
            for (int i = 0; i < byTempCardNo.Length; i++)
            {
                if (i > m_struCond.byCardNo.Length)
                {
                    MessageBox.Show("card number length too long!");
                    return;
                }
                m_struCond.byCardNo[i] = byTempCardNo[i];
            }

            m_struCond.dwSize = (uint)Marshal.SizeOf(m_struCond);
            uint   dwSizeCard  = (uint)Marshal.SizeOf(m_struCond);
            IntPtr ptrStruCard = Marshal.AllocHGlobal((int)dwSizeCard);

            Marshal.StructureToPtr(m_struCond, ptrStruCard, false);

            uint   dwStatus    = 0;
            IntPtr ptrdwStatus = Marshal.AllocHGlobal(Marshal.SizeOf(dwStatus));

            Marshal.WriteInt32(ptrdwStatus, (int)dwStatus);

            uint   dwSizeUse   = (uint)Marshal.SizeOf(m_struUserInfo);
            IntPtr ptrStruUser = Marshal.AllocHGlobal((int)dwSizeUse);

            Marshal.StructureToPtr(m_struUserInfo, ptrStruUser, false);

            if (!CHCNetSDK.NET_DVR_GetDeviceConfig(m_lUserID, CHCNetSDK.NET_DVR_GET_CARD_USERINFO_CFG,
                                                   1, ptrStruCard, dwSizeCard, ptrdwStatus, ptrStruUser, dwSizeUse))
            {
                Marshal.FreeHGlobal(ptrStruCard);
                Marshal.FreeHGlobal(ptrStruUser);
                string strTemp = null;
                strTemp = string.Format("NET_DVR_GET_CARD_USERINFO_CFG FAIL ERROR CODE {0}", CHCNetSDK.NET_DVR_GetLastError());
                MessageBox.Show(strTemp);
                return;
            }
            else
            {
                dwStatus = (uint)Marshal.ReadInt32(ptrdwStatus);
                if (dwStatus != CHCNetSDK.NET_DVR_NOERROR)
                {
                    string strTemp = null;
                    strTemp = string.Format("NET_DVR_GET_CARD_USERINFO_CFG Error Status{0}", dwStatus);
                    MessageBox.Show(strTemp);
                    Marshal.FreeHGlobal(ptrStruCard);
                    Marshal.FreeHGlobal(ptrStruUser);
                    return;
                }
                m_struUserInfo         = (CHCNetSDK.NET_DVR_CARD_USER_INFO_CFG)Marshal.PtrToStructure(ptrStruUser, typeof(CHCNetSDK.NET_DVR_CARD_USER_INFO_CFG));
                textBoxUserName.Text   = System.Text.Encoding.UTF8.GetString(m_struUserInfo.byUsername);
                textBoxUserNumber.Text = m_struUserInfo.byRes2[0].ToString();
                Marshal.FreeHGlobal(ptrStruCard);
                Marshal.FreeHGlobal(ptrStruUser);
            }
        }
Esempio n. 6
0
        private void btnGetTemplate_Click(object sender, EventArgs e)
        {
            uint dwCommand = 0;

            string[] strCommand = { "NET_DVR_GET_CARD_RIGHT_HOLIDAY_GROUP_V50", "NET_DVR_GET_VERIFY_HOLIDAY_GROUP", "NET_DVR_GET_DOOR_STATUS_HOLIDAY_GROUP" };

            uint   dwReturned = 0;
            string strTemp    = null;
            uint   dwSize     = (uint)Marshal.SizeOf(m_struGroupCfg);
            IntPtr ptrPlanCfg = Marshal.AllocHGlobal((int)dwSize);

            Marshal.StructureToPtr(m_struGroupCfg, ptrPlanCfg, false);

            switch (cbDeviceType.SelectedIndex)
            {
            case 1:
            case 2:
                if (cbDeviceType.SelectedIndex == 2)
                {
                    dwCommand = (uint)CHCNetSDK.NET_DVR_GET_DOOR_STATUS_HOLIDAY_GROUP;
                }
                else
                {
                    dwCommand = (uint)CHCNetSDK.NET_DVR_GET_VERIFY_HOLIDAY_GROUP;
                }

                int holidayGroupNumberHGIndex;
                int.TryParse(textBoxHGNumber.Text, out holidayGroupNumberHGIndex);

                if (!CHCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, dwCommand, holidayGroupNumberHGIndex, ptrPlanCfg, dwSize, ref dwReturned))
                {
                    Marshal.FreeHGlobal(ptrPlanCfg);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[cbDeviceType.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    strTemp = string.Format("{0} Succ", strCommand[cbDeviceType.SelectedIndex]);
                    MessageBox.Show(strTemp);
                }
                break;

            case 0:
                dwCommand = (uint)CHCNetSDK.NET_DVR_GET_CARD_RIGHT_HOLIDAY_GROUP_V50;
                uint dwConSize = (uint)Marshal.SizeOf(m_struGroupCond);
                m_struGroupCond.dwSize = dwConSize;
                // limited input data guarantee parse success
                uint.TryParse(textBoxHGNumber.Text, out m_struGroupCond.dwHolidayGroupNumber);
                ushort.TryParse(textBoxLocalControllerID.Text, out m_struGroupCond.wLocalControllerID);

                IntPtr ptrPlanCon = Marshal.AllocHGlobal((int)dwConSize);
                Marshal.StructureToPtr(m_struGroupCond, ptrPlanCon, false);
                IntPtr ptrDwReturned = Marshal.AllocHGlobal(4);

                if (!CHCNetSDK.NET_DVR_GetDeviceConfig(m_lUserID, dwCommand, 1, ptrPlanCon, dwConSize, ptrDwReturned, ptrPlanCfg, dwSize))
                {
                    Marshal.FreeHGlobal(ptrPlanCfg);
                    Marshal.FreeHGlobal(ptrPlanCon);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[cbDeviceType.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    dwReturned = (uint)Marshal.ReadInt32(ptrDwReturned);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    Marshal.FreeHGlobal(ptrPlanCon);
                    strTemp = string.Format("{0} Succ", strCommand[cbDeviceType.SelectedIndex]);
                    MessageBox.Show(strTemp);
                }

                break;

            default:
                Marshal.FreeHGlobal(ptrPlanCfg);
                MessageBox.Show("unknown command");
                return;
            }

            m_struGroupCfg = (CHCNetSDK.NET_DVR_HOLIDAY_GROUP_CFG)Marshal.PtrToStructure(ptrPlanCfg, typeof(CHCNetSDK.NET_DVR_HOLIDAY_GROUP_CFG));

            if (1 == m_struGroupCfg.byEnable)
            {
                checkBoxEnableHG.Checked = true;
            }
            else
            {
                checkBoxEnableHG.Checked = false;
            }

            Encoding ec = System.Text.Encoding.GetEncoding("gb2312");

            //textBoxHolidayGroupNameHG.Text
            //var byteToString4 = System.Text.Encoding.ASCII.GetString(m_struGroupCfg.byGroupName);
            textBoxHGName.Text = ec.GetString(m_struGroupCfg.byGroupName);
            // Console.WriteLine(byteToString4);

            UpdateListGroupNo();

            Marshal.FreeHGlobal(ptrPlanCfg);
        }