예제 #1
0
        public void DisplayProductCatalog()
        {
            ProductOperations productOperations = new ProductOperations(ProductFilePath);

            bool ProductStop = false;

            while (ProductStop != true)
            {
                Console.WriteLine("1. Add a Product");
                Console.WriteLine("2. List all Products");
                Console.WriteLine("3. Delete a Product(Enter Short Code or ID to delete)");
                Console.WriteLine("4. Search a Product");
                Console.WriteLine("5. Exit");

                int i = Convert.ToInt32(Console.ReadLine());
                switch (i)
                {
                case 1:
                    Console.WriteLine("Enter a Product Details");
                    productOperations.AddProduct();

                    break;

                case 2:
                    Console.WriteLine("List all Product");
                    productOperations.DisplayProduct();

                    break;

                case 3:
                    Console.WriteLine("Delete a Product");
                    productOperations.DeleteProduct();
                    break;

                case 4:
                    Console.WriteLine("Search a Product");
                    productOperations.findProduct();
                    break;

                case 5:
                    ProductStop = true;
                    Console.WriteLine("Exiting");
                    Console.Clear();
                    // this.DisplayCatalog();
                    break;

                default:
                    Console.WriteLine("Invalid Operation");
                    break;
                }
            }
        }
        private void Delete_Click(object sender, EventArgs e)
        {
            Product product = new Product();

            product.ID          = Convert.ToInt32(textID.Text);
            product.Title       = textBox1.Text;
            product.Description = textBox2.Text;
            product.Color       = textBox3.Text;
            //  product.Size = Convert.ToDouble(textBox4.Text);
            //  product.Price = Convert.ToDouble(textBox5.Text);
            //product.Stock = Convert.ToInt32(textBox6.Text);

            ProductOperations bl = new ProductOperations();

            bl.DeleteProduct(product);

            MessageBox.Show("Operation succesful");
        }
예제 #3
0
        private void buttonDeleteProduct_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show($"Delete this product? {selectedProduct.Name}", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                int affectedRow = productOperations.DeleteProduct(selectedProduct);
                if (affectedRow > 0)
                {
                    MessageBox.Show("Product deleting is successful!", "Information", MessageBoxButtons.OK);
                    getProducts();
                    FillAllComboBox();
                    Cleartxt(this);
                }
                else
                {
                    MessageBox.Show("Product is couldn't be deleted!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
예제 #4
0
        public async Task <HttpResponseMessage> DeleteProduct(int productId)
        {
            try
            {
                int response = await productOp.DeleteProduct(productId);

                if (response == 0)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Product with Id = " + productId.ToString() + " not found to delete"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "Product with Id = " + productId.ToString() + " is deleted"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
 public void Delete()
 {
     try
     {
         bool isDeleted = false;
         isDeleted = productOperationObj.DeleteProduct(CurrentProduct.Id);
         if (isDeleted)
         {
             ProductOperationResultMessage = "Product has been deleted";
             LoadData();
         }
         else
         {
             ProductOperationResultMessage = "Product has not been deleted";
         }
     }
     catch (Exception ex)
     {
         ProductOperationResultMessage = ex.Message;
     }
 }
예제 #6
0
        public bool DeleteProduct(int productID)
        {
            ProductOperations po = new ProductOperations();

            return(po.DeleteProduct(productID));
        }