Example #1
0
 public void Delete()
 {
     if (MessageBox.Show("Are you sure you want to delete this product?", "Delete Product", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         int productId = (int)productGridView.SelectedRows[0].Cells[0].Value;
         _productLogic.DeleteProduct(productId);
         productGridView.DataSource = "";
         LoadDataGrid();
     }
 }
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            DirModel dml = new DirModel();

            dml.Add("@product_id", (sender as LinkButton).CommandArgument);
            if (pageLogic.DeleteProduct(dml))
            {
                AlertMessage("删除成功.");
                xsPage.RefreshPage();
            }
        }
Example #3
0
 public ActionResult Delete(int id)
 {
     try
     {
         ProductLogic.DeleteProduct(id);
         return(Json(new { IsSucceeded = true }));
     }
     catch
     {
         return(Json(new { IsSucceeded = false }));
     }
 }
Example #4
0
        public void DeleteAnExistingProduct()
        {
            ProductLogic logic = new ProductLogic();

            logic.AddProduct(5, "Hamburguesa", "Rica hamburguesa doble queso", 2500);
            Product lastProduct = logic.SearchByID(5);

            Assert.IsNotNull(lastProduct);
            logic.DeleteProduct(5);

            lastProduct = logic.SearchByID(5);
            Assert.IsNull(lastProduct);
        }
 public ActionResult DeleteProduct(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         productLogic.DeleteProduct(id);
         return(RedirectToAction("IndexProduct"));
     }
     catch
     {
         return(View());
     }
 }
Example #6
0
        public HttpResponseMessage DeleteProduct(int id)
        {
            var status = logic.DeleteProduct(id);

            if (status)
            {
                return(Request.CreateResponse(HttpStatusCode.Accepted, "Deleted the Product"));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, "Failed to Delete Product due to internal error"));
            }
        }
Example #7
0
        private void btn_DeleteProduct_Click(object sender, RoutedEventArgs e)
        {
            bool wasSucces = interaction.DeleteProduct("product", product.ProductID);

            if (wasSucces)
            {
                CreateMessage.ShowDeleteSuccesful("Product");
            }
            if (!wasSucces)
            {
                CreateMessage.ShowFailureMessage();
            }
            NavigationService.Navigate(new ViewProducts());
        }
Example #8
0
        public IActionResult DeleteProduct(string _id)
        {
            var result = ProductLogic.DeleteProduct(_id);

            if (result.GetErrorMessage == null)
            {
                if (result.GetModel != null && !BLL.ProductLogic.IFthisPhoroUseMoreProduct(result.GetModel.PhotoPath))
                {
                    _environment.DeletePhoto(result.GetModel.PhotoPath);
                    TempData["ProductDeletMessage"] = "Product deleted with photo";
                    return(RedirectToAction("Categories", "Product"));
                }
                else
                {
                    TempData["ProductDeletMessage"] = "Product deleted without photo";
                    return(RedirectToAction("Categories", "Product"));
                }
            }
            TempData["ProductDeletMessage"] = result.GetErrorMessage;
            return(RedirectToAction("Categories", "Product"));
        }
Example #9
0
        public IActionResult DeleteProduct(int productId)
        {
            _productLogic.DeleteProduct(productId);

            return(RedirectToAction("ProductManagment"));
        }
