Exemplo n.º 1
0
        private void resetAvailabilityToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var AvailabilityQuery = from x in context.Availability select x;
            var availabilities    = AvailabilityQuery.ToList <Availability>();

            foreach (Availability a in availabilities)
            {
                a.C9am  = false;
                a.C10am = false;
                a.C11am = false;
                a.C12pm = false;
                a.C1pm  = false;
                a.C2pm  = false;
                a.C3pm  = false;
                a.C4pm  = false;
                a.C5pm  = false;
            }

            context.SaveChanges();
            RefreshAvailabilityDataGrid();
        }
Exemplo n.º 2
0
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            BookingCompleteDialog bookingCompleteDialog = new BookingCompleteDialog();

            bookingCompleteDialog.Location     = this.Location;
            bookingCompleteDialog.FormClosing += delegate {
                ConfirmButton.Enabled          = false;
                this.toolStripStatusLabel.Text = "Booking has been completed!";
                ConfirmationLabel.Visible      = true;
            };

            try
            {
                // Build a new Booking transaction object to insert into
                BookingTransaction newBookingTransaction = new BookingTransaction()
                {
                    CustomerID  = this.customerId,
                    VenueID     = this.venueID,
                    DateCreated = DateTime.Now,
                    BookedDate  = bookedDate,
                    BookedHour  = timeslot,
                    Status      = "Confirmed",
                    Remark      = remark
                };
                context.BookingTransaction.Add(newBookingTransaction);
                context.SaveChanges();

                context = new SportsFacilitiesEntities();

                // Update the availability table to show that the timeslot is occupied
                var          query        = from x in context.Availability where venueID == x.VenueID select x;
                Availability availability = query.First();

                switch (timeslot)
                {
                case "9am":
                    availability.C9am = true;
                    break;

                case "10am":
                    availability.C10am = true;
                    break;

                case "11am":
                    availability.C11am = true;
                    break;

                case "12pm":
                    availability.C12pm = true;
                    break;

                case "1pm":
                    availability.C1pm = true;
                    break;

                case "2pm":
                    availability.C2pm = true;
                    break;

                case "3pm":
                    availability.C3pm = true;
                    break;

                case "4pm":
                    availability.C4pm = true;
                    break;

                case "5pm":
                    availability.C5pm = true;
                    break;
                }
            }

            catch (Exception ex)
            {
                toolStripStatusLabel.Text = ex.ToString();
                Console.WriteLine("\n\n" + ex.ToString());
            }

            context.SaveChanges();
            bookingCompleteDialog.ShowDialog();
        }