コード例 #1
0
        private void FillComboPackageId()
        {
            List <Package> myPackList = MainPackageDB.GetPackages();

            // adding product id to the CBName (combo box)
            var packLinq = from pack in myPackList
                           select new
            {
                pack.PackageId
            };

            foreach (var item in packLinq)
            {
                cboPackId.Items.Add(item.PackageId);
            }
        }
コード例 #2
0
        // populate drop down with names of pkg objects from the Packages list
        private void PopulatePackages()
        {
            // return list of packages created in GetPackages()
            List <Package> packageList = MainPackageDB.GetPackages();

            // adding package names to the CBName (combo box)
            var packageLinq = from pkg in packageList
                              select new
            {
                pkg.PkgName
            };

            foreach (var item in packageLinq)
            {
                cBName.Items.Add(item.PkgName);
            }
        }
コード例 #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;
                }
            }
        }