예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #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();
                    }
                }
            }
        }
예제 #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.");
        }
예제 #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();
        }
예제 #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();
            }
        }