コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: rjustesen/Sterling
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string arg = String.Empty;

        if (sender is Button && !String.IsNullOrEmpty(((Button)sender).CommandArgument))
        {
            arg = ((Button)sender).CommandArgument;
        }
        if (!String.IsNullOrEmpty(arg))
        {
            this.Validate(arg);
        }
        else
        {
            this.Validate();
        }
        if (this.IsValid)
        {
            SavePortfolio(AccordianControl.SelectedIndex);
            MissingItems = PortfolioService.GetMissingItems(GetPortfolio());
            if (AccordianControl.SelectedIndex < AccordianControl.Panes.Count)
            {
                AccordianControl.SelectedIndex += 1;
            }
            else
            {
                AccordianControl.SelectedIndex = 0;
            }
        }
    }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: rjustesen/Sterling
    private string GetStatus(Portfolio portfolio)
    {
        StringBuilder       html  = new StringBuilder("<table><tr><th colspan=\"2\">Missing Items (Things that need to be competed)</th></tr>");
        IList <MissingItem> items = PortfolioService.GetMissingItems(portfolio);

        if (items.Count == 0)
        {
            html.Append("<tr><td>All Items Completed</td></tr>");
        }
        foreach (MissingItem i in items)
        {
            html.Append(string.Format("<tr><td>{0:s}</td><td>{1:s}</tr>", i.Name, i.Description));
        }
        html.Append("</table>");
        return(html.ToString());
    }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: rjustesen/Sterling
    private void LoadPortfolio()
    {
        Portfolio portfolio = GetPortfolio();

        MissingItems = PortfolioService.GetMissingItems(portfolio);
        lblName.Text = CurrentUser.FullName;

        IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, portfolio.Id);
        var letters = from a in attachments
                      where a.Category == AttachmentCategory.LetterOfRecomendation
                      select a;

        lnkLetter.Visible    = !letters.Any();
        lvLetters.DataSource = letters;
        lvLetters.DataBind();

        var docs = from a in attachments
                   where a.Category == AttachmentCategory.CategoryDescription
                   select a;

        lnkCatDocsUpload.Visible = docs.Count() < 2;

        lvCatDocs.DataSource = docs;
        lvCatDocs.DataBind();

        docs = from a in attachments
               where a.Category == AttachmentCategory.LeadershipDescription
               select a;

        lnkLeadership.Visible = docs.Count() < 2;

        lvLeadership.DataSource = docs;
        lvLeadership.DataBind();

        docs = from a in attachments
               where a.Category == AttachmentCategory.CitizenshipDescription
               select a;

        lnkCitizenship.Visible   = docs.Count() < 2;
        lvCitizenship.DataSource = docs;
        lvCitizenship.DataBind();

        Attachment image = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.PersonalPhoto);

        if (null != image && AccordianControl.SelectedIndex == 0)
        {
            picNominee.Visible  = true;
            picNominee.ImageUrl = "~/ImageHandler.ashx?id=" + image.Id;
        }
        else
        {
            picNominee.Visible  = false;
            picNominee.ImageUrl = "";
        }

        lvTranscript.DataSource = attachments.Where(x => x.Category == AttachmentCategory.Transcript);
        lvTranscript.DataBind();

        lblSchoolEdit.Text      = portfolio.School.Name;
        lblCategoryEdit.Text    = portfolio.Category.Name;
        txtName.Text            = CurrentUser.FullName;
        txtParents.Text         = portfolio.Parents;
        txtAddress.Text         = portfolio.Address;
        txtCity.Text            = portfolio.City;
        ddlState.SelectedValue  = portfolio.State;
        txtZip.Text             = portfolio.Zip;
        txtPhone.Text           = portfolio.User.PhoneNumber;
        ddlGender.SelectedValue = portfolio.Sex.ToString();
        LoadPortfolio(portfolio);


        IEnumerable <PortfolioItem> catItems = portfolio.Items.Where(x => x.Type == ItemType.Category);

        foreach (PortfolioItem item in catItems)
        {
            TextBox tb = AccordionPane4.FindControl("txtCategory" + item.ItemIndex.ToString()) as TextBox;
            if (tb != null)
            {
                tb.Text = item.Text;
            }
        }

        PortfolioItem i = portfolio.Items.FirstOrDefault(x => x.Type == ItemType.CategoryDescription);

        if (i != null)
        {
            txtCategoryDescription.Text = i.Text;
        }

        IEnumerable <PortfolioItem> leaderItems = portfolio.Items.Where(x => x.Type == ItemType.Leadership);

        foreach (PortfolioItem item in leaderItems)
        {
            TextBox tb = AccordionPane6.FindControl("txtLeadership" + item.ItemIndex.ToString()) as TextBox;
            if (tb != null)
            {
                tb.Text = item.Text;
            }
        }
        i = portfolio.Items.FirstOrDefault(x => x.Type == ItemType.LeadershipDescription);
        if (i != null)
        {
            txtLeadershipDescription.Text = i.Text;
        }

        IEnumerable <PortfolioItem> citizenItems = portfolio.Items.Where(x => x.Type == ItemType.Citizenship);

        foreach (PortfolioItem item in citizenItems)
        {
            TextBox tb = AccordionPane8.FindControl("txtCitizenship" + item.ItemIndex.ToString()) as TextBox;
            if (tb != null)
            {
                tb.Text = item.Text;
            }
        }

        i = portfolio.Items.FirstOrDefault(x => x.Type == ItemType.CitizenshipDescription);
        if (i != null)
        {
            txtCitizenshipDescription.Text = i.Text;
        }

        i = portfolio.Items.FirstOrDefault(x => x.Type == ItemType.LifeEnrichment);
        if (i != null)
        {
            txtLifeEnrichment.Text = i.Text;
        }

        i = portfolio.Items.FirstOrDefault(x => x.Type == ItemType.UniqueQualities);
        if (i != null)
        {
            txtUniqueQualities.Text = i.Text;
        }

        if (null != portfolio)
        {
            IList <Attachment> list = PortfolioService.GetAttachments(AttachmentCategory.Document, AttachmentType.Portfolio, portfolio.Id);
            lvAttachDocs.DataSource = list;
            lvAttachDocs.DataBind();
            btnUploadDocs.Visible = (list.Count == 0);
            list               = PortfolioService.GetAttachments(AttachmentCategory.Image, AttachmentType.Portfolio, portfolio.Id);
            btnImage.Visible   = (list.Count == 0);
            lvImage.DataSource = list;
            lvImage.DataBind();
            list               = PortfolioService.GetAttachments(AttachmentCategory.Media, AttachmentType.Portfolio, portfolio.Id);
            btnMedia.Visible   = (list.Count == 0);
            lvMedia.DataSource = list;
            lvMedia.DataBind();
            list = PortfolioService.GetAttachments(AttachmentCategory.Url, AttachmentType.Portfolio, portfolio.Id);
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

            var attachment = list.FirstOrDefault(x => "Document".Equals(x.Name));
            if (null != attachment)
            {
                txtDocDescription.Text = attachment.Description;
                attachment             = PortfolioService.GetAttachment(attachment.Id);
                txtDocLink.Text        = encoding.GetString(attachment.Data);
            }
            attachment = list.FirstOrDefault(x => "Image".Equals(x.Name));
            if (null != attachment)
            {
                txtImageDescription.Text = attachment.Description;
                attachment        = PortfolioService.GetAttachment(attachment.Id);
                txtImageLink.Text = encoding.GetString(attachment.Data);
            }
            attachment = list.FirstOrDefault(x => "Media".Equals(x.Name));
            if (null != attachment)
            {
                txtMediaDescription.Text = attachment.Description;
                attachment        = PortfolioService.GetAttachment(attachment.Id);
                txtMediaLink.Text = encoding.GetString(attachment.Data);
            }
        }
        else
        {
            PortfolioService.SavePortfolio(portfolio);
        }
        if (portfolio.Status != Status.Incomplete)
        {
            DisableButtons(Page.Controls);
        }
    }
