Ejemplo n.º 1
0
        // ADD a supplier to current product click
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int index = cboSupplier.SelectedIndex;
            int supId = suppliersList[index].SupplierId;
            Products_Suppliers productsSuppliers = new Products_Suppliers();

            if (supId < 1)
            {
                MessageBox.Show("Please select supplier to add");
            }
            else
            {
                try
                {
                    int ProductSupplierId = Products_SuppliersDB.AddSupplierById((int)prodId, supId);
                    MessageBox.Show("Supplier added", "Success!");
                    this.DialogResult = DialogResult.OK;
                    Products_Suppliers ps = Products_SuppliersDB.GetProductSupplierById(ProductSupplierId);
                    currentProductSupplierIds.Add(ps);
                    DisplayProductSupplier();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            }
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int index  = cboProducts.SelectedIndex;
            int prodId = productsList[index].ProductId;
            Products_Suppliers productsSuppliers = new Products_Suppliers();

            if (prodId < 1) // no selection
            {
                MessageBox.Show("Please select supplier to add");
            }
            else // user selected a product to add
            {
                try
                {
                    int ProductSupplierId = Products_SuppliersDB.AddSupplierById(prodId, (int)supId);
                    MessageBox.Show("Product deleted", "Success!");
                    this.DialogResult = DialogResult.OK;
                    Products_Suppliers ps = Products_SuppliersDB.GetProductSupplierById(ProductSupplierId); // selected product
                                                                                                            //add selected product
                    currentProductSupplierIds.Add(ps);                                                      // add to current  product supplier list
                    loadData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
                //DisplayCurrentPackageProductSupplierData();
            }
        }