public void NewBooking()
        {           // adding new booking to the booking table
            using (var context = new SunShine_HotelEntities())
            {
                var AddBooking = new Booking();
                {
                    AddBooking.RoomIDFK    = BookingDetailsDTO.roomID;
                    AddBooking.BookingFrom = BookingDetailsDTO.BookingFrom;
                    AddBooking.BookingTo   = BookingDetailsDTO.BookingTo;
                    AddBooking.RoomCost    = BookingDetailsDTO.roomCost;
                }
                if (AddBooking.RoomIDFK == 0 && AddBooking.RoomCost == 0)
                {
                    MessageBox.Show(" Room No and Room Cost not selected");
                }
                else
                {
                    context.Bookings.Add(AddBooking);

                    MessageBox.Show("Room : " + BookingDetailsDTO.roomID + " " + "has been booked Between  : "
                                    + "\n" + BookingDetailsDTO.BookingFrom + " - " + BookingDetailsDTO.BookingTo
                                    + "\n" + " At total cost of : $" + BookingDetailsDTO.roomCost);

                    //save the changes
                    context.SaveChanges();
                    myguest.NewGuest();
                    myBilling.addBilling();
                }
            }
        }
Beispiel #2
0
        public void NewGuest()
        {           //get the current booking date
            DateTime BookingDate;

            BookingDate = DateTime.Now;
            //get the last booking ID from the new booking, really difficult

            using (var context = new SunShine_HotelEntities())
            {             //get the last booking ID from the new booking, really difficult
                var bookingId =
                    Convert.ToInt16(
                        context.Bookings.OrderByDescending(b => b.BookingID).Select(c => c.BookingID).First());
                //var RoomID = Convert.ToInt16(
                //	context.Bookings.OrderByDescending(b => b.BookingID).Select(c => c.RoomIDFK).First());
                var AddGuest = new Guest();

                AddGuest.Name        = BookingDetailsDTO.guestName;
                AddGuest.Address     = BookingDetailsDTO.guestAddress;
                AddGuest.Guests      = BookingDetailsDTO.GuestNumbers;
                AddGuest.Phone       = BookingDetailsDTO.GuestPhoneNo;
                AddGuest.Room        = BookingDetailsDTO.roomID;
                AddGuest.BookingDate = BookingDate;
                AddGuest.BookingIDFK = bookingId;
                context.Guests.Add(AddGuest);
                context.SaveChanges();
            }
        }
        //public void LoadBookings()
        //{
        //	ChooseRoomForBookingDgv = Database.ListAllBookingsAfterToday();

        //}
        //public void BookRoomClick()
        //{
        //	//Book rooms between dates
        //	_isRoomConflict = false; //set the conflict
        //							 //get all the dates for that room to compare them with the dates entered
        //	using (var context = new SunShine_HotelEntities())
        //	{
        //		var roomBookingConflict =
        //			context.Bookings.Where(b => b.RoomIDFK == RoomIdfk && b.BookingFrom >= DateTime.Today.Date)
        //				.Select(b => new { b.BookingFrom, b.BookingTo })
        //				.ToList();

        //		foreach (var bdate in roomBookingConflict)
        //		{
        //			//if the new booked start date is bigger than the existing start date and less than the existing end date or the new booked end date is bigger than existing start date and before the existing end date - conflict!
        //			if (BookingDetailsDTO.BookingTo.Date >= bdate.BookingFrom && BookingDetailsDTO.BookingFrom.Date < bdate.BookingTo ||
        //				BookingDetailsDTO.BookingTo.Date >= bdate.BookingFrom && BookingDetailsDTO.BookingTo.Date < bdate.BookingTo)
        //			{
        //				//throw a message
        //				MessageBox.Show("The room is already booked between " + BookingDetailsDTO.BookingFrom.Date + " and " +
        //								BookingDetailsDTO.BookingTo.Date);

        //				//exit out if there is a conflict
        //				_isRoomConflict = true;
        //				return;
        //			}
        //		} //end the foreach

        //		//add new booking if there is no conflict
        //		if (_isRoomConflict == false)
        //		{
        //			NewBooking();
        //			//must book the room before you book the guest
        //			//_allGuests.AddGuest();
        //		}
        //	}
        //}
        public void deleteBooking(int bookingId)
        {
            using (var context = new SunShine_HotelEntities())
            {
                var delete = context.Bookings.FirstOrDefault(b => b.BookingID == bookingId);


                context.Bookings.Remove(delete);
                context.SaveChanges();
                MessageBox.Show(" Selected booking has been deleted successfully ....");
            }
        }
