示例#1
0
        private void Login()
        {
            string password = txtPassword.Text;

            if (IsMasterPassword(password))
            {
                _isMaster = true;
                this.Close();
            }
            else
            {
                try
                {
                    IDataController dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

                    int employeeNumber = Convert.ToInt32(txtEmployeeNumber.Text);
                    _user = dtCtrl.GetFaceIDUser(employeeNumber);

                    if (_user == null)
                    {
                        MessageBox.Show("User not found.");
                    }
                    else
                    {
                        if (_user.Password != password)
                        {
                            MessageBox.Show("Incorrect password.");
                        }
                        else
                        {
                            _userLoginCaller.SetUserAccess(_user);
                            this.Close();
                        }
                    }
                }
                catch (FormatException)
                {
                    MessageBox.Show("Invalid Employee Number.");
                }
                catch (OleDbException)
                {
                    MessageBox.Show("Cannot connect to Database.");
                    Environment.Exit(0);
                }
                catch(Exception ex)
                {
                    Util.ShowErrorMessage(ex);
                }
            }
        }
示例#2
0
 public void SetUserAccess(FaceIDUser user)
 {
     if (user != null) //not master
     {
         btnAttendance.Enabled = user.AttendanceManagementAccess;
         btnCompany.Enabled = user.CompanyDepartmentManagementAccess;
         btnDepartment.Enabled = user.CompanyDepartmentManagementAccess;
         btnEmployee.Enabled = user.EmployeeManagementAccess;
         btnReprocess.Enabled = user.AttendanceManagementAccess;
         btnTerminal.Enabled = user.TerminalManagementAccess;
         btnUser.Enabled = user.UserManagementAccess;
         btnWorkingCalendar.Enabled = user.WorkingCalendarManagementAccess;
     }
 }
