Ejemplo n.º 1
0
        public static string PerpareQuotationRequestEmail(Enquiry enquiry, string templatePath)
        {
            string readTemplateFile = string.Empty;

            using (StreamReader streamReader = new StreamReader(System.Web.HttpContext.Current.Server.MapPath(templatePath)))
            {
                readTemplateFile = streamReader.ReadToEnd();

                readTemplateFile = readTemplateFile.Replace("$$CATEGORY$$", HtmlDropDownExtensions.GetEnumDisplay(enquiry.Category));
                readTemplateFile = readTemplateFile.Replace("$$GOODS_DESCRIPTION$$", enquiry.GoodsDescription);
                readTemplateFile = readTemplateFile.Replace("$$PLANNED_SHIPMENT_DATE$$", enquiry.PlannedShipmentTime.ToLongDateString());
                readTemplateFile = readTemplateFile.Replace("$$ORIGIN_CITYY$$", enquiry.OriginCity);
                readTemplateFile = readTemplateFile.Replace("$$ORIGIN_COUNTRY$$", enquiry.OriginCountry.Name);
                readTemplateFile = readTemplateFile.Replace("$$DESTINATION_CITY$$", enquiry.DestinationCity);
                readTemplateFile = readTemplateFile.Replace("$$DESTINATION_COUNTRY$$", enquiry.DestinationCountry.Name);
                readTemplateFile = readTemplateFile.Replace("$$NUMBER_OF_PACKAGES$$", enquiry.NumberOfPackages.ToString());
                readTemplateFile = readTemplateFile.Replace("$$GROSS_WEIGHT$$", enquiry.GrossWeight.ToString());
                readTemplateFile = readTemplateFile.Replace("$$VOLUMETRIC_WEIGHT$$", enquiry.VolumetricWeight.ToString());

                if (enquiry.InsuranceRequired)
                {
                    readTemplateFile = readTemplateFile.Replace("$$INSURANCE_REQUIRED$$", "is insured");
                }
            }

            return(readTemplateFile);
        }
Ejemplo n.º 2
0
        public static string PrepareCustomerConfirmationEmail(Enquiry enquiry, string templatePath)
        {
            string readTemplateFile = string.Empty;

            using (StreamReader streamReader = new StreamReader(System.Web.HttpContext.Current.Server.MapPath(templatePath)))
            {
                readTemplateFile = streamReader.ReadToEnd();

                if (enquiry is PotentialCustomerEnquiry)
                {
                    readTemplateFile = readTemplateFile.Replace("$$FIRST_NAME$$", ((PotentialCustomerEnquiry)enquiry).FirstName);
                }
                else if (enquiry is ExistingCustomerEnquiry)
                {
                    if (((ExistingCustomerEnquiry)enquiry).Customer is Individual)
                    {
                        readTemplateFile = readTemplateFile.Replace("$$FIRST_NAME$$", (((Individual)((ExistingCustomerEnquiry)enquiry).Customer)).FirstName);
                    }
                    else if (((ExistingCustomerEnquiry)enquiry).Customer is Company)
                    {
                        readTemplateFile = readTemplateFile.Replace("$$FIRST_NAME$$", "Sir/Madam");
                    }
                }

                readTemplateFile = readTemplateFile.Replace("$$CATEGORY$$", HtmlDropDownExtensions.GetEnumDisplay(enquiry.Category));
                readTemplateFile = readTemplateFile.Replace("$$GOODS_DESCRIPTION$$", enquiry.GoodsDescription);
                readTemplateFile = readTemplateFile.Replace("$$PLANNED_SHIPMENT_DATE$$", enquiry.PlannedShipmentTime.ToLongDateString());
                readTemplateFile = readTemplateFile.Replace("$$ORIGIN_CITYY$$", enquiry.OriginCity);
                readTemplateFile = readTemplateFile.Replace("$$ORIGIN_COUNTRY$$", enquiry.OriginCountry.Name);
                readTemplateFile = readTemplateFile.Replace("$$DESTINATION_CITY$$", enquiry.DestinationCity);
                readTemplateFile = readTemplateFile.Replace("$$DESTINATION_COUNTRY$$", enquiry.DestinationCountry.Name);
                readTemplateFile = readTemplateFile.Replace("$$NUMBER_OF_PACKAGES$$", enquiry.NumberOfPackages.ToString());
                readTemplateFile = readTemplateFile.Replace("$$GROSS_WEIGHT$$", enquiry.GrossWeight.ToString());
                readTemplateFile = readTemplateFile.Replace("$$VOLUMETRIC_WEIGHT$$", enquiry.VolumetricWeight.ToString());

                if (enquiry.InsuranceRequired)
                {
                    readTemplateFile = readTemplateFile.Replace("$$INSURANCE_REQUIRED$$", "is insured");
                }
            }

            return(readTemplateFile);
        }