Example #10
0
        public void AdminMenu(User user)
        {
            Boolean exit = false;

            do
            {
                Console.Clear();
                Console.WriteLine("Administrador\n\n1- Ver usuarios\n2- Crear Usuario\n3- Eliminar Usuario\n4- Ver Productos\n5- Agregar Producto\n6- Eliminar Producto\n7- Ver todas las mesas\n8- Agregar nueva mesa\n9- Salir");
                int opc = Int16.Parse(Console.ReadLine());
                switch (opc)
                {
                case 1:
                    Console.Clear();
                    Console.WriteLine(userLo.GetUsersListString());
                    Console.ReadKey();
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine(userLo.createUser("prueba", "12345", "prueba", "prueba", 100, "client"));
                    Console.ReadKey();
                    break;

                case 3:
                    Console.Clear();
                    Console.WriteLine("Digite el nombre de usuario a eliminar: ");
                    string username = Console.ReadLine();
                    Console.WriteLine(userLo.DeleteUser(username, user.Username));
                    Console.ReadKey();
                    break;

                case 4:
                    Console.Clear();
                    Console.WriteLine(productLo.GetProductsString());
                    Console.ReadKey();
                    break;

                case 5:
                    Console.Clear();
                    Console.WriteLine(productLo.AddProduct(8, "ProductoPrueba", "DescripPrueba", 0));
                    Console.ReadKey();
                    break;

                case 6:
                    Console.Clear();
                    Console.WriteLine("Digite el id del producto a eliminar: ");
                    int id = Int16.Parse(Console.ReadLine());
                    Console.WriteLine(productLo.DeleteProduct(id));
                    Console.ReadKey();
                    break;

                case 7:
                    Console.Clear();
                    Console.WriteLine(tableLo.GetTablesString());
                    Console.ReadKey();
                    break;

                case 8:
                    Console.Clear();
                    Console.WriteLine(tableLo.AddTable(12, 25));
                    Console.ReadKey();
                    break;

                case 9:
                    exit = true;
                    break;
                }
            } while (!exit);
        }
Example #11
0
        public static void AdminMenu()
        {
            Boolean continuar = true;

            while (continuar)
            {
                Console.WriteLine("Ingrese el numero que antescede la opcion que desea \n\n1.Crear un nuevo usuario" +
                                  "\n2.Deshabilitar un usuario \n3.Crear una nueva mesa \n4.Crear un producto" +
                                  "\n5.Eliminar un producto. \n6.Cerrar Sesion");
                int option = Convert.ToInt32(Console.ReadLine());
                switch (option)
                {
                case 1:
                    Console.WriteLine("Ingrese el nuevo nombre de usuario");
                    string NewUsername = Console.ReadLine();
                    Console.WriteLine("Ingrese la contraseña para " + NewUsername);
                    string Password = Console.ReadLine();
                    Console.WriteLine("Ingrese nombre");
                    string Name = Console.ReadLine();
                    Console.WriteLine("Ingrese apellido");
                    string Lastname = Console.ReadLine();
                    Console.WriteLine("Ingrese el tipo de usuario (admin,waiter,table,cashier)");
                    string type     = Console.ReadLine();
                    User   lastUser = Userlogic.CreateUser(NewUsername, Password, Name, Lastname, type);
                    if (lastUser != null)
                    {
                        Console.WriteLine("Usuario creado correctamente");
                    }
                    else
                    {
                        Console.WriteLine("Los datos ingresados fueron incorrectos");
                    }
                    break;

                case 2:
                    Console.WriteLine("Ingrese el nombre de usuario");
                    string Username = Console.ReadLine();
                    Userlogic.DisableUser(Username, LoggedUser.Username);
                    Console.WriteLine("Usuario deshabilitado correctamente");
                    break;

                case 3:
                    Console.WriteLine("Ingrese el ID de mesa");
                    int table_id = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Ingrese la cantindad de personas de la mesa");
                    int people = Convert.ToInt32(Console.ReadLine());
                    Tablelogic.AddTable(table_id, people);
                    Console.WriteLine("Mesa creada correctamente.");
                    break;

                case 4:
                    Console.WriteLine("Ingrese el id del producto");
                    int product_id = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Ingrese el nombre del producto");
                    string name = Console.ReadLine();
                    Console.WriteLine("Ingrese la descripcion del producto");
                    string description = Console.ReadLine();
                    Console.WriteLine("Ingrese el costo del producto");
                    decimal cost = Convert.ToDecimal(Console.ReadLine());
                    Produclogic.AddProduct(product_id, name, description, cost);
                    Console.WriteLine("Producto creado correctamente");
                    break;

                case 5:
                    Console.WriteLine("Ingrese el id del producto");
                    int product_id_delete = Convert.ToInt32(Console.ReadLine());
                    Produclogic.DeleteProduct(product_id_delete);
                    Console.WriteLine("Producto eliminado correctamente");
                    break;

                case 6:
                    continuar = false;
                    Console.WriteLine("La sesion ha terminado.");
                    break;

                default:
                    Console.WriteLine("El numero ingresado no coincide con ninguna de las opciones");
                    break;
                }
            }
        }
 public ActionResult Delete(int id)
 {
     ProductLogic.DeleteProduct(id);
     return(RedirectToAction("Product"));
 }
