protected void Page_Load(object sender, EventArgs e) { if (Session["Customer_ID"] == null) { Response.Redirect("Login.aspx"); } else { uid = Convert.ToInt32(Session["Customer_ID"].ToString()); SqlConnection con = new SqlConnection(CS); SqlDataAdapter da = new SqlDataAdapter("ProductIDsAndQuantities", con); da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.AddWithValue("@UserId", uid); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count == 0) { lblMsg.Text = "Your shopping cart is currently empty, please go to menu and select items you wish to purchase"; //lblMsg2.Visible = false; } else { lblMsg.Text = "These are the iterms in your cart: "; RptProducts.DataSource = dt; RptProducts.DataBind(); } } }
private void BindData(String criteria = "") { try { productsList.Clear(); priceList.Clear(); cartList.Clear(); user = Session["LoginUser"] as User; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { conn.Open(); string query = @"SELECT a.quantity, p.productID, p.ProductName, ar.ArtFullName, p.ProductPrice, p.path1, p.quantity, CASE WHEN a.quantity = p.quantity THEN 0 ELSE 1 END AS productMax FROM [ADDTOCARTLIST] A INNER JOIN PRODUCTS P ON (P.ProductID = A.ProductID) INNER JOIN Artist AR ON (AR.ArtistID = P.ArtistID) WHERE A.CustID = @CustID "; if (criteria != "") { query += "ORDER BY " + criteria; } SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("CustID", user.ID); using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { DataTable dt = new DataTable(); sda.Fill(dt); RptProducts.DataSource = dt; RptProducts.DataBind(); for (var i = 0; i < dt.Rows.Count; i++) { productsList.Add(dt.Rows[i][1].ToString(), Int32.Parse(dt.Rows[i][6].ToString())); priceList.Add(dt.Rows[i][1].ToString(), Double.Parse(dt.Rows[i][4].ToString())); cartList.Add(dt.Rows[i][1].ToString(), Int32.Parse(dt.Rows[i][0].ToString())); } CalculateTotal(); } } if (RptProducts.Items.Count == 0) { LblNone.Visible = true; LblCheckout.Enabled = false; ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "failalert('Warning','Empty in cart.');", true); } } catch (Exception ex) { throw ex; } }
private void ReloadPass(bool isNew = false) { if (isNew) { _hotelRepository = new HotelRepository(); _productRepository = new ProductRepository(); _isReload = true; } var products = _productRepository.SearchProductsByHotelId(PublicHotel.HotelId) .Where(p => p.ProductType != (int)Enums.ProductType.AddOns); RptProducts.DataSource = products; RptProducts.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] == null) { Response.Redirect("OurProducts.aspx"); } else { id = Convert.ToInt32(Request.QueryString["id"].ToString()); DataTable dt = getData("select * from tblProduct2 where Product_ID = " + id); RptProducts.DataSource = dt; RptProducts.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection(CS); SqlDataAdapter da = new SqlDataAdapter("select * from tblProduct2 where Product_Category = 'weave'", con); DataTable dt = new DataTable(); da.Fill(dt); RptProducts.DataSource = dt; RptProducts.DataBind(); SqlDataAdapter da2 = new SqlDataAdapter("select * from tblProduct2 where Product_Category = 'Remy'", con); DataTable dt2 = new DataTable(); da2.Fill(dt2); RptProducts2.DataSource = dt2; RptProducts2.DataBind(); }