protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int rowIndex = e.RowIndex; Product product = new Product(); product.Product_id = Convert.ToInt32(this.GridView1.DataKeys[rowIndex].Value); ProductProvider provider = new ProductProvider(); if (provider.Delete(product)) { this.Alert("删除成功!!!"); if (this.txt_Name.Text == "") { this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1; this.BindSource(null); } else { this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1; this.BindSource("%" + this.txt_Name.Text + "%"); } } }
public void Test_Add_QueryById_Update_Delete_ProductProvider() { var product = new Product { Name = "Product1", UtcCreationDate = DateTime.UtcNow, UtcUpdateDate = DateTime.UtcNow }; //Add brand provider.Add(product); Console.WriteLine("Add OK!"); //QueryBy var productQueryBy = provider.QueryById(product.Id); Assert.IsNotNull(productQueryBy); Console.WriteLine("QueryBy OK!"); //update product.Name = "newName"; provider.Update(product); var productUpdate = provider.QueryById(product.Id); Assert.AreEqual("newName", productUpdate.Name); Console.WriteLine("Update OK!"); //Delete provider.Delete(product); var productDelete = provider.QueryById(product.Id); Assert.IsNull(productDelete); Console.WriteLine("Delete OK!"); }
private void Delete() { provider.ID = holdID.Value.ToInt(); if (provider.Delete()) { Clear(); this.AlertSuccess(lblMsg, "Data Deleted successfully"); LoadData(); } else { MessageHelper.ShowAlertMessage("No data deleted"); } }
public ActionResult Delete(string SnNum) { ProductProvider provider = new ProductProvider(); int line = provider.Delete(SnNum); if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } else { this.ReturnJson.AddProperty("d", ""); } return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 根据产品唯一编号批量删除产品 /// </summary> /// <returns></returns> public ActionResult Delete() { List <string> list = WebUtil.GetFormObject <List <string> >("List"); string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); ProductProvider provider = new ProductProvider(CompanyID); int line = provider.Delete(list); DataResult result = new DataResult(); if (line > 0) { result.Code = (int)EResponseCode.Success; result.Message = string.Format("产品删除成功,受影响行数{0}行", line); } else { result.Code = (int)EResponseCode.Exception; result.Message = "产品删除失败"; } return(Content(JsonHelper.SerializeObject(result))); }
public ActionResult BatchDel(string SnNum) { ProductProvider provider = new ProductProvider(); var list = SnNum.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <string> ls = new List <string>(); int line = 0; foreach (string t in list) { line += provider.Delete(t); } if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } else { this.ReturnJson.AddProperty("d", ""); } return(Content(this.ReturnJson.ToString())); }
public ActionResult Delete(int id) { productprovider.Delete(id); return(RedirectToAction("GetProduct")); }