private void viewProductsForm_Load(object sender, EventArgs e) { IProductUtility prodUtil = DependencyInjectorUtility.GetProductsUtility(); List <Product> AllCustomers = prodUtil.GetProductList(); List <ProductViewModel> pVMCollection = new List <ProductViewModel>(); foreach (Product ProductDTO in AllCustomers) { //create new view model object ProductViewModel pVM = new ProductViewModel(ProductDTO); //add to pVMVollection collection pVMCollection.Add(pVM); } //datasource grid view dgvViewProducts.DataSource = null; dgvViewProducts.DataSource = pVMCollection; }
private void ProductUpdateForm_Load(object sender, EventArgs e) { //Variables Product product; //Load Product IProductUtility prodUtil = DependencyInjectorUtility.GetProductsUtility(); product = prodUtil.GetProductList(id); //Populate the Form with the Product Data txtName.Text = product.Name; txtListPrice.Text = product.ListPrice.ToString(); txtStandardPrice.Text = product.StandardCost.ToString(); txtColor.Text = product.Color; txtWeight.Text = product.Weight.ToString(); //Load picture if (product.ThumbNailPhoto != null) { ShowPicture(product.ThumbNailPhoto); } }