Example #13
0
        static void Main(string[] args)
        {
            var           finalizar        = false;
            var           connectionString = "Server=DESKTOP-RCIFPVC\\SQLEXPRESS; Database=Tienda; User Id=labUser; Password=Password01.;";
            IProductLogic logic            = new ProductLogic(new ProductDataAccessDatabase(connectionString));

            while (!finalizar)
            {
                Console.WriteLine(@"Las opciones disponibles son
                    1 listado de productos
                    2 alta de producto
                    3 eliminar producto
                    4 modificar producto
                    5 Obtener productos filtrados
                    6 salir
                ");
                var entrada = Console.ReadLine();

                switch (entrada)
                {
                case "1":
                {
                    Console.WriteLine("listado");
                    var productos = logic.ListProducts();
                    if (!productos.Any())
                    {
                        Console.WriteLine("No hay productos");
                    }

                    foreach (var producto in productos)
                    {
                        Console.WriteLine($" id {producto.Id}, Nombre {producto.Name}, Descripcion {producto.Description}, Precio {producto.Price}");
                    }


                    break;
                };

                case "2":
                {
                    Console.WriteLine("alta");

                    Console.WriteLine("Ingrese id");
                    if (!int.TryParse(Console.ReadLine(), out int id))
                    {
                        Console.WriteLine("Id incorrecto");
                        break;
                    }

                    var newProduct = RequestProductData(id);

                    if (newProduct != null)
                    {
                        try
                        {
                            logic.CreateProduct(newProduct);
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("hubo un error al ingresar el producto");
                        }
                    }

                    break;
                };

                case "3":
                {
                    Console.WriteLine("eliminar");

                    Console.WriteLine("Ingrese id");
                    if (!int.TryParse(Console.ReadLine(), out int id))
                    {
                        Console.WriteLine("Id incorrecto");
                        break;
                    }
                    try
                    {
                        var success = logic.DeleteProduct(id);
                        if (success)
                        {
                            Console.WriteLine("Producto eliminado");
                        }
                        else
                        {
                            Console.WriteLine("No se encontró el producto");
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("hubo un error al eliminar el producto");
                    }
                    break;
                };

                case "4":
                {
                    Console.WriteLine("modificar");

                    Console.WriteLine("Ingrese id a modificar");
                    if (!int.TryParse(Console.ReadLine(), out int id))
                    {
                        Console.WriteLine("Id incorrecto");
                        break;
                    }
                    try
                    {
                        var product = logic.GetProduct(id);
                        if (product == null)
                        {
                            Console.WriteLine("El producto no existe");
                            break;
                        }
                        else
                        {
                            var newProductData = RequestProductData(id);
                            if (newProductData != null)
                            {
                                newProductData.Id = id;
                                logic.UpdateProduct(newProductData);
                                Console.WriteLine("Producto actualizado");
                            }
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("hubo un error al modificar el producto");
                    }
                    break;
                };

                case "5":
                {
                    Console.WriteLine("Obtener producto filtrado");

                    Console.Write("PageIndex: ");
                    int pageIndex = int.Parse(Console.ReadLine());
                    Console.Write("PageSize: ");
                    int pageSize = int.Parse(Console.ReadLine());
                    Console.Write("Name: ");
                    string name = Console.ReadLine();
                    Console.Write("CategoryId: ");
                    int categoryId;
                    int.TryParse(Console.ReadLine(), out categoryId);
                    Console.Write("OrderByNameOrPrice: ");
                    string orderby = Console.ReadLine();
                    Console.Write("AscOrDesc: ");
                    string asc = Console.ReadLine();

                    var products = logic.GetProductsPaginated(pageIndex, pageSize, name, categoryId, orderby, asc);
                    foreach (var producto in products)
                    {
                        Console.WriteLine($" id {producto.Id}, Nombre {producto.Name}, Descripcion {producto.Description}, Precio {producto.Price}");
                    }
                    break;
                };

                case "6":
                {
                    Console.WriteLine("salir");
                    finalizar = true;
                    break;
                };

                default:
                {
                    Console.WriteLine("Opcion incorrecta");
                    break;
                };
                }
            }
        }
Example #14
0
 public ActionResult Delete(ProductViewModel model)
 {
     ProductLogic.DeleteProduct(model.Id);
     return(RedirectToAction("Index"));
 }