Exemplo n.º 1
0
    protected void gvPhotos_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Portfolio          portfolio   = e.Row.DataItem as Portfolio;
            IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, portfolio.Id);
            Label      labStatus           = e.Row.FindControl("labStatus") as Label;
            Image      imgPhoto            = e.Row.FindControl("imgPhoto") as Image;
            LinkButton lnkDownLoad         = e.Row.FindControl("lnkDownLoad") as LinkButton;

            labStatus.Text = portfolio.Status.ToDescription();

            Attachment image = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.PersonalPhoto);
            if (null != image)
            {
                imgPhoto.ImageUrl           = "~/ImageHandler.ashx?id=" + image.Id;
                lnkDownLoad.CommandArgument = image.Id.ToString();
            }
            else
            {
                imgPhoto.Visible  = false;
                imgPhoto.ImageUrl = "";
            }
        }
    }
Exemplo n.º 2
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        FileUpload fileUpload = modalImageDlg.FindControl("txtFileUpload") as FileUpload;

        if (null != fileUpload && fileUpload.HasFile)
        {
            IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.User, CurrentUser.Id);
            Attachment         image       = null;
            if (null != attachments && attachments.Count > 0)
            {
                image = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.GroupPhoto);
            }
            if (null == image)
            {
                image             = new Attachment();
                image.Category    = AttachmentCategory.GroupPhoto;
                image.Type        = AttachmentType.User;
                image.ObjectRowId = CurrentUser.Id;
                image.Description = "Group Picture";
            }
            image.Name = fileUpload.FileName;
            using (BinaryReader reader = new BinaryReader(fileUpload.FileContent))
            {
                byte[] buf = reader.ReadBytes((int)fileUpload.FileContent.Length);
                fileUpload.FileContent.Close();
                image.Data = buf;// ImageUtils.NormalizeImage(buf);
                reader.Close();
            }
            PortfolioService.SaveAttachment(image);
            imgPhoto.Visible  = true;
            imgPhoto.ImageUrl = "~/ImageHandler.ashx?id=" + image.Id;
        }
        modalImageDlg.HideModal();
    }
Exemplo n.º 3
0
    protected void gvCoordinators_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DisplayUser ds     = e.Row.DataItem as DisplayUser;
            User        user   = UserService.GetUser(ds.Id);
            School      school = RegionService.GetSchoolByUser(user);

            Label      labSchool   = e.Row.FindControl("labSchool") as Label;
            Label      labCaption  = e.Row.FindControl("labCaption") as Label;
            Image      imgPhoto    = e.Row.FindControl("imgGroupPhoto") as Image;
            LinkButton lnkDownLoad = e.Row.FindControl("lnkDownLoad") as LinkButton;

            labSchool.Text = school.Name;

            IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.User, user.Id);
            Attachment         image       = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.GroupPhoto);
            if (null != image)
            {
                imgPhoto.Visible            = true;
                imgPhoto.ImageUrl           = "~/ImageHandler.ashx?id=" + image.Id;
                lnkDownLoad.CommandArgument = image.Id.ToString();
            }
            IList <KeyValue> keyValues = PortfolioService.GetKeyValues(ObjectTypes.User, user.Id);
            var val = keyValues.FirstOrDefault(x => "GroupCaption".Equals(x.KeyName) && x.Type == KeyValueType.String);
            if (val != null)
            {
                labCaption.Text = val.StringValue;
            }
        }
    }
Exemplo n.º 4
0
    protected void valTrans_ServerValidate(object source, ServerValidateEventArgs args)
    {
        Portfolio          portfolio   = PortfolioService.GetPortfolio(PortfolioId);
        IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, portfolio.Id);

        if (attachments.FirstOrDefault(x => x.Category == AttachmentCategory.Transcript) == null)
        {
            args.IsValid = false;
        }
    }
