コード例 #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
        }
コード例 #2
0
        //create table to show the bookings for that week
        private void createTableforBooking(DateTime now, bool cancel)
        {
            table = new DataTable();
            table.Columns.Add("Kid Name");
            table.Columns.Add("Mon");
            table.Columns.Add("Tues");
            table.Columns.Add("Weds");
            table.Columns.Add("Thurs");
            table.Columns.Add("Friday");


            MiscDB miscdb = new MiscDB(db);
            List <List <string> > data = miscdb.BookingDays(now, cancel);

            foreach (List <string> current in data)
            {
                table.Rows.Add(current[0] + " " + current[1]);
            }
            amountlbl.Text              = "Booking amount: " + data.Count.ToString();
            WeekView.DataSource         = table;
            WeekView.AllowUserToAddRows = false;
            int x          = 0;
            int daysbooked = 0;

            foreach (DataGridViewRow row in WeekView.Rows) //need to loop through the rows in order to color the cells accordingly
            {
                List <string> current = data[x];
                for (int i = 0; i < 5; i++)
                {
                    if (current[i + 2] == "1")
                    {
                        row.Cells[i + 1].Style.BackColor = Color.LimeGreen; //green for booked
                        daysbooked++;                                       //count the number of days booked
                    }
                    else
                    {
                        row.Cells[i + 1].Style.BackColor = Color.Red;//red for not booked
                    }
                }
                x++;
            }
            PricesDB pdb = new PricesDB(db);

            revenue          = data.Count * pdb.getBase();
            revenuelbl.Text  = "Estimated revenue: £" + ((data.Count * pdb.getBase()) * daysbooked).ToString(); //not including discounts
            WeekView.Enabled = false;
        }
コード例 #3
0
ファイル: Prices.cs プロジェクト: SlOneRPC/A2Coursework
        //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();
        }
コード例 #4
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");
        }