Beispiel #4
0
        public void DeleteGuest(int guestID)
        {
            using (var context = new SunShine_HotelEntities())
            {
                var deleteGuest = context.Guests.FirstOrDefault(g => g.GuestID == guestID);


                context.Guests.Remove(deleteGuest);
                context.SaveChanges();
                MessageBox.Show("Guest has been deleted successfully ....");
            }
        }
 public void updateBilling(int billingID, decimal barCharge, decimal phonecharge, decimal roomcharge, decimal wifiCharge)
 {
     using (var context = new SunShine_HotelEntities())
     {
         var update = context.Billings.FirstOrDefault(b => b.BillingID == billingID);
         update.BarCharge   = barCharge;
         update.WiFiCharges = wifiCharge;
         update.TeleChrage  = phonecharge;
         update.RoomCharge  = roomcharge;
         context.SaveChanges();
         MessageBox.Show(" Expenses has been updated for the selected guest !!");
     }
 }
Beispiel #6
0
 public void updateGuest(int guestId)
 {
     using (var context = new SunShine_HotelEntities())
     {
         var update = context.Guests.FirstOrDefault(g => g.GuestID == guestId);
         update.Name    = BookingDetailsDTO.guestName;
         update.Address = BookingDetailsDTO.guestAddress;
         update.Phone   = BookingDetailsDTO.GuestPhoneNo;
         update.Guests  = BookingDetailsDTO.GuestNumbers;
         update.Room    = BookingDetailsDTO.roomID;
         context.SaveChanges();
     }
 }
Beispiel #7
0
        public void updateRoom(int roomID, int singleBed, int doublrBed, decimal tariffSingle, decimal tariffdouble, decimal tariffExtraPerson)
        {
            using (var context = new SunShine_HotelEntities())
            {
                var update = context.Rooms.FirstOrDefault(r => r.RoomID == roomID);
                update.SingleBeds         = singleBed;
                update.DoubleBeds         = doublrBed;
                update.TariffSinglePerson = tariffSingle;
                update.TariffDoublePerson = tariffdouble;
                update.TariffExtraPerson  = tariffExtraPerson;

                context.SaveChanges();
            }
        }
Beispiel #8
0
        public void addRoom(int singleBed, int doubleBed, decimal tariffSingle, decimal tariffDouble, decimal tariffExtra)
        {
            using (var context = new SunShine_HotelEntities())
            {
                var AddRoom = new Room();
                AddRoom.SingleBeds         = singleBed;
                AddRoom.DoubleBeds         = doubleBed;
                AddRoom.TariffSinglePerson = tariffSingle;
                AddRoom.TariffDoublePerson = tariffDouble;
                AddRoom.TariffExtraPerson  = tariffExtra;

                context.Rooms.Add(AddRoom);
                context.SaveChanges();
            }
        }
Beispiel #9
0
        //confirm guest check in
        public void CheckIn(int bookingId)
        {
            using (var context = new SunShine_HotelEntities())
            {
                //checkInDate = Convert.ToDateTime(
                //context.Bookings.Where(b => b.BookingID == bookingId).Select(b => b.BookingFrom));


                var confirm = context.Guests.FirstOrDefault(b => b.BookingIDFK == bookingId);
                confirm.CheckIn = DateTime.Now;



                context.SaveChanges();
            }
        }
