Exemplo n.º 1
0
    /// <summary>
    /// Deletes project task. Called when the "Delete task" button is pressed.
    /// Expects the CreateProjectTask method to be run first.
    /// </summary>
    private bool DeleteProjectTask()
    {
        // Prepare the parameters
        string where = "ProjectTaskDisplayName LIKE N'My new task%'";
        string orderBy = "";
        int    topN    = 0;
        string columns = "";

        // Get the data
        DataSet tasks = ProjectTaskInfoProvider.GetProjectTasks(where, orderBy, topN, columns);

        if (!DataHelper.DataSourceIsEmpty(tasks))
        {
            // Get the project task
            ProjectTaskInfo deleteTask = new ProjectTaskInfo(tasks.Tables[0].Rows[0]);

            // Delete the project task
            ProjectTaskInfoProvider.DeleteProjectTaskInfo(deleteTask);

            return(deleteTask != null);
        }
        return(false);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Handles UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of the action which should be performed</param>
    /// <param name="actionArgument">ID of the item the action should be performed with</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        int projectTaskId = ValidationHelper.GetInteger(actionArgument, 0);

        RaiseOnAction(actionName, actionArgument);
        if (projectTaskId > 0)
        {
            switch (actionName.ToLower())
            {
            case "edit":
                this.SelectedItemID = projectTaskId;
                this.RaiseOnEdit();
                break;

            case "delete":
                // Delete the object
                this.SelectedItemID = projectTaskId;
                if (CheckPermissions("CMS.ProjectManagement", ProjectManagementPermissionType.DELETE, CMSAdminControl.PERMISSION_MANAGE))
                {
                    // Use try/catch due to license check
                    try
                    {
                        ProjectTaskInfoProvider.DeleteProjectTaskInfo(projectTaskId);
                        this.RaiseOnDelete();
                    }
                    catch (Exception ex)
                    {
                        lblError.Visible = true;
                        lblError.Text    = ex.Message;
                    }
                }

                // Reload data
                gridElem.ReloadData();
                break;

            case "up":
                // Do not check permissions for user order
                if ((OrderByType != ProjectTaskOrderByEnum.ProjectOrder) || (CheckPermissions("CMS.ProjectManagement", ProjectManagementPermissionType.MODIFY, CMSAdminControl.PERMISSION_MANAGE) &&
                                                                             showArrows))
                {
                    // Use try/catch due to license check
                    try
                    {
                        gridElem.SortDirect = string.Empty;
                        gridElem.ReloadData();
                        ProjectTaskInfoProvider.MoveTaskUp(projectTaskId, OrderByType);
                    }
                    catch (Exception ex)
                    {
                        lblError.Visible = true;
                        lblError.Text    = ex.Message;
                    }
                }
                break;

            case "down":
                // Do not check permissions for user order
                if ((OrderByType != ProjectTaskOrderByEnum.ProjectOrder) || (CheckPermissions("CMS.ProjectManagement", ProjectManagementPermissionType.MODIFY, CMSAdminControl.PERMISSION_MANAGE) &&
                                                                             showArrows))
                {
                    // Use try/catch due to license check
                    try
                    {
                        gridElem.SortDirect = string.Empty;
                        gridElem.ReloadData();
                        ProjectTaskInfoProvider.MoveTaskDown(projectTaskId, OrderByType);
                    }
                    catch (Exception ex)
                    {
                        lblError.Visible = true;
                        lblError.Text    = ex.Message;
                    }
                }
                break;

            case "reminder":
                this.ReminderTaskID  = projectTaskId;
                txtReminderText.Text = string.Empty;
                ShowReminderPopup();
                break;
            }
        }
    }