Beispiel #1
0
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            ProductClass modifyProduct   = new ProductClass();
            String       x               = "AddProduct";
            AddProduct   addProductClick = new AddProduct(x, modifyProduct);
            var          result          = addProductClick.ShowDialog();

            if (result == DialogResult.OK)
            {
                ProductClass AddProducts    = addProductClick.added;
                bool         returnedResult = ProductDB_Class.AddProduct(AddProducts);
                if (returnedResult)
                {
                    FillListViewProduct();
                    MessageBox.Show("Product added");
                }
                else
                {
                    MessageBox.Show("Error");
                }
            }
        }
Beispiel #2
0
        private void btnModifyProduct_Click(object sender, EventArgs e)
        {
            ProductClass modifyProduct = new ProductClass();

            if (lstProduct.SelectedItems.Count > 0)
            {
                ListViewItem item = lstProduct.SelectedItems[0];
                modifyProduct.nameProduct        = item.SubItems[0].Text;
                modifyProduct.descriptionProduct = item.SubItems[1].Text;
                modifyProduct.createdProduct     = Convert.ToDateTime(item.SubItems[2].Text);
                modifyProduct.updatedProduct     = Convert.ToDateTime(item.SubItems[3].Text);
                modifyProduct.costProduct        = Convert.ToDouble(item.SubItems[4].Text);
                modifyProduct.idStatusProduct    = Convert.ToInt32(item.SubItems[6].Text);
                modifyProduct.idProduct          = Convert.ToInt32(item.SubItems[7].Text);

                String     x = "ModifyProduct";
                AddProduct modifyProductClick = new AddProduct(x, modifyProduct);
                var        result             = modifyProductClick.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ProductClass modifyingProduct = modifyProductClick.modifiedProduct;
                    bool         returnedResult   = ProductDB_Class.ModifyProduct(modifyingProduct);
                    if (returnedResult)
                    {
                        FillListViewProduct();
                        MessageBox.Show("Product changed");
                    }
                    else
                    {
                        MessageBox.Show("Error");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select a product ");
            }
        }