/// <summary>
/// 绑定主表和明显表到GridView
/// </summary>
/// <param name="machineProduct">主表</param>
/// <param name="configureData">字表</param>
private void MasterDatailToGridView(DataTable machineProduct, DataTable configureData)
{
machineProduct.TableName = "MachineProduct";
DataSet ds = new DataSet();
ds.Tables.Add(machineProduct);
DataTable dtNew = configureData.Clone();
dtNew.TableName = "AccessoryConfigure";
foreach (DataRow dr in configureData.Rows)
{
object[] arr = dr.ItemArray;
dtNew.Rows.Add(arr);
}
ds.Tables.Add(dtNew);
//关联字段为GOODS_ID(商品ID)
DataColumn keyColumn = ds.Tables["MachineProduct"].Columns["GOODS_ID"];
DataColumn foreignKeyColumn = ds.Tables["AccessoryConfigure"].Columns["GOODS_ID"];
ds.Relations.Add("商品单位", keyColumn, foreignKeyColumn, false);
this.gridControl1.DataSource = ds.Tables["MachineProduct"];
this.gridControl1.ForceInitialize();
MachineProductGridView.ExpandAllGroups(); // 默认展开分组
}
#endregion