Пример #1
0
        private void btnProductModify_Click(object sender, EventArgs e)
        {
            try
            {
                int         i        = lstMaintainProduct.SelectedIndex;
                ProductForm prodForm = new ProductForm();

                if (i != -1)
                {
                    Product product = prods[i];
                    prodForm.SetProdFormFields(product);
                    product.Code    = 0;
                    product.Name    = null;
                    product.Version = 0;
                    product.Date    = null;
                    MessageBox.Show("Modify the record and click save !");
                    FillProductListBox();
                    product = prodForm.GetNewProduct();

                    if (product != null)
                    {
                        if (ProductDB.AddProduct(product))
                        {
                            MessageBox.Show("Product added successfully !");
                            FillProductListBox();
                        }
                        else
                        {
                            MessageBox.Show("Failed to add Product");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Пример #2
0
 private void btnProductAdd_Click(object sender, EventArgs e)
 {
     try
     {
         ProductForm product = new ProductForm();
         Product     p       = product.GetNewProduct();
         if (p != null)
         {
             if (ProductDB.AddProduct(p))
             {
                 MessageBox.Show("Product added successfully !");
                 FillProductListBox();
             }
             else
             {
                 MessageBox.Show("Failed to add Product");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error");
     }
 }