private void btnProdSearch_Click(object sender, EventArgs e) { ViewProductForm searchProd = new ViewProductForm(); searchProd.ShowDialog(); IProductUtility prodUtil = DependencyInjectorUtility.GetProductsUtility(); if (string.IsNullOrWhiteSpace(txtProductSearch.Text)) { MessageBox.Show("Product Search value required."); return; } //good search List <Product> prodSearchResults = prodUtil.ProductSearch(txtProductSearch.Text); List <ProductViewModel> psVMCollection = new List <ProductViewModel>(); foreach (Product prodDTO in prodSearchResults) { //create new view model object ProductViewModel psVM = new ProductViewModel(prodDTO); //add to psVMVollection collection psVMCollection.Add(psVM); } //datasource grid view dgvProductSearch.DataSource = null; dgvProductSearch.DataSource = psVMCollection; }
private void buttonSearch_Click(object sender, EventArgs e) { flpProducts.Controls.Clear(); //removes existing controls IProductUtility prodUtil = DependencyInjectorUtility.GetProductsUtility(); if (string.IsNullOrWhiteSpace(txtProductSearch.Text)) { MessageBox.Show("Product Search value required."); return; } //good search List <Product> prodSearchResults = prodUtil.ProductSearch(txtProductSearch.Text); List <ProductViewModel> psVMCollection = new List <ProductViewModel>(); foreach (Product prodDTO in prodSearchResults) { ucProdSearch puc = new ucProdSearch(prodDTO); flpProducts.Controls.Add(puc); } }