private void fillGrid() { List <Products> lstProducts = new bllProducts().GetAllProducts(); lstProductsView.DataSource = lstProducts; lstProductsView.DataBind(); }
protected void ddlstPCode_TextChanged(object sender, EventArgs e) { List <Products> lst = new bllProducts().GetAllProducts(); if (ddlstPCode.SelectedItem.Text != "") { string unitType = lst.Find(x => x.Id.Equals(int.Parse(ddlstPCode.SelectedValue.ToString()))).UnitType; lblamount.Text = unitType.ToString(); } else { lblamount.Text = " "; } }
private int FindProductID(string pCode) { List <Products> lstproducts = new bllProducts().GetAllProducts(); int pid = -1; foreach (Products element in lstproducts) { if (element.ProductCode.Equals(pCode)) { pid = element.Id; } } return(pid); }
protected void btnKaydet_Click(object sender, EventArgs e) { bllProducts productLib = new bllProducts(); List <Products> productList = productLib.GetAllProducts(); bool control = true; Products product = new Products() { ProductName = txtPName.Text, ProductCode = txtPcode.Text, ProductCategoryID = int.Parse(ddlstCategory.SelectedValue), Comment = txtComm.Text, UnitID = int.Parse(ddlstUnit.SelectedValue), Title = txtTitle.Text, SerialNum = int.Parse(txtSerialNo.Text), StatusID = int.Parse(ddlstStatus.SelectedValue) }; if (control == true) { try { if (!productLib.PCodeContains(product)) { bool flag = productLib.Insert(product); if (flag) { Response.Redirect("products.aspx"); } } else { throw new StockException(); } } catch (StockException) { txtPcode.Text = ""; txtPName.Text = ""; txtSerialNo.Text = ""; ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"Seri numarası veya ürün kodu bulunan ürün ekleyemezsiniz.Tekrar deneyiniz\");", true); } } }
protected void btnFilter_Click(object sender, EventArgs e) { try { List <Products> lst = new bllProducts().GetAllProducts(); lst = lst.Where(x => (string.IsNullOrEmpty(txtPrCode.Text) || (x.ProductCode.IndexOf(txtPrCode.Text, 0, StringComparison.CurrentCultureIgnoreCase) > -1)) && (string.IsNullOrEmpty(txtPrName.Text) || (x.ProductName.IndexOf(txtPrName.Text, 0, StringComparison.CurrentCultureIgnoreCase) > -1)) && (string.IsNullOrEmpty(txtBirim.Text) || (x.UnitType.IndexOf(txtBirim.Text, 0, StringComparison.CurrentCultureIgnoreCase) > -1)) && (string.IsNullOrEmpty(txtTitle.Text) || (x.Title.IndexOf(txtTitle.Text, 0, StringComparison.CurrentCultureIgnoreCase) > -1)) && (string.IsNullOrEmpty(txtStatus.Text) || (x.Title.IndexOf(txtTitle.Text, 0, StringComparison.CurrentCultureIgnoreCase) > -1)) && (string.IsNullOrEmpty(txtCategory.Text) || (x.CategoryType.IndexOf(txtCategory.Text, 0, StringComparison.CurrentCultureIgnoreCase) > -1)) && (string.IsNullOrEmpty(txtComment.Text) || (x.Comment.IndexOf(txtComment.Text, 0, StringComparison.CurrentCultureIgnoreCase) > -1)) && (string.IsNullOrEmpty(txtSerialNo.Text) || (x.SerialNum.Equals(int.Parse(txtSerialNo.Text)))) ).ToList(); lstProducts.DataSource = lst; lstProducts.DataBind(); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "alert", ex.Message, true); Response.Write(ex.Message); } }