Пример #1
0
        protected override List <PurchaseOrder> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            DataLoadOptions opt = new DataLoadOptions();

            opt.LoadWith <PurchaseOrder>(item => item.Items);
            dc.LoadOptions = opt;
            IQueryable <PurchaseOrder> ret = dc.GetTable <PurchaseOrder>();

            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 PurchaseOrderSearchCondition)
            {
                PurchaseOrderSearchCondition con = search as PurchaseOrderSearchCondition;
                if (!string.IsNullOrEmpty(con.SupplierID))
                {
                    ret = ret.Where(item => item.SupplierID == con.SupplierID);
                }
                if (!string.IsNullOrEmpty(con.Buyer))
                {
                    ret = ret.Where(item => item.Buyer == con.Buyer);
                }
                if (con.WithTax != null)
                {
                    if (con.WithTax.Value)
                    {
                        ret = ret.Where(item => item.WithTax == true);
                    }
                    else
                    {
                        ret = ret.Where(item => item.WithTax == false);
                    }
                }
            }
            List <PurchaseOrder> sheets = ret.ToList();

            return(sheets);
        }
Пример #2
0
 protected override List <object> GetDataSource()
 {
     if (SearchCondition == null)
     {
         PurchaseOrderSearchCondition con = new PurchaseOrderSearchCondition();
         con.LastActiveDate = new DateTimeRange(DateTime.Today.AddYears(-1), DateTime.Now);
         _Sheets            = (new PurchaseOrderBLL(AppSettings.Current.ConnStr)).GetItems(con).QueryObjects;
     }
     else
     {
         _Sheets = (new PurchaseOrderBLL(AppSettings.Current.ConnStr)).GetItems(SearchCondition).QueryObjects;
     }
     return(FilterData());
 }
Пример #3
0
        protected override List <PurchaseItemRecord> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            DataLoadOptions opt = new DataLoadOptions();

            opt.LoadWith <PurchaseItemRecord>(item => item.Supplier);
            opt.LoadWith <PurchaseItemRecord>(item => item.Product);
            dc.LoadOptions = opt;
            IQueryable <PurchaseItemRecord> ret = dc.GetTable <PurchaseItemRecord>();

            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 PurchaseOrderSearchCondition)
            {
                PurchaseOrderSearchCondition con = search as PurchaseOrderSearchCondition;
                if (!string.IsNullOrEmpty(con.SupplierID))
                {
                    ret = ret.Where(item => item.SupplierID == con.SupplierID);
                }
                if (!string.IsNullOrEmpty(con.Buyer))
                {
                    ret = ret.Where(item => item.Buyer == con.Buyer);
                }
            }
            if (search is PurchaseItemRecordSearchCondition)
            {
                PurchaseItemRecordSearchCondition con = search as PurchaseItemRecordSearchCondition;
                if (!string.IsNullOrEmpty(con.ProductID))
                {
                    ret = ret.Where(item => item.ProductID == con.ProductID);
                }
                if (!string.IsNullOrEmpty(con.OrderID))
                {
                    ret = ret.Where(item => item.OrderID == con.OrderID);
                }
            }
            List <PurchaseItemRecord> items = ret.ToList();

            if (search is PurchaseItemRecordSearchCondition)
            {
                PurchaseItemRecordSearchCondition con = search as PurchaseItemRecordSearchCondition;
                if (con.HasOnway != null)
                {
                    if (con.HasOnway.Value)
                    {
                        items = items.Where(item => item.OnWay > 0).ToList();
                    }
                    else
                    {
                        items = items.Where(item => item.OnWay == 0).ToList();
                    }
                }
            }
            return(items);
        }