创建DataTable

System.Data.DataSet ds = new System.Data.DataSet();
System.Data.DataTableCollection dtCollection = ds.get_Tables();
System.Data.DataTable table1 = new System.Data.DataTable("Table1");
System.Data.DataRowCollection dataRowCollection = table1.get_Rows();
System.Data.DataColumnCollection dataColCollection = table1.get_Columns();
System.Data.DataRow row;

dtCollection.Add(table1);
dataColCollection.Add("ID", System.Type::GetType("System.Int32"));
dataColCollection.Add("ItemId", System.Type::GetType("System.String"));
dataColCollection.Add("ItemName", System.Type::GetType("System.String"));
dataColCollection.Add("WmsLocationId", System.Type::GetType("System.String"));
dataColCollection.Add("BatchSerial", System.Type::GetType("System.String"));
dataColCollection.Add("Qty", System.Type::GetType("System.Double"));
dataColCollection.Add("InventQty", System.Type::GetType("System.Double"));
dataColCollection.Add("UnitId", System.Type::GetType("System.String"));
dataColCollection.Add("Mark", System.Type::GetType("System.String"));

while select journalTrans
where journalTrans.JournalID == journalTable.JournalID
{
  invDim = InventDim::find(journalTrans.InventDimId);
  batchSerial = strfmt("%1%2",invDim.inventBatchId,invDim.inventSerialId);
  inventQty = WL_availQty(journalTrans.ItemId,invDim.InventLocationId,invDim.wMSLocationId,invDim.inventBatchId,invDim.inventSerialId);

  i++;
  row = table1.NewRow();
  row.set_Item("ID",i);
  row.set_Item("ItemId",journalTrans.ItemId);
  row.set_Item("ItemName",journalTrans.itemName());
  row.set_Item("WmsLocationId",invDim.wMSLocationId);
  row.set_Item("BatchSerial",batchSerial);
  row.set_Item("Qty",journalTrans.Qty);
  row.set_Item("InventQty",inventQty);
  row.set_Item("UnitId",journalTrans.unitId());
  dataRowCollection.Add(row);
}

 

posted @ 2021-08-21 15:01  学习是进步的阶梯  阅读(125)  评论(0编辑  收藏  举报