private void LoadData() { DataSet ds = provider.GetAll(); gvProduct.DataSource = ds; gvProduct.DataBind(); btnUpdate.Visible = false; }
private void BindDDL() { ProductProvider product = new ProductProvider(); this.ddl_Product.DataSource = product.GetAll(); this.ddl_Product.DataBind(); this.ddl_Product.Items.Add("所有"); this.ddl_Product.SelectedIndex = this.ddl_Product.Items.Count - 1; BrandProvider brand = new BrandProvider(); this.ddl_BrandName.DataSource = brand.GetAll(); this.ddl_BrandName.DataBind(); this.ddl_BrandName.Items.Add("所有"); this.ddl_BrandName.SelectedIndex = this.ddl_BrandName.Items.Count - 1; }
private void BindSource() { UnitProvider unit = new UnitProvider(); this.ddl_Unit.DataSource = unit.GetAll(); this.ddl_Unit.DataBind(); ProductProvider product = new ProductProvider(); this.ddl_Product.DataSource = product.GetAll(); this.ddl_Product.DataBind(); BrandProvider brand = new BrandProvider(); this.ddl_BrandName.DataSource = brand.GetAll(); this.ddl_BrandName.DataBind(); }
public void Delete_ProductExists_ReturnTrue() { // Arrange ProductProvider productProvider = new ProductProvider(); var allProducts = productProvider.GetAll().OrderByDescending(p => p.Id); Product lastProduct = allProducts.FirstOrDefault() ?? new Product(); ProductHandler productHandler = new ProductHandler(); // Act bool result = productHandler.Delete(lastProduct.Id); var deletedProduct = productProvider.GetById(lastProduct.Id); // Assert Assert.IsTrue(result); Assert.IsNull(deletedProduct); }
/// <summary> /// 绑定Product信息的数据源 /// </summary> private void BindSource(int start, string name) { if (name != null) { Product product = new Product(); product.Product_name = name; ProductProvider provider = new ProductProvider(); DataTable table = provider.Select(product, start, this.ListPager1.PageSize); this.GridView1.DataSource = table.DefaultView; this.GridView1.DataBind(); } else { ProductProvider provider = new ProductProvider(); DataTable table = provider.GetAll(start, this.ListPager1.PageSize); this.GridView1.DataSource = table.DefaultView; this.GridView1.DataBind(); } }
public void Add_ProductCorrectEntity_ReturnId() { // Arrange ProductProvider productProvider = new ProductProvider(); var allProducts = productProvider.GetAll().OrderByDescending(p => p.Id); Product lastProduct = allProducts.FirstOrDefault() ?? new Product(); ProductHandler productHandler = new ProductHandler(); Product product = new Product(); product.Name = "Name"; product.Description = "Description"; product.Price = 123.45m; // Act int id = productHandler.Add(product); // Assert Assert.IsTrue(lastProduct.Id < id); }
public IHttpActionResult Products() { return(Json( ProductProvider.GetAll())); }