コード例 #1
0
        private void EliminarBtn_Click(object sender, EventArgs e)
        {
            bool result = false;

            try {
                DialogResult res = MessageBox.Show("¿Desea eliminar el proveedor?",
                                                   "My Store Desktop", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (res == DialogResult.Yes)
                {
                    int fila = dgvDatos.CurrentRow.Index;
                    producto = productos.ElementAt(fila);
                    ProductsDAO pDAO = new ProductsDAO();
                    result = pDAO.Delete(producto.ProductID);
                    if (result)
                    {
                        GetProductos();
                    }
                    else
                    {
                        MessageBox.Show("Error al eliminar el producto",
                                        "My Store Desktop", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show("Error al eliminar el producto: " + ex.Message, "My Store Desktop",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        public ActionResult <bool> Delete(int id)
        {
            ProductModel product = repository.GetProductByID(id);
            bool         status  = repository.Delete(product);

            return(status);
        }
コード例 #3
0
        public IActionResult Delete(int Id)
        {
            ProductModel product = productsDAO.GetProductById(Id);

            productsDAO.Delete(product);
            return(View("Index", productsDAO.GetAllProducts()));
        }
コード例 #4
0
        public ActionResult <int> Delete(int id)
        {
            ProductModel product = repository.GetProductById(id);
            int          success = repository.Delete(product);

            return(success);
        }
コード例 #5
0
        public ActionResult <int> Delete(int Id)
        {
            ProductModel product   = productsDAO.GetProductById(Id);
            int          DeletedId = productsDAO.Delete(product);

            return(DeletedId);
        }
コード例 #6
0
        public ActionResult <int> DeleteOne(int Id)
        {
            ProductsDAO  products = new ProductsDAO();
            ProductModel product  = products.GetProductById(Id);
            int          success  = products.Delete(product);

            return(success);
        }
コード例 #7
0
 /// <summary>
 /// Delete registers based on class values informed. MinValues and nulls are skipped.
 /// Must have "MultipleActiveResultSets=True" on connection string.
 /// </summary>
 /// <param name="parProductsInfo">Item to delete</param>
 /// <param name="transaction">Transaction context</param>
 /// <param name="errorMessage">Error message</param>
 public virtual void Delete(ProductsInfo parProductsInfo, DbTransaction transaction, out string errorMessage)
 {
     errorMessage = string.Empty;
     ProductsDAO.Delete(parProductsInfo, transaction, out errorMessage);
     //By default, the caller of this method will do the commit.
     //motor.Commit();
     //motor.CloseConnection();
 }
コード例 #8
0
        public ActionResult Delete(Guid id, IFormCollection collection)
        {
            try
            {
                _productsDAO.Delete(id);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
コード例 #9
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            ProductsPOJO objProducto = ProductsDAO.Select(int.Parse(dtgProducts.CurrentRow.Cells[0].Value.ToString()));

            if (MessageBox.Show("¿Está seguro de querere eliminar el producto " + objProducto.ProductName + "?", "Eliminar producto", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (ProductsDAO.Delete(objProducto.ProductID) == true)
                {
                    MessageBox.Show("Producto eliminado");
                    data();
                }
                else
                {
                    MessageBox.Show("El producto no pudo ser eliminado");
                }
            }
        }
コード例 #10
0
 //GET /api/productsapi/deletebyid/products
 public ActionResult <IEnumerable <ProductModel> > DeleteById(ProductModel product)
 {
     repository.Delete(product);
     return(repository.AllProducts());
 }
コード例 #11
0
 public IActionResult DeleteById(ProductModel product)
 {
     repository.Delete(product);
     return(View("Index", repository.AllProducts()));
 }