Exemplo n.º 5
0
    protected void lnkTrans_Click(object sender, EventArgs e)
    {
        Portfolio          portfolio   = GetPortfolio();
        IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, portfolio.Id);
        Attachment         attachment  = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.Transcript);

        if (null == attachment)
        {
            ShowUploadDlg(-1, AttachmentCategory.Transcript, "Upload Transcript", "A certified list of high school grades must be included in your profile. This transcript must be stamped, bearing the official school seal or principal's signature and MUST include class ranking, cumulative GPA and ACT scores. Proof of ACT scores is required if not on the transcript.");
        }
        else
        {
            ShowUploadDlg(attachment.Id, AttachmentCategory.Transcript, "Upload Transcript", "A certified list of high school grades must be included in your profile. This transcript must be stamped, bearing the offical school seal or principal's signature and MUST include class ranking, cumulative GPA and ACT scores. Proof of ACT scores is required if not on the transcript.");
        }
    }
Exemplo n.º 6
0
    protected void lnkPicture_Click(object sender, EventArgs e)
    {
        Portfolio          portfolio   = GetPortfolio();
        IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, portfolio.Id);
        Attachment         image       = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.PersonalPhoto);

        if (null == image)
        {
            ShowUploadDlg(-1, AttachmentCategory.PersonalPhoto, "Upload Photo", "Personal photos must be in JPG or PNG format and should be no larger than 640 x 480 pixels. Images will be automatically resized to these dimensions but we recommend resizing your images before you upload them to avoid any potential problems.");
        }
        else
        {
            ShowUploadDlg(image.Id, AttachmentCategory.PersonalPhoto, "Upload Photo", "Personal photos must be in JPG or PNG format and should be no larger than 640 x 480 pixels. Images will be automatically resized to these dimensions but we recommend resizing your images before you upload them to avoid any potential problems.");
        }
    }
Exemplo n.º 7
0
    protected void lnkLetter_Click(object sender, EventArgs e)
    {
        Portfolio          portfolio   = GetPortfolio();
        IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, portfolio.Id);
        Attachment         image       = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.LetterOfRecomendation);

        if (null == image)
        {
            ShowUploadDlg(-1, AttachmentCategory.LetterOfRecomendation, "Upload Letter of Recommendation", "Include a Letter of Recommendation from any teacher or instructor in a supported format.");
        }
        else
        {
            ShowUploadDlg(image.Id, AttachmentCategory.LetterOfRecomendation, "Upload Letter of Recommendation", "Include a Letter of Recommendation from any teacher or instructor in a supported format.");
        }
    }
Exemplo n.º 8
0
    protected void lnkViewTrans_Click(object sender, EventArgs e)
    {
        IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, PortfolioId);
        Attachment         attachment  = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.Transcript);

        if (null != attachment)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=JavaScript id='openit'>");
            sb.Append("window.open('../DocView.aspx?id=" + attachment.Id + "', '', '');");
            sb.Append("</script>");
            if (!ClientScript.IsStartupScriptRegistered("openit"))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "openit", sb.ToString());
            }
        }
    }
Exemplo n.º 9
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        FileUpload fileUpload            = modalDialog.FindControl("txtFileUpload") as FileUpload;
        Label      lblAttachmentCategory = modalDialog.FindControl("lblAttachmentCategory") as Label;
        Label      lblUploadInstructions = modalDialog.FindControl("lblUploadInstructions") as Label;
        Label      lblAttachmentName     = modalDialog.FindControl("lblAttachmentName") as Label;
        Label      lblAttachmentId       = modalDialog.FindControl("lblAttachmentId") as Label;

        AttachmentCategory category = (AttachmentCategory)Enum.Parse(typeof(AttachmentCategory), lblAttachmentCategory.Text);

        this.Validate("Upload");

        if (this.IsValid && null != fileUpload && fileUpload.HasFile && FileUtils.IsValidFile(fileUpload.FileName))
        {
            IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, PortfolioId);
            int        id         = Convert.ToInt32(lblAttachmentId.Text);
            Attachment attachment = attachments.FirstOrDefault(x => x.Id == id);
            if (null == attachment)
            {
                attachment             = new Attachment();
                attachment.Type        = AttachmentType.Portfolio;
                attachment.ObjectRowId = PortfolioId;
            }
            attachment.Category    = category;
            attachment.Description = lblAttachmentName.Text;
            attachment.Name        = fileUpload.FileName;

            using (BinaryReader reader = new BinaryReader(fileUpload.FileContent))
            {
                byte[] buf = reader.ReadBytes((int)fileUpload.FileContent.Length);
                reader.Close();
                fileUpload.FileContent.Close();
                if (FileUtils.IsImageFile(attachment.Name))
                {
                    attachment.Data = buf;// ImageUtils.NormalizeImage(buf);
                }
                else
                {
                    attachment.Data = buf;
                }
            }
            PortfolioService.SaveAttachment(attachment);
            modalDialog.HideModal();
            LoadApplication();
        }
    }
