Exemplo n.º 1
0
 private void dataGridProdSupp_SelectionChanged(object sender, EventArgs e)
 {
     currentProd = (Product)dataGridProdSupp.CurrentRow.DataBoundItem;
     packageList = ProductsSuppliersDB.GetPackagesWith(currentSupp.SupplierId, currentProd.ProductId);
     datagridPackages.DataSource = packageList;
     //store currently selected row data to product Object
 }
Exemplo n.º 2
0
 private void Display()
 {
     allProdList  = ProductsSuppliersDB.GetProducts();
     prodSuppList = ProductsSuppliersDB.GetProductSuppBySuppID(currentSupp.SupplierId);
     dataGridProdSupp.DataSource = prodSuppList;
     dataGridAllProd.DataSource  = allProdList;
 }
Exemplo n.º 3
0
 private void frmSuppliers_Load(object sender, EventArgs e)
 {
     dataGridSuppliers.DataSource = ProductsSuppliersDB.GetSuppliers();
     datagridPackages.DataSource  = packageList;
     FindProductSuppliers();
     dataGridSuppliers.Columns[0].Width = 300;
     dataGridAllProd.Columns[0].Width   = 200;
     dataGridProdSupp.Columns[0].Width  = 200;
     datagridPackages.Columns[0].Width  = 100;
 }
Exemplo n.º 4
0
 private void GetSuppliersProducts(int supplierId)
 {
     try
     {
         prodSuppList = ProductsSuppliersDB.GetProductSuppBySuppID(supplierId);
         allProdList  = ProductsSuppliersDB.GetProducts();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString());
     }
 }
Exemplo n.º 5
0
        private void btnAddSupp_Click(object sender, EventArgs e)
        {
            frmAddEditSupplier addSuppfrm = new frmAddEditSupplier();

            addSuppfrm.AddSuppliers = true;

            DialogResult res = addSuppfrm.ShowDialog();

            if (res == DialogResult.OK)
            {
                suppList = ProductsSuppliersDB.GetSuppliers();
                dataGridSuppliers.DataSource = suppList;
                Display();
                FindProductSuppliers();
            }
        }
Exemplo n.º 6
0
        } //delete supplier

        private void btnAddProdToList_Click(object sender, EventArgs e) //add new products to suppliers
        {
            if (dataGridAllProd.SelectedRows.Count == 0)
            {
                MessageBox.Show(@"No product/s to add! " + @"Try Again", @"No Product", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            int newProdId = ((Product)dataGridAllProd.CurrentRow.DataBoundItem).ProductId;

            var products = from ps in prodSuppList
                           where ps.ProductId == newProdId
                           select ps;

            if (products.Count() != 0)
            {
                MessageBox.Show(@"This Product is already added!", @"Duplicate", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            Product_Supplier newProdSupp = new Product_Supplier();

            try
            {
                newProdSupp.ProductId  = newProdId;
                newProdSupp.SupplierId = currentSupp.SupplierId;

                newProdSupp.ProductSupplierId = ProductsSuppliersDB.AddToProdSupp(newProdSupp);

                currentSupp = dataGridSuppliers.CurrentRow.DataBoundItem as Supplier;
                if (currentSupp != null)
                {
                    GetSuppliersProducts(currentSupp.SupplierId);

                    Display();
                }

                Display();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 7
0
        private void btnEditSupp_Click(object sender, EventArgs e)
        {
            frmAddEditSupplier editSuppfrm = new frmAddEditSupplier(); //Instantiate a new form

            if (currentSupp != null)
            {
                editSuppfrm.supplier     = currentSupp; // selected supplier is now the next form's supplier
                editSuppfrm.AddSuppliers = false;

                DialogResult res = editSuppfrm.ShowDialog();
                if (res == DialogResult.OK)
                {
                    suppList = ProductsSuppliersDB.GetSuppliers();
                    dataGridSuppliers.DataSource = suppList;
                    Display();
                    FindProductSuppliers();
                }
            }
        }
Exemplo n.º 8
0
        private void btnEditProd_Click(object sender, EventArgs e)
        {
            FrmAddModifyProducts editProdForm = new FrmAddModifyProducts();

            editProdForm.AddProducts = false;
            editProdForm.product     = currentAllProd;

            DialogResult res = editProdForm.ShowDialog();

            if (res == DialogResult.OK)
            {
                currentProd = editProdForm.product;
                allProdList = ProductsSuppliersDB.GetProducts();
                dataGridAllProd.DataSource = allProdList;
                Display();
            }
            else
            {
                editProdForm.ClearControls();
            }
        }
Exemplo n.º 9
0
 private void btnDeleteSupp_Click(object sender, EventArgs e)
 {
     if (currentSupp != null)
     {
         try
         {
             if (MessageBox.Show(@"Are you sure you want to delete: " + currentSupp.SupName + @" Supplier?",
                                 @"Delete Supplier", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 currentSupp.DeleteSupp(); // delete current supplier
                 suppList = ProductsSuppliersDB.GetSuppliers();
                 dataGridSuppliers.DataSource = suppList;
                 Display();
                 FindProductSuppliers(); // find Suppliers
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(@"Cannot delete this supplier, it is currently supplying products!", @"Delete", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 } //delete supplier
Exemplo n.º 10
0
 public void RemoveFromSupplier(int SupplierId)
 {
     ProductsSuppliersDB.RemoveProdFromSupp(ProductId, SupplierId);
 }