示例#3
0
        private void AddUpdateUser()
        {
            try
            {
                if (ValidatePassword() == false)
                {
                    return;
                }

                FaceIDUser fUser = new FaceIDUser();
                GetUserProperies(ref fUser);

                if (_update == false) //add
                {
                    if (_dtCtrl.IsFaceIDUser(fUser.EmployeeNumber))
                    {
                        throw new Exception("This employee has already been added as an user.");
                    }

                    if (_dtCtrl.AddFaceIDUser(fUser) > 0)
                    {
                        MessageBox.Show("User added.");
                        SetState(-1);
                    }
                }
                else
                {
                    if (_dtCtrl.UpdateFaceIDUser(fUser))
                    {
                        MessageBox.Show("User updated.");
                        SetState(-1);
                    }
                }
            }
            catch (Exception ex)
            {
                Util.ShowErrorMessage(ex);
                return;
            }

            BindUser();
        }
        public int AddFaceIDUser(FaceIDUser faceIDUser)
        {
            OleDbCommand odCom1 = BuildInsertCmd("FaceIDUser",
                new string[] { "Password"
                ,"UserManagementAccess"
                ,"TerminalManagementAccess"
                ,"CompanyDepartmentManagementAccess"
                ,"WorkingCalendarManagementAccess"
                ,"EmployeeManagementAccess"
                ,"AttendanceManagementAccess"
                ,"EmployeeNumber"
                },
                new object[] { faceIDUser.Password
                ,faceIDUser.UserManagementAccess
                ,faceIDUser.TerminalManagementAccess
                ,faceIDUser.CompanyDepartmentManagementAccess
                ,faceIDUser.WorkingCalendarManagementAccess
                ,faceIDUser.EmployeeManagementAccess
                ,faceIDUser.AttendanceManagementAccess
                ,faceIDUser.EmployeeNumber
                }
            );

            if (odCom1.ExecuteNonQuery() == 1)
            {
                return faceIDUser.EmployeeNumber;
            }
            return -1;
        }
        public bool UpdateFaceIDUser(FaceIDUser faceIDUser)
        {
            OleDbCommand odCom1 = BuildUpdateCmd("FaceIDUser",
                new string[] { "Password"
                ,"UserManagementAccess"
                ,"TerminalManagementAccess"
                ,"CompanyDepartmentManagementAccess"
                ,"WorkingCalendarManagementAccess"
                ,"EmployeeManagementAccess"
                ,"AttendanceManagementAccess"
                },
                new object[] { faceIDUser.Password
                ,faceIDUser.UserManagementAccess
                ,faceIDUser.TerminalManagementAccess
                ,faceIDUser.CompanyDepartmentManagementAccess
                ,faceIDUser.WorkingCalendarManagementAccess
                ,faceIDUser.EmployeeManagementAccess
                ,faceIDUser.AttendanceManagementAccess
                },
                "EmployeeNumber=@ID", new object[] { "@ID", faceIDUser.EmployeeNumber }
            );

            return odCom1.ExecuteNonQuery() > 0 ? true : false;
        }
        public List<FaceIDUser> GetFaceIDUserList()
        {
            OleDbCommand odCom = BuildSelectCmd("FaceIDUser", "*", null);
            OleDbDataReader odRdr = odCom.ExecuteReader();
            List<FaceIDUser> faceIDUserList = new List<FaceIDUser>();
            FaceIDUser faceIDUser = null;
            while (odRdr.Read())
            {
                faceIDUser = new FaceIDUser();

                faceIDUser.EmployeeNumber = Convert.ToInt32(odRdr["EmployeeNumber"]);
                faceIDUser.Password = odRdr["Password"].ToString();
                faceIDUser.UserManagementAccess = Convert.ToBoolean(odRdr["UserManagementAccess"]);
                faceIDUser.TerminalManagementAccess = Convert.ToBoolean(odRdr["TerminalManagementAccess"]);
                faceIDUser.CompanyDepartmentManagementAccess = Convert.ToBoolean(odRdr["CompanyDepartmentManagementAccess"]);
                faceIDUser.WorkingCalendarManagementAccess = Convert.ToBoolean(odRdr["WorkingCalendarManagementAccess"]);
                faceIDUser.EmployeeManagementAccess = Convert.ToBoolean(odRdr["EmployeeManagementAccess"]);
                faceIDUser.AttendanceManagementAccess = Convert.ToBoolean(odRdr["AttendanceManagementAccess"]);

                faceIDUserList.Add(faceIDUser);
            }

            odRdr.Close();
            return faceIDUserList;
        }
        public FaceIDUser GetFaceIDUser(int id)
        {
            OleDbCommand odCom = BuildSelectCmd("FaceIDUser", "*", "EmployeeNumber=@ID", new object[] { "@ID", id });
            OleDbDataReader odRdr = odCom.ExecuteReader();

            FaceIDUser faceIDUser = null;
            if (odRdr.Read())
            {
                faceIDUser = new FaceIDUser();

                faceIDUser.EmployeeNumber = Convert.ToInt32(odRdr["EmployeeNumber"]);
                faceIDUser.Password = odRdr["Password"].ToString();
                faceIDUser.UserManagementAccess = Convert.ToBoolean(odRdr["UserManagementAccess"]);
                faceIDUser.TerminalManagementAccess = Convert.ToBoolean(odRdr["TerminalManagementAccess"]);
                faceIDUser.CompanyDepartmentManagementAccess = Convert.ToBoolean(odRdr["CompanyDepartmentManagementAccess"]);
                faceIDUser.WorkingCalendarManagementAccess = Convert.ToBoolean(odRdr["WorkingCalendarManagementAccess"]);
                faceIDUser.EmployeeManagementAccess = Convert.ToBoolean(odRdr["EmployeeManagementAccess"]);
                faceIDUser.AttendanceManagementAccess = Convert.ToBoolean(odRdr["AttendanceManagementAccess"]);
            }

            odRdr.Close();
            return faceIDUser;
        }
示例#8
0
        private void GetUserProperies(ref FaceIDUser fUser)
        {
            fUser.EmployeeNumber = (int)cbxEmployeeNumber.SelectedValue;

            fUser.Password = txtPassword.Text;

            fUser.AttendanceManagementAccess = chbAttendanceManagement.Checked;
            fUser.CompanyDepartmentManagementAccess = chbCompanyDepartmentManagement.Checked;
            fUser.EmployeeManagementAccess = chbEmployeeManagement.Checked;
            fUser.TerminalManagementAccess = chbTerminalManagement.Checked;
            fUser.UserManagementAccess = chbUserManagement.Checked;
            fUser.WorkingCalendarManagementAccess = chbWorkingCalendarManagement.Checked;
        }
示例#9
0
        private string GetAccessStr(FaceIDUser user)
        {
            string accessStr = "";

            if (user.AttendanceManagementAccess)
                accessStr += "Attendance" + "\r\n";
            if (user.CompanyDepartmentManagementAccess)
                accessStr += "Company/Department" + "\r\n";
            if (user.EmployeeManagementAccess)
                accessStr += "Employee" + "\r\n";
            if (user.TerminalManagementAccess)
                accessStr += "Terminal" + "\r\n";
            if (user.UserManagementAccess)
                accessStr += "User" + "\r\n";
            if (user.WorkingCalendarManagementAccess)
                accessStr += "WorkingCalendar" + "\r\n";
            if (accessStr == "")
                accessStr = "None";

            return accessStr;
        }