When completed, the ProductMain
form should look something like Figure A-6.
Before this form can be used a few changes need to be made. Open the form in design mode and doubleclick
any gray area to view the code behind the form and to create the Load() event for this form. Next,
add the following line of code directly above the ProductMain form constructor:
private int _productID;
A new constructor needs to be added so that a ProductID can be passed in, so add the following code
below the default ProductMain constructor.
public ProductMain(int productID)
{
InitializeComponent();
_productID = productID;
}
Then, enter the following code in the ProductMain form??™s Load() event. It populates the form??™s two
lookup combos.
323
Appendix A: Case Study
Figure A-6
FabrikamDataContext context =
new FabrikamDataContext("user id=username;password=password");
//first, the producttypes
IEnumerable
result =
from prod in context.ProductTypes
orderby prod.Name
select prod;
DataTable dt = new DataTable("ProductType");
DataColumn dc;
DataRow dr;
dc = new DataColumn();
dc.
Pages:
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502