private DataTable GetSalesOrderTable()
        {
            long telHlp = 0;
            long faxHlp = 0;
            string telfmt = "000-000-0000";
            string szTel = "";

            TimelyDepotContext db01 = new TimelyDepotContext();

            DataTable table = null;
            DataRow row = null;

            SalesOrderList thesalesorderlist = null;
            List<SalesOrderList> vendorList = new List<SalesOrderList>();

            var qrySalesOrder = db.CustomersContactAddresses.Join(db.SalesOrders, ctad => ctad.CustomerId, slod => slod.CustomerId, (ctad, slod)
                => new { ctad, slod }).OrderBy(cact => cact.slod.SalesOrderId);
            if (qrySalesOrder.Count() > 0)
            {
                foreach (var item in qrySalesOrder)
                {
                    if (string.IsNullOrEmpty(item.ctad.Tel))
                    {
                        szTel = "0";
                    }
                    else
                    {
                        szTel = item.ctad.Tel;
                    }
                    telHlp = Convert.ToInt64(szTel);
                    szTel = string.Format("{0}", telHlp.ToString(telfmt));

                    thesalesorderlist = new SalesOrderList();
                    thesalesorderlist.SalesOrderId = item.slod.SalesOrderId;
                    thesalesorderlist.SalesOrderNo = item.slod.SalesOrderNo;
                    thesalesorderlist.SODate = item.slod.SODate;
                    thesalesorderlist.CustomerNo = GetCustomerDataSO(db01, item.ctad.CustomerId.ToString());
                    thesalesorderlist.CompanyName = item.ctad.CompanyName;
                    thesalesorderlist.PurchaseOrderNo = item.slod.PurchaseOrderNo;
                    thesalesorderlist.ShipDate = item.slod.ShipDate;
                    thesalesorderlist.PaymentAmount = GetSalesOrderAmount(db01, item.slod.SalesOrderId);

                    vendorList.Add(thesalesorderlist);
                }
            }

            table = new DataTable("SalesOrderList");

            // Set the header
            DataColumn col01 = new DataColumn("SalesOrderNo", System.Type.GetType("System.String"));
            DataColumn col02 = new DataColumn("SODate", System.Type.GetType("System.String"));
            DataColumn col03 = new DataColumn("CustomerNo", System.Type.GetType("System.String"));
            DataColumn col04 = new DataColumn("CompanyName", System.Type.GetType("System.String"));
            DataColumn col05 = new DataColumn("PurchaseOrderNo", 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 vendorList)
            {
                row = table.NewRow();
                row["SalesOrderNo"] = item.SalesOrderNo;
                row["SODate"] = item.SODate;
                row["CustomerNo"] = item.CustomerNo;
                row["CompanyName"] = item.CompanyName;
                row["PurchaseOrderNo"] = item.PurchaseOrderNo;
                row["ShipDate"] = item.ShipDate;
                row["Amount"] = item.PaymentAmount;
                table.Rows.Add(row);
            }

            return table;
        }
        public PartialViewResult SalesOrderList(int? page)
        {
            int pageIndex = 0;
            int pageSize = PageSize;

            TimelyDepotContext db01 = new TimelyDepotContext();

            SalesOrderList thesalesorderlist = null;
            List<SalesOrderList> customerList = new List<SalesOrderList>();

            var qrySalesOrder = db.CustomersContactAddresses.Join(db.SalesOrders, ctad => ctad.CustomerId, slod => slod.CustomerId, (ctad, slod)
                => new { ctad, slod }).OrderBy(cact => cact.slod.SalesOrderId);
            if (qrySalesOrder.Count() > 0)
            {
                foreach (var item in qrySalesOrder)
                {
                    thesalesorderlist = new SalesOrderList();
                    thesalesorderlist.SalesOrderId = item.slod.SalesOrderId;
                    thesalesorderlist.SalesOrderNo = item.slod.SalesOrderNo;
                    thesalesorderlist.SODate = item.slod.SODate;
                    thesalesorderlist.CustomerNo = GetCustomerDataSO(db01, item.ctad.CustomerId.ToString());
                    thesalesorderlist.CompanyName = item.ctad.CompanyName;
                    thesalesorderlist.PurchaseOrderNo = item.slod.PurchaseOrderNo;
                    thesalesorderlist.ShipDate = item.slod.ShipDate;
                    thesalesorderlist.PaymentAmount = GetSalesOrderAmount(db01, item.slod.SalesOrderId);

                    customerList.Add(thesalesorderlist);
                }
            }

            //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));
        }