public void LoadProductSupplierList() { suppliers = SupplierDB.GetAllSuppliers(); products_suppliers = ProductSupplierDB.GetProductSuppliers(); var sup = from prod_supp in products_suppliers join supp in suppliers on prod_supp.SupplierId equals supp.SupplierId where prod_supp.ProductId == (int)productIdComboBox.SelectedItem select new { prod_supp.SupplierId, supp.SupName, prod_supp.ProductId, prod_supp.ProductSupplierId }; lvProductSupplier.Items.Clear(); int i = 0; foreach (var s in sup) { lvProductSupplier.Items.Add(s.SupplierId.ToString()); lvProductSupplier.Items[i].SubItems.Add(s.SupName); lvProductSupplier.Items[i].SubItems.Add(s.ProductId.ToString()); lvProductSupplier.Items[i].SubItems.Add(s.ProductSupplierId.ToString()); i++; } }
private void refreshDataSource() { ProdSups = ProductSupplierDB.GetProductSuppliers(); var data = from ps in ProdSups orderby ps.Supplier.Name select new { ID = ps.ProductSupplierId, Supplier = ps.Supplier.Name, Product = ps.Product.Name, ps.FullName }; source.DataSource = data; }
private void cboProduct_SelectedIndexChanged(object sender, EventArgs e) { suppliers = new List <Supplier>(); int productID = (int)cboProduct.SelectedValue; //Populate supplier list for all suppliers offering the selected product //Get supplierIDs var possibleSuppliers = ProductSupplierDB.GetProductSuppliers(); var availableSupplierIDs = from supplier in possibleSuppliers where supplier.ProductId == productID select supplier.SupplierId; //Add suppliers to our list foreach (int id in availableSupplierIDs) { suppliers.Add(SupplierDB.GetSupplier(id)); } //Add list to the dropdown cboSuppliers.DataSource = suppliers; }