Exemplo n.º 10
0
    /// <summary>
    /// Load all applications for this school
    /// </summary>
    private void LoadApplications()
    {
        School            school = GetSchool();
        IList <Portfolio> list   = PortfolioService.GetPortfolios(school);

        //lnkSubmit.Visible = (list.FirstOrDefault(x => x.Status != ApplicationStatus.Certified) == null);
        gvNominees.DataSource = list;
        gvNominees.DataBind();

        IList <Category> missing    = new List <Category>();
        IList <Category> categories = CategoryService.GetCategories(school.Area.Region);

        foreach (Category c in categories)
        {
            if (list.FirstOrDefault(x => x.Category.Name.Equals(c.Name)) == null)
            {
                missing.Add(c);
            }
        }
        lvMissingCats.DataSource = missing;
        lvMissingCats.DataBind();

        IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.User, CurrentUser.Id);
        Attachment         image       = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.GroupPhoto);

        if (null != image)
        {
            imgPhoto.Visible  = true;
            imgPhoto.ImageUrl = "~/ImageHandler.ashx?id=" + image.Id;
        }
        IList <KeyValue> keyValues = PortfolioService.GetKeyValues(ObjectTypes.User, CurrentUser.Id);
        var val = keyValues.FirstOrDefault(x => "GroupCaption".Equals(x.KeyName) && x.Type == KeyValueType.String);

        if (val != null)
        {
            txtCaption.Text = val.StringValue;
        }
    }
Exemplo n.º 11
0
    private void LoadData()
    {
        //public virtual int Id { get; set; }
        //public virtual string  { get; set; }
        //public virtual string Description { get; set; }
        //public virtual int  { get; set; }
        string where = " where 1=1 ";

        if (ddlCategory.SelectedValue != "-1")
        {
            AttachmentCategory category = (AttachmentCategory)Enum.Parse(typeof(AttachmentCategory), ddlCategory.SelectedValue.ToString());
            where += " and a.Category = " + (int)category;
        }
        if (ddlType.SelectedValue != "-1")
        {
            AttachmentType type = (AttachmentType)Enum.Parse(typeof(AttachmentType), ddlType.SelectedValue.ToString());
            where += " and a.Type = " + (int)type;
        }
        if (!String.IsNullOrEmpty(txtDescription.Text))
        {
            where += " and (a.Description like '%" + txtDescription.Text + "%')";
        }
        if (!String.IsNullOrEmpty(txtName.Text))
        {
            where += " and (a.Name like '%" + txtName.Text + "%')";
        }
        if (!String.IsNullOrEmpty(txtObjectRow.Text))
        {
            where += " and (a.ObjectRowId = " + txtObjectRow.Text + ")";
        }
        // string orderby = (SortDirection == SortDirection.Ascending) ? " order by " + SortColumn + " ASC " : " order by " + SortColumn + " DESC ";
        IList <Attachment> list = PortfolioService.GetAttachments(where);

        gvAttachments.DataSource = list;
        gvAttachments.DataBind();
    }
Exemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string       report = Request["report"];
            MemoryStream stream = null;

            if ("profile".Equals(report))
            {
                string id           = Request["id"];
                String UrlDirectory = Request.Url.GetLeftPart(UriPartial.Path);
                UrlDirectory = UrlDirectory.Substring(0, UrlDirectory.LastIndexOf("/"));
                Portfolio portfolio = PortfolioService.GetPortfolio(Convert.ToInt32(id));
                if (CurrentUser.Role == RoleType.Nominee)
                {
                    if (portfolio.User.Id != CurrentUser.Id)
                    {
                        portfolio = PortfolioService.GetPortfolioByUser(CurrentUser);
                    }
                }
                else if (CurrentUser.Role == RoleType.Coordinator)
                {
                    School school = RegionService.GetSchoolByUser(CurrentUser);
                    if (portfolio.School.Id != school.Id)
                    {
                        portfolio = null;
                    }
                }
                if (null != portfolio)
                {
                    IList <Attachment> list = PortfolioService.GetAttachments(AttachmentCategory.Portfolio, AttachmentType.FinalPortfolio, portfolio.Id);
                    if (list.Count > 0)
                    {
                        stream = new MemoryStream();
                        Attachment attachment = PortfolioService.GetAttachment(list[0].Id);
                        stream.Write(attachment.Data, 0, attachment.Data.Length);
                    }
                    else
                    {
                        stream = ReportService.CreatePortfolioReport(portfolio, UrlDirectory);
                    }
                }
            }
            if ("principal".Equals(report))
            {
                if (CurrentUser.Role == RoleType.Principal || CurrentUser.Role == RoleType.Coordinator)
                {
                    string    id        = Request["id"];
                    Portfolio portfolio = PortfolioService.GetPortfolio(Convert.ToInt32(id));
                    stream = ReportService.CreatePrincipalReport(portfolio);
                }
                else
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
            if ("nominees".Equals(report))
            {
                if (CurrentUser.Role != RoleType.Nominee)
                {
                    string id     = Request["id"];
                    School school = RegionService.GetSchool(Convert.ToInt32(id));
                    stream = ReportService.NomineeReport(school);
                }
                else
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
            Response.Clear();
            Response.ContentType = "application/pdf";

            Response.OutputStream.Write(stream.GetBuffer(), 0, (int)stream.GetBuffer().Length);
            Response.OutputStream.Flush();
            Response.OutputStream.Close();
            Response.End();
        }
    }
