ProductTypeID;
dr2["Name"] = product.Name;
dt2.Rows.Add(dr2);
}
cboManufacturer.DataSource = dt2;
cboManufacturer.DisplayMember = "Name";
cboManufacturer.ValueMember = "ID";
if (_productID > 0)
{
this.GetProduct(_productID, context);
}
This code also looks to see if a productID was passed in. If a productID was passed in, you know that
the user clicked the Edit button on the SelectProduct form and wants to display the product details
of the product he selected in the grid; you want to call the GetProduct() method.
325
Appendix A: Case Study
Well, the GetProduct() method has not been created yet, so add it now below the Load() event:
private void GetProduct(int productID, FabrikamDataContext context)
{
var prodQuery = context.Products.Single(p => p.ProductID == productID);
txtName.Text = prodQuery.Name;
txtProductID.Text = Convert.ToString(prodQuery.ProductID);
txtDescription.Text = prodQuery.Description;
cboProductCategory.SelectedValue = Convert.Int32(prodQuery.ProductTypeID);
cboManufacturer.SelectedValue = Convert.Int32(prodQuery.
Pages:
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504