protected void grdFollowUpBudget_ItemCreated(object sender, GridItemEventArgs e)
        {
            try
            {
                string budgetVersion = ReturnBudgetVersionFromCombo();
                if (!IsDeleteButtonEnable())
                {
                    if (e.Item is GridFooterItem)
                    {
                        GridFooterItem commandItem = e.Item as GridFooterItem;
                        IndImageButton button      = commandItem.FindControl("btnDelete") as IndImageButton;
                        button.Enabled = false;

                        button.ImageUrl = ResolveUrl("~/Images/buttons_delete_disabled.png");
                    }
                    if (e.Item is GridItem)
                    {
                        GridItem itm = e.Item as GridItem;
                        CheckBox ck  = itm.FindControl("chkDeleteCol") as CheckBox;
                        if (ck != null)
                        {
                            ck.Enabled = false;
                        }
                    }
                }
                if (e.Item is GridFooterItem)
                {
                    GridFooterItem commandItem = e.Item as GridFooterItem;
                    LinkButton     navigateAll = commandItem.FindControl("btnNavigateAll") as LinkButton;
                    if (IsBATAOrPM(currentUser) || IsFunctionalManager(currentUser))
                    {
                        switch (CmbTypeSelectedValue)
                        {
                        case ApplicationConstants.BUDGET_TYPE_INITIAL:
                            navigateAll.PostBackUrl = "~/Pages/Budget/WPPreselection/WPPreselection.aspx?Code=" + ApplicationConstants.MODULE_INITIAL + "&IdAssociate=" + ApplicationConstants.INT_NULL_VALUE + "&BudgetVersion=" + budgetVersion + "&IsFromFollowUp=1";
                            break;

                        case ApplicationConstants.BUDGET_TYPE_REVISED:
                            navigateAll.PostBackUrl = "~/Pages/Budget/WPPreselection/WPPreselection.aspx?Code=" + ApplicationConstants.MODULE_REVISED + "&IdAssociate=" + ApplicationConstants.INT_NULL_VALUE + "&BudgetVersion=" + budgetVersion + "&IsFromFollowUp=1";
                            break;

                        case ApplicationConstants.BUDGET_TYPE_TOCOMPLETION:
                            navigateAll.PostBackUrl = "~/Pages/Budget/WPPreselection/WPPreselection.aspx?Code=" + ApplicationConstants.MODULE_REFORECAST + "&IdAssociate=" + ApplicationConstants.INT_NULL_VALUE + "&BudgetVersion=" + budgetVersion + "&IsFromFollowUp=1";
                            break;

                        default:
                            navigateAll.PostBackUrl = "~/Pages/Budget/WPPreselection/WPPreselection.aspx?Code=" + ApplicationConstants.MODULE_INITIAL + "&IdAssociate=" + ApplicationConstants.INT_NULL_VALUE;
                            break;
                        }
                        navigateAll.PostBackUrl += "&BudgetType=" + (cmbType.SelectedIndex - 1);
                    }
                    else
                    {
                        navigateAll.Visible = false;
                    }
                }
            }
            catch (IndException ex)
            {
                ShowError(ex);
                return;
            }
            catch (Exception ex)
            {
                ShowError(new IndException(ex));
                return;
            }
        }
示例#2
0
        /// <summary>
        /// Applies the permissions depending on the current user
        /// </summary>
        private void ApplyPermissions()
        {
            //this.Parent should always be GenericUserControl
            Debug.Assert(this.Parent is GenericUserControl, ApplicationMessages.EXCEPTION_CONTROL_NOT_PLACED_CORRECT);

            //Code for setting permissions is in OnInit method
            //Enable/Diasble each item
            foreach (GridDataItem item in GenericGrid.Items)
            {
                GridColumn gridColumn = GenericGrid.Columns.FindByDataFieldSafe("IdCountry");
                if (item["EditColumn"].Controls.Count > 0)
                {
                    if (!(item["EditColumn"].Controls[0] is ImageButton))
                    {
                        throw new IndException(ApplicationMessages.EXCEPTION_EDITCOLUMN_NOT_CONTAIN_IMAGEBUTTON);
                    }
                    //Get the column controls and set them disabled if it is the case
                    IndImageButton btnEdit = item["EditColumn"].Controls[0] as IndImageButton;
                    if (GenericGrid.Columns.FindByUniqueNameSafe("IsProgramManager") != null && _EditPermission == Permissions.Restricted)
                    {
                        btnEdit.Enabled = bool.Parse(item["IsProgramManager"].Text);
                    }
                    else
                    {
                        //Set the corresponding permissions
                        if (gridColumn != null && _EditPermission == Permissions.Restricted)
                        {
                            btnEdit.Enabled = (_currentUser.IdCountry == int.Parse(item["IdCountry"].Text));
                        }
                        else
                        {
                            btnEdit.Enabled = (_EditPermission == Permissions.None) ? false : true;
                        }
                    }
                    //If the edit button is disabled (because the user does not have the right to edit), set its image to the disabled image
                    if (!btnEdit.Enabled)
                    {
                        btnEdit.ImageUrl = "~/Images/buttons_editrow_disabled.png";
                    }
                }
                if (item["DeleteColumn"].Controls.Count > 0)
                {
                    //This column should always have a CheckBox
                    if (!(item["DeleteColumn"].Controls[0] is CheckBox))
                    {
                        throw new IndException(ApplicationMessages.EXCEPTION_DELETECOLUMN_NOT_CONTAIN_CHECKBOX);
                    }
                    CheckBox chkDelete = item["DeleteColumn"].Controls[0] as CheckBox;
                    //Set the corresponding permissions
                    if (gridColumn != null && _DeletePermission == Permissions.Restricted)
                    {
                        chkDelete.Enabled = (_currentUser.IdCountry == int.Parse(item["IdCountry"].Text));
                    }
                    else
                    {
                        chkDelete.Enabled = (_DeletePermission == Permissions.None) ? false : true;
                    }
                }
            }
            GenericGrid.btnAdd.Enabled = (_AddPermission == Permissions.None) ? false : true;
            //If the add button is disabled (because the user does not have the right to add), set its image to the disabled image
            if (!GenericGrid.btnAdd.Enabled)
            {
                GenericGrid.btnAdd.ImageUrl = "~/Images/buttons_new_disabled.png";
            }
            GenericGrid.btnDelete.Enabled = (_DeletePermission == Permissions.None) ? false : true;
            //If the delete button is disabled (because the user does not have the right to delete), set its image to the disabled image
            if (!GenericGrid.btnDelete.Enabled)
            {
                GenericGrid.btnDelete.ImageUrl = "~/Images/buttons_delete_disabled.png";
            }
        }