Exemplo n.º 13
0
    private void SavePortfolio(int index)
    {
        Portfolio portfolio = GetPortfolio();

        switch (index)
        {
        case 0:
            CurrentUser.FullName    = txtName.Text;
            portfolio.Parents       = txtParents.Text;
            portfolio.Address       = txtAddress.Text;
            portfolio.City          = txtCity.Text;
            portfolio.State         = ddlState.SelectedValue;
            portfolio.Zip           = txtZip.Text;
            CurrentUser.PhoneNumber = txtPhone.Text;
            portfolio.Sex           = (Sexes)Enum.Parse(typeof(Sexes), ddlGender.SelectedValue.ToString());
            UserService.SaveUser(CurrentUser);
            break;

        case 1:
            SavePortfolio(portfolio);
            break;

        case 2:
            break;

        case 3:
            for (int i = 0; i < 6; i++)
            {
                TextBox tb = AccordianControl.FindControl("txtCategory" + i.ToString()) as TextBox;
                if (tb != null && !string.IsNullOrEmpty(tb.Text))
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Category, i);
                    item.Text = tb.Text;
                }
                else
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Category, i);
                    if (null != item)
                    {
                        PortfolioService.RemovePortfolioItem(portfolio, ItemType.Category, i);
                    }
                }
            }
            break;

        case 4:
        {
            if (!String.IsNullOrEmpty(txtCategoryDescription.Text))
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.CategoryDescription, 0);
                item.Text = txtCategoryDescription.Text;
            }
            else
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.CategoryDescription, 0);
                if (null != item)
                {
                    PortfolioService.RemovePortfolioItem(portfolio, ItemType.CategoryDescription, 0);
                }
            }
        }
        break;

        case 5:
            for (int i = 0; i < 6; i++)
            {
                TextBox tb = AccordianControl.FindControl("txtLeadership" + i.ToString()) as TextBox;
                if (tb != null && !string.IsNullOrEmpty(tb.Text))
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Leadership, i);
                    item.Text = tb.Text;
                }
                else
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Leadership, i);
                    if (null != item)
                    {
                        PortfolioService.RemovePortfolioItem(portfolio, ItemType.Leadership, i);
                    }
                }
            }
            break;

        case 6:
            if (!String.IsNullOrEmpty(txtLeadershipDescription.Text))
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.LeadershipDescription, 0);
                item.Text = txtLeadershipDescription.Text;
            }
            else
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.LeadershipDescription, 0);
                if (null != item)
                {
                    PortfolioService.RemovePortfolioItem(portfolio, ItemType.LeadershipDescription, 0);
                }
            }
            break;

        case 7:
            for (int i = 0; i < 6; i++)
            {
                TextBox tb = AccordianControl.FindControl("txtCitizenship" + i.ToString()) as TextBox;
                if (tb != null && !string.IsNullOrEmpty(tb.Text))
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Citizenship, i);
                    item.Text = tb.Text;
                }
                else
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Citizenship, i);
                    if (null != item)
                    {
                        PortfolioService.RemovePortfolioItem(portfolio, ItemType.Citizenship, i);
                    }
                }
            }
            break;

        case 8:
            if (!String.IsNullOrEmpty(txtCitizenshipDescription.Text))
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.CitizenshipDescription, 0);
                item.Text = txtCitizenshipDescription.Text;
            }
            else
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.CitizenshipDescription, 0);
                if (null != item)
                {
                    PortfolioService.RemovePortfolioItem(portfolio, ItemType.CitizenshipDescription, 0);
                }
            }
            break;

        case 9:
            if (!String.IsNullOrEmpty(txtUniqueQualities.Text))
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.UniqueQualities, 0);
                item.Text = txtUniqueQualities.Text;
            }
            else
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.UniqueQualities, 0);
                if (null != item)
                {
                    PortfolioService.RemovePortfolioItem(portfolio, ItemType.UniqueQualities, 0);
                }
            }
            break;

        case 10:

            if (!String.IsNullOrEmpty(txtLifeEnrichment.Text))
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.LifeEnrichment, 0);
                item.Text = txtLifeEnrichment.Text;
            }
            else
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.LifeEnrichment, 0);
                if (null != item)
                {
                    PortfolioService.RemovePortfolioItem(portfolio, ItemType.LifeEnrichment, 0);
                }
            }
            break;

        case 11:
        {
            IList <Attachment> list = PortfolioService.GetAttachments(AttachmentCategory.Url, AttachmentType.Portfolio, portfolio.Id);
            var attachment          = list.FirstOrDefault(x => "Document".Equals(x.Name));
            if (!string.IsNullOrEmpty(txtDocLink.Text))
            {
                SaveUrl(attachment, "Document", txtDocDescription.Text, txtDocLink.Text, portfolio);
            }
            else if (null != attachment)
            {
                PortfolioService.DeleteAttachment(attachment);
            }
            attachment = list.FirstOrDefault(x => "Image".Equals(x.Name));
            if (!string.IsNullOrEmpty(txtImageLink.Text))
            {
                SaveUrl(attachment, "Image", txtImageDescription.Text, txtImageLink.Text, portfolio);
            }
            else if (null != attachment)
            {
                PortfolioService.DeleteAttachment(attachment);
            }
            attachment = list.FirstOrDefault(x => "Media".Equals(x.Name));
            if (!string.IsNullOrEmpty(txtMediaLink.Text))
            {
                SaveUrl(attachment, "Media", txtMediaDescription.Text, txtMediaLink.Text, portfolio);
            }
            else if (null != attachment)
            {
                PortfolioService.DeleteAttachment(attachment);
            }
            break;
        }

        default:
            break;
        }
        PortfolioService.Save(portfolio);
    }
Exemplo n.º 14
0
    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);
        }
    }
Exemplo n.º 15
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;
        }
    }