Exemple #1
0
        private void FillRolesDropdown(UsersAndRolesDataAccess dataAccess)
        {
            var roleListItems = dataAccess.GetRoleListItems();

            roleListItems.Insert(0, ParameterDataAccess.EmptyItem);
            ddlRole.Items.AddRange(roleListItems.ToArray());
        }
Exemple #2
0
        public void ChangeRoleCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e != null)
            {
                var commandEventArgs = e as CommandEventArgs;
                if (commandEventArgs.CommandName == GrantCommand || commandEventArgs.CommandName == RevokeCommand)
                {
                    var roleId       = int.Parse(commandEventArgs.CommandArgument.ToString());
                    var grantCommand = commandEventArgs.CommandName == GrantCommand;

                    using (var dataAccess = new UsersAndRolesDataAccess())
                    {
                        if (grantCommand)
                        {
                            dataAccess.GrantUserRole(UserIdSelected, roleId);
                        }
                        else
                        {
                            dataAccess.RevokeUserRole(UserIdSelected, roleId);
                        }
                        var roles = dataAccess.GetRolesForUser(UserIdSelected);
                        BindUserRolesRepeater(roles);
                    }

                    mpeUserUpdate.Show();
                }
            }
        }
Exemple #3
0
        private void CreateNewUser()
        {
            var employeeId = tbEmployeeId.Text;
            var racfId     = tbRacfId.Text;

            if (employeeId == string.Empty &&
                !racfId.ToLower().Contains("itdemo"))
            {
                lblMessage.Text = NoEmployeeId;
                ShowPopup();
                return;
            }

            using (var dataAccess = new UsersAndRolesDataAccess())
            {
                var companyId  = ddlCompany.SelectedIndex < 1 ? (int?)null : int.Parse(ddlCompany.SelectedValue);
                var userEntity = new UserEntity
                {
                    EmployeeId    = employeeId == string.Empty ? racfId : employeeId,
                    CompanyTypeId = UserTypeIdSelected,
                    CompanyId     = companyId
                };
                var insertResult = dataAccess.AddMarsUserEntry(userEntity);
                if (insertResult != string.Empty)
                {
                    lblMessage.Text = insertResult;
                    ShowPopup();
                    return;
                }

                PopulateUserGrid(dataAccess);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var comData = CommunicationDataAccess.GetAllActiveNewsItems();

                rptComm.DataSource = comData;
                rptComm.DataBind();

                var documents = CommunicationDataAccess.GetAllDocuments().ToList();
                rptDocs.DataSource = documents;
                rptDocs.DataBind();

                using (var dataAccess = new UsersAndRolesDataAccess())
                {
                    var employeeId    = ApplicationAuthentication.GetEmployeeId();
                    var userType      = dataAccess.GetUserType(employeeId);
                    var countryAdmins = dataAccess.GetCountryAdmin(userType);
                    gvCountryAdmins.DataSource = countryAdmins.OrderBy(d => d.Country).ThenBy(d => d.Name);
                }
                using (var dataAccess = new UserTrainingDataAccess())
                {
                    var trainingEntities = dataAccess.GetActiveEntries();
                    rptTraining.DataSource = trainingEntities;
                }
                gvCountryAdmins.DataBind();
                rptTraining.DataBind();
            }
        }
Exemple #5
0
 protected void btnRefreshUsersList_Click(object sender, EventArgs e)
 {
     tbUserSearch.Text = string.Empty;
     using (var dataAccess = new UsersAndRolesDataAccess())
     {
         PopulateUserGrid(dataAccess);
     }
 }
Exemple #6
0
        private void FillUserTypes(UsersAndRolesDataAccess dataAccess)
        {
            var userTypes          = dataAccess.GetCompanyTypes();
            var parameterUserTypes = dataAccess.GetCompanyTypes();

            ddlUserType.Items.AddRange(userTypes.ToArray());
            parameterUserTypes.Insert(0, ParameterDataAccess.EmptyItem);
            ddlParameterUserType.Items.AddRange(parameterUserTypes.ToArray());
        }
Exemple #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (var dataAccess = new UsersAndRolesDataAccess())
         {
             var companyTypes = dataAccess.GetCompanyTypes();
             rblCompanyTypes.Items.AddRange(companyTypes.ToArray());
             rblCompanyTypes.SelectedIndex = 0;
         }
         PopulateRolesListBox();
     }
 }
