Exemplo n.º 1
0
    /// <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);
    }
Exemplo n.º 2
0
    /// <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();
    }
Exemplo n.º 3
0
    /// <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);
    }