private static async Task <DataTable> ExtractSalesData(GridView shoppingCart) { var Cart = shoppingCart; return(await Task.Run(() => { var data = new OrderSet().Tables[0]; for (int i = 0; i < Cart.RowCount; i++) { var row = data.NewRow(); row["Product Name"] = Cart.GetRowCellValue(i, "ProductName"); row["Unit Price"] = Cart.GetRowCellValue(i, "Price"); row["Qty"] = Cart.GetRowCellValue(i, "Quantity"); row["Sub Total"] = Cart.GetRowCellValue(i, "Total"); data.Rows.Add(row); } return data; })); }
private async Task <DataTable> GetDataTable(DataGridView shopping) { var Cart = shopping; return(await Task.Run(() => { var data = new OrderSet().Tables[0]; for (int i = 0; i < Cart.RowCount; i++) { DataRow row = data.NewRow(); row["Product"] = Cart.Rows[i].Cells["Product"]; row["Price"] = Cart.Rows[i].Cells["Price"]; row["Quantity"] = Cart.Rows[i].Cells["Quantity"]; row["Total"] = Cart.Rows[i].Cells["Total"]; data.Rows.Add(row); BindingSource bs = new BindingSource(); bs.DataSource = data; } return data; })); }