Exemplo n.º 1
0
        public static List <string> GetFreeRoomIDs()
        {
            List <string> allFreeRooms;

            using (var context = new HotelFinalProjectEntities1())
            {
                // Get all bookedrooms
                var allBookedRooms = context.Bookings.Where(b => b.FromDate >= DateTime.Today || b.FromDate <= DateTime.Today && DateTime.Today <= b.ToDate)
                                     .Select(r => new { r.RoomIDFK, r.FromDate, r.ToDate });
                // Get all rooms
                var allRooms = context.Rooms.Select(r => r.RoomID);
                //Create a list of all free rooms
                allFreeRooms = new List <string>(allRooms.ToList());
                foreach (var bookedroom in allBookedRooms)
                {
                    // Remove unavailable room from all rooms
                    if ((bookedroom.FromDate <= bookedFrom && bookedFrom < bookedroom.ToDate) || (bookedFrom > bookedroom.FromDate && bookedTo <= bookedroom.ToDate || bookedFrom < bookedroom.FromDate && bookedTo >= bookedroom.ToDate) || (bookedroom.FromDate < bookedFrom && bookedFrom < bookedroom.ToDate && bookedroom.ToDate < bookedTo))
                    {
                        if (allFreeRooms.Contains(Convert.ToString(bookedroom.RoomIDFK)))
                        {
                            allFreeRooms.Remove(Convert.ToString(bookedroom.RoomIDFK));
                        }
                    }
                }
                return(allFreeRooms);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 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();
     }
 }
Exemplo n.º 4
0
        public static List <string> GetTodayFreeRoomIDs()
        {
            List <string> allToday_FreeRooms;

            using (var context = new HotelFinalProjectEntities1())
            {
                // Get all bookedrooms
                var allBookedRooms = context.Bookings.Where(b => b.FromDate == DateTime.Today || b.FromDate < DateTime.Today && DateTime.Today < b.ToDate)
                                     .Select(r => new { r.RoomIDFK, r.FromDate, r.ToDate }).ToList();
                // Get all rooms
                var allRooms = context.Rooms.Select(r => r.RoomID);
                allToday_FreeRooms = new List <string>(allRooms.ToList());
                AllRoomIDs         = new List <string>(allRooms.ToList());
                // Remove bookedroom from all rooms
                foreach (var bookedroom in allBookedRooms)
                {
                    //if (allToday_FreeRooms.Contains(Convert .ToString(bookedroom.RoomIDFK )) || bookedroom.FromDate<=DateTime.Today && DateTime.Today<=bookedroom.ToDate){
                    if (allToday_FreeRooms.Contains(Convert.ToString(bookedroom.RoomIDFK)))
                    {
                        allToday_FreeRooms.Remove(Convert.ToString(bookedroom.RoomIDFK));
                    }
                }
                return(allToday_FreeRooms);
            }
        }
Exemplo n.º 5
0
 /*
  * Get all room details
  */
 public void GetAllRoomDetails()
 {
     using (var context = new HotelFinalProjectEntities1())
     {
         var room = context.Rooms.Select(r => new { r.RoomID, r.RoomType, r.Rate });
         dgvAllRooms.DataSource = room.ToList();
     }
 }
Exemplo n.º 6
0
 /*
  * Get all uncleaned rooms
  */
 public void GetUncleanedRooms()
 {
     using (var context = new HotelFinalProjectEntities1())
     {
         var room = context.Customers.Where(r => r.CheckOut == DateTime.Today && r.RoomStatus.Equals(null)).Select(o => new { o.RoomBooked, o.CheckIn, o.CheckOut });
         dgvAllUncleanedRooms.DataSource = room.ToList();
     }
 }
Exemplo n.º 7
0
 /*
  * This will show all customers who will check in today
  */
 public void CustomerToCheckOut()
 {
     using (var context = new HotelFinalProjectEntities1())
     {
         var customer = context.Customers.Where(c => !(c.CheckIn.Equals(null)) && c.CheckOut.Equals(null)).Select(c => new { c.CustomerID, c.BookedIDFK, c.FirstName, c.RoomBooked, c.BookedToDate, c.CheckIn, c.CheckOut });
         dgvCustomerToCheckOut.DataSource = customer.ToList();
     }
 }
