protected void RepeatHotel_ItemCommand(object source, RepeaterCommandEventArgs e) { RepeaterItem hotels = e.Item; if (Session["tourist_id"] == null && Session["tourguide_id"] == null) { Response.Redirect("Login.aspx"); } else { try { Label1.Text = Session["tourist_id"].ToString(); } catch (NullReferenceException) { Label1.Text = Session["tourguide_id"].ToString(); } } string attName; string attDesc = "Item price cost consists of base price of hotel with the check in duration"; double price; DateTime expDate; int code; int user_id = Convert.ToInt32(Session["tourist_id"]); int quantity; decimal totalCost; HiddenField getHotelId = (HiddenField)hotels.FindControl("hotelId"); Session["voucher_id"] = getHotelId.Value; Label gethotelPrice = (Label)hotels.FindControl("hotelPrice"); Session["hotelPrice"] = gethotelPrice.Text; price = Convert.ToDouble(gethotelPrice.Text); DateTime date = DateTime.Now; TimeSpan duration = new TimeSpan(30, 0, 0, 0); expDate = date.Add(duration); int hotelId = new Random().Next(100000, 999999); code = new Random().Next(100000, 999999); DropDownList hotelQty = (DropDownList)hotels.FindControl("roomQty"); Session["roomQty"] = hotelQty.SelectedValue; quantity = Convert.ToInt32(hotelQty.SelectedValue); //DateTime checkInDateTime = Convert.ToDateTime(checkInTB); //DateTime checkOutDateTime = Convert.ToDateTime(checkOutTB); //TimeSpan difference = checkInDateTime - checkOutDateTime; //int stayDuration = Convert.ToInt32(difference.TotalDays); DropDownList getHotelDuration = (DropDownList)hotels.FindControl("durationQty"); Session["durationQty"] = getHotelDuration.SelectedValue; int stayDuration = Convert.ToInt32(getHotelDuration.SelectedValue); DateTime dateToday = Convert.ToDateTime(DateTime.Today); DateTime expiryDate = dateToday.AddDays(stayDuration); totalCost = Convert.ToDecimal(price * quantity * stayDuration); String hotelPaid = "Not paid"; //Ticket tkt = new Ticket(attName, attDesc, price, expDate, code, "not paid", user_id); //tkt.AddNewTicket(); Label getHotelName = (Label)hotels.FindControl("hotelName"); Session["hotelName"] = getHotelName.Text; string attDuration = stayDuration.ToString(); attName = getHotelName.Text + " (" + attDuration + " Days" + ")"; double cartPrice = Convert.ToDouble(price) * Convert.ToDouble(stayDuration); System.Web.UI.WebControls.Image hotelImage = (System.Web.UI.WebControls.Image)hotels.FindControl("hotelImage"); DateTime reservedate = DateTime.Now; string imageurl = hotelImage.ToString(); Cart cart = new Cart(attName, attDesc, cartPrice, quantity, user_id, imageurl); cart.InsertHotel(); Cart newCart = new Cart(); newCart = newCart.GetCartId(attName, user_id); HotelTrans hotel = new HotelTrans(hotelId, totalCost, quantity, expiryDate, user_id, attName, code, hotelPaid, newCart.productId, reservedate); hotel.AddNewHotel(); string hotelAdded = getHotelName.Text + " " + "(rooms: " + quantity.ToString() + ")" + "(duration: " + stayDuration.ToString() + "days" + ")" + "has been added to shop Cart"; Session["hotelAdded"] = hotelAdded; Response.Redirect("HotelPage.aspx"); return; }