Hi,
I have load data method as follows:
public List<SalesOrderHeader> Load_SaleOrderRelatedInfo()
{
try
{
using (var context = new AdventureWorksEntities())
{
return context.SalesOrderHeaders.Include("SalesOrderDetails").OrderBy(so => so.SalesOrderNumber).ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
and method for data binding:
public static DataTable Binding_SaleOrderInfoRelated()
{
using (var services = new ServiceTransferClient())
{
var table = new DataTable();
SalesOrderHeader[] orders = services.Load_SaleOrderRelatedInfo();
table.Columns.Add("SalesOrderID", typeof(int));
table.Columns.Add("RevisionNumber", typeof(int));
table.Columns.Add("OrderDate", typeof(DateTime));
table.Columns.Add("DueDate", typeof(DateTime));
table.Columns.Add("ShipDate", typeof(DateTime));
table.Columns.Add("Status", typeof(int));
table.Columns.Add("OnlineOrderFlag", typeof(int));
table.Columns.Add("SalesOrderNumber", typeof(string));
table.Columns.Add("PurchaseOrderNumber", typeof(string));
table.Columns.Add("AccountNumber", typeof(string));
table.Columns.Add("CustomerID", typeof(int));
table.Columns.Add("ContactID", typeof(int));
table.Columns.Add("SalesPersonID", typeof(int));
table.Columns.Add("TerritoryID", typeof(int));
table.Columns.Add("BillToAddressID", typeof(int));
table.Columns.Add("ShipToAddressID", typeof(int));
table.Columns.Add("ShipMethodID", typeof(int));
table.Columns.Add("CreditCardID", typeof(int));
table.Columns.Add("CreditCardApprovalCode", typeof(string));
table.Columns.Add("CurrencyRateID", typeof(int));
table.Columns.Add("SubTotal", typeof(decimal));
table.Columns.Add("TaxAmt", typeof(decimal));
table.Columns.Add("Freight", typeof(decimal));
table.Columns.Add("TotalDue", typeof(decimal));
table.Columns.Add("Comment", typeof(string));
table.Columns.Add("SalesOrderDetailID", typeof(int));
table.Columns.Add("CarrierTrackingNumber", typeof(string));
table.Columns.Add("OrderQty", typeof(int));
table.Columns.Add("ProductID", typeof(int));
table.Columns.Add("SpecialOfferID", typeof(int));
table.Columns.Add("UnitPrice", typeof(decimal));
table.Columns.Add("UnitPriceDiscount", typeof(decimal));
table.Columns.Add("LineTotal", typeof(double));
foreach (var o in orders)
{
var rows = table.NewRow();
rows["SalesOrderID"] = o.SalesOrderID;
rows["RevisionNumber"] = o.RevisionNumber;
rows["OrderDate"] = o.OrderDate;
rows["DueDate"] = o.DueDate;
rows["ShipDate"] = o.ShipDate;
rows["Status"] = o.Status;
rows["OnlineOrderFlag"] = o.OnlineOrderFlag;
rows["SalesOrderNumber"] = o.SalesOrderNumber;
rows["PurchaseOrderNumber"] = o.PurchaseOrderNumber;
rows["AccountNumber"] = o.AccountNumber;
rows["CustomerID"] = o.CustomerID;
rows["ContactID"] = o.ContactID;
rows["SalesPersonID"] = o.SalesPersonID.GetValueOrDefault();
rows["TerritoryID"] = o.TerritoryID;
rows["BillToAddressID"] = o.BillToAddressID;
rows["ShipToAddressID"] = o.ShipToAddressID;
rows["ShipMethodID"] = o.ShipMethodID;
rows["CreditCardID"] = o.CreditCardID.GetValueOrDefault();
rows["CreditCardApprovalCode"] = o.CreditCardApprovalCode;
rows["CurrencyRateID"] = o.CurrencyRateID.GetValueOrDefault();
rows["SubTotal"] = o.SubTotal;
rows["TaxAmt"] = o.TaxAmt;
rows["Freight"] = o.Freight;
rows["TotalDue"] = o.TotalDue;
rows["Comment"] = o.Comment;
table.Rows.Add(rows);
foreach (var od in o.SalesOrderDetails)
{
var rows1 = table.NewRow();
rows1["SalesOrderID"] = o.SalesOrderID;
rows1["SalesOrderDetailID"] = od.SalesOrderDetailID;
rows1["CarrierTrackingNumber"] = od.CarrierTrackingNumber;
rows1["OrderQty"] = od.OrderQty;
rows1["ProductID"] = od.ProductID;
rows1["SpecialOfferID"] = od.SpecialOfferID;
rows1["UnitPrice"] = od.UnitPrice;
rows1["UnitPriceDiscount"] = od.UnitPriceDiscount;
rows1["LineTotal"] = od.LineTotal;
table.Rows.Add(rows1);
}
}
return table;
}
}
because the amount of data so large that when executed method take times. To reduce the waiting and anxious, can use the progress bar, progress bar is finished when the data is loaded.
How can I do?
THANKS!