void GridViewBind() { GoodsActions goodsActions = new GoodsActions(); List<Goods> listGoods = goodsActions.GetGoods(selectedCategoryID); if (listGoods.Count > 0) { dataTable.Columns.Add("ID"); dataTable.Columns.Add("Image"); dataTable.Columns.Add("Name"); dataTable.Columns.Add("Price"); dataTable.Columns.Add("IsDiscount"); dataTable.Columns.Add("Discount"); for (int i = 0; i < listGoods.Count; i++) { dataTable.Rows.Add(listGoods[i].ID, string.Format(@"ImageHelp.aspx?imgID={0}", listGoods[i].ID), listGoods[i].Name, listGoods[i].Price + "грн", listGoods[i].IsDiscount, listGoods[i].Discount ); } ViewState.Add("dataTable", dataTable); GridViewGoods.DataSource = dataTable; GridViewGoods.DataBind(); } else { Label1.Text = "This category don`t have a goods"; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["selectedID"] != null) { int selectedID = (int)Session["selectedID"]; goods = new Goods(); GoodsActions goodsActions = new GoodsActions(); goods = goodsActions.FindSelectedGoods(selectedID); DataSourceAdapterBinding dataSourceAdapterBinding = new DataSourceAdapterBinding(); GoodsPreview1.DataSource = dataSourceAdapterBinding.AdapterFill(goods); } }
protected void Page_Load(object sender, EventArgs e) { string imgID = Request.Params.Get("imgID"); int goodsID; if (int.TryParse(imgID, out goodsID)) { GoodsActions goodsActions = new GoodsActions(); byte[] responsePicture = goodsActions.FindPicture(goodsID); Response.BinaryWrite(responsePicture); } }
protected void Page_Init(object sender, EventArgs e) { if (Session["SelectedGoodsID"] != null) { selectedGoodsID = int.Parse(Session["SelectedGoodsID"].ToString()); GoodsEditControl1.GoodsID = selectedGoodsID; GoodsActions goodsActions = new GoodsActions(); var goods = goodsActions.FindSelectedGoods(selectedGoodsID); DataSourceAdapterBinding dataSourceAdapterBinding = new DataSourceAdapterBinding(); GoodsPreviewControl1.DataSource = dataSourceAdapterBinding.AdapterFill(goods); } }
public void ButtonAdd_Click(object sender, EventArgs e) { string name = TextBoxName.Text; float price; float.TryParse(TextBoxPrice.Text, out price); bool isDiscount = CheckBox1.Checked; int discount; int.TryParse(TextBoxDiscount.Text, out discount); byte[] image = null; byte[] miniImage = null; if (FileUploadImage.HasFile) { image = FileUploadImage.FileBytes; } if (FileUploadMiniImage.HasFile) { miniImage = FileUploadMiniImage.FileBytes; } var args = new ButtonSubmitEventArgs(name, price, isDiscount, discount, image, miniImage); ButtonAdd_OnClick(args); var goods = new Goods(); goods.Name = name; goods.Price = price; goods.IsDiscount = isDiscount; if (discount > 0) { goods.Discount = discount; } goods.AdditionDate = DateTime.Now; var goodsImages = new GoodsImages(); goodsImages.Image = image; goodsImages.MiniImage = miniImage; GoodsActions goodsActions = new GoodsActions(); goodsActions.AddGoods(goods, goodsImages, goodsID); Response.Redirect("~/Administrator/GoodsPreview.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GoodsActions goodsActions = new GoodsActions(); var goods = goodsActions.FindSelectedGoods(goodsID); TextBoxName.Text = goods.Name; TextBoxPrice.Text = goods.Price.ToString(); TextBoxDiscount.Text = goods.Discount.ToString(); CheckBox1.Checked = goods.IsDiscount; if (CheckBox1.Checked) { TextBoxDiscount.Enabled = true; } } }
protected void Page_Load(object sender, EventArgs e) { TreeViewControl1.SelectedNodeChanged += new TestWork_Nix.Categoties.Controls.TreeViewCategoriesControl.TreeViewManageEventHandler(TreeViewControl1_SelectedNodeChanged); if (Session["SelectedGoodsID"] != null) { SelectedGoodsID = int.Parse(Session["SelectedGoodsID"].ToString()); if (!Page.IsPostBack) { categoriesGoodsList = new List<Categories>(); RelationsCategoriesGoodsActions R_C_G_Actions = new RelationsCategoriesGoodsActions(); categoriesGoodsList = R_C_G_Actions.GetCategoriesForGoods(SelectedGoodsID); ViewState["categoriesGoodsList"] = categoriesGoodsList; RepeaterGoodsCategories.DataSource = categoriesGoodsList; RepeaterGoodsCategories.DataBind(); GoodsActions goodsActions = new GoodsActions(); Label1.Text = "Manage categories for " + (goodsActions .FindSelectedGoods(SelectedGoodsID)).Name + ":"; } } }
protected void GridViewGoods_RowDeleting(object sender, GridViewDeleteEventArgs e) { int index = e.RowIndex; if (ViewState["dataTable"] != null) { dataTable = (DataTable)ViewState["dataTable"]; object[] row = dataTable.Rows[index].ItemArray; int goodsID; int.TryParse(row[0].ToString(), out goodsID); if (goodsID != null) { GoodsActions goodsActions = new GoodsActions(); goodsActions.DeleteGoods(goodsID); } dataTable.Rows.RemoveAt(index); GridViewGoods.DataSource = dataTable; ViewState.Add("dataTable", dataTable); GridViewGoods.DataBind(); } }