コード例 #1
0
        private void ShowPriceSummary()
        {
            var engine = new Discounts.DiscountsEngine(Quote);

            var output = new StringBuilder();

            output.Append(
                string.Format("<table cellpadding=3 cellspacing=3><tr><td>Policy base price: </td><td>${0:####0.00}</td></tr>", engine.BasePolicyPrice));

            foreach (var driver in Quote.Drivers)
            {
                var discountString = string.Empty;
                foreach (var discount in driver.DriverDiscounts)
                {
                    discountString += string.Format("{0} ({1}%)&#013;", discount.DiscountPerState.Discount.DiscountName, discount.AppliedDiscountValue);
                }
                discountString += string.Format("TOTAL: {0}%", driver.DriverDiscounts.Sum(d => d.AppliedDiscountValue));

                output.Append(
                    string.Format(
                        "<tr><td>Driver: {0} {1}:</td><td>${2:####0.00}</td><td><img valign='bottom' src='Styles/help.png' title='{3}' /></td></tr>", driver.FirstName, driver.LastName, engine.PriceDriver(driver), discountString));
            }

            foreach (var vehicle in Quote.Vehicles)
            {
                var discountString = string.Empty;
                foreach (var discount in vehicle.VehicleDiscounts)
                {
                    discountString += string.Format("{0} ({1}%)&#013;", discount.DiscountPerState.Discount.DiscountName, discount.AppliedDiscountValue);
                }
                discountString += string.Format("TOTAL: {0}%", vehicle.VehicleDiscounts.Sum(d => d.AppliedDiscountValue));

                output.Append(
                    string.Format(
                        "<tr><td>Vehicle: {0} {1} {2}:</td><td>${3:####0.00}</td><td><img valign='bottom' src='Styles/help.png' title='{4}' /></td></tr>",
                        vehicle.Make,
                        vehicle.Model,
                        vehicle.Year,
                        engine.PriceVehicle(vehicle),
                        discountString));
            }

            var quoteDiscountString = string.Empty;

            foreach (var discount in Quote.QuoteDiscounts)
            {
                quoteDiscountString += string.Format("{0} ({1}%)&#013;", discount.DiscountPerState.Discount.DiscountName, discount.AppliedDiscountValue);
            }
            quoteDiscountString += string.Format("TOTAL: {0}%", Quote.QuoteDiscounts.Sum(d => d.AppliedDiscountValue));

            output.Append(
                string.Format("<tr><td>Quote adjustments:</td><td>${0:####0.00}</td><td><img valign='bottom' src='Styles/help.png' title='{1}' /></td></tr>", engine.GetQuoteAdjustment(), quoteDiscountString));

            output.Append("</table>");

            Literal1.Text = output.ToString();

            lblTotal.Text = string.Format("Total policy price: ${0:####0.00}", engine.GetTotalPrice());
        }
コード例 #2
0
        private void ShowPriceSummary()
        {
            var engine = new Discounts.DiscountsEngine(Quote);

            var output = new StringBuilder();

            output.Append(
                string.Format("<table cellpadding=3 cellspacing=3><tr><td>Policy base price: </td><td>${0:####0.00}</td></tr>", engine.BasePolicyPrice));

            foreach (var driver in Quote.Drivers)
            {
                var discountString = string.Empty;
                foreach (var discount in driver.DriverDiscounts)
                {
                    discountString += string.Format("{0} ({1}%)&#013;", discount.DiscountPerState.Discount.DiscountName, discount.AppliedDiscountValue);
                }
                discountString += string.Format("TOTAL: {0}%", driver.DriverDiscounts.Sum(d => d.AppliedDiscountValue));

                output.Append(
                    string.Format(
                        "<tr><td>Driver: {0} {1}:</td><td>${2:####0.00}</td><td><img valign='bottom' src='Styles/help.png' title='{3}' /></td></tr>", driver.FirstName, driver.LastName, engine.PriceDriver(driver), discountString));
            }

            foreach (var vehicle in Quote.Vehicles)
            {
                var discountString = string.Empty;
                foreach (var discount in vehicle.VehicleDiscounts)
                {
                    discountString += string.Format("{0} ({1}%)&#013;", discount.DiscountPerState.Discount.DiscountName, discount.AppliedDiscountValue);
                }
                discountString += string.Format("TOTAL: {0}%", vehicle.VehicleDiscounts.Sum(d => d.AppliedDiscountValue));

                output.Append(
                    string.Format(
                        "<tr><td>Vehicle: {0} {1} {2}:</td><td>${3:####0.00}</td><td><img valign='bottom' src='Styles/help.png' title='{4}' /></td></tr>",
                        vehicle.Make,
                        vehicle.Model,
                        vehicle.Year,
                        engine.PriceVehicle(vehicle),
                        discountString));
            }

            var quoteDiscountString = string.Empty;
            foreach (var discount in Quote.QuoteDiscounts)
            {
                quoteDiscountString += string.Format("{0} ({1}%)&#013;", discount.DiscountPerState.Discount.DiscountName, discount.AppliedDiscountValue);
            }
            quoteDiscountString += string.Format("TOTAL: {0}%", Quote.QuoteDiscounts.Sum(d => d.AppliedDiscountValue));

            output.Append(
                string.Format("<tr><td>Quote adjustments:</td><td>${0:####0.00}</td><td><img valign='bottom' src='Styles/help.png' title='{1}' /></td></tr>", engine.GetQuoteAdjustment(), quoteDiscountString));

            output.Append("</table>");

            Literal1.Text = output.ToString();

            lblTotal.Text = string.Format("Total policy price: ${0:####0.00}", engine.GetTotalPrice());
        }