Exemplo n.º 1
0
        private void savetodb()
        {
            //add customer to Database
            BookingDB book = new BookingDB(db);

            if (existingcustomer == null) //if no existing customer
            {
                book.Addcustomer(cust.Forename, cust.Surname, cust.TeleNo, cust.Postcode, cust.Address);
            }
            else
            {
                cust = existingcustomer;
            }

            if (existingkid != null) // if existing kid
            {
                foreach (DateTime date in finishedbookings[0].Mondays)
                {
                    if (alreadybooked.Contains(date))
                    {
                        finishedbookings[0].Mondays.Remove(date);
                        book.UpdateDate(date, existingkid.Forename, existingkid.Surname);
                    }
                }
                book.AddDate(finishedbookings[0].Mondays, existingkid.Forename, existingkid.Surname); // add dates to db
                if (Dates2Remove.Count > 0)
                {
                    book.removeDate(Dates2Remove, existingkid.Forename, existingkid.Surname); //remove dates that have been unbooked
                }
            }
            else //else add new kids/bookings
            {
                int i = 0;
                foreach (Kid child in kids)
                {
                    book.Addkid(child.Forename, child.Surname, child.DOB, cust.Forename, cust.Surname);
                    book.AddBooking(child.Forename, MiscFunctions.getgroupfromage(child.DOB), finishedbookings[i].Days[0], finishedbookings[i].Days[1], finishedbookings[i].Days[2], finishedbookings[i].Days[3], finishedbookings[i].Days[4], child.Surname);
                    book.AddDate(finishedbookings[i].Mondays, child.Forename, child.Surname);
                    if (Dates2Remove.Count > 0)
                    {
                        book.removeDate(Dates2Remove, child.Forename, child.Surname);
                    }
                    i++;
                }
            }



            MessageBox.Show("Booking completed");
            CrecheMenu next = new Gui.CrecheMenu();

            this.Hide();
            next.Show();
        }
Exemplo n.º 2
0
 public static void AddBooking(string Firstname, string Lastname, List <Room> Rooms, DateTime BeginDate, DateTime EndDate, int NbPerson)
 {
     BookingDB.AddBooking(Firstname, Lastname, Rooms, BeginDate, EndDate, NbPerson);
 }