Пример #1
0
        private void btEnroll_Click(object sender, EventArgs e)
        {
            if (cbxFinger.SelectedIndex == 10)
            {
                MessageBox.Show("Select A finger To enroll");
                return;
            }

            if ((!string.IsNullOrEmpty(textBoxFirstName.Text)) && (!string.IsNullOrEmpty(textBoxLastName.Text)))
            {
                _userInEnroll.firstName = textBoxFirstName.Text;
                _userInEnroll.lastName  = textBoxLastName.Text;

                string        strlogin        = _userInEnroll.firstName + "_" + _userInEnroll.lastName;
                List <string> lstInactiveUser = _tcpArmClients[cbArmReader.SelectedIndex]._tcpArmDevice.GetUnregisteredUsers();
                if (lstInactiveUser.Contains(strlogin))
                {
                    _tcpArmClients[cbArmReader.SelectedIndex]._tcpArmDevice.UpdatePermission(strlogin, UserGrant.UG_MASTER_AND_SLAVE);
                }
                DeviceGrant ExistingUser = _tcpArmClients[cbArmReader.SelectedIndex]._tcpArmDevice.GetUserByName(strlogin);


                List <object> arguments = new List <object>();
                arguments.Add(cbArmReader.SelectedIndex);
                arguments.Add(strlogin);
                arguments.Add(cbxFinger.SelectedIndex);


                if (ExistingUser != null)
                {
                    backgroundWorkerEnroll.RunWorkerAsync(arguments);
                }
                else
                {
                    DeviceGrant dg = new DeviceGrant();
                    dg.user      = new UserClassTemplate();
                    dg.user      = _userInEnroll;
                    dg.userGrant = UserGrant.UG_MASTER_AND_SLAVE;
                    if (_tcpArmClients[cbArmReader.SelectedIndex]._tcpArmDevice.AddUser(dg))
                    {
                        backgroundWorkerEnroll.RunWorkerAsync(arguments);
                    }
                    else
                    {
                        updateStatus("Unable to create user");
                    }
                }
            }
            else
            {
                MessageBox.Show(ResStrings.str_Please_enter_FirstName_and_LastName_field_before_enroll, ResStrings.strInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #2
0
        private void backgroundWorkerEnroll_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            string      strlogin     = _userInEnroll.firstName + "_" + _userInEnroll.lastName;
            DeviceGrant ExistingUser = _tcpArmClients[cbArmReader.SelectedIndex]._tcpArmDevice.GetUserByName(strlogin);

            if (ExistingUser != null)
            {
                if (_db.StoreUser(ExistingUser.user))
                {
                    StoreGrant();
                    _bSaved = true;
                    Reset();
                    MessageBox.Show(ResStrings.str_DATA_SAVED, ResStrings.strInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                UpdateGridFinger();
                UpdateListBoxUser();
            }
        }