public void loadData(DataTable t) { DataTable view = new DataTable(); view.Columns.Add("ProductID", typeof(string)); view.Columns.Add("ProductName", typeof(string)); view.Columns.Add("DateImport", typeof(string)); view.Columns.Add("ImportFrom", typeof(string)); view.Columns.Add("NumberPackImport", typeof(string)); view.Columns.Add("Price", typeof(string)); for (int i = 0; i < t.Rows.Count; i++) { view.Rows.Add(t.Rows[i]["ProductID"].ToString(), ProDAO.getNameByID(t.Rows[i]["ProductID"].ToString().Trim()), t.Rows[i]["DateImport"].ToString(), t.Rows[i]["ImportFrom"].ToString(), t.Rows[i]["NumberPackageImport"].ToString(), t.Rows[i]["PriceImport"].ToString()); } dgvHistory.DataSource = view; }
public void loadData(DataTable t) { DataTable view = new DataTable(); view.Columns.Add("ProductID", typeof(string)); view.Columns.Add("ProductName", typeof(string)); view.Columns.Add("DateImport", typeof(string)); view.Columns.Add("ImportFrom", typeof(string)); view.Columns.Add("NumberPackImport", typeof(string)); view.Columns.Add("Price", typeof(string)); float sum = 0; for (int i = 0; i < t.Rows.Count; i++) { sum += float.Parse(t.Rows[i]["PriceImport"].ToString()); view.Rows.Add(t.Rows[i]["ProductID"].ToString(), ProDAO.getNameByID(t.Rows[i]["ProductID"].ToString().Trim()), t.Rows[i]["DateImport"].ToString(), t.Rows[i]["ImportFrom"].ToString(), t.Rows[i]["NumberPackageImport"].ToString(), float.Parse(t.Rows[i]["PriceImport"].ToString()).ToString("N", CultureInfo.CreateSpecificCulture("es-ES"))); } view.Rows.Add("Total: ", "", "", "", "", sum.ToString("N", CultureInfo.CreateSpecificCulture("es-ES")) + "VND"); dgvHistory.DataSource = view; }