private DataTable GetPurchaseOrderTable() { long telHlp = 0; long faxHlp = 0; string telfmt = "000-000-0000"; string szTel = ""; TimelyDepotContext db01 = new TimelyDepotContext(); DataTable table = null; DataRow row = null; PurchaseOrderList thepurchaseorderlist = null; List<PurchaseOrderList> purchaseList = new List<PurchaseOrderList>(); var qryPurchaseOrder = db.Vendors.Join(db.PurchaseOrders, vdad => vdad.VendorNo, prod => prod.VendorId, (vdad, prod) => new { vdad, prod }).OrderBy(vdod => vdod.prod.PurchaseOrderNo); if (qryPurchaseOrder.Count() > 0) { foreach (var item in qryPurchaseOrder) { thepurchaseorderlist = new PurchaseOrderList(); thepurchaseorderlist.PurchaseOrderId = item.prod.PurchaseOrderId; thepurchaseorderlist.PurchaseOrderNo = item.prod.PurchaseOrderNo; thepurchaseorderlist.SODate = item.prod.PODate; thepurchaseorderlist.VendorNo = item.prod.VendorId; //thepurchaseorderlist.VendorNo = GetCustomerDataSO(db01, item.ctad.VendorId.ToString()); thepurchaseorderlist.CompanyName = GetVendorData01(db01, item.prod.VendorId); thepurchaseorderlist.SalesOrderNo = item.prod.SalesOrderNo; thepurchaseorderlist.ShipDate = item.prod.ShipDate; thepurchaseorderlist.PaymentAmount = this.GetTotalPO01(db01, item.prod.PurchaseOrderId); purchaseList.Add(thepurchaseorderlist); } } table = new DataTable("SalesOrderList"); // Set the header DataColumn col01 = new DataColumn("PurchaseOrderNo", System.Type.GetType("System.String")); DataColumn col02 = new DataColumn("Date", System.Type.GetType("System.String")); DataColumn col03 = new DataColumn("VendorNo", System.Type.GetType("System.String")); DataColumn col04 = new DataColumn("VendorCompanyName", System.Type.GetType("System.String")); DataColumn col05 = new DataColumn("SalesOrderNo", System.Type.GetType("System.String")); DataColumn col06 = new DataColumn("ShipDate", System.Type.GetType("System.String")); DataColumn col07 = new DataColumn("Amount", System.Type.GetType("System.String")); table.Columns.Add(col01); table.Columns.Add(col02); table.Columns.Add(col03); table.Columns.Add(col04); table.Columns.Add(col05); table.Columns.Add(col06); table.Columns.Add(col07); //Set the data row foreach (var item in purchaseList) { row = table.NewRow(); row["PurchaseOrderNo"] = item.PurchaseOrderNo; row["Date"] = item.SODate; row["VendorNo"] = item.VendorNo; row["VendorCompanyName"] = item.CompanyName; row["SalesOrderNo"] = item.SalesOrderNo; row["ShipDate"] = item.ShipDate; row["Amount"] = item.PaymentAmount; table.Rows.Add(row); } return table; }
public PartialViewResult PurchaseOrderList(int? page) { int pageIndex = 0; int pageSize = PageSize; TimelyDepotContext db01 = new TimelyDepotContext(); PurchaseOrderList thepurchaseorderlist = null; List<PurchaseOrderList> customerList = new List<PurchaseOrderList>(); var qryPurchaseOrder = db.Vendors.Join(db.PurchaseOrders, vdad => vdad.VendorNo, prod => prod.VendorId, (vdad, prod) => new { vdad, prod }).OrderBy(vdod => vdod.prod.PurchaseOrderNo); if (qryPurchaseOrder.Count() > 0) { foreach (var item in qryPurchaseOrder) { thepurchaseorderlist = new PurchaseOrderList(); thepurchaseorderlist.PurchaseOrderId = item.prod.PurchaseOrderId; thepurchaseorderlist.PurchaseOrderNo = item.prod.PurchaseOrderNo; thepurchaseorderlist.SODate = item.prod.PODate; thepurchaseorderlist.VendorNo = item.prod.VendorId; //thepurchaseorderlist.VendorNo = GetCustomerDataSO(db01, item.ctad.VendorId.ToString()); thepurchaseorderlist.CompanyName = GetVendorData01(db01, item.prod.VendorId); thepurchaseorderlist.SalesOrderNo = item.prod.SalesOrderNo; thepurchaseorderlist.ShipDate = item.prod.ShipDate; thepurchaseorderlist.PaymentAmount = this.GetTotalPO01(db01, item.prod.PurchaseOrderId); customerList.Add(thepurchaseorderlist); } } //Set the page if (page == null) { pageIndex = 1; } else { pageIndex = Convert.ToInt32(page); } var onePageOfData = customerList.ToPagedList(pageIndex, pageSize); ViewBag.OnePageOfData = onePageOfData; return PartialView(customerList.ToPagedList(pageIndex, pageSize)); }