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 AddProduct_OnClick(object sender, EventArgs e) { HttpPostedFile postedFile = FileUpload.PostedFile; //Extract Image File Name. string name = Path.GetFileName(postedFile.FileName); string data = Path.GetExtension(postedFile.FileName); string type = data.ToLower(); bool fileIsPic = (type == ".png" || type == ".gif" || type == ".bmp" || type == ".jpg"); if (Page.IsValid && fileIsPic) { BlShopManager user = (BlShopManager)Session["user"]; string productName = ProductName.Text; double productPrice = double.Parse(ProductPrice.Text); int shopId = user.ShopId; try { string path = name; //Save the Image File in Folder. postedFile.SaveAs(Server.MapPath(path)); BLFlyPack.BLProduct product = new BLProduct(productPrice, productName, shopId, -1, path); MSG.Text = product.Id != -1 ? "product added !!" : "product added failed"; } catch (Exception exception) { Console.WriteLine(exception); throw; } } else { MSG.Text = "Please check if file is picture or all other field are valid"; } }
public List <BlUser> GetUserList(string ShopManagerPassword) { BlShopManager shopManager = new BlShopManager(ShopManagerPassword); return(shopManager.CustomersList()); }