Пример #1
0
        private void BtnAdd_Click(object sender, EventArgs e)

        /*Adds a new Product to the Supplier by creating new Supplier and Product objects
         * and getting the IDs from the appropriate control to pass as args.
         * Added by Shanice Talan*/
        {
            TravelExpertsClass.Products prod = new TravelExpertsClass.Products(); //there's 2 Products.cs
            Supplier sup = new Supplier();

            prod.ProductsID = Convert.ToInt32(productIdTextBox.Text);
            sup.SupplierID  = Convert.ToInt32(supNameComboBox.SelectedValue);

            Products_SuppliersDB.AddProductSupplier(sup, prod);
        }
 private void btnAccept_Click(object sender, EventArgs e)
 {
     if (addProductSupplier)
     {
         productSupplier = new Products_Suppliers();
         this.PutProductSupplierData(productSupplier);
         try
         {
             productSupplier.ProductSupplierId = Products_SuppliersDB.AddProductSupplier(productSupplier);
             this.DialogResult = DialogResult.OK;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, ex.GetType().ToString());
         }
     }
     else
     {
         Products_Suppliers newProductSupplier = new Products_Suppliers();
         newProductSupplier.ProductSupplierId = productSupplier.ProductSupplierId;
         this.PutProductSupplierData(newProductSupplier);
         try
         {
             if (!Products_SuppliersDB.UpdateProductSupplier(productSupplier, newProductSupplier))
             {
                 MessageBox.Show("Another user has updated or " +
                                 "deleted that product supplier.", "Database Error");
                 this.DialogResult = DialogResult.Retry;
             }
             else
             {
                 productSupplier   = newProductSupplier;
                 this.DialogResult = DialogResult.OK;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, ex.GetType().ToString());
         }
     }
 }