public void LoadData() { mapNameAmountInStock = loadAmountofMaterial(); BUS_InventoryExport export = new BUS_InventoryExport(); DataTable temp = export.SelectDetail(selectionID); tbDescription.Text = export.SelectDescription(selectionID); Console.WriteLine(temp.Rows.Count); foreach (DataRow row in temp.Rows) { string name = row["Tên"].ToString(); string amount = row["Số lượng"].ToString(); string unit = row["Unit"].ToString(); string materID = row["MaterialID"].ToString(); list.Add(new InventoryObject() { amount = amount, name = name, unit = unit, id = materID }); if (mapNameAmountInStock.ContainsKey(name)) { mapNameAmountInStock[name] += int.Parse(amount); } } this.dataGridMaterialExport.ItemsSource = list; if (list.Count == 0) { return; } tbDescription.Text = list[0].description; }
public void LoadData() { var list = new ObservableCollection <InventoryExportDetailObject>(); BUS_InventoryExport export = new BUS_InventoryExport(); DataTable temp = export.SelectDetail(selectionID); tbDescription.Text = export.SelectDescription(selectionID); Console.WriteLine(temp.Rows.Count); foreach (DataRow row in temp.Rows) { string name = row["Tên"].ToString(); string amount = row["Số lượng"].ToString(); string unit = row["Unit"].ToString(); list.Add(new InventoryExportDetailObject() { number = list.Count + 1, amount = amount, name = name, unit = unit }); } this.dataGridMaterialExport.ItemsSource = list; }