protected void gvRoom_ItemCommand(object source, DataListCommandEventArgs e)
 {
     //Allowing access to show the feedback panel to give feedback
     lbladded.Visible = false;
     if (e.CommandName == "feedback")
     {
         //Retrieving the selected item details
         List <ItemBooking> itemList = (List <ItemBooking>)Session["OldRoom"];
         ItemBooking        item     = ItemBookingDB.getAllItemBookingbyID(e.CommandArgument.ToString());
         //Showing feedback panel to allow giving feedbacks
         lblTitle.Text        = item.RoomID.Hotel.Name;
         pnlFeedback.Visible  = true;
         pnlFeedback0.Visible = false;
         pnlFeedback1.Visible = false;
         gvRoom.Visible       = true;
         Session["retrieve"]  = item;
     }
 }
 protected void gvRestaurant_ItemCommand(object source, DataListCommandEventArgs e)
 {
     //Allowing access to show the feedback panel to give feedback
     lbladded.Visible = false;
     if (e.CommandName == "feedback")
     {
         //Retrieving the selected item details to show respective feedback panel
         List <ItemBooking> itemList = (List <ItemBooking>)Session["OldRestaurant"];
         ItemBooking        item     = ItemBookingDB.getAllItemBookingbyID(e.CommandArgument.ToString());
         lblTitle1.Text = "Restaurant Name: " + item.RestaurantID.Name;
         //Showing feedback panel to allow giving feedbacks
         pnlFeedback1.Visible = true;
         pnlFeedback0.Visible = false;
         pnlFeedback.Visible  = false;
         dlRestaurant.Visible = true;
         Session["retrieve"]  = item;
         gvRoom.Visible       = false;
         dlTicket.Visible     = false;
     }
 }
    protected void dlRestaurant_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());
            //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.RestaurantID.OrgEmail.ToString());
                msg.Subject = "Booking cancellation";
                msg.Body    = "Your arranged 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";
                if (item.ItemBookingStatus != "Canceled")
                {
                    client.Send(msg1);
                }
            }
            //When email server is not accessible
            catch (Exception er)
            {
                lblNoResult.Visible = true;
                lblNoResult.Text    = "Internet connection required ";
            }

            //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.getAllRestaurantItemBooking();
            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);
                    dlRestaurant.DataSource = items;
                    dlRestaurant.DataBind();
                    Session["RestaurantItem"] = items;
                }
            }
        }
    }