Beispiel #10
0
        public void GuestsCheckOut(int guestID, decimal total)
        {
            using (var context = new SunShine_HotelEntities())
            {         //check if the guest checked In or not
                var currentGuest = context.Guests.SingleOrDefault(g => g.GuestID == guestID);
                if (currentGuest.CheckIn == null)
                {
                    MessageBox.Show(" Guest hasn't checked in yet");
                }
                else
                {
                    MessageBox.Show("Guest is ready to check out" + "\n" + "With Total Expenses to pay :  $" + total);
                    currentGuest.CheckOut = DateTime.Now.Date;

                    context.SaveChanges();
                }
            }
        }
        //adding the room charges to billing
        public void addBilling()
        {
            using (var context = new SunShine_HotelEntities())
            {
                var guestId =
                    Convert.ToInt16(
                        context.Guests.OrderByDescending(g => g.GuestID).Select(c => c.GuestID).First());
                var newBilling = new Billing();
                newBilling.GuestIDFK   = guestId;
                newBilling.RoomCharge  = BookingDetailsDTO.roomCost;
                newBilling.BarCharge   = Convert.ToDecimal("0.00");
                newBilling.TeleChrage  = Convert.ToDecimal("0.00");
                newBilling.WiFiCharges = Convert.ToDecimal("0.00");

                context.Billings.Add(newBilling);
                context.SaveChanges();
            }
        }
Beispiel #12
0
        internal void DeleteRoom(int roomID)
        {
            using (var context = new SunShine_HotelEntities())
            {
                var roomBooked = context.Bookings.FirstOrDefault(b => b.RoomIDFK == roomID);
                if (roomBooked.BookingFrom > DateTime.Today.Date)
                {
                    MessageBox.Show("Can't delete the room : " + roomID + " as its booked on : " + roomBooked.BookingFrom);
                }
                else
                {
                    var deleteRoom = context.Rooms.FirstOrDefault(r => r.RoomID == roomID);

                    context.Rooms.Remove(deleteRoom);
                    context.SaveChanges();
                    MessageBox.Show("Room" + " " + roomID + " " + " has been deleted successfully ....");
                }
            }
        }
        public void addCharges(int gId, decimal barCharge, decimal phonecharge, decimal roomcharge, decimal wifiCharge)
        {
            using (var context = new SunShine_HotelEntities())
            {
                if ((from b in context.Billings where b.GuestIDFK == gId select b).Count() > 0)
                {
                    MessageBox.Show("Expenses already added for this guest....");
                }
                else
                {
                    var AddBilling = new Billing();

                    AddBilling.BarCharge   = barCharge;
                    AddBilling.GuestIDFK   = gId;
                    AddBilling.TeleChrage  = phonecharge;
                    AddBilling.WiFiCharges = wifiCharge;
                    AddBilling.RoomCharge  = roomcharge;
                    context.Billings.Add(AddBilling);
                    context.SaveChanges();
                }
            }
        }
        /// <summary>
        ///     Adds a new booking if there isn't a conflict
        ///     this runs from the BookRoomClick method above if there is no date conflict
        /// </summary>
        public void AddNewBooking()
        {
            //make a new instance and pass that to the class
            var myRB = new Booking()
            {
                RoomIDFK    = RoomIdfk,
                BookingFrom = BookingFrom,
                BookingTo   = BookingTo,
                RoomCost    = RoomBookedPrice()
            };

            if (myRB.RoomIDFK != 0 && myRB.RoomCost != 0)
            {
                using (var context = new SunShine_HotelEntities())
                {
                    context.Bookings.Add(myRB);
                    context.SaveChanges();
                }
            }
            else
            {
                MessageBox.Show(myRB.RoomIDFK + " RoomIDFK is null " + myRB.RoomCost + " Roomcost is null");
            }
        }