예제 #1
0
        /// <summary>
        ///
        /// </summary>

        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (ValidData())           //making sure data is valid
            {
                if (addPackageProdSup) // if user clciked the add button
                {
                    productSupplier = new Product_Supplier();
                    this.ProductSupplierData(productSupplier);
                    try
                    {
                        productSupplier.ProductSupplierID = Product_SupplierDB.AddProduct_Supplier(productSupplier);
                        Packages_Products_SuppliersDB.Add(productSupplier, package);
                        this.DialogResult = DialogResult.OK;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ex.GetType().ToString());
                    }
                }
                else //if user clicks modify button
                {
                    Product_Supplier newProductSupplier = new Product_Supplier();
                    newProductSupplier.ProductSupplierID = packProdSup.ProductSupplerID;
                    this.ProductSupplierData(newProductSupplier);
                    try
                    {
                        if (!Product_SupplierDB.UpdateProduct_Supplier_Packages(packProdSup, newProductSupplier)) //if product update was unsuccessful
                        {
                            MessageBox.Show("Another user has updated or " +
                                            "deleted that customer.", "Database Error");
                            this.DialogResult = DialogResult.Retry;
                        }
                        else
                        {
                            this.DialogResult = DialogResult.OK;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
예제 #2
0
 //user clicks accept button
 private void btnAccept_Click(object sender, EventArgs e)
 {
     if (ValidData())
     {
         if (addProductSupplier) //add button was pressed
         {
             productSupplier = new Product_Supplier();
             this.ProductSupplierData(productSupplier); //set the product supplier data to the product supplier object
             try
             {
                 productSupplier.ProductSupplierID = Product_SupplierDB.AddProduct_Supplier(productSupplier);
                 this.DialogResult = DialogResult.OK;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, ex.GetType().ToString());
             }
         }
         else //modify button was pressed
         {
             Product_Supplier newProductSupplier = new Product_Supplier();
             newProductSupplier.ProductSupplierID = productSupplier.ProductSupplierID;
             this.ProductSupplierData(newProductSupplier);
             try
             {
                 if (!Product_SupplierDB.UpdateProduct_Supplier(productSupplier, newProductSupplier))
                 {
                     MessageBox.Show("Another user has updated or " +
                                     "deleted that customer.", "Database Error");
                     this.DialogResult = DialogResult.Retry;
                 }
                 else
                 {
                     this.DialogResult = DialogResult.OK;
                 }
             }
             catch (Exception ex)
             {
                 throw ex;
             }
         }
     }
 }