コード例 #4
0
    private void LoadApplication()
    {
        Portfolio portfolio = PortfolioService.GetPortfolio(PortfolioId);


        ddlState.DataSource     = StateService.GetStates();
        ddlState.DataValueField = "StateCode";
        ddlState.DataTextField  = "StateName";
        ddlState.DataBind();

        if (null != portfolio)
        {
            ddlCategory.DataMember    = "Id";
            ddlCategory.DataTextField = "Name";
            ddlCategory.DataSource    = CategoryService.GetCategories(portfolio.School.Area.Region);
            ddlCategory.DataBind();


            IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, portfolio.Id);

            Attachment image = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.PersonalPhoto);
            lnkPicture.Visible = true;

            lnkTransUpload.Visible  = (attachments.FirstOrDefault(x => x.Category == AttachmentCategory.Transcript) == null);
            lvTranscript.DataSource = attachments.Where(x => x.Category == AttachmentCategory.Transcript);;
            lvTranscript.DataBind();

            if (null != image)
            {
                picNominee.Visible  = true;
                picNominee.ImageUrl = "~/ImageHandler.ashx?id=" + image.Id;
            }

            LoadTestScores(portfolio);
            ddlStatus.SelectedValue = portfolio.Status.ToString();

            ddlCategory.SelectedValue = portfolio.Category.Name;
            ddlCategory.Enabled       = false;
            txtFullName.Text          = portfolio.User.FullName;
            txtEmail.Text             = portfolio.User.EMail;
            txtComment.Text           = portfolio.User.Comment;
            txtPhone.Text             = portfolio.User.PhoneNumber;
            txtParents.Text           = portfolio.Parents;
            txtAddress.Text           = portfolio.Address;
            txtCity.Text            = portfolio.City;
            ddlState.SelectedValue  = portfolio.State;
            txtZip.Text             = portfolio.Zip;
            ddlGender.SelectedValue = portfolio.Sex.ToString();
            lblStudentName.Text     = "Missing Items for " + portfolio.User.FullName;
            lvItems.DataSource      = PortfolioService.GetMissingItems(portfolio);
            lvItems.DataBind();
        }
        else
        {
            ddlCategory.DataMember    = "Id";
            ddlCategory.DataTextField = "Name";
            ddlCategory.DataSource    = CategoryService.GetCategories(GetSchool().Area.Region);
            ddlCategory.DataBind();

            ddlCategory.Enabled    = true;
            ddlStatus.Enabled      = false;
            txtFullName.Text       = "";
            txtEmail.Text          = "";
            txtComment.Text        = "";
            txtPhone.Text          = "";
            txtParents.Text        = "";
            txtAddress.Text        = "";
            txtCity.Text           = "";
            ddlState.SelectedValue = "UT";
            txtZip.Text            = "";
            lnkPicture.Visible     = false;
            lnkTransUpload.Visible = false;
        }
    }