ManufacturerID);
txtManufacturerSKU.Text = prodQuery.ManufacturerSKU;
txtLength.Text = Convert.ToString(prodQuery.Length);
txtWidth.Text = Convert.ToString(prodQuery.Width);
txtDepth.Text = Convert.ToString(prodQuery.Depth);
txtHeight.Text = Convert.ToString(prodQuery.Height);
txtCost.Text = Convert.ToString(prodQuery.Cost);
txtPrice.Text = Convert.ToString(prodQuery.Price);
txtQuantity.Text = Convert.ToString(prodQuery.QuantityOnHand);
}
This code takes the productID that was passed in and uses LINQ to SQL to return a single product
record. It then populates the ProductMain combo controls with the corresponding data.
Now add the following code to the OK button??™s Click() event. This code looks at the txtProductID
control to see if there is a value. If not, it is a new product and a new instance of the Product entity is
created, populated, and saved back to the database, all via LINQ to SQL. If there is an existing productID,
the current record is updated and the changes are saved back to the database.
try
{
FabrikamDataContext context =
new FabrikamDataContext("user id=username;password=password");
if (txtProductID.
Pages:
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505