protected void Page_Load(object sender, EventArgs e) { //Session["user"] = new BlShopManager("12345678"); if (!(Session["user"] is BlShopManager)) { Response.Redirect("HomePage.aspx"); } BlShopManager manager = (BlShopManager)Session["user"]; if (!Page.IsPostBack) { //set data source productOrder.DataSource = OrderByArr; //// Bind the data to the control. productOrder.DataBind(); // Set the default selected item, if desired. productOrder.SelectedIndex = 0; //set data source List <BLProduct> products = BLProduct.GetAllProductsByShopId(manager.ShopId, ""); Session["products"] = null; UpdateData(products); } }
protected void Shops_OnSelectedIndexChanged(object sender, EventArgs e) { ChangeShop.Visible = true; searchPanel.Visible = true; Products.Visible = true; shopSelectDiv.Visible = false; List <BLProduct> productsCart = (List <BLProduct>)Session["productsCart"]; bool toChangeShop = true; if (productsCart != null && productsCart.Count > 0) { //massage to delete all products in cart /* bool ToDelete= */ Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "Confirm()", true); string isConfirmString = isConfirm.Value; if (isConfirmString == "1") { Session["productsCart"] = null; toChangeShop = false; } isConfirm.Value = "0"; //DialogResult dialogResult = MessageBox.Show("Sure", "Some Title", MessageBoxButtons.YesNo); //if (dialogResult == DialogResult.Yes) //{ // //do something //} //else if (dialogResult == DialogResult.No) //{ // //do something else //} } if (toChangeShop) { int shopId = int.Parse(Shops.SelectedValue);//get shop id if (shopId == -1) { Products.ProductsCollections = BLProduct.GetAllProducts(""); } else { shopName.Text = BlShop.GetShopById(shopId).ShopName; //set data source List <BLProduct> products = BLProduct.GetAllProductsByShopId(shopId, ""); if (products != null && products.Count > 0) { Products.ProductsCollections = products; } else { Products.ProductsCollections = null; } } } }
protected void productOrder_OnSelectedIndexChanged(object sender, EventArgs e) { string stringOrderBy = productOrder.SelectedValue; //get stringOrderBy int orderBy = TurnOrderByToInt(stringOrderBy); //turn to int int shopId = int.Parse(Shops.SelectedValue); //get shop id string condition = BLProduct.setOrderBy(orderBy); //get condition by order by int List <BLProduct> products = null; if (shopId == -1) { //set data source if no shop selected products = BLProduct.GetAllProducts(condition); Products.ProductsCollections = products; } else { //set data source products = BLProduct.GetAllProductsByShopId(shopId, condition); Products.ProductsCollections = products; } }
protected void productOrder_OnSelectedIndexChanged(object sender, EventArgs e) { string stringOrderBy = productOrder.SelectedValue; //get stringOrderBy int orderBy = TurnOrderByToInt(stringOrderBy); //turn to int int shopId = ((BlShopManager)Session["user"]).ShopId; //get shop id string condition = BLProduct.setOrderBy(orderBy); //get condition by order by int List <BLProduct> products = null; if (shopId == -1) { //set data source if no shop selected products = BLProduct.GetAllProducts(condition); UpdateData(products); } else { //set data source products = BLProduct.GetAllProductsByShopId(shopId, condition); UpdateData(products); } }
public List <BLProduct> GetAllProductsByShopId(int ShopId) { List <BLProduct> products = BLProduct.GetAllProductsByShopId(ShopId, ""); return(products); }//get all product of shop