Exemplo n.º 8
0
 /*
  * This will show all customers who will check in today
  */
 public void CustomerToCheckIn()
 {
     using (var context = new HotelFinalProjectEntities1())
     {
         var customer = context.Customers.Where(c => c.BookedFromDate == DateTime.Today && c.CheckOut.Equals(null)).Select(c => new { c.CustomerID, c.BookedIDFK, c.FirstName, c.LastName, c.BookedFromDate, c.CheckIn });
         dgvBookedCustomers.DataSource = customer.ToList();
     }
 }
Exemplo n.º 9
0
 /*
  * Get the detail of customer who is in the hotel
  */
 public void GetInHotelCustomerDetails(string room_ID)
 {
     using (var context = new HotelFinalProjectEntities1())
     {
         var detail = context.Customers.Where(c => c.RoomBooked == room_ID && c.CheckOut.Equals(null) && c.BookedToDate > DateTime.Today).Select(o => new { o.FirstName, o.LastName, o.BookedFromDate, o.BookedToDate }).ToList();
         dgvInHouseCustomer.DataSource = detail;
     }
 }
Exemplo n.º 10
0
 /*
  * This will show all customer who just checked out today
  */
 public void TodayCheckedOutCustomers()
 {
     using (var context = new HotelFinalProjectEntities1())
     {
         var customer = context.Customers.Where(c => c.CheckOut == DateTime.Today).Select(c => new { c.FirstName, c.LastName, c.RoomBooked, c.Balance });
         dgvTodayCheckOutCustomers.DataSource = customer.ToList();
     }
 }
Exemplo n.º 11
0
 /*
  * This will show all booking customers who made the booking
  */
 public static void BookingCustomersNotYetCheckIn()
 {
     using (var context = new HotelFinalProjectEntities1())
     {
         var customer = context.Customers.Where(c => c.BookedFromDate >= DateTime.Today && c.CheckIn.Equals(null)).Select(c => new { c.CustomerID, c.FirstName, c.BookedIDFK, c.BookedFromDate, c.BookedToDate });
         dgvBookingCustomersNotYetCheckIn.DataSource = customer.ToList();
     }
 }
Exemplo n.º 12
0
        /*
         * Get all room types
         */
        public static HashSet <string> GetRoomTypes()
        {
            // Use HashSet as it stores no duplicate items
            HashSet <string> allRoomTypes;

            using (var context = new HotelFinalProjectEntities1())
            {
                var type = context.Rooms.Select(t => t.RoomType);
                allRoomTypes = new HashSet <string>(type.ToList());
            }
            return(allRoomTypes);
        }
Exemplo n.º 13
0
        public static List <string> getPassword()
        {
            List <string> allPasswords;

            using (var context = new HotelFinalProjectEntities1())
            {
                var key = context.Logins.Select(r => r.Password);
                allPasswords = new List <string>(key.ToList());
            }

            return(allPasswords);
        }
Exemplo n.º 14
0
        public static List <string> getUsername()
        {
            List <string> allUserNames;

            using (var context = new HotelFinalProjectEntities1())
            {
                var name = context.Logins.Select(r => r.Name);
                allUserNames = new List <string>(name.ToList());
            }

            return(allUserNames);
        }
Exemplo n.º 15
0
        public static double GetCheckedOutBalance(string cust_id)
        {
            double checkedout_balance = 0;

            using (var context = new HotelFinalProjectEntities1())
            {
                var balance = context.Customers.Where(c => c.CustomerID == cust_id).Select(b => b.Balance).ToList();
                foreach (var item in balance)
                {
                    checkedout_balance = Convert.ToDouble(item);
                }
            } return(checkedout_balance);
        }
Exemplo n.º 16
0
        // Maybe dont need this

        public static DateTime GetCheckedOutDate(string cust_ID)
        {
            using (var context = new HotelFinalProjectEntities1())
            {
                DateTime date          = new DateTime();
                var      checkIn_dates = context.Customers.Where(c => c.CustomerID == cust_ID).Select(o => o.CheckOut).ToList();
                foreach (var item in checkIn_dates)
                {
                    date = Convert.ToDateTime(item);
                }
                return(date);
            }
        }
