Esempio n. 1
0
        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
        }
Esempio n. 2
0
        public IActionResult DeleteProduct(int idToDelete)
        {
            ProductRepo repo = new ProductRepo();

            repo.DeleteProduct(idToDelete);
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        public ActionResult DelProduct(long id)
        {
            long uid = pr.FindProduct(id).OwnerId;

            pr.DeleteProduct(id);
            var products = pr.GetOwnProducts(uid);

            return(View("ShowOwnProducts", products));
        }
Esempio n. 4
0
 public void deleteProduct()
 {
     using (var db = new ProductDbContext())
     {
         var repo = new ProductRepo();
         repo.DeleteProduct(idnewProduct);
         var list = repo.GetProduct(idnewProduct);
         Assert.AreEqual(null, list);
     }
 }
Esempio n. 5
0
        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"));
        }
Esempio n. 6
0
        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");
            }
        }
Esempio n. 7
0
        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();
                }
            }
        }
Esempio n. 8
0
        //
        // 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());
            }
        }
Esempio n. 9
0
 public void DeleteProduct(int productId)
 {
     _productRepo.DeleteProduct(productId);
 }
 public IActionResult DeleteConfirmed(int id)
 {
     _productRepo.DeleteProduct(id);
     return(RedirectToAction(nameof(GetAll)));
 }