Ejemplo n.º 3
0
        public static FileContentResult GenerateQuote(Enquiry enquiry, string filePath)
        {
            HSSFWorkbook templateWorkbook;

            using (FileStream templateFileStream = new FileStream(System.Web.HttpContext.Current.Server.MapPath(filePath), FileMode.Open, FileAccess.Read))
            {
                templateWorkbook = new HSSFWorkbook(templateFileStream, true);

                ISheet workSheet = templateWorkbook.GetSheet("Estimate");

                // Row 9
                IRow dataRow = workSheet.GetRow(8);

                if (enquiry is PotentialCustomerEnquiry)
                {
                    // Cell A9
                    dataRow.GetCell(0).SetCellValue(((PotentialCustomerEnquiry)enquiry).Company);
                    // Cell B9
                    dataRow.GetCell(1).SetCellValue(((PotentialCustomerEnquiry)enquiry).FirstName);
                    // Cell C9
                    dataRow.GetCell(2).SetCellValue(((PotentialCustomerEnquiry)enquiry).EmailAddress);
                    // Cell D9
                    dataRow.GetCell(3).SetCellValue(((PotentialCustomerEnquiry)enquiry).ContactNumber);
                }
                else if (enquiry is ExistingCustomerEnquiry)
                {
                    // Cell A9
                    dataRow.GetCell(0).SetCellValue(((ExistingCustomerEnquiry)enquiry).Customer.DisplayName);

                    if (((ExistingCustomerEnquiry)enquiry).Customer is Individual)
                    {
                        // Cell B9
                        dataRow.GetCell(1).SetCellValue(((ExistingCustomerEnquiry)enquiry).Customer.DisplayName);
                    }
                    else
                    {
                        // Cell B9
                        dataRow.GetCell(1).SetCellValue("-");
                    }
                    // Cell C9
                    dataRow.GetCell(2).SetCellValue(((ExistingCustomerEnquiry)enquiry).Customer.EmailAddress);
                    // Cell D9
                    dataRow.GetCell(3).SetCellValue(((ExistingCustomerEnquiry)enquiry).Customer.ContactNumber);
                }
                // Cell E9
                dataRow.GetCell(4).SetCellValue(HtmlDropDownExtensions.GetEnumDisplay(enquiry.Category));
                // Cell F9
                dataRow.GetCell(5).SetCellValue(enquiry.CreateDate.ToShortDateString());

                // Row 12
                dataRow = workSheet.GetRow(11);
                // Cell A12
                dataRow.GetCell(0).SetCellValue(enquiry.OriginCity + ", " + enquiry.OriginCountry.Name);
                // Cell C12
                dataRow.GetCell(2).SetCellValue(enquiry.DestinationCity + ", " + enquiry.DestinationCountry.Name);

                // Row 19
                dataRow = workSheet.GetRow(18);
                // Cell A19
                dataRow.GetCell(0).SetCellValue(enquiry.NumberOfPackages);
                // Cell A19
                dataRow.GetCell(1).SetCellValue(enquiry.VolumetricWeight.ToString());
                // Cell A19
                dataRow.GetCell(2).SetCellValue(enquiry.GrossWeight.ToString());

                // Enable formula re-calculation
                workSheet.ForceFormulaRecalculation = true;
            }

            MemoryStream memoryStream = new MemoryStream();

            templateWorkbook.Write(memoryStream);

            FileContentResult fileContentResult = new FileContentResult(memoryStream.ToArray(), "application/vnd.ms-excel");

            fileContentResult.FileDownloadName = "TranryEstimate.xls";

            return(fileContentResult);
        }