protected void gvHistory_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     lbladded.Visible    = false;
     gvRoom.Visible      = false;
     pnlFeedback.Visible = false;
     //show the full details of selected role
     if (e.CommandName == "Select")
     {
         List <Booking> bookingList = (List <Booking>)Session["History"];
         Booking        book        = bookingList[gvHistory.PageIndex * gvHistory.PageSize + Convert.ToInt32(e.CommandArgument)];
         //Checking room item booking to display
         List <ItemBooking> itemList = ItemBookingDB.getAllRoomItemBooking();
         List <ItemBooking> item     = new List <ItemBooking>();
         //Showing each item that is under the selected booking
         foreach (ItemBooking it in itemList)
         {
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 gvRoom.Visible = true;
                 ItemBooking room = it;
                 item.Add(room);
             }
         }
         //Not showing rooms when there's no rooms under selected booking
         if (item.Count > 0)
         {
             gvRoom.DataSource = item;
             gvRoom.DataBind();
             Session["OldRoom"] = item;
         }
         List <ItemBooking> tList   = ItemBookingDB.getAllTicketItemBooking();
         List <ItemBooking> tickets = new List <ItemBooking>();
         foreach (ItemBooking it in tList)
         {
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 dlTicket.Visible = true;
                 ItemBooking ticket = it;
                 tickets.Add(ticket);
                 gvTicket.DataSource = tickets;
                 gvTicket.DataBind();
                 Session["OldTicket"] = tickets;
             }
         }
         List <ItemBooking> rList       = ItemBookingDB.getAllRestaurantItemBooking();
         List <ItemBooking> restaurants = new List <ItemBooking>();
         foreach (ItemBooking it in rList)
         {
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 dlRestaurant.Visible = true;
                 ItemBooking restaurant = it;
                 restaurants.Add(restaurant);
                 gvRestaurant.DataSource = restaurants;
                 gvRestaurant.DataBind();
                 Session["OldRestaurant"] = restaurants;
             }
         }
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        //if user hotel is null
        if (Session["userHotel"] == null)
        {
            Response.Redirect("LoginForm.aspx"); //brings to the loginform page
        }
        lblNoResult.Text    = "";
        lblFeedback.Visible = false;

        if (!IsPostBack)
        {
            //Displaying upcoming and past bookings
            lblCustomer.Visible = false;
            dlCustomer.Visible  = false;
            gvFeedback.Visible  = false;
            lblTitle.Text       = "Upcoming Booking";
            gvHistory.Visible   = false;
            //Getting current signed in user
            Hotel hotel = (Hotel)Session["userHotel"];
            //Getting booked rooms from database and display them
            List <ItemBooking> itemList = ItemBookingDB.getAllRoomItemBooking();
            List <ItemBooking> upcoming = new List <ItemBooking>();
            List <ItemBooking> history  = new List <ItemBooking>();
            foreach (ItemBooking it in itemList)
            {
                //Checking the date to show only the upcoming events
                if (it.RoomID.Hotel.OrgEmail == hotel.OrgEmail)
                {
                    if (it.StartDate > DateTime.Now && it.ItemBookingStatus != "Canceled")
                    {
                        ItemBooking item = it;
                        upcoming.Add(item);
                        gvUpcoming.DataSource = upcoming;
                        gvUpcoming.DataBind();
                        //Keep the list of upcoming bookings in a session for further use
                        Session["upcoming"] = upcoming;
                    }
                    //Displaying the past bookings
                    else
                    {
                        ItemBooking item = it;
                        history.Add(item);
                        gvHistory.DataSource = history;
                        gvHistory.DataBind();
                        //Keep the list of past bookings in a session for further use
                        Session["history"] = history;
                    }
                }
            }
            Hotel acc = (Hotel)Session["userHotel"];
            //Getting feedback from database and display them
            List <Review> feedbackList = ReviewDB.getAllHotelReviewByID(acc.HotelID);
            gvFeedback.DataSource = feedbackList;
            gvFeedback.DataBind();
            Session["Feedback"] = feedbackList;
        }
    }
