private void toolStripMenuItemDelete_Click(object sender, EventArgs e) { //delete the selected row string productId = dataGridViewProducts .Rows[deleteSelectedRow].Cells[PRODUCT_ID].Value?.ToString(); int id; bool success = int.TryParse(productId, out id); if (success) { try { productRepo.DeleteProduct(id); MessageBox.Show("Product deleted.", DELETE_DIALOG_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("This product has already been invoiced so it cannot be deleted.", DELETE_DIALOG_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } deleteSelectedRow = -1;//reset the index }
public IActionResult DeleteProduct(int idToDelete) { ProductRepo repo = new ProductRepo(); repo.DeleteProduct(idToDelete); return(RedirectToAction("Index")); }
public ActionResult DelProduct(long id) { long uid = pr.FindProduct(id).OwnerId; pr.DeleteProduct(id); var products = pr.GetOwnProducts(uid); return(View("ShowOwnProducts", products)); }
public void deleteProduct() { using (var db = new ProductDbContext()) { var repo = new ProductRepo(); repo.DeleteProduct(idnewProduct); var list = repo.GetProduct(idnewProduct); Assert.AreEqual(null, list); } }
public ActionResult DeleteProduct(int id) { ProductRepo productRepo = new ProductRepo(); Boolean b = productRepo.DeleteProduct(id); if (b == true) { ViewData["Deleted"] = "True"; } else { ViewData["Deleted"] = "False"; } return(RedirectToAction("ProductDetails")); }
private void ProductDeleteBtn_Click(object sender, EventArgs e) { Product item = new Product(); item.ProductId = this.ProductIdTB.Text; if (pr.DeleteProduct(item)) { MessageBox.Show("Product Removed"); this.ProductRefreshBtn_Click(sender, e); } else { MessageBox.Show("Can Not Remove"); } }
private void ProductDeletebtn_Click(object sender, EventArgs e) { if (IsEmpty(productIdBox.Text.Trim())) { MessageBox.Show("Hey bro, Select any product first!"); } else { string productId = productIdBox.Text.Trim(); var deleted = _productRepo.DeleteProduct(productId); if (deleted > 0) { Clear(); MessageBox.Show("Product successfully deleted...!!"); ProductTableFetch(); } } }
// // GET: /Product/Delete/5 public ActionResult Delete(int id, int?category, bool ajax = false) { try { products.DeleteProduct(id); if (ajax) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } return(RedirectToAction("Index", "Category", new { id = category.Value })); } catch (Exception e) { if (ajax) { return(Json(new { success = false, error = e.Message }, JsonRequestBehavior.AllowGet)); } return(View()); } }
public void DeleteProduct(int productId) { _productRepo.DeleteProduct(productId); }
public IActionResult DeleteConfirmed(int id) { _productRepo.DeleteProduct(id); return(RedirectToAction(nameof(GetAll))); }