Beispiel #1
0
        public static string Delbooking(int Booking_ID)                          //here booking details can be deleted
        {
            try
            {
                var book = from i in d.tblBookings
                           where i.Booking_ID == Booking_ID
                           select i;

                tblBooking b  = book.First();
                var        E1 = from E2 in d.tblHotelDetails
                                where E2.HotelID == b.HotelID
                                select E2;
                tblHotelDetail h2 = E1.First();
                DateTime       D  = Convert.ToDateTime(b.BookingDate);
                DateTime       TD = DateTime.Today;


                TimeSpan limit = TD - D;
                var      E8    = from E9 in d.tblPayments
                                 where E9.TransactionID == b.Booking_ID
                                 select E9;
                tblPayment p2 = E8.First();
                if (limit.Days <= 3)                                       //if we want to cancel  within 3 days after booking then cancellation is possible
                {
                    if (b.Room_Type == "AC")
                    {
                        d.tblBookings.Remove(b);
                        h2.Number_of_AC_Rooms = b.Number_of_Rooms + h2.Number_of_AC_Rooms;
                        d.tblPayments.Remove(p2);
                        d.SaveChanges();
                        return("Successfully deleted");
                    }
                    else
                    {
                        d.tblBookings.Remove(b);
                        h2.Number_of_Non_AC_Rooms = b.Number_of_Rooms + h2.Number_of_Non_AC_Rooms;
                        d.tblPayments.Remove(p2);
                        d.SaveChanges();
                        return("Successfully deleted");
                    }
                }
                else
                {
                    return("Cancellation is not available");
                }
            }
            catch (InvalidOperationException E)
            {
                return("You cannot cancel the booking now");
            }
        }
Beispiel #2
0
        public static bool getpayment(tblPayment p)                    //payment values are inserted in tblpayment
        {
            tblPayment p1 = new tblPayment();
            var        E6 = from E2 in d.tblCustomers
                            where E2.Customer_ID == p.Customer_ID
                            select E2;
            tblCustomer h3 = E6.First();

            if (h3.CustomerType == "senior citizen")
            {
                p1.Customer_ID         = p.Customer_ID;
                p1.Bank_ID             = p.Bank_ID;
                p1.Credit_card_Number  = p.Credit_card_Number;
                p1.Card_Type           = p.Card_Type;
                p1.Name_on_Card        = p.Name_on_Card;
                p1.Date_of_Transaction = DateTime.Now;
                p1.Expiry_Date         = p.Expiry_Date;
                p1.CVV_Number          = p.CVV_Number;
                p1.Account_Number      = p.Account_Number;
                p1.Pin_Number          = p.Pin_Number;
                p1.Amount = p.Amount - ((5 * p.Amount) / 100);
                d.tblPayments.Add(p1);
                d.SaveChanges();
                return(true);
            }
            else
            {
                p1.Customer_ID         = p.Customer_ID;
                p1.Bank_ID             = p.Bank_ID;
                p1.Credit_card_Number  = p.Credit_card_Number;
                p1.Card_Type           = p.Card_Type;
                p1.Name_on_Card        = p.Name_on_Card;
                p1.Date_of_Transaction = DateTime.Now;
                p1.Expiry_Date         = p.Expiry_Date;
                p1.CVV_Number          = p.CVV_Number;
                p1.Account_Number      = p.Account_Number;
                p1.Pin_Number          = p.Pin_Number;
                p1.Amount = p.Amount;
                d.tblPayments.Add(p1);
                d.SaveChanges();
                return(true);
            }
        }
