/// <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 (this.ProjectstatusObj == null) { this.ProjectstatusObj = new ProjectStatusInfo(); this.ProjectstatusObj.StatusOrder = ProjectStatusInfoProvider.GetStatusCount(false) + 1; } // Initialize object this.ProjectstatusObj.StatusName = this.txtStatusName.Text.Trim(); this.ProjectstatusObj.StatusDisplayName = this.txtStatusDisplayName.Text.Trim(); this.ProjectstatusObj.StatusColor = this.colorPicker.SelectedColor; this.ProjectstatusObj.StatusIcon = this.txtStatusIcon.Text.Trim(); this.ProjectstatusObj.StatusIsFinished = this.chkStatusIsFinished.Checked; this.ProjectstatusObj.StatusIsNotStarted = this.chkStatusIsNotStarted.Checked; this.ProjectstatusObj.StatusEnabled = this.chkStatusEnabled.Checked; // Save object data to database ProjectStatusInfoProvider.SetProjectStatusInfo(this.ProjectstatusObj); this.ItemID = this.ProjectstatusObj.StatusID; this.RaiseOnSaved(); // Set the info message this.lblInfo.Text = GetString("general.changessaved"); } }
/// <summary> /// Loads the data to the status dropdown field. /// </summary> private void LoadDropDown() { drpProjectStatus.DataSource = ProjectStatusInfoProvider.GetProjectStatuses(true); drpProjectStatus.DataValueField = "StatusID"; drpProjectStatus.DataTextField = "StatusDisplayName"; drpProjectStatus.DataBind(); }
/// <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> /// 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 projectstatusId = ValidationHelper.GetInteger(actionArgument, 0); if (projectstatusId > 0) { switch (actionName.ToLowerCSafe()) { case "edit": SelectedItemID = projectstatusId; RaiseOnEdit(); break; case "delete": if (!ProjectStatusInfoProvider.CheckDependencies(projectstatusId)) { ShowError(GetString("pm.projectstatus.removedenied")); return; } if (ProjectStatusInfoProvider.GetStatusCount() <= 1) { ltlInfo.Text = ScriptHelper.GetScript("alert('" + GetString("pm.projectstatus.deletealert") + "');"); return; } // Delete the object ProjectStatusInfoProvider.DeleteProjectStatusInfo(projectstatusId); RaiseOnDelete(); // Reload data gridElem.ReloadData(); break; case "up": ProjectStatusInfoProvider.MoveStatusUp(projectstatusId); break; case "down": ProjectStatusInfoProvider.MoveStatusDown(projectstatusId); break; } } }
/// <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); }