protected override List <object> GetDataSource() { if (SearchCondition == null) { StackInSheetSearchCondition con = new StackInSheetSearchCondition(); con.LastActiveDate = new DateTimeRange(DateTime.Today.AddYears(-1), DateTime.Now); _Sheets = (new StackInSheetBLL(AppSettings.Current.ConnStr)).GetItems(con).QueryObjects; } else { _Sheets = (new StackInSheetBLL(AppSettings.Current.ConnStr)).GetItems(SearchCondition).QueryObjects; } _Warehouses = (new WareHouseBLL(AppSettings.Current.ConnStr)).GetItems(null).QueryObjects; return(FilterData()); }
protected override List <StackInSheet> GetingItems(DataContext dc, SearchCondition search) { //这种通过两次查询获取信息的方式,在商品很多时会引起性能问题,以后看能不能做联接查询,一次出结果 DataLoadOptions opt = new DataLoadOptions(); opt.LoadWith <StackInSheet>(sheet => sheet.Items); dc.LoadOptions = opt; IQueryable <StackInSheet> ret = dc.GetTable <StackInSheet>(); if (search is SheetSearchCondition) { SheetSearchCondition con = search as SheetSearchCondition; if (con.SheetDate != null) { ret = ret.Where(item => item.SheetDate >= con.SheetDate.Begin && item.SheetDate <= con.SheetDate.End); } if (con.LastActiveDate != null) { ret = ret.Where(item => item.LastActiveDate >= con.LastActiveDate.Begin && item.LastActiveDate <= con.LastActiveDate.End); } if (con.SheetNo != null && con.SheetNo.Count > 0) { ret = ret.Where(item => con.SheetNo.Contains(item.ID)); } if (con.States != null && con.States.Count > 0) { ret = ret.Where(item => con.States.Contains(item.State)); } } if (search is StackInSheetSearchCondition) { StackInSheetSearchCondition con = search as StackInSheetSearchCondition; if (!string.IsNullOrEmpty(con.SupplierID)) { ret = ret.Where(item => item.SupplierID == con.SupplierID); } if (!string.IsNullOrEmpty(con.WareHouseID)) { ret = ret.Where(item => item.WareHouseID == con.WareHouseID); } } List <StackInSheet> sheets = ret.ToList(); return(sheets); }
protected override List <StackInRecord> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search) { DataLoadOptions opt = new DataLoadOptions(); opt.LoadWith <StackInRecord>(item => item.Supplier); opt.LoadWith <StackInRecord>(item => item.WareHouse); opt.LoadWith <StackInRecord>(item => item.Product); opt.LoadWith <Product>(item => item.Category); dc.LoadOptions = opt; IQueryable <StackInRecord> ret = dc.GetTable <StackInRecord>(); if (search is SheetSearchCondition) { SheetSearchCondition con = search as SheetSearchCondition; if (con.LastActiveDate != null) { ret = ret.Where(item => item.LastActiveDate >= con.LastActiveDate.Begin && item.LastActiveDate <= con.LastActiveDate.End); } if (con.SheetNo != null && con.SheetNo.Count > 0) { ret = ret.Where(item => con.SheetNo.Contains(item.SheetNo)); } if (con.States != null && con.States.Count > 0) { ret = ret.Where(item => con.States.Contains(item.State)); } } if (search is StackInSheetSearchCondition) { StackInSheetSearchCondition con = search as StackInSheetSearchCondition; if (!string.IsNullOrEmpty(con.SupplierID)) { ret = ret.Where(item => item.SupplierID == con.SupplierID); } if (!string.IsNullOrEmpty(con.WareHouseID)) { ret = ret.Where(item => item.WareHouseID == con.WareHouseID); } } if (search is StackInRecordSearchCondition) { StackInRecordSearchCondition con = search as StackInRecordSearchCondition; if (!string.IsNullOrEmpty(con.ProductID)) { ret = ret.Where(item => item.ProductID == con.ProductID); } if (!string.IsNullOrEmpty(con.CategoryID)) { ret = ret.Where(item => item.Product.CategoryID == con.CategoryID); } if (!string.IsNullOrEmpty(con.OrderID)) { ret = ret.Where(item => item.OrderID == con.OrderID); } if (!string.IsNullOrEmpty(con.PurchaseID)) { ret = ret.Where(item => item.PurchaseOrder == con.PurchaseID); } if (con.OrderItem != null) { ret = ret.Where(item => item.OrderItem == con.OrderItem); } if (con.PurchaseItem != null) { ret = ret.Where(item => item.PurchaseItem == con.PurchaseItem); } } List <StackInRecord> items = ret.ToList(); return(items); }