Пример #1
0
        public DisplayQuote(Desk desk, DeskQuote quote)
        {
            InitializeComponent();
            name.Text            = quote.CustName;
            width.Text           = desk.Width.ToString() + " inches";
            depth.Text           = desk.Depth.ToString() + " inches";
            drawerCount.Text     = desk.DrawerCount.ToString();
            surfaceMaterial.Text = desk.SurfaceMaterial.ToString();
            deliveryTime.Text    = quote.DeliveryTime.ToString() + " Days";
            CostBreakDown costDetail = quote.CalcCost(desk, quote);
            int           aCost      = costDetail.areaCost;
            int           mCost      = costDetail.materialCost;
            int           rCost      = costDetail.rushCost;
            int           dCost      = costDetail.drawerCost;

            areaCost.Text     = "$" + aCost.ToString();
            materialCost.Text = "$" + mCost.ToString();
            rushCost.Text     = "$" + rCost.ToString();
            drawerCost.Text   = "$" + dCost.ToString();
            totalCost.Text    = "$" + quote.Cost.ToString();
            quoteDate.Text    = quote.OrderDate.ToString();
        }
Пример #2
0
        public CostBreakDown CalcCost(Desk desk, DeskQuote quote)
        {
            const int baseCost     = 200;
            int       areaCost     = 0;
            int       drawerCost   = desk.DrawerCount * 50;
            int       surfaceCost  = 0;
            int       deliveryCost = 0;
            double    totalCost    = 0;

            int area = desk.Width * desk.Depth;

            if (area > 1000)
            {
                areaCost = (area - 1000);
            }

            switch (desk.SurfaceMaterial)
            {
            case Material.Laminate:
                surfaceCost = 100;
                break;

            case Material.Oak:
                surfaceCost = 200;
                break;

            case Material.Pine:
                surfaceCost = 50;
                break;

            case Material.Rosewood:
                surfaceCost = 300;
                break;

            case Material.Veneer:
                surfaceCost = 125;
                break;
            }
            //Calc delivery Cost
            if (quote.DeliveryTime == 3)
            {
                if (area < 1000)
                {
                    deliveryCost = 60;
                }
                else if (area > 2000)
                {
                    deliveryCost = 80;
                }
                else
                {
                    deliveryCost = 70;
                }
            }

            if (quote.DeliveryTime == 5)
            {
                if (area < 1000)
                {
                    deliveryCost = 40;
                }
                else if (area > 2000)
                {
                    deliveryCost = 60;
                }
                else
                {
                    deliveryCost = 50;
                }
                if (quote.DeliveryTime == 7)
                {
                    if (area < 1000)
                    {
                        deliveryCost = 30;
                    }
                    else if (area > 2000)
                    {
                        deliveryCost = 40;
                    }
                    else
                    {
                        deliveryCost = 35;
                    }
                }
            }

            totalCost = baseCost + areaCost + drawerCost + surfaceCost + deliveryCost;
            this.Cost = totalCost;

            CostBreakDown costDetail = new CostBreakDown(areaCost, surfaceCost, deliveryCost, drawerCost);

            return(costDetail);
        }