Beispiel #3
0
        public static string GetbookData(tblBooking H, tblBooking s)             //here we are updating values of booking and changing availabilty of rooms based on updation and generating amount
        {
            try
            {
                // tblBooking b = new tblBooking();
                var E1 = from E2 in d.tblHotelDetails
                         where E2.HotelID == H.HotelID
                         select E2;
                tblHotelDetail h  = E1.First();
                DateTime       D  = Convert.ToDateTime(H.ArrivalDate);
                DateTime       TD = DateTime.Today;


                var b1 = from p9 in d.tblBookings
                         where p9.Booking_ID == s.Booking_ID
                         select p9;
                tblBooking x  = b1.First();
                var        p1 = from p2 in d.tblPayments
                                where p2.TransactionID == s.Booking_ID
                                select p2;
                tblPayment pp = p1.First();

                if (D > TD)
                {
                    if (H.Room_Type == "AC" && H.Number_of_Rooms <= h.Number_of_AC_Rooms)
                    {
                        if (H.Number_of_Nights > 5)
                        {
                            double billamount = (H.Number_of_Adults * h.Rate_for_one_night_for_one_adult_AC)
                                                + (H.Number_of_Children * h.Rate_for_one_night_for_one_children_AC);
                            billamount = billamount - ((2.5 * billamount) / 100);
                            pp.Amount  = (int)billamount;

                            d.SaveChanges();
                            h.Number_of_AC_Rooms = h.Number_of_AC_Rooms + x.Number_of_Rooms - H.Number_of_Rooms;
                            d.SaveChanges();
                            x.Customer_ID        = H.Customer_ID;
                            x.HotelID            = H.HotelID;
                            x.BookingDate        = DateTime.Now;
                            x.ArrivalDate        = H.ArrivalDate;
                            x.DepartureDate      = H.DepartureDate;
                            x.Number_of_Adults   = H.Number_of_Adults;
                            x.Number_of_Children = H.Number_of_Children;
                            x.Number_of_Nights   = H.Number_of_Nights;
                            x.Room_Type          = H.Room_Type;
                            x.Number_of_Rooms    = H.Number_of_Rooms;

                            d.SaveChanges();
                            // h.Number_of_AC_Rooms = h.Number_of_AC_Rooms + x.Number_of_Rooms - H.Number_of_Rooms;
                            // d.SaveChanges();
                            return("updated successfully");
                        }
                        else
                        {
                            double billamount = (H.Number_of_Adults * h.Rate_for_one_night_for_one_adult_AC)
                                                + (H.Number_of_Children * h.Rate_for_one_night_for_one_children_AC);
                            pp.Amount = (int)billamount;

                            d.SaveChanges();
                            h.Number_of_AC_Rooms = h.Number_of_AC_Rooms + x.Number_of_Rooms - H.Number_of_Rooms;
                            d.SaveChanges();
                            x.Customer_ID        = H.Customer_ID;
                            x.HotelID            = H.HotelID;
                            x.BookingDate        = DateTime.Now;
                            x.ArrivalDate        = H.ArrivalDate;
                            x.DepartureDate      = H.DepartureDate;
                            x.Number_of_Adults   = H.Number_of_Adults;
                            x.Number_of_Children = H.Number_of_Children;
                            x.Number_of_Nights   = H.Number_of_Nights;
                            x.Room_Type          = H.Room_Type;
                            x.Number_of_Rooms    = H.Number_of_Rooms;
                            d.SaveChanges();
                            //h.Number_of_AC_Rooms = h.Number_of_AC_Rooms + x.Number_of_Rooms - H.Number_of_Rooms;
                            //d.SaveChanges();

                            return("updated successfully");
                        }
                    }
                    else if (H.Room_Type == "NONAC" && H.Number_of_Rooms <= h.Number_of_Non_AC_Rooms)
                    {
                        if (H.Number_of_Nights > 5)
                        {
                            double billamount = (H.Number_of_Adults * h.Rate_for_one_night_for_one_adult_NONAC) +
                                                (H.Number_of_Children * h.Rate_for_one_night_for_one_children_NONAC);
                            billamount = billamount - ((2.5 * billamount) / 100);
                            pp.Amount  = (int)billamount;

                            d.SaveChanges();
                            h.Number_of_Non_AC_Rooms = h.Number_of_Non_AC_Rooms + x.Number_of_Rooms - H.Number_of_Rooms;
                            d.SaveChanges();
                            x.Customer_ID        = H.Customer_ID;
                            x.HotelID            = H.HotelID;
                            x.BookingDate        = DateTime.Now;
                            x.ArrivalDate        = H.ArrivalDate;
                            x.DepartureDate      = H.DepartureDate;
                            x.Number_of_Adults   = H.Number_of_Adults;
                            x.Number_of_Children = H.Number_of_Children;
                            x.Number_of_Nights   = H.Number_of_Nights;
                            x.Room_Type          = H.Room_Type;
                            x.Number_of_Rooms    = H.Number_of_Rooms;

                            d.SaveChanges();
                            //h.Number_of_Non_AC_Rooms = h.Number_of_Non_AC_Rooms + x.Number_of_Rooms - H.Number_of_Rooms;
                            //d.SaveChanges();

                            return("updated successfully");
                        }
                        else
                        {
                            double billamount = (H.Number_of_Adults * h.Rate_for_one_night_for_one_adult_NONAC) +
                                                (H.Number_of_Children * h.Rate_for_one_night_for_one_children_NONAC);
                            pp.Amount = (int)billamount;

                            d.SaveChanges();
                            h.Number_of_Non_AC_Rooms = h.Number_of_Non_AC_Rooms + x.Number_of_Rooms - H.Number_of_Rooms;
                            d.SaveChanges();
                            x.Customer_ID        = H.Customer_ID;
                            x.HotelID            = H.HotelID;
                            x.BookingDate        = DateTime.Now;
                            x.ArrivalDate        = H.ArrivalDate;
                            x.DepartureDate      = H.DepartureDate;
                            x.Number_of_Adults   = H.Number_of_Adults;
                            x.Number_of_Children = H.Number_of_Children;
                            x.Number_of_Nights   = H.Number_of_Nights;
                            x.Room_Type          = H.Room_Type;
                            x.Number_of_Rooms    = H.Number_of_Rooms;

                            d.SaveChanges();
                            //h.Number_of_Non_AC_Rooms = h.Number_of_Non_AC_Rooms + x.Number_of_Rooms - H.Number_of_Rooms;
                            //d.SaveChanges();

                            return("updated successfully");
                        }
                    }
                    else
                    {
                        return("No available rooms");
                    }
                }


                else
                {
                    return("arrival date must be greater than current date");
                }
            }
            catch (InvalidOperationException E)
            {
                return(" Scheduled Time is Over For Updating");
            }
        }