Example #1
0
        //calculate price and apply the discount depending how far in the future the booking is made for
        private void calculatePrice(DateTime bookeddate, bool remove)
        {
            PricesDB pdb      = new PricesDB(db);
            int      baserate = pdb.getBase();

            if (bookeddate > DateTime.Now.AddMonths(3) && bookeddate < DateTime.Now.AddMonths(6))
            {
                currentDiscount = pdb.getMedDiscount(); //medium discount applied
            }
            else if (bookeddate >= DateTime.Now.AddMonths(6))
            {
                currentDiscount = pdb.getMaxDiscount(); //max discount applied
            }
            else
            {
                currentDiscount = pdb.getMinDiscount(); //min discount applied
            }
            currentprice = baserate * (1 - currentDiscount / 100);
            if (remove)//check if we want to remove the cost
            {
                finalprice  -= currentprice * 5;
                childsprice -= currentprice * 5;
            }
            else
            {
                finalprice  += currentprice * 5;
                childsprice += currentprice * 5;
            }

            totalpricelbl.Visible = true;
            totalpricelbl.Text    = "Total Price: £" + (finalprice).ToString("00.00");//calculate cost and display on a label
        }
Example #2
0
        //setup the prices on load
        private void setPrices()
        {
            PricesDB pdb = new PricesDB(db);

            Base.Value = pdb.getBase();
            MinD.Value = pdb.getMinDiscount();
            MedD.Value = pdb.getMedDiscount();
            MaxD.Value = pdb.getMaxDiscount();
        }
Example #3
0
        //calculate the price to pay including discounts
        private void setPrice(List <DateTime> dates)
        {
            double   discount        = 0;
            string   discountApplied = "";
            PricesDB pdb             = new PricesDB(db);
            int      baseprice       = pdb.getBase(); //reduce load on db
            double   price           = 0;

            foreach (DateTime date in dates)
            {
                if (date >= DateTime.Now.AddMonths(6))
                {
                    discount        = pdb.getMaxDiscount();
                    discountApplied = discount.ToString() + "%";
                }
                else if (date > DateTime.Now.AddMonths(3) && date < DateTime.Now.AddMonths(6))
                {
                    discount        = pdb.getMedDiscount();
                    discountApplied = discount.ToString() + "%";
                }
                else
                {
                    discount        = pdb.getMinDiscount();
                    discountApplied = discount.ToString() + "%";
                }
                price += (baseprice) * (1 - (discount / 100) * 5);
            }
            if (discount == 0)
            {
                discountlbl.Text = "Discount Applied: None";
            }
            else
            {
                discountlbl.Text = "Discount Applied: " + discountApplied;
            }
            totalpricelbl.Text = "Total Price: £" + price.ToString("00.00");
        }