private void btnDelete_Click(object sender, EventArgs e)
        {
            //delete a product
            int i = lstProducts.SelectedIndex;

            if (i != -1) //user has selected item to delete
            {
                Product product = products[i];
                string  message = "Are you sure you want to delete the product";

                DialogResult confirm = MessageBox.Show(message, "Confirm Deletion",
                                                       MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                                       MessageBoxDefaultButton.Button2);

                if (confirm == DialogResult.Yes)
                {
                    products.Remove(product);
                    ProductDB.SaveProducts(products);
                    FillProductListBox();
                }
            }
            else
            {
                MessageBox.Show("Please select a product to delete",
                                "Delete Unsuccessful", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }
        }
Example #2
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            frmNewProduct newProductForm = new frmNewProduct();
            Product       product        = newProductForm.GetNewProduct();

            if (product != null)
            {
                products.Add(product);
                ProductDB.SaveProducts(products);
                FillProductListBox();
            }
        }
Example #3
0
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            frmNewProduct addProduct = new frmNewProduct();

            addProduct.ShowDialog();
            Product p = addProduct.GetNewProduct();

            if (p != null)
            {
                products.Add(p);
                ProductDB.SaveProducts(products);
                FillProductListBox();
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //the form to add new product is displayed
            frmNewProduct newProductForm = new frmNewProduct();

            Product product = newProductForm.GetNewProduct();

            if (product != null)
            {
                products.Add(product);
                ProductDB.SaveProducts(products);
                FillProductListBox();
            }
        }
Example #5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int i = lstProducts.SelectedIndex;

            if (i != -1)
            {
                Product product = (Product)products[i];
                string  message = "Are your sudre your want to delete "
                                  + product.Description + "?";
                DialogResult button = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo);
                if (button == DialogResult.Yes)
                {
                    products.Remove(product);
                }
                ProductDB.SaveProducts(products);
                FillProductListBox();
            }
        }
Example #6
0
        private void btnDeleteProduct_Click(object sender, EventArgs e)
        {
            int     selectedPosition = lstProducts.SelectedIndex;
            Product p;

            if (selectedPosition != -1)
            {
                DialogResult confirm = MessageBox.Show("Do you want to delete selected product?",
                                                       "Cofirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
                                                       MessageBoxDefaultButton.Button1);
                if (confirm == DialogResult.Yes)
                {
                    lstProducts.Items.RemoveAt(selectedPosition);

                    products.RemoveAt(selectedPosition);

                    ProductDB.SaveProducts(products);
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int i = lstProducts.SelectedIndex;

            if (i != -1)
            {
                DialogResult confirm = MessageBox.Show("Are you sure you want to delete the product?", "Confirm Delete",
                                                       MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                Product product = products[i];

                if (confirm == DialogResult.Yes)
                {
                    products.Remove(product);
                    ProductDB.SaveProducts(products);
                    FillProductListBox();
                }
            }
            else
            {
                MessageBox.Show("Please select the product to delete", "Delletiuon Unsuccessful",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #8
0
 public void Save() => ProductDB.SaveProducts(this);
 public void Save() => ProductDB.SaveProducts(products);