示例#3
0
 protected void gvBooking_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Item") //if admin selected on the specific booking id
     {
         dlRestaurant.Visible = false;
         dlRoom.Visible       = false;
         dlTicket.Visible     = false;
         List <Booking>     bookingList = (List <Booking>)Session["Booking"];    //retrieve the booking session
         List <ItemBooking> itemList    = ItemBookingDB.getAllRoomItemBooking(); //get the data from database for room details
         List <ItemBooking> item        = new List <ItemBooking>();              //add new list into itembooking
         foreach (ItemBooking it in itemList)                                    //use foreach to check with the itembookinglist
         {
             for (int n = 0; n < bookingList.Count; n++)                         //use for loop to check how many rows are there inside of the database
             {
                 //to check whether booking is available in database
                 if (it.BookingID.BookingID.ToString() == bookingList[n].BookingID.ToString() && bookingList[n].BookingID.ToString() == e.CommandArgument.ToString())
                 {
                     //to show the room details into datalist
                     ItemBooking room = it;
                     item.Add(room);
                     dlRoom.DataSource = item;
                     dlRoom.DataBind();
                     Session["room"] = item;
                 }
             }
         }
         //retrieve the booking session
         //get the ticket item booking from database
         //add new list from itembooking classes
         List <Booking>     tList          = (List <Booking>)Session["Booking"];
         List <ItemBooking> itemTicketList = ItemBookingDB.getAllTicketItemBooking();
         List <ItemBooking> itemT          = new List <ItemBooking>();
         foreach (ItemBooking it in itemTicketList)      //use foreach to check the itembooking
         {
             for (int n = 0; n < bookingList.Count; n++) //use for loop to check how many rows are there inside of the database
             {
                 //check with the booking id, if the data is available in database
                 if (it.BookingID.BookingID.ToString() == bookingList[n].BookingID.ToString() && bookingList[n].BookingID.ToString() == e.CommandArgument.ToString())
                 {
                     //to show the ticket into datalist
                     ItemBooking ticket = it;
                     itemT.Add(ticket);
                     dlTicket.DataSource = itemT;
                     dlTicket.DataBind();
                     Session["ticket"] = it.ItemBookingID;
                 }
             }
         }
         //retrieve the booking session
         //get the restaurant item booking from database
         //add new list from itembooking classes
         List <Booking>     rList     = (List <Booking>)Session["Booking"];
         List <ItemBooking> itemRlist = ItemBookingDB.getAllRestaurantItemBooking();
         List <ItemBooking> itemR     = new List <ItemBooking>();
         foreach (ItemBooking it in itemRlist)           //use foreach to check the itembooking
         {
             for (int n = 0; n < bookingList.Count; n++) //use for loop to check how many rows are there inside of the database
             {
                 //check with the booking id, if the data is available in database
                 if (it.BookingID.BookingID.ToString() == bookingList[n].BookingID.ToString() && bookingList[n].BookingID.ToString() == e.CommandArgument.ToString())
                 {
                     //to show the restaurant details into datalist
                     ItemBooking restaurant = it;
                     itemR.Add(restaurant);
                     dlRestaurant.DataSource = itemR;
                     dlRestaurant.DataBind();
                     Session["restaurant"] = itemR;
                 }
             }
         }
         //to check the item is more than zero -- ticket, hotel room and resturant
         if (itemT.Count > 0)
         {
             dlTicket.Visible = true;
         }
         if (itemR.Count > 0)
         {
             dlRestaurant.Visible = true;
         }
         if (item.Count > 0)
         {
             dlRoom.Visible = true;
         }
     }
 }
    protected void dlRoom_ItemCommand(object source, DataListCommandEventArgs e)
    {
        //When user clicked a booking to cancel, server will send the notification email
        if (e.CommandName == "cancel")
        {
            ItemBooking item = ItemBookingDB.getAllItemBookingbyID(e.CommandArgument.ToString());
            if (item.ItemBookingStatus == "Approved")
            {
                //Deleting dividend of service provider
                Dividend d = DividendDB.getADividendByItemBookingID(item.ItemBookingID);
                DividendDB.deleteDividend(d);
            }
            //Sending email to both customer and service provider to inform about service cancellation
            SmtpClient client = new SmtpClient("smtp.gmail.com");
            client.EnableSsl   = true;
            client.Credentials = new NetworkCredential("*****@*****.**", "smart-travel1005");
            try
            {
                MailMessage msg = new MailMessage("*****@*****.**", item.RoomID.HID.OrgEmail.ToString());
                msg.Subject = "Booking cancellation";
                msg.Body    = "Your booking " + item.BookingID.BookingID + " has been cancelled";
                client.Send(msg);
            }
            //When email server is not accessible
            catch (Exception er)
            {
                lblNoResult.Visible = true;
                lblNoResult.Text    = "Internet connection required ";
            }
            try
            {
                //Sending email to Customer
                MailMessage msg1 = new MailMessage("*****@*****.**", item.BookingID.CID.CustEmail.ToString());
                msg1.Subject = "Booking cancellation";
                msg1.Body    = "Your booking " + item.BookingID.BookingID + " has been cancelled";
                client.Send(msg1);
            }
            //When email server is not accessible
            catch (Exception er)
            {
                lblNoResult.Visible = true;
                lblNoResult.Text    = "Internet connect required: " + er;
            }
            //Booking cancellation text displayed
            lblNoResult.Visible = true;
            lblNoResult.Text    = "Your booking has been cancelled";

            //Updating booking status
            item.ItemBookingStatus = "Canceled";
            int update = ItemBookingDB.UpdateItemBooking(item);
            List <ItemBooking> itemList = ItemBookingDB.getAllRoomItemBooking();
            List <ItemBooking> items    = new List <ItemBooking>();
            //Reloading data to show the updated booking status
            Booking book = item.BookingID;
            foreach (ItemBooking it in itemList)
            {
                if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
                {
                    dlRoom.Visible = true;
                    ItemBooking room = it;
                    items.Add(room);
                    dlRoom.DataSource = items;
                    dlRoom.DataBind();
                    Session["RoomItem"] = items;
                }
            }
        }
    }
 protected void gvUpcoming_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     lblNoResult.Visible = false;
     lblNoResult.Visible = false;
     if (e.CommandName == "Select") //if user select the upcoming bookinglist
     {
         dlRoom.Visible       = false;
         dlTicket.Visible     = false;
         dlRestaurant.Visible = false;
         List <Booking>     bookingList = (List <Booking>)Session["Upcoming"]; //retrieve the upcoming session
         Booking            book        = bookingList[gvUpcoming.PageIndex * gvUpcoming.PageSize + Convert.ToInt32(e.CommandArgument)];
         List <ItemBooking> itemList    = ItemBookingDB.getAllRoomItemBooking();
         List <ItemBooking> item        = new List <ItemBooking>();
         foreach (ItemBooking it in itemList) //use foreach to check with itembooking database
         {
             //check with the booking
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 dlRoom.Visible = true;
                 ItemBooking room = it;
                 item.Add(room);
                 //show the room details into datalist
                 dlRoom.DataSource = item;
                 dlRoom.DataBind();
                 Session["RoomItem"] = item; //create a session for room item
             }
         }
         //get the itembooking ticket details from database
         List <ItemBooking> tList = ItemBookingDB.getAllTicketItemBooking();
         //add the new list to itembooking
         List <ItemBooking> tickets = new List <ItemBooking>();
         //use foreach to check with itembooking database
         foreach (ItemBooking it in tList)
         {
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 dlTicket.Visible = true;
                 ItemBooking ticket = it;
                 tickets.Add(ticket);
                 //show the ticket details into datalist
                 dlTicket.DataSource = tickets;
                 dlTicket.DataBind();
                 Session["TicketItem"] = tickets; //create a session for ticket item
             }
         }
         //get the itembooking restaurant details from database
         List <ItemBooking> rList = ItemBookingDB.getAllRestaurantItemBooking();
         //add the new list to itembooking
         List <ItemBooking> restaurants = new List <ItemBooking>();
         //use foreach to check with itembooking database
         foreach (ItemBooking it in rList)
         {
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 dlRestaurant.Visible = true;
                 ItemBooking restaurant = it;
                 restaurants.Add(restaurant);
                 //show the restaurant details into datalist
                 dlRestaurant.DataSource = restaurants;
                 dlRestaurant.DataBind();
                 Session["RestaurantItem"] = restaurants; //create a restaurant item into datalist
             }
         }
     }
 }