private void cmdRead_Click(object sender, EventArgs e)
        {
            Boolean vRet       = true;
            int     vErrorCode = 0;

            lblMessage.Text = "Waiting...";
            Application.DoEvents();

            if (!bpc.EnableDevice(Program.gMachineNumber, 0)) // 0 : false
            {
                lblMessage.Text = util.gstrNoDevice;
                return;
            }

            GCHandle gh = GCHandle.Alloc(dbBellInfoList, GCHandleType.Pinned);
            IntPtr   AddrOfmlngBellInfo = gh.AddrOfPinnedObject();
            int      nAddr = AddrOfmlngBellInfo.ToInt32();

            vRet = bpc.GetBellTime(Program.gMachineNumber, ref mBellCount, ref nAddr);

            if (vRet)
            {
                ShowValue();
                lblMessage.Text = "Success!";
            }
            else
            {
                bpc.GetLastError(ref vErrorCode);
                lblMessage.Text = util.ErrorPrint(vErrorCode);
            }

            gh.Free();
            bpc.EnableDevice(Program.gMachineNumber, 1); // 1 : true
        }
        private void cmdRead_Click(object sender, EventArgs e)
        {
            bool bRet;
            int  vErrorCode = 0;

            lblMessage.Text = "Working...";
            Application.DoEvents();

            bRet = bpc.EnableDevice(Program.gMachineNumber, 0); // 0 : disable

            if (!bRet)
            {
                lblMessage.Text = util.gstrNoDevice;
                return;
            }

            GCHandle gh = GCHandle.Alloc(unlockGroupInfo, GCHandleType.Pinned);
            IntPtr   AddrOfunlockGroupInfo = gh.AddrOfPinnedObject();
            int      nAddr = AddrOfunlockGroupInfo.ToInt32();

            bRet = bpc.GetDeviceLongInfo(Program.gMachineNumber, 7, ref nAddr);

            if (bRet)
            {
                lblMessage.Text = "Success!";
            }
            else
            {
                bpc.GetLastError(ref vErrorCode);
                lblMessage.Text = util.ErrorPrint(vErrorCode);
            }

            bRet = bpc.EnableDevice(Program.gMachineNumber, 1); // 1 : enable
        }
        private void cmdGetSerialNumber_Click(object sender, EventArgs e)
        {
            string  vSerialNumber = "";
            Boolean vRet;
            int     vErrorCode = 0;

            txtSerialNo.Text = "";
            lblMessage.Text  = "Waiting...";
            Application.DoEvents();

            vRet = bpc.EnableDevice(Program.gMachineNumber, 0); // 0 : false
            if (!vRet)
            {
                lblMessage.Text = util.gstrNoDevice;
                return;
            }

            vRet = bpc.GetSerialNumber(Program.gMachineNumber, ref vSerialNumber);
            if (vRet)
            {
                txtSerialNo.Text = vSerialNumber;
                lblMessage.Text  = "Success";
            }
            else
            {
                bpc.GetLastError(ref vErrorCode);
                lblMessage.Text = util.ErrorPrint(vErrorCode);
            }

            bpc.EnableDevice(Program.gMachineNumber, 1); // 1 : true
        }
