Esempio n. 1
0
        private string GetValue(string key, BLL.GiftCertificateDetail detail)
        {
            LetterTemplateService letterService = new LetterTemplateService();

            if (!string.IsNullOrEmpty(key) && detail != null)
            {
                switch (key.ToUpper())
                {
                case CertificateDetailFields.CURRENCY:
                    return(letterService.FindById(detail.DCurrencyID).Name);

                case CertificateDetailFields.ACCOUNTNUMBER:
                    return(detail.AccountNumber.ToString());

                case CertificateDetailFields.BILLOFLOADING:
                    return(detail.BillOfLoading);

                case CertificateDetailFields.COMMODITY:
                    return(detail.Commodity.Name);

                case CertificateDetailFields.BUDGETTYPE:
                    return(letterService.FindById(detail.DBudgetTypeID).Name);

                case CertificateDetailFields.FUNDSOURCE:
                    return(letterService.FindById(detail.DFundSourceID).Name);

                case CertificateDetailFields.ESTIMATEDPRICE:
                    return(detail.EstimatedPrice.ToString("N3"));

                case CertificateDetailFields.ESTIMATEDTAX:
                    return(detail.EstimatedPrice.ToString("N3"));

                case CertificateDetailFields.WEIGHTINMT:
                    return(detail.WeightInMT.ToString("N3"));

                case CertificateDetailFields.YEARPURCHASED:
                    return(detail.YearPurchased.ToString());

                case CertificateFields.DONOR:
                    return(detail.GiftCertificate.Donor.Name);

                case CertificateFields.ETA:
                    return(detail.GiftCertificate.ETA.ToShortDateString());

                case CertificateFields.GIFTDATE:
                    return(detail.GiftCertificate.GiftDate.ToShortDateString());

                case CertificateFields.REFERENCENO:
                    return(detail.GiftCertificate.ReferenceNo);

                case CertificateFields.SINUMBER:
                    return(detail.GiftCertificate.SINumber);

                case CertificateFields.VESSEL:
                    return(detail.GiftCertificate.Vessel);
                }
            }
            return(string.Empty);
        }
Esempio n. 2
0
        public string Parse(int certificateId, int templateId)
        {
            IUnitOfWork            repository    = new UnitOfWork();
            LetterTemplateService  letterService = new LetterTemplateService();
            GiftCertificateService giftService   = new GiftCertificateService(repository);

            BLL.GiftCertificate gift = giftService.FindById(certificateId);

            BLL.LetterTemplate template    = letterService.FindById(templateId);
            string             raw         = HttpContext.Current.Server.HtmlDecode(template.Template);
            string             tableString = string.Empty;
            int startIndex = raw.IndexOf("<table id=\"detail\"");//("<table id=\"detail\" style=\"width:100%;\">")

            if (startIndex != -1)
            {
                int lastIndex = raw.IndexOf("</table>", startIndex) + 8;
                if (lastIndex != -1)
                {
                    int length = lastIndex - startIndex;
                    tableString = raw.Substring(startIndex, length);
                }
            }
            if (@tableString != "")
            {
                raw = raw.Replace(@tableString, "{tablePlaceHolder}");
            }
            raw = PopulateCertificate(raw, gift);
            string populatedTable = string.Empty;

            if (@tableString != "")
            {
                populatedTable = PopulateTableData(gift.GiftCertificateDetails.ToList(), tableString.Replace("&nbsp;", ""));
            }
            string finalString = raw.Replace("{tablePlaceHolder}", populatedTable);

            return(finalString);
        }