/// <summary> /// Validates the form. If validation succeeds returns true, otherwise returns false. /// </summary> private bool Validate() { string codename = this.txtStatusName.Text.Trim(); // Validate required fields string errorMessage = new Validator() .NotEmpty(this.txtStatusDisplayName.Text.Trim(), this.rfvStatusDisplayName.ErrorMessage) .NotEmpty(codename, this.rfvStatusName.ErrorMessage) .IsCodeName(codename, GetString("general.invalidcodename")).Result; // Check the uniqueness of the codename ProjectStatusInfo psi = ProjectStatusInfoProvider.GetProjectStatusInfo(codename); if ((psi != null) && (psi.StatusID != this.StatusID)) { errorMessage = GetString("general.codenameexists"); } // Give error if status is both: started and finished if (this.chkStatusIsFinished.Checked && this.chkStatusIsNotStarted.Checked) { errorMessage = GetString("pm.projectstatus.startandfinish"); } // Set the error message if (!String.IsNullOrEmpty(errorMessage)) { this.lblError.Text = errorMessage; return(false); } return(true); }
/// <summary> // Processes the form - saves the data. /// </summary> private void Process() { // Validate the form if (Validate()) { // Ensure the info object if (ProjectstatusObj == null) { ProjectstatusObj = new ProjectStatusInfo(); ProjectstatusObj.StatusOrder = ProjectStatusInfoProvider.GetStatusCount(false) + 1; } // Initialize object ProjectstatusObj.StatusName = txtStatusName.Text.Trim(); ProjectstatusObj.StatusDisplayName = txtStatusDisplayName.Text.Trim(); ProjectstatusObj.StatusColor = colorPicker.SelectedColor; ProjectstatusObj.StatusIcon = txtStatusIcon.Text.Trim(); ProjectstatusObj.StatusIsFinished = chkStatusIsFinished.Checked; ProjectstatusObj.StatusIsNotStarted = chkStatusIsNotStarted.Checked; ProjectstatusObj.StatusEnabled = chkStatusEnabled.Checked; // Save object data to database ProjectStatusInfoProvider.SetProjectStatusInfo(ProjectstatusObj); ItemID = ProjectstatusObj.StatusID; RaiseOnSaved(); // Show confirmation ShowChangesSaved(); } }
/// <summary> /// Selects status the in drop down list. /// </summary> /// <param name="value">The selected value</param> private void SetStatusDrp(int value) { if (drpProjectStatus.Items.FindByValue(value.ToString()) == null) { // Status not found (is disabled) - add manually ProjectStatusInfo status = ProjectStatusInfoProvider.GetProjectStatusInfo(value); if (status != null) { drpProjectStatus.Items.Add(new ListItem(status.StatusDisplayName, status.StatusID.ToString())); } } drpProjectStatus.SelectedValue = value.ToString(); }
/// <summary> /// Creates project. Called when the "Create project" button is pressed. /// </summary> private bool CreateProject() { ProjectStatusInfo status = ProjectStatusInfoProvider.GetProjectStatusInfo("NotStarted"); if (status != null) { int currentUserID = MembershipContext.AuthenticatedUser.UserID; // Create new project object ProjectInfo newProject = new ProjectInfo(); // Set the properties newProject.ProjectDisplayName = "My new project"; newProject.ProjectName = "MyNewProject"; newProject.ProjectStatusID = status.StatusID; newProject.ProjectSiteID = SiteContext.CurrentSiteID; newProject.ProjectOwner = currentUserID; newProject.ProjectCreatedByID = currentUserID; // Save the project ProjectInfoProvider.SetProjectInfo(newProject); } return(true); }