Пример #1
0
        private void btnConnecttb4_Click(object sender, EventArgs e)
        {
            if (cbDevicestb4.SelectedIndex < 0)
            {
                return;
            }
            //////////////////////////////////////////////////////DisConnect/////////////////////////////
            ComboboxItem cbitem = (ComboboxItem)cbDevicestb4.SelectedItem;

            ip     = cbitem.Text;
            type   = cbitem.Value.ToString();
            Cursor = Cursors.WaitCursor;
            if (btnConnecttb4.Text == "DisConnect")
            {
                if (iFaceDevice != null)
                {
                    if (iFaceDevice.bIsConnected)
                    {
                        iFaceDevice.iFace_Discoonect();
                        cbDevicestb4.Enabled       = true;
                        cbDevicestb4.SelectedIndex = -1;
                    }
                }
                if (MA500Device != null)
                {
                    if (MA500Device.bIsConnected)
                    {
                        MA500Device.MA500_Disconnect();
                        cbDevicestb4.Enabled       = true;
                        cbDevicestb4.SelectedIndex = -1;
                    }
                }
                btnConnecttb4.Text = "Connect";

                Cursor = Cursors.Default;
                return;
            }
            //////////////////////////////////////////////////////Connect/////////////////////////////

            List <string> Users = new List <string>();

            //lbstatus.Text = cmbdevices.SelectedItem.ToString() + " " + type ;
            if (type == "IFACE")
            {
                iFaceDevice = new iFace(ip, "");
                iFaceDevice.axCZKEM1.OnHIDNum += new zkemkeeper._IZKEMEvents_OnHIDNumEventHandler(axCZKEM1_OnHIDNum);
                Cursor = Cursors.WaitCursor;
                iFaceDevice.iFace_Connect();
                if (iFaceDevice.bIsConnected)
                {
                    btnConnecttb4.Text   = "DisConnect";
                    lblStatustb4.Text    = ip + " Connected ";
                    cbDevicestb4.Enabled = false;
                }
                else
                {
                    cbDevicestb4.Enabled = true;
                    lblStatustb4.Text    = "Connection Faild";
                }
                Cursor = Cursors.Default;
            }
            if (type == "MA500")
            {
                MA500Device          = new MA500(ip, Devices[cbDevicestb4.SelectedIndex + 1][2]);
                cbDevicestb3.Enabled = false;
                Cursor = Cursors.WaitCursor;
                MA500Device.MA500_Connect();
                if (MA500Device.bIsConnected)
                {
                    btnConnecttb4.Text   = "DisConnect";
                    lblStatustb4.Text    = ip + " Connected ";
                    cbDevicestb4.Enabled = false;

                    MA500Device.EnableCradTimer();
                    MA500Device.ReadingCard += MA500Device_ReadingCard;
                }
                else
                {
                    cbDevicestb4.Enabled = true;
                    lblStatustb4.Text    = "Connection Faild";
                }
                //MA500Device.MA500_Disconnect();

                Cursor = Cursors.Default;
            }
        }
Пример #2
0
        private void btConnect_Click(object sender, EventArgs e)
        {
            if (cmbdevices.SelectedIndex < 0)
            {
                return;
            }
            //////////////////////////////////////////////////////DisConnect/////////////////////////////
            ComboboxItem cbitem = (ComboboxItem)cmbdevices.SelectedItem;

            //cbUser.Items.Clear();
            ip     = cbitem.Text;
            type   = cbitem.Value.ToString();
            Cursor = Cursors.WaitCursor;
            if (btConnect.Text == "DisConnect")
            {
                if (iFaceDevice != null)
                {
                    if (iFaceDevice.bIsConnected)
                    {
                        iFaceDevice.iFace_Discoonect();
                        cmbdevices.Enabled = true;
                        lbstatus.Text      = iFaceDevice.IPAdreess + " DisConnected";
                    }
                }
                if (MA500Device != null)
                {
                    if (MA500Device.bIsConnected)
                    {
                        MA500Device.MA500_Disconnect();
                        cmbdevices.Enabled       = true;
                        lbstatus.Text            = MA500Device.IPAdreess + " DisConnected";
                        cmbdevices.SelectedIndex = -1;
                    }
                }
                btConnect.Text = "Connect";
                cbUser.Items.Clear();
                txtCardNumber.Text  = "";
                txtFaceCount.Text   = "";
                txtFingerCount.Text = "";
                Cursor = Cursors.Default;
                return;
            }
            //////////////////////////////////////////////////////Connect/////////////////////////////

            List <string> Users = new List <string>();

            //lbstatus.Text = cmbdevices.SelectedItem.ToString() + " " + type ;
            if (type == "IFACE")
            {
                iFaceDevice = new iFace(ip, "");
                iFaceDevice.axCZKEM1.OnHIDNum += new zkemkeeper._IZKEMEvents_OnHIDNumEventHandler(axCZKEM1_OnHIDNum);
                Cursor = Cursors.WaitCursor;
                cbUser.Items.Clear();
                //cbUser.BeginUpdate();
                iFaceDevice.iFace_Connect();
                if (iFaceDevice.bIsConnected)
                {
                    btConnect.Text     = "DisConnect";
                    lbstatus.Text      = ip + " Connected ";
                    cmbdevices.Enabled = false;
                    Users = iFaceDevice.UserIDs();
                    if (Users.Count <= 0)
                    {
                        lbstatus.Text = "Error Reading Users";
                    }
                    cbUser.Items.Clear();
                    foreach (string user in Users)
                    {
                        cbUser.Items.Add(user);
                    }
                }
                else
                {
                    cmbdevices.Enabled = true;
                    lbstatus.Text      = "Connection Faild";
                }
                cbUser.EndUpdate();
                Cursor = Cursors.Default;
            }
            if (type == "MA500")
            {
                MA500Device        = new MA500(ip, Devices[cmbdevices.SelectedIndex + 1][2]);
                cmbdevices.Enabled = false;
                Cursor             = Cursors.WaitCursor;
                MA500Device.MA500_Connect();
                if (MA500Device.bIsConnected)
                {
                    MA500Device.EnableCradTimer();
                    MA500Device.ReadingCard += MA500Device_ReadingCard;

                    btConnect.Text = "DisConnect";
                    lbstatus.Text  = ip + " Connected ";
                    Users          = MA500Device.MA500_Users();

                    if (Users.Count <= 0)
                    {
                        lbstatus.Text = "Error Reading Users";
                    }
                    cbUser.Items.Clear();
                    cbUser.Items.AddRange(Users.ToArray());
                }
                else
                {
                    cmbdevices.Enabled = true;
                    lbstatus.Text      = "Connection Faild";
                }
                //MA500Device.MA500_Disconnect();
                cbUser.EndUpdate();
                Cursor = Cursors.Default;
            }
        }