Exemple #8
0
        private void ProcessUser(string employeeId, string redirectUrl, CompanyTypeEnum companyType)
        {
            using (var dataAccess = new UsersAndRolesDataAccess())
            {
                var companyTypeId = dataAccess.GetCompanyIdForType(companyType);
                var userEnitty    = dataAccess.GetUserEntityByEmployeeId(employeeId);

                if (userEnitty == null)             //User doesn't exist
                {
                    var userEntity = new UserEntity
                    {
                        EmployeeId    = employeeId,
                        CompanyTypeId = companyTypeId,
                        CompanyId     = null
                    };

                    var insertResult = dataAccess.AddMarsUserEntry(userEntity);
                    if (companyType == CompanyTypeEnum.Corporate)
                    {
                        if (insertResult == string.Empty)
                        {
                            Response.Redirect(redirectUrl);
                        }
                        else
                        {
                            lblMessage.Text = insertResult;
                        }
                    }
                    else            //Newly created Lisencee, needs Company
                    {
                        lblMessage.Text = NotInActiveDirectoy;
                    }
                }
                else                                //User does exist
                {
                    if (userEnitty.CompanyTypeId != companyTypeId)
                    {
                        dataAccess.ChangeUserCompanyType(userEnitty.MarsUserId, companyTypeId);
                    }

                    if (companyType == CompanyTypeEnum.Licensee && userEnitty.CompanyId == null)
                    {
                        pnlCountryAdmin.Visible = true;
                        lblMessage.Text         = LicenceeUserNeedsCompany;
                        return;
                    }

                    Response.Redirect(redirectUrl);
                }
            }
        }
Exemple #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                using (var dataAccess = new UsersAndRolesDataAccess())
                {
                    LicenseeCountryAdmins = dataAccess.GetCountryAdmin(CompanyTypeEnum.Licensee);
                }
                var ddlItems = LicenseeCountryAdmins.Select(d => new ListItem(d.Country));
                ddlLicenseeCountries.Items.AddRange(ddlItems.ToArray());
                ddlLicenseeCountries.Items.Insert(0, new ListItem("Select", ""));
            }


            this.LogOnControl.ADGroup    = Mars.Properties.Settings.Default.ADGroup;
            PanelLogOn.DefaultLinkButton = LogOnControl.LogOnButton;
            lblMessage.Text = string.Empty;
        }
Exemple #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblMessage.Text = string.Empty;
            if (!IsPostBack)
            {
                OverviewSortColumn    = null;
                OverviewSortDirection = SortDirection.Descending;

                using (var dataAccess = new UsersAndRolesDataAccess())
                {
                    PopulateUserGrid(dataAccess);
                    FillUserTypes(dataAccess);
                    FillCountryDropdown(ddlCompanyCountry);
                    FillCountryDropdown(ddlParameterCompanyCountry);
                    FillRolesDropdown(dataAccess);

                    var parameterCompanyCountryId = ddlParameterCompanyCountry.SelectedValue == string.Empty ? 0 : int.Parse(ddlParameterCompanyCountry.SelectedValue);
                    var parameterUserTypeId       = ddlParameterUserType.SelectedValue == string.Empty ? 0 : int.Parse(ddlParameterUserType.SelectedValue);
                    PopulateCompanyDropdown(parameterCompanyCountryId, parameterUserTypeId, ddlParameterCompany, true);
                }
            }
        }
Exemple #11
0
        protected override bool OnBubbleEvent(object sender, EventArgs args)
        {
            var handled = false;

            if (args is CommandEventArgs)
            {
                var commandArgs = args as CommandEventArgs;
                if (commandArgs.CommandName == UserEntity.EditUserCommand)
                {
                    var userId = int.Parse(commandArgs.CommandArgument.ToString());
                    UserIdSelected = userId;
                    using (var dataAccess = new UsersAndRolesDataAccess())
                    {
                        var roles = dataAccess.GetRolesForUser(userId);
                        BindUserRolesRepeater(roles);
                        SetUserDetails();
                    }
                }
                handled = true;
            }
            return(handled);
        }
Exemple #12
0
        private void UpdateExistingUser()
        {
            var companyId = ddlCompany.SelectedIndex == -1 ||
                            ddlCompany.SelectedValue == "-1" ? (int?)null : int.Parse(ddlCompany.SelectedValue);
            var userEntity = new UserEntity
            {
                MarsUserId    = UserIdSelected,
                CompanyTypeId = UserTypeIdSelected,
                CompanyId     = companyId
            };

            using (var dataAccess = new UsersAndRolesDataAccess())
            {
                var updateResult = dataAccess.UpdateMarsUserEntry(userEntity);
                if (updateResult != string.Empty)
                {
                    lblMessage.Text = updateResult;
                    ShowPopup();
                }
                PopulateUserGrid(dataAccess);
            }
        }
Exemple #13
0
 private void PopulateUserGrid(UsersAndRolesDataAccess dataAccess)
 {
     GridData = dataAccess.GetUserEntities();
 }