Exemplo n.º 1
0
        //populate combo boxes so there is a supplierID and product ID to choose from
        //Populate the Product list with products from the database
        //Populate the Supplier list with supplier from the database
        private void FillComboBoxes()
        {
            // return list of productID created in GetProductName()
            List <Product> myProdList = ProductsDB.GetProducts();

            // adding product names to the CBName (combo box)
            var prodLinq = from prod in myProdList
                           select new
            {
                prod.ProductId
            };

            foreach (var item in prodLinq)
            {
                cboProdID.Items.Add(item.ProductId);
            }

            // return list of supplierID names created in GetProductName()
            List <Supplier> mySupList = SuppliersDB.GetSuppliers();

            // adding package names to the CBName (combo box)
            var supLinq = from sup in mySupList
                          select new
            {
                sup.SupplierId
            };

            foreach (var item in supLinq)
            {
                cboSupID.Items.Add(item.SupplierId);
            }
        }
Exemplo n.º 2
0
        // populate drop down with names of sup objects from the Suppliers list
        private void PopulateSuppliers()
        {
            // return list of suppliers created in GetSuppliers()
            List <Supplier> supplierList = SuppliersDB.GetSuppliers();
            //if (btnUpdateClicked)
            // {
            // adding supplier names to the CBName (combo box)
            var supplierLinq = from sup in supplierList
                               select new
            {
                sup.SupName
            };

            foreach (var item in supplierLinq)
            {
                cBName.Items.Add(item.SupName);
            }
            // }
            // else
            // {
            //// adding supplier names to the CBName (combo box)
            //var supplierLinq = from sup in supplierList
            //                   select new
            //                   {
            //                       sup.SupplierId
            //                   };

            //foreach (var item in supplierLinq)
            //{
            //    cbSupID.Items.Add(item.SupplierId);
            //}


            cbSupID.DataSource    = supplierList;
            cbSupID.DisplayMember = "SupName";
            cbSupID.ValueMember   = "SupplierId";
            //}
        }
Exemplo n.º 3
0
        // when name combo box (ddl) is used to select an object from the list
        private void cBPkgName_SelectedIndexChanged(object sender, EventArgs e)
        {
            // if the Products button was most recently clicked
            if (btnProdClicked)
            {
                // return list of packages created in GetProducts()
                List <Product> productList = ProductsDB.GetProducts();

                // display information about the selected product
                if (cBName.SelectedIndex != -1)
                {
                    var prod = (from selectedprod in productList where
                                selectedprod.ProdName == cBName.Text
                                select selectedprod).First();

                    txtID.Text = prod.ProductId.ToString();

                    //Maryam
                    SingleProd = prod;
                }
            }

            // if the Suppliers button was most recently clicked
            else if (btnSupClicked)
            {
                // return list of packages created in GetSuppliers()
                List <Supplier> supplierList = SuppliersDB.GetSuppliers();

                // if a selection is made from the combobox
                if (cBName.SelectedIndex != -1)
                {
                    // display information about the selected supplier
                    var sup = (from selectedsup in supplierList
                               where selectedsup.SupName == cBName.Text
                               select selectedsup).First();

                    txtID.Text = sup.SupplierId.ToString();

                    //Maryam
                    SingleSup            = new Supplier();
                    SingleSup.SupplierId = Convert.ToInt32(txtID.Text);
                    SingleSup.SupName    = cBName.Text;
                }
            }

            // if the Packages button was most recently clicked
            // or on form load
            else
            {
                // return list of packages created in GetPackages()
                List <Package> packageList = MainPackageDB.GetPackages();

                // if a selection is made from the combo box
                if (cBName.SelectedIndex != -1)
                {
                    // display information about the selected package
                    var pkg = (from selectedpkg in packageList where
                               selectedpkg.PkgName == cBName.Text
                               select selectedpkg).First();

                    txtID.Text         = pkg.PackageId.ToString();
                    dTPStartDate.Value = Convert.ToDateTime(pkg.PkgStartDate);
                    dTPEndDate.Value   = Convert.ToDateTime(pkg.PkgEndDate);
                    txtDesc.Text       = pkg.PkgDesc;
                    txtBasePrice.Text  = pkg.PkgBasePrice.ToString("c");
                    txtAgencyComm.Text = pkg.PkgAgencyCommission.ToString("c");

                    //Maryam
                    SinglePkg = pkg;
                }
            }
        }