public static Boolean InsertBooking() { string message = "Cannot add the same reference number!"; string caption = "Error"; MessageBoxButtons button = MessageBoxButtons.OK; try { using (var context = new HotelFinalProjectEntities1()) { var booking = new Booking(); booking.BookedID = bookingReference; booking.RoomIDFK = roomBookedID; booking.RoomType = roomType; booking.FromDate = bookedFrom; booking.ToDate = bookedTo; booking.Cost = roomCost; context.Bookings.Add(booking); context.SaveChanges(); } return(true); } catch (Exception) { MessageBox.Show(message, caption, button); return(false); } }
public void InsertCustomer() { using (var context = new HotelFinalProjectEntities1()) { var customer = new Customer(); customer.CustomerID = customerID; customer.BookedIDFK = bookedIDFK; customer.FirstName = firstName; customer.LastName = lastName; customer.Address = address; customer.Phone = phone; customer.City = city; customer.Country = country; customer.Licence = licence; customer.NumberOfGuest = getNumOfGuest(); customer.RoomBooked = getRoomNumber(); customer.BookedFromDate = bookedFromDate; customer.BookedToDate = bookedToDate; //customer.CheckIn = checkInDate; //customer.CheckOut = checkOutDate; customer.Balance = balance; context.Customers.Add(customer); context.SaveChanges(); } }
public static void DeleteBooking(string booking_id) { try { using (var context = new HotelFinalProjectEntities1()) { var booking = (from b in context.Bookings where b.BookedID == booking_id select b).SingleOrDefault(); context.Bookings.Remove(booking); context.SaveChanges(); // MessageBox.Show("Booking with ID " + booking_id + " has been successfully removed."); } } catch (Exception) { // MessageBox.Show("Please select Booking Id to cancel the reservation!"); } }
/* * Delete customer when the reservation was cancelled */ public void DeleteCustomer(string ID) { try { using (var context = new HotelFinalProjectEntities1()) { var customer = (from c in context.Customers where c.BookedIDFK == ID select c).SingleOrDefault(); context.Customers.Remove(customer); context.SaveChanges(); // MessageBox.Show("Customer has been successfully removed."); } } catch (Exception) { //MessageBox.Show("Please select customer to cancel the reservation."); } }
public static void InsertPayment() { using (var context = new HotelFinalProjectEntities1()) { Payment payment = new Payment(); payment.CustomerIDFK = custIDFK; payment.PaymentDate = DateTime.Today; payment.FirstDateOccupied = firstDateOccupied; payment.LastDateOccupied = lastDateOccupied; payment.PaymentType = paymentType; payment.TotalDays = totalDays; payment.TaxRate = taxRate; payment.TaxAmount = taxAmount; payment.PaymentTotal = paymentTotal; context.Payments.Add(payment); context.SaveChanges(); } }
/* * Update room status after it was cleaned up */ public void UpdateRoomStatus(string checkedout_roomID) { try { using (var context = new HotelFinalProjectEntities1()) { var update = context.Customers.Where(r => r.RoomBooked == checkedout_roomID); foreach (var item in update) { item.RoomStatus = "Clean"; } context.SaveChanges(); MessageBox.Show("Room " + checkedout_roomID + " is now clean !"); } } catch (Exception) { throw; } }
/* * This function below will update the room rate , * If user wants to change the room cost */ public void UpdateRoomRate(string room_Type) { try { using (var context = new HotelFinalProjectEntities1()) { var update = context.Rooms.Where(r => r.RoomType == room_Type); foreach (var item in update) { item.Rate = roomRate; } context.SaveChanges(); MessageBox.Show("Room " + room_Type + " has been updated !"); } } catch (Exception) { throw; } }
/* * Update customer table after checked in */ public void UpdateAfterCheckedIn() { try { using (var context = new HotelFinalProjectEntities1()) { var update = context.Customers.Where(c => c.CustomerID == customerSelectedIdFromDGV).First(); if (update.CheckIn.Equals(null)) { update.CheckIn = DateTime.Today; context.SaveChanges(); } else { MessageBox.Show("The customer has already checked in !"); } } } catch (Exception) { } }
public static string AddUser() { using (var context = new HotelFinalProjectEntities1()) { var user = new Login(); if (username == Convert.ToString("") || password == Convert.ToString("")) { return(" Name or password cannot be empty!"); } else { user.Name = username; user.Password = password; context.Logins.Add(user); context.SaveChanges(); } return(" Successfully added a new log-in !"); //user.Name = username; //user.Password = password; //context.Logins.Add(user); //context.SaveChanges(); } }
/* * Update customer table after checked out */ public void UpdateAfterCheckedOut() { try { using (var context = new HotelFinalProjectEntities1()) { var update = context.Customers.Where(c => c.CustomerID == custCheckOutSelectedIdFromDGV).First(); if (update.CheckOut.Equals(null)) { update.CheckOut = DateTime.Today; // Set Balance to 0 atfter checked out update.Balance = 0.0; context.SaveChanges(); } else { MessageBox.Show("The customer has already checked out !"); } } } catch (Exception) { } }