Exemplo n.º 17
0
        /*
         * Count number of Today check out
         */
        public int GetNumOfTodayCheckOut()
        {
            int num_CheckOut = 0;

            using (var context = new HotelFinalProjectEntities1())
            {
                var count = (from o in context.Customers
                             where o.CheckOut == DateTime.Today
                             select o).Count();
                num_CheckOut = count;
            }
            return(num_CheckOut);
        }
Exemplo n.º 18
0
        public static void AvailableRooms()
        {
            //dgvAvailableRooms = new DataGridView();
            List <string> allRoomsIDs = new List <string>();

            allRoomsIDs = GetFreeRoomIDs();
            using (var context = new HotelFinalProjectEntities1())
            {
                var freeroom = context.Rooms.Where(r => allRoomsIDs.Contains(r.RoomID))
                               .Select(l => new { l.RoomID, l.RoomType, l.Rate });
                dgvAvailableRooms.DataSource = freeroom.ToList();
            }
        }
Exemplo n.º 19
0
        /*
         * This function will return a checked out room type
         */
        public string GetCheckedOutRoomType(string booked_id)
        {
            string roomtype = "";

            using (var context = new HotelFinalProjectEntities1())
            {
                var room = context.Bookings.Where(t => t.BookedID == booked_id).Select(r => r.RoomType).ToList();
                foreach (var item in room)
                {
                    roomtype = item;
                }
            }
            return(roomtype);
        }
Exemplo n.º 20
0
        /*
         * Return room rate for room type Twin
         */
        private static int Twin_Rate()
        {
            int roomrate = 0;

            using (var context = new HotelFinalProjectEntities1())
            {
                var rate = context.Rooms.Where(t => t.RoomType == "Twin").Select(r => r.Rate).ToList();
                foreach (var item in rate)
                {
                    roomrate = item.Value;
                }
                return(roomrate);
            }
        }
Exemplo n.º 21
0
        /*
         * Get the details of customer who didnt appear to check in
         */
        public string GetBookingIDOfCustomerNotAppearToCheckIN()
        {
            string ID = "";

            using (var context = new HotelFinalProjectEntities1())
            {
                var bookingID = context.Customers.Where(c => c.BookedToDate <= DateTime.Today && c.CheckIn.Equals(null) && c.CheckOut.Equals(null)).Select(r => r.BookedIDFK).ToList();
                foreach (var item in bookingID)
                {
                    ID = item.ToString();
                }
            }
            return(ID);
        }
Exemplo n.º 22
0
 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!");
     }
 }
Exemplo n.º 23
0
 /*
  * 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.");
     }
 }
Exemplo n.º 24
0
 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();
     }
 }
Exemplo n.º 25
0
 /*
  * 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;
     }
 }
Exemplo n.º 26
0
        /*
         * 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;
            }
        }
Exemplo n.º 27
0
 /*
  * This method is get the payment details based on customer ID
  */
 public void GetPaymentDetail(string cust_ID)
 {
     using (var context = new HotelFinalProjectEntities1())
     {
         var payment = (from o in context.Payments
                        where o.CustomerIDFK == cust_ID
                        select o).ToList();
         foreach (var item in payment)
         {
             custIDFK          = item.CustomerIDFK;
             paymentDate       = Convert.ToDateTime(item.PaymentDate);
             firstdateOccupied = Convert.ToDateTime(item.FirstDateOccupied);
             lastdateOccupied  = Convert.ToDateTime(item.LastDateOccupied);
             paymentType       = item.PaymentType;
             totalDay          = Convert.ToInt32(item.TotalDays);
             taxRate           = Convert.ToDouble(item.TaxRate);
             taxAmount         = Convert.ToDouble(item.TaxAmount);
             paymentTotal      = Convert.ToDouble(item.PaymentTotal);
         }
     }
 }
Exemplo n.º 28
0
 /*
  * 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)
     {
     }
 }
Exemplo n.º 29
0
 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();
     }
 }
Exemplo n.º 30
0
 /*
  * 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)
     {
     }
 }