Example #1
0
        private void DisplayComboBoxes()
        {
            List <ProductsSuppliers> prodid = new List <ProductsSuppliers>();
            List <ProductsSuppliers> supid  = new List <ProductsSuppliers>();

            try
            {
                prodid = ProductSupplierIdDB.GetUniqueProSupId("p");
                supid  = ProductSupplierIdDB.GetUniqueProSupId("s");

                cboProdId.DataSource    = prodid;
                cboProdId.DisplayMember = "ProdName";
                cboProdId.ValueMember   = "ProductId";
                cboSupId.DataSource     = supid;
                cboSupId.DisplayMember  = "SupName";
                cboSupId.ValueMember    = "SupplierId";
                if (!addProductsSuppler)
                {
                    cboProdId.SelectedValue = productsupplier.ProductId;
                    cboSupId.SelectedValue  = productsupplier.SupplierId;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
        }
Example #2
0
        // STEP 3
        private void cboProductsSupplierrId_SelectedIndexChanged(object sender, EventArgs e)
        {
            int pid = 0;

            try
            {
                pid = Convert.ToInt32(cboProductsSupplierrId.SelectedValue);
            }
            catch { }
            SelectedPS = ProductSupplierIdDB.GetSelected(pid);
            this.DisplayPS(SelectedPS);
        }
Example #3
0
        //Alex
        private void cboSupplierName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboSupplierName.SelectedIndex != 0)
            {
                int selectedprodid = Convert.ToInt32(cboProductName.SelectedIndex);
                selectedprodid = selectedprodid + 1;

                int sup = (int)cboSupplierName.SelectedValue;
                //int selectedsupplier = sup.SupplierId;
                cboPSPPS.DataSource    = ProductSupplierIdDB.GetProductSupplierId2Inputs(selectedprodid, sup);
                cboPSPPS.ValueMember   = "ProductSupplierId";
                cboPSPPS.DisplayMember = "ProductSupplierId";
            }
        }
Example #4
0
        //*******************************************************************
        //*                                                                 *
        //*                             ALEX                                *
        //*                                                                 *
        //*******************************************************************



        // STEP 1
        public void GetProductsSuppliers()
        {
            List <ProductsSuppliers> productssupplierid = new List <ProductsSuppliers>();

            try
            {
                productssupplierid = ProductSupplierIdDB.GetProductsSupplierId();
                cboProductsSupplierrId.DataSource    = productssupplierid;
                cboProductsSupplierrId.DisplayMember = "ProductSupplierId";
                cboProductsSupplierrId.ValueMember   = "ProductSupplierId";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
        }
Example #5
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (Validator.IsPresent(cboProdId) &&
                Validator.IsPresent(cboSupId))
            {
                if (addProductsSuppler)
                {
                    productsupplier = new ProductsSuppliers();
                    this.PutProductSupplierData(productsupplier);
                    try
                    {
                        productsupplier.ProductSupplierId = ProductSupplierIdDB.AddProductSupplier(productsupplier);
                        this.DialogResult = DialogResult.OK;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ex.GetType().ToString());
                    }
                }

                else
                {
                    ProductsSuppliers newProductSupplier = new ProductsSuppliers();
                    newProductSupplier.ProductSupplierId = productsupplier.ProductSupplierId;
                    this.PutProductSupplierData(newProductSupplier);

                    try
                    {
                        if (!ProductSupplierIdDB.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());
                    }
                }
            }
        }
Example #6
0
        private void btnDeletePS_Click(object sender, EventArgs e)
        {
            int ps;

            ps = ((int)cboProductsSupplierrId.SelectedValue);

            bool logic = ProductSupplierIdDB.Delete(ps);

            this.GetProductsSuppliers();


            if (logic == true)
            {
                MessageBox.Show("You have Deleted Products Suplliers combination!");
            }
            else
            {
                MessageBox.Show("Delete product from pachages first!");
            }
        }
Example #7
0
        //Alex
        private void cboProductName_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedprodid = Convert.ToInt32(cboProductName.SelectedIndex);

            selectedprodid                = selectedprodid + 1;
            cboSupplierName.DataSource    = ProductSupplierIdDB.GetSupplierName(selectedprodid);
            cboSupplierName.DisplayMember = "SupName";
            cboSupplierName.ValueMember   = "SupplierId";
            int?selectedsupplier = (int?)cboSupplierName.SelectedValue;

            if (selectedsupplier != null)
            {
                cboPSPPS.DataSource = ProductSupplierIdDB.GetProductSupplierId2Inputs(selectedprodid, selectedsupplier);
            }
            else
            {
                MessageBox.Show("This selection does not have existing suplliers, add a supplier first");
            }


            //cboPSPPS.DataSource=ProductSupplierIdDB.Get
        }
Example #8
0
 // STEP 2
 public void GetPackages()
 {
     try
     {
         packages = PackagesDB.GetPackages();
         cboPackageId.DataSource    = packages;
         cboPackageId.DisplayMember = "PackageId";
         cboPackageId.ValueMember   = "PackageId";
         packages2               = PackagesDB.GetPackages();
         cboPkgPPS.DataSource    = packages2;
         cboPkgPPS.DisplayMember = "PackageId";
         cboPkgPPS.ValueMember   = "PackageId";
         List <ProductsSuppliers> productssupplierid = new List <ProductsSuppliers>();
         productssupplierid     = ProductSupplierIdDB.GetProductsSupplierId();
         cboPSPPS.DataSource    = productssupplierid;
         cboPSPPS.DisplayMember = "ProductSupplierId";
         cboPSPPS.ValueMember   = "ProductSupplierId";
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString());
     }
 }