Exemplo n.º 1
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            using (var context = new HotelBookingsEntities())
            {
                var booking = context.Bookings.Find(Booking.BookingID);
                booking.StartDate  = dtpStartDate.Value.Date;
                booking.EndDate    = dtpEndDate.Value.Date;
                booking.TotalPrice = CalculateAmount();
                context.SaveChanges();
            }

            MessageBox.Show("Booking dates updated.");
            Close();
        }
Exemplo n.º 2
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            using (var context = new HotelBookingsEntities())
            {
                var guest = (from g in context.Guests
                             where g.GuestID == Guest.GuestID
                             select g).SingleOrDefault();

                guest.Name  = txtName.Text;
                guest.Email = txtEmail.Text;
                guest.Phone = txtPhone.Text;
                context.SaveChanges();
            }

            Close();
        }
Exemplo n.º 3
0
        private void cmdSubmit_Click(object sender, EventArgs e)
        {
            using (var context = new HotelBookingsEntities())
            {
                var booking = Booking;
                {
                    booking.Time    = DateTime.Now;
                    booking.GuestID = Guest.GuestID;
                };
                context.Bookings.Add(booking);

                context.SaveChanges();
            }

            Close();
        }
Exemplo n.º 4
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            using (var context = new HotelBookingsEntities())
            {
                var guest = new Guest()
                {
                    Name  = txtName.Text,
                    Email = txtEmail.Text,
                    Phone = txtPhone.Text
                };
                context.Guests.Add(guest);

                context.SaveChanges();
            }

            Close();
        }
Exemplo n.º 5
0
        private void CheckValidBooking()
        {
            using (var context = new HotelBookingsEntities())
            {
                foreach (var booking in Bookings)
                {
                    Booking b = context.Bookings.Find(booking.BookingID);

                    if ((DateTime.Now.Date - booking.Time.Date).Days > 10 && b.Invoices.Count() == 0)
                    {
                        context.Invoices.RemoveRange(b.Invoices);
                        context.Bookings.Remove(b);

                        context.SaveChanges();
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void cmdDeleteBooking_Click(object sender, EventArgs e)
        {
            Booking selectedBooking = (Booking)lstBookings.SelectedItem;

            using (var context = new HotelBookingsEntities())
            {
                var booking = (from b in context.Bookings
                               where b.BookingID == selectedBooking.BookingID
                               select b).SingleOrDefault();

                context.Invoices.RemoveRange(booking.Invoices);
                context.Bookings.Remove(booking);

                context.SaveChanges();
            }

            MessageBox.Show("Booking cancelled.");
        }
Exemplo n.º 7
0
        private void cmdPay_Click(object sender, EventArgs e)
        {
            Invoice = new Invoice();

            using (var context = new HotelBookingsEntities())
            {
                var invoice = Invoice;
                {
                    invoice.BookingID = Booking.BookingID;
                    invoice.Amount    = Booking.TotalPrice;
                    invoice.Date      = DateTime.Now;
                };
                context.Invoices.Add(invoice);

                context.SaveChanges();
            }

            Close();
        }
Exemplo n.º 8
0
        private void cmdDeleteAccount_Click(object sender, EventArgs e)
        {
            if (Bookings.Count > 0)
            {
                MessageBox.Show("You cannot delete an account with bookings!");
            }
            else
            {
                using (var context = new HotelBookingsEntities())
                {
                    var guest = context.Guests.Find(Guest.GuestID);
                    context.Guests.Remove(guest);

                    context.SaveChanges();
                }

                MessageBox.Show("Account successfully removed.");
                Close();
            }
        }