Beispiel #4
0
        private void cmdGetDoorStatus_Click(object sender, EventArgs e)
        {
            int     vValue     = 0;
            int     vErrorCode = 0;
            Boolean vRet;

            lblMessage.Text = "Working...";
            Application.DoEvents();

            vRet = bpc.EnableDevice(Program.gMachineNumber, 0); // 0 : false
            if (!vRet)
            {
                lblMessage.Text = util.gstrNoDevice;
                return;
            }

            vRet = bpc.GetDoorStatus(Program.gMachineNumber, ref vValue);
            if (vRet)
            {
                if (vValue == 1)
                {
                    lblMessage.Text = "Uncond Door Open State!";
                }
                else if (vValue == 2)
                {
                    lblMessage.Text = "Uncond Door Close State!";
                }
                else if (vValue == 3)
                {
                    lblMessage.Text = "Door Open State!";
                }
                else if (vValue == 4)
                {
                    lblMessage.Text = "Auto Recover State!";
                }
                else if (vValue == 5)
                {
                    lblMessage.Text = "Door Close State!";
                }
                else if (vValue == 6)
                {
                    lblMessage.Text = "Watching for Close!";
                }
                else if (vValue == 7)
                {
                    lblMessage.Text = "Illegal open!";
                }
                else
                {
                    lblMessage.Text = "User State !";
                }
            }
            else
            {
                bpc.GetLastError(ref vErrorCode);
                lblMessage.Text = util.ErrorPrint(vErrorCode);
            }

            bpc.EnableDevice(Program.gMachineNumber, 1); // 1 : true
            Application.DoEvents();
        }
        private void cmdGetEnrollData_Click(object sender, EventArgs e)
        {
            int     vEnrollNumber;
            int     vEMachineNumber;
            int     vFingerNumber;
            int     vPrivilege = 0;
            Boolean vRet;
            int     vErrorCode = 0;
            int     i;

            GCHandle gh;
            IntPtr   AddrOfTemplngEnrollData;

            lblEnrollData.Text = "Enrolled Data";
            lstEnrollData.Items.Clear();
            Label2.Text = "";
            lstEnrollData.Items.Clear();
            lblMessage.Text = "Working...";
            Application.DoEvents();

            vRet = bpc.EnableDevice(Program.gMachineNumber, 0); // 0 : false
            if (!vRet)
            {
                lblMessage.Text = util.gstrNoDevice;
                return;
            }

            vEnrollNumber = Convert.ToInt32(txtEnrollNumber.Text);
            vFingerNumber = Convert.ToInt32(cmbBackupNumber.Text);
            if (vFingerNumber == 10)
            {
                vFingerNumber = 15;
            }
            vEMachineNumber = Convert.ToInt32(cmbEMachineNumber.Text);

            gh = GCHandle.Alloc(gTemplngEnrollData, GCHandleType.Pinned);
            AddrOfTemplngEnrollData = gh.AddrOfPinnedObject();

            glngEnrollPData = 0;
            int nAddr = AddrOfTemplngEnrollData.ToInt32();

            vRet = bpc.GetEnrollData1(Program.gMachineNumber, vEnrollNumber, vFingerNumber, ref vPrivilege, ref nAddr, ref glngEnrollPData);

            gh.Free();


            if (vRet)
            {
                cmbPrivilege.SelectedIndex = vPrivilege;
                lblMessage.Text            = "GetEnrollData OK";
                if (vFingerNumber == 15)
                {
                    txtCardNumber.Text = "";
                    while (glngEnrollPData > 0)
                    {
                        i = glngEnrollPData % 16 - 1 + ascii.GetBytes("0")[0];
                        Byte[] b = new Byte[1];
                        b[0] = (Byte)i;
                        txtCardNumber.Text = txtCardNumber.Text + ascii.GetString(b);
                        glngEnrollPData    = glngEnrollPData / 16;
                    }
                }
                else if (vFingerNumber == 11)
                {
                    txtCardNumber.Text = (Convert.ToString(glngEnrollPData, 16).ToUpper());
                }
                else if (vFingerNumber == 14)
                {
                    txtUserTz1.Text = Convert.ToString(glngEnrollPData / 256);
                    txtUserTz2.Text = Convert.ToString(glngEnrollPData % 256);
                }
                else
                {
                    for (i = 0; i < DATASIZE; i++)
                    {
                        lstEnrollData.Items.Add(Convert.ToString(gTemplngEnrollData[i]));
                    }
                }
            }
            else
            {
                bpc.GetLastError(ref vErrorCode);
                lblMessage.Text = util.ErrorPrint(vErrorCode);
            }

            bpc.EnableDevice(Program.gMachineNumber, 1); // 1 : true
        }
        private void cmdGetDeviceTime_Click(object sender, EventArgs e)
        {
            int     vYear      = 0;
            int     vMonth     = 0;
            int     vDay       = 0;
            int     vHour      = 0;
            int     vMinute    = 0;
            int     vSecond    = 0;
            int     vDayOfWeek = 0;
            string  strDataTime;
            Boolean vRet;
            int     vErrorCode = 0;

            lblMessage.Text = "Working...";
            Application.DoEvents();

            vRet = bpc.EnableDevice(Program.gMachineNumber, 0); // 0 : false
            if (!vRet)
            {
                lblMessage.Text = util.gstrNoDevice;
                return;
            }

            vRet = bpc.GetDeviceTime(Program.gMachineNumber,
                                     ref vYear,
                                     ref vMonth,
                                     ref vDay,
                                     ref vHour,
                                     ref vMinute,
                                     ref vSecond,
                                     ref vDayOfWeek);
            if (vRet)
            {
                if (vDayOfWeek == 0)
                {
                    vDayOfWeek = 7;
                }
                strDataTime     = "Date = " + Convert.ToString(vYear) + "/" + Convert.ToString(vMonth) + "/" + Convert.ToString(vDay) + " , " + GetWeekDay(vDayOfWeek) + " , Time = " + Convert.ToString(vHour) + ":" + Convert.ToString(vMinute) + ":" + Convert.ToString(vSecond);
                lblMessage.Text = strDataTime;
            }
            else
            {
                bpc.GetLastError(ref vErrorCode);
                lblMessage.Text = util.ErrorPrint(vErrorCode);
            }
            bpc.EnableDevice(Program.gMachineNumber, 1); // 1 : true
            Application.DoEvents();
        }