Exemple #1
0
    /// <summary>
    /// Saves the data.
    /// </summary>
    public bool Save()
    {
        // Validate the form
        if (Validate())
        {
            // New task
            if (ProjectTaskObj == null)
            {
                // New task - check permission of project task (ad-hoc task are allowed to create)
                if (!CheckPermissions("CMS.ProjectManagement", ProjectManagementPermissionType.CREATE, PERMISSION_MANAGE))
                {
                    return(false);
                }

                ProjectTaskInfo pi = new ProjectTaskInfo();
                pi.ProjectTaskProjectOrder = 0;
                pi.ProjectTaskUserOrder    = 0;
                pi.ProjectTaskProjectID    = ProjectID;
                pi.ProjectTaskCreatedByID  = MembershipContext.AuthenticatedUser.UserID;
                mProjectTaskObj            = pi;
            }
            else
            {
                ItemID = ProjectTaskObj.ProjectTaskID;
                if (!CheckPermissions("CMS.ProjectManagement", ProjectManagementPermissionType.MODIFY, PERMISSION_MANAGE))
                {
                    return(false);
                }
            }

            // Initialize object
            ProjectTaskObj.ProjectTaskDisplayName = txtProjectTaskDisplayName.Text.Trim();
            int assignedToUserId = ValidationHelper.GetInteger(selectorAssignee.UniSelector.Value, 0);
            if (assignedToUserId != ProjectTaskObj.ProjectTaskAssignedToUserID)
            {
                // If the task is reassigned - reset user order
                ProjectTaskObj.ProjectTaskUserOrder        = ProjectTaskInfoProvider.GetTaskMaxOrder(ProjectTaskOrderByEnum.UserOrder, assignedToUserId) + 1;
                ProjectTaskObj.ProjectTaskAssignedToUserID = assignedToUserId;
            }

            ProjectTaskObj.ProjectTaskProgress = ValidationHelper.GetInteger(txtProjectTaskProgress.Text, 0);
            ProjectTaskObj.ProjectTaskHours    = ValidationHelper.GetDouble(txtProjectTaskHours.Text, 0);
            ProjectTaskObj.ProjectTaskOwnerID  = ValidationHelper.GetInteger(selectorOwner.UniSelector.Value, 0);
            ProjectTaskObj.ProjectTaskDeadline = dtpProjectTaskDeadline.SelectedDateTime;
            if ((ProjectTaskObj.ProjectTaskDeadline != DateTimeHelper.ZERO_TIME) &&
                (ProjectTaskObj.ProjectTaskDeadline > DateTime.Now))
            {
                ProjectTaskObj.ProjectTaskNotificationSent = false;
            }
            ProjectTaskObj.ProjectTaskStatusID    = ValidationHelper.GetInteger(drpTaskStatus.SelectedValue, 0);
            ProjectTaskObj.ProjectTaskPriorityID  = ValidationHelper.GetInteger(drpTaskPriority.SelectedValue, 0);
            ProjectTaskObj.ProjectTaskIsPrivate   = chkProjectTaskIsPrivate.Checked;
            ProjectTaskObj.ProjectTaskDescription = htmlTaskDescription.ResolvedValue;


            // Use try/catch due to license check
            try
            {
                // Save object data to database
                ProjectTaskInfoProvider.SetProjectTaskInfo(ProjectTaskObj);

                ItemID = ProjectTaskObj.ProjectTaskID;
                RaiseOnSaved();

                ShowChangesSaved();
                return(true);
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        return(false);
    }
Exemple #2
0
    /// <summary>
    /// Saves the data.
    /// </summary>
    public bool Save()
    {
        // Validate the form
        if (Validate())
        {
            // New task
            if (this.ProjectTaskObj == null)
            {
                // New task - check permission of project task (ad-hoc task are allowed to create)
                if (!CheckPermissions("CMS.ProjectManagement", ProjectManagementPermissionType.CREATE, CMSAdminControl.PERMISSION_MANAGE))
                {
                    return(false);
                }

                ProjectTaskInfo pi = new ProjectTaskInfo();
                pi.ProjectTaskProjectOrder = 0;
                pi.ProjectTaskUserOrder    = 0;
                pi.ProjectTaskProjectID    = ProjectID;
                pi.ProjectTaskCreatedByID  = CMSContext.CurrentUser.UserID;
                mProjectTaskObj            = pi;
            }
            else
            {
                this.ItemID = ProjectTaskObj.ProjectTaskID;
                if (!CheckPermissions("CMS.ProjectManagement", ProjectManagementPermissionType.MODIFY, CMSAdminControl.PERMISSION_MANAGE))
                {
                    return(false);
                }
            }

            // Initialize object
            this.ProjectTaskObj.ProjectTaskDisplayName = this.txtProjectTaskDisplayName.Text.Trim();
            int assignedToUserId = ValidationHelper.GetInteger(selectorAssignee.UniSelector.Value, 0);
            if (assignedToUserId != this.ProjectTaskObj.ProjectTaskAssignedToUserID)
            {
                // If the task is reassigned - reset user order
                this.ProjectTaskObj.ProjectTaskUserOrder        = ProjectTaskInfoProvider.GetTaskMaxOrder(ProjectTaskOrderByEnum.UserOrder, assignedToUserId) + 1;
                this.ProjectTaskObj.ProjectTaskAssignedToUserID = assignedToUserId;
            }

            this.ProjectTaskObj.ProjectTaskProgress = ValidationHelper.GetInteger(this.txtProjectTaskProgress.Text, 0);
            this.ProjectTaskObj.ProjectTaskHours    = ValidationHelper.GetDouble(this.txtProjectTaskHours.Text, 0);
            this.ProjectTaskObj.ProjectTaskOwnerID  = ValidationHelper.GetInteger(selectorOwner.UniSelector.Value, 0);
            this.ProjectTaskObj.ProjectTaskDeadline = this.dtpProjectTaskDeadline.SelectedDateTime;
            if ((this.ProjectTaskObj.ProjectTaskDeadline != DateTimeHelper.ZERO_TIME) &&
                (this.ProjectTaskObj.ProjectTaskDeadline > DateTime.Now))
            {
                this.ProjectTaskObj.ProjectTaskNotificationSent = false;
            }
            this.ProjectTaskObj.ProjectTaskStatusID    = ValidationHelper.GetInteger(drpTaskStatus.SelectedValue, 0);
            this.ProjectTaskObj.ProjectTaskPriorityID  = ValidationHelper.GetInteger(drpTaskPriority.SelectedValue, 0);
            this.ProjectTaskObj.ProjectTaskIsPrivate   = this.chkProjectTaskIsPrivate.Checked;
            this.ProjectTaskObj.ProjectTaskDescription = htmlTaskDescription.ResolvedValue;



            // Use try/catch due to license check
            try
            {
                // Save object data to database
                ProjectTaskInfoProvider.SetProjectTaskInfo(this.ProjectTaskObj);

                this.ItemID = this.ProjectTaskObj.ProjectTaskID;
                this.RaiseOnSaved();

                this.lblInfo.Text = GetString("general.changessaved");
                return(true);
            }
            catch (Exception ex)
            {
                lblError.Visible = true;
                lblError.Text    = ex.Message;
            }
        }
        return(false);
    }