void Control_OnAfterDataLoad(object sender, EventArgs e) { if (Project == null) { return; } int groupId = QueryHelper.GetInteger("parentobjectid", 0); // Set group ID to user selector for project owner var ownerControl = Control.FieldControls["ProjectOwner"]; Type ownerControlType = ownerControl.GetType(); PropertyInfo groupIdProperty = ownerControlType.GetProperty("GroupID"); if (groupIdProperty != null) { groupIdProperty.SetValue(ownerControl, groupId, null); } if (Project.ProjectID > 0) { // Load progress int progress = ProjectInfoProvider.GetProjectProgress(Project.ProjectID); Control.FieldControls["ProjectProgress"].Text = ProjectTaskInfoProvider.GenerateProgressHtml(progress, true); } else { Project.ProjectGroupID = groupId; Control.FieldsToHide.Add("ProjectProgress"); Control.FieldsToHide.Add("ProjectAttachments"); } }
void Control_OnAfterDataLoad(object sender, EventArgs e) { if (Project == null) { return; } if (Project.ProjectID != 0) { // Load progress int progress = ProjectInfoProvider.GetProjectProgress(Project.ProjectID); Control.FieldControls["ProjectProgress"].Text = ProjectTaskInfoProvider.GenerateProgressHtml(progress, true); } else { Control.FieldsToHide.Add("ProjectProgress"); Control.FieldsToHide.Add("ProjectAttachments"); } }
/// <summary> /// Loads the data into the form. /// </summary> public void LoadData() { // Check if the projects belongs to the current site if ((this.ProjectObj != null) && (this.ProjectObj.ProjectSiteID != CMSContext.CurrentSiteID)) { return; } // If dealayed reload or not postback with not delayed reload if (((!URLHelper.IsPostback()) && (!DelayedReload)) || (DelayedReload)) { LoadDropDown(); } // Load the form from the info object if (this.ProjectObj != null) { this.txtProjectName.Text = this.ProjectObj.ProjectName; this.txtProjectDisplayName.Text = this.ProjectObj.ProjectDisplayName; this.txtProjectDescription.Text = this.ProjectObj.ProjectDescription; this.dtpProjectStartDate.SelectedDateTime = this.ProjectObj.ProjectStartDate; this.dtpProjectDeadline.SelectedDateTime = this.ProjectObj.ProjectDeadline; int progress = ProjectInfoProvider.GetProjectProgress(this.ProjectObj.ProjectID); this.ltrProjectProgress.Text = ProjectTaskInfoProvider.GenerateProgressHtml(progress, true); if (this.ProjectObj.ProjectOwner != 0) { userSelector.UniSelector.Value = this.ProjectObj.ProjectOwner; } else { userSelector.UniSelector.Value = String.Empty; } this.chkProjectAllowOrdering.Checked = this.ProjectObj.ProjectAllowOrdering; SetStatusDrp(this.ProjectObj.ProjectStatusID); if (this.ProjectObj.ProjectNodeID != 0) { SetProjectPage(this.ProjectObj.ProjectNodeID); } } else { userSelector.UniSelector.Value = ""; CurrentUserInfo cui = CMSContext.CurrentUser; if (!this.IsLiveSite || cui.UserEnabled) { // Load default data userSelector.UniSelector.Value = CMSContext.CurrentUser.UserID; } this.pageSelector.Value = String.Empty; if (ProjectNodeID != 0) { SetProjectPage(ProjectNodeID); } this.ltrProjectProgress.Text = ProjectTaskInfoProvider.GenerateProgressHtml(0, true); // Hide progress bar for a new project this.plcProgress.Visible = false; } }
/// <summary> /// Saves control with actual data. /// </summary> public bool Save() { if (!CheckPermissions("CMS.ProjectManagement", CMSAdminControl.PERMISSION_MANAGE)) { return(false); } // Validate the form if (Validate()) { // Indicates whether project is new bool isNew = false; int progress = 0; // Ensure the info object if (this.ProjectObj == null) { // New project ProjectInfo pi = new ProjectInfo(); // First initialization of the Access propery - allow authenticated users pi.ProjectAccess = 1222; pi.ProjectCreatedByID = CMSContext.CurrentUser.UserID; pi.ProjectOwner = 0; if (CommunityGroupID != 0) { pi.ProjectGroupID = CommunityGroupID; // Set default access to the group pi.ProjectAccess = 3333; } mProjectObj = pi; isNew = true; } else { // Existing project // Reset ProjectOrder if checkbox was unchecked if ((this.ProjectObj.ProjectAllowOrdering) && (!this.chkProjectAllowOrdering.Checked)) { ProjectInfoProvider.ResetProjectOrder(this.ProjectObj.ProjectID); } // Clear the hashtables if the codename has been changed if ((this.ProjectObj.ProjectGroupID > 0) && this.ProjectObj.ProjectName != this.txtProjectName.Text) { ProjectInfoProvider.Clear(true); } progress = ProjectInfoProvider.GetProjectProgress(this.ProjectObj.ProjectID); } this.ltrProjectProgress.Text = ProjectTaskInfoProvider.GenerateProgressHtml(progress, true); // Initialize object this.ProjectObj.ProjectSiteID = CMSContext.CurrentSiteID; if (DisplayMode == ControlDisplayModeEnum.Simple) { if (isNew) { this.ProjectObj.ProjectName = ValidationHelper.GetCodeName(txtProjectDisplayName.Text, 50) + ((CommunityGroupID > 0) ? "_group_" : "_general_") + this.CodenameGUID; } } else { this.ProjectObj.ProjectName = this.txtProjectName.Text.Trim(); } this.ProjectObj.ProjectDisplayName = this.txtProjectDisplayName.Text.Trim(); this.ProjectObj.ProjectDescription = this.txtProjectDescription.Text.Trim(); this.ProjectObj.ProjectStartDate = this.dtpProjectStartDate.SelectedDateTime; this.ProjectObj.ProjectDeadline = this.dtpProjectDeadline.SelectedDateTime; this.ProjectObj.ProjectOwner = ValidationHelper.GetInteger(userSelector.UniSelector.Value, 0); this.ProjectObj.ProjectStatusID = ValidationHelper.GetInteger(drpProjectStatus.SelectedValue, 0); this.ProjectObj.ProjectAllowOrdering = this.chkProjectAllowOrdering.Checked; // Set ProjectNodeID if (!this.ShowPageSelector) { // Set current node id for new project if (isNew && (CMSContext.CurrentDocument != null)) { this.ProjectObj.ProjectNodeID = CMSContext.CurrentDocument.NodeID; } } else { TreeProvider treeProvider = new TreeProvider(); TreeNode node = treeProvider.SelectSingleNode(ValidationHelper.GetGuid(this.pageSelector.Value, Guid.Empty), TreeProvider.ALL_CULTURES, CMSContext.CurrentSiteName); if (node != null) { this.ProjectObj.ProjectNodeID = node.NodeID; } else { this.ProjectObj.ProjectNodeID = 0; } } // Use try/catch due to license check try { // Save object data to database ProjectInfoProvider.SetProjectInfo(this.ProjectObj); this.ProjectID = this.ProjectObj.ProjectID; this.ItemID = this.ProjectObj.ProjectID; this.RaiseOnSaved(); // Set the info message this.lblInfo.Text = GetString("general.changessaved"); return(true); } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } } return(false); }
/// <summary> /// Loads the data into the form. /// </summary> public void LoadData() { // Check if the projects belongs to the current site if ((ProjectObj != null) && (ProjectObj.ProjectSiteID != SiteContext.CurrentSiteID)) { return; } // If delayed reload or not post back with not delayed reload if (((!URLHelper.IsPostback()) && (!DelayedReload)) || (DelayedReload)) { LoadDropDown(); } // Load the form from the info object if (ProjectObj != null) { txtProjectName.Text = ProjectObj.ProjectName; txtProjectDisplayName.Text = ProjectObj.ProjectDisplayName; txtProjectDescription.Text = ProjectObj.ProjectDescription; dtpProjectStartDate.SelectedDateTime = ProjectObj.ProjectStartDate; dtpProjectDeadline.SelectedDateTime = ProjectObj.ProjectDeadline; int progress = ProjectInfoProvider.GetProjectProgress(ProjectObj.ProjectID); ltrProjectProgress.Text = ProjectTaskInfoProvider.GenerateProgressHtml(progress, true); if (ProjectObj.ProjectOwner != 0) { userSelector.UniSelector.Value = ProjectObj.ProjectOwner; userSelector.ReloadData(); } else { userSelector.UniSelector.Value = String.Empty; } chkProjectAllowOrdering.Checked = ProjectObj.ProjectAllowOrdering; SetStatusDrp(ProjectObj.ProjectStatusID); if (ProjectObj.ProjectNodeID != 0) { SetProjectPage(ProjectObj.ProjectNodeID); } plcAttachments.Visible = true; lstAttachments.ObjectID = ProjectObj.ProjectID; lstAttachments.ReloadData(true); } else { userSelector.UniSelector.Value = ""; var cui = MembershipContext.AuthenticatedUser; if (!IsLiveSite || !cui.UserIsDisabledManually) { // Load default data userSelector.UniSelector.Value = MembershipContext.AuthenticatedUser.UserID; } pageSelector.Value = String.Empty; if (ProjectNodeID != 0) { SetProjectPage(ProjectNodeID); } ltrProjectProgress.Text = ProjectTaskInfoProvider.GenerateProgressHtml(0, true); // Hide progress bar for a new project plcProgress.Visible = false; // Hide atachments for a new project plcAttachments.Visible = false; } }