public void DeleteTest() { ProductDAL dal = new ProductDAL(); Product p = new Product(); p.ProductID = "3"; Assert.IsTrue(dal.Delete(p)); Assert.IsNull(dal.FindByID("3")); p.ProductID = "6"; Assert.IsFalse(dal.Delete(p)); }
private void btnDeleteCrudShop_Click(object sender, EventArgs e) { ProductDAL productDAL = new ProductDAL(); var product = productDAL.GetByFilter(x => x.Id == Convert.ToInt32(dgvShop.CurrentRow.Cells[0].Value)); DialogResult result = MessageBox.Show("Are you sure?", "Warning", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { if (product.UserId == CurrentUser.Id || CurrentUser.Type == 2) { if (CurrentUser.Type == 2) { LogDAL LogDAL = new LogDAL(); bool productExists = LogDAL.ProductExists(Convert.ToInt32(dgvShop.CurrentRow.Cells[0].Value)); Log log = new Log() { UserId = CurrentUser.Id, Description = txbDescriptionCrudProducts.Text, ProductId = Convert.ToInt32(dgvShop.CurrentRow.Cells[0].Value), Type = Convert.ToInt32(LogTypeEnum.Delete), ModifiedDate = DateTime.Now }; if (productExists) { int logId = LogDAL.GetByFilter(x => x.ProductId == Convert.ToInt32(dgvShop.CurrentRow.Cells[0].Value)).Id; log.Id = logId; } bool isValid = ValidationOperation <Log> .ValidateOperation(log); if (isValid) { productDAL.Delete(Convert.ToInt32(product.Id)); LogDAL.Update(log); MessageBox.Show("Successfully Deleted"); productDAL.GetGridData(dgvShop); } } else { productDAL.Delete(Convert.ToInt32(product.Id)); MessageBox.Show("Successfully Deleted"); productDAL.GetGridData(dgvShop); } } else { MessageBox.Show("You are not allowed to delete others' products"); } } }
private void btnDeletePrdct_Click(object sender, EventArgs e) { if (txtPrdctID.Text.Length == 0) { Mymessage mymessage = new Mymessage("Product ID is required for updation!"); mymessage.Show(); return; } else { p.id = int.Parse(txtPrdctID.Text); } bool success = pdal.Delete(p); if (success == true) { Mymessage mymessage = new Mymessage("Product Successfully Deleted"); mymessage.Show(); Clear(); DataTable dt = pdal.Select(); GDVProduct.DataSource = dt; } else { Mymessage mymessage = new Mymessage("Product Deletion Failed!"); mymessage.Show(); } }
private void UrunSilToolStripMenuItem_Click(object sender, EventArgs e) { try { if (dGvUrunler.SelectedRows.Count > 0) { DialogResult sonuc = MessageBox.Show("Silmek İstediğinizden Emin Misiniz ?", "Uyarı", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (sonuc == DialogResult.OK) { ProductDAL pDal = new ProductDAL(); foreach (DataGridViewRow row in dGvUrunler.SelectedRows) { pDal.Delete(dGvUrunler.SelectedRows[0].Cells[0].Value); MessageBox.Show("Ürününüz Başarılı Bir Şekilde Silinmiştir.", "Bilgi Mesajı", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { return; } } else { MessageBox.Show("Lütfen Bir Ürün Seçiniz!!!"); } } catch (Exception ex) { MessageBox.Show("Lütfen Silmek İstediğiniz Ürünü 'Ürünler' Sekmesinden Listeleyip Ürün Seçiniz...\n\n" + ex.Message); } }
//deleta um conjunto de dados na tabela public Response Delete(Product product) { Response resultDelete = _productDAL.Delete(product); if (!resultDelete.Success) { return(resultDelete); } return(Response.CreateSuccess("Produto removido com sucesso!")); }
public void DeleteTest() { Product p = new Product(); p.ProductID = "4"; ProductDAL target = new ProductDAL(); bool atual = target.Delete(p); //实际的结果 bool expected = true; //预期的结果 Assert.AreEqual(expected, atual); //断言判等 //测试无效的 p.ProductID = "4"; atual = target.Delete(p); //实际的结果 expected = false; //预期的结果 Assert.AreEqual(expected, atual); //断言判等 }
public Boolean Delete(SqlInt32 ProductID) { ProductDAL ProductDAL = new ProductDAL(); if (ProductDAL.Delete(ProductID)) { return(true); } else { this.Message = ProductDAL.Message; return(false); } }
public Boolean Delete(SqlInt32 ProductID) { ProductDAL dalProduct = new ProductDAL(); if (dalProduct.Delete(ProductID)) { return(true); } else { Message = dalProduct.Message; return(false); } }
private void BtnDelete_Click(object sender, EventArgs e) { bl.id = Convert.ToInt32(txt_productID.Text); bool success = dl.Delete(bl); if (success == true) { MessageBox.Show("Product Deleted Succcessfully"); DataTable dt = dl.select(); dataGridView1.DataSource = dt; } else { MessageBox.Show("Failed to delete user"); } }
public JsonResult Delete(string pId) { if (string.IsNullOrEmpty(pId)) { return(Json(false, JsonRequestBehavior.AllowGet)); } int productID = 0; int.TryParse(pId, out productID); if (productID <= 0) { return(Json(false, JsonRequestBehavior.AllowGet)); } ProductDAL db = new ProductDAL(); if (db.Delete(productID) == 1) { return(Json(true, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); }
public void Delete(int id) { ProductDAL.Delete(id); }
public bool Delete(Product o) { return(prod.Delete(o)); }
public bool Delete(int id) { return(productDAL.Delete(id)); }
public ApiMessage <string> Delete(string id) { return(_dal.Delete(id)); }
public bool Delete(int stuId) { return(clsDal.Delete(stuId) > 0); }
// DELETE: api/products/5 public void Delete(int id) { Product Product = ProductDAL.Get(id); ProductDAL.Delete(id); }
public IActionResult Delete(int id) { ProductDAL.Delete(id); return(RedirectToAction("Index")); }
public bool Delete(string id) { ProductDAL dal = new ProductDAL(); return(dal.Delete(id)); }
public void DeleteProduct(string sku) { var productDAL = new ProductDAL(); productDAL.Delete(sku); }
public bool DeleteProduct(Product item) { return(productDAL.Delete(item)); }
public string Delete(long Code) { ProductDAL productDAL = new ProductDAL(); return(productDAL.Delete(Code)); }
public Product Delete(long id) { return(dal.Delete(id)); }
public Product Delete(long id) { return(productDAL.Delete(id)); }
public JsonResult Delete(long id) { return(Json(new { done = productDAL.Delete(id) }, JsonRequestBehavior.AllowGet)); }