//delete button pressed for product supplier tab
        private void btnDeleteProductSupplier_Click(object sender, EventArgs e)
        {
            //showing yes or no message box to give user choice
            DialogResult     result          = MessageBox.Show("Are you sure?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            Product_Supplier productSupplier = productSuppliers[product_SupplierDataGridView.CurrentCell.RowIndex];

            //SelectRowProducts_Suppliers(); //delete later
            if (result == DialogResult.Yes)
            {
                try
                {
                    if (!Product_SupplierDB.DeleteProduct_Supplier(productSupplier)) //if database delete was not sucessful
                    {
                        MessageBox.Show("Another user has updated or deleted this product supplier information", "Datebase Error");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            }
            this.DisplayProductSupplier();
            this.DisplayPackages();
            this.DisplayPackageProdSup();
        }
예제 #2
0
 private void AddModifyProductsSupplier_Load(object sender, EventArgs e)
 {
     this.LoadComboBox();    //load combo boxs with values
     if (addProductSupplier) //if add was pressed
     {
         this.Text = "Add Product Supplier";
         //combo box has no selection
         cbProductId.SelectedIndex  = -1;
         cbSupplierID.SelectedIndex = -1;
         txtProdSupplierID.Text     = Product_SupplierDB.GetNextProductSupplierID().ToString();//get next id value
     }
     else//modify button was pressed
     {
         this.Text = "Modify Product Supplier";
         DisplayProductSuppliers();
     }
 }
예제 #3
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;
                    }
                }
            }
        }
예제 #4
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;
             }
         }
     }
 }
 //display product supplier
 private void DisplayProductSupplier()
 {
     productSuppliers = Product_SupplierDB.GetProduct_Supplier(); //getting product supplier from the database
     product_SupplierDataGridView.DataSource = productSuppliers;
 }