Ejemplo n.º 1
0
    public bool IsUserAccessAllowed(SystemUser user)
    {
        user.Passwd = EncryptString(user.Passwd);
        datatable   = datafile.GetUserAccessibility(user);
        int foundRows = datatable.Rows.Count;

        if (foundRows > 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    private void Access(SystemUser user)
    {
        user.Passwd = bll.EncryptString(user.Passwd);
        dataTable   = datafile.GetUserAccessibility(user);
        int    UserID         = int.Parse(dataTable.Rows[0]["UserID"].ToString());
        string RoleCode       = dataTable.Rows[0]["RoleCode"].ToString();
        bool   IsActiveRole   = bool.Parse(dataTable.Rows[0]["IsRoleActive"].ToString());
        bool   IsActiveArea   = bool.Parse(dataTable.Rows[0]["IsAreaActive"].ToString());
        bool   IsActiveBranch = bool.Parse(dataTable.Rows[0]["IsBranchActive"].ToString());
        bool   IsActiveUser   = bool.Parse(dataTable.Rows[0]["Active"].ToString());
        bool   IsLoggedIn     = bool.Parse(dataTable.Rows[0]["LoggedOn"].ToString());
        bool   reset          = bool.Parse(dataTable.Rows[0]["Reset"].ToString());

        if (IsActiveRole)
        {
            if (IsActiveArea)
            {
                if (IsActiveBranch)
                {
                    if (IsActiveUser)
                    {
                        string Message = "";
                        if (reset)
                        {
                            Message = "Please you need to change your password to continue";
                            RequestToChangePassword(Message);
                            Label1.Text = UserID.ToString();
                            Label2.Text = user.Uname;
                        }
                        else
                        {
                            DateTime DateOfChange = AssignSessions(dataTable);
                            if (bll.PasswordExpired(DateOfChange))
                            {
                                Message = "Your Password expired and needs to be changed";
                                RequestToChangePassword(Message);
                                Label1.Text = UserID.ToString();
                                txtNewPassword.Focus();
                                ShowMessage(".", true);
                            }
                            else
                            {
                                double RemainingDays = bll.IsRemainingDays(DateOfChange);
                                if (RemainingDays < 5)
                                {
                                    //Message = "Your Password will expire in "+RemainingDays+" day(s), Do you want to change";
                                    WarnAboutExpiry(RemainingDays);
                                    Label1.Text = UserID.ToString();
                                    Label2.Text = user.Uname;
                                    txtNewPassword.Focus();
                                    ShowMessage(".", true);
                                }

                                else
                                {
                                    string StartPage = Session["Page"].ToString();
                                    Redirection(StartPage);
                                    AssignUserCookie();
                                }
                            }
                        }
                        //}
                    }
                    else
                    {
                        ShowMessage("Your Account is disabled, Please Contact System Administrators", true);
                    }
                }
                else
                {
                    ShowMessage("Your Company is disabled, Please Contact System Administrators", true);
                }
            }
            else
            {
                ShowMessage("Your Operating Region is disabled, Please Contact System Administrators", true);
            }
        }
        else
        {
            ShowMessage("Your System Role is disabled, Please Contact System Administrators", true);
        }
    }