Esempio n. 1
0
        private void FrmProductInventoryRecordsView_Load(object sender, EventArgs e)
        {
            StackOutRecordSearchCondition con1 = new StackOutRecordSearchCondition();

            con1.LastActiveDate = new DateTimeRange(DateTime.Today.AddMonths(-1), DateTime.Now);
            con1.States         = new List <SheetState>();
            con1.States.Add(SheetState.Shipped);
            con1.ProductID   = ProductInventory.ProductID;
            con1.WareHouseID = ProductInventory.WareHouseID;
            List <StackOutRecord> item1 = new StackOutSheetBLL(AppSettings.Current.ConnStr).GetDeliveryRecords(con1).QueryObjects;

            StackInRecordSearchCondition con2 = new StackInRecordSearchCondition();

            con2.LastActiveDate = new DateTimeRange(DateTime.Today.AddMonths(-1), DateTime.Now);
            con2.States         = new List <SheetState>();
            con2.States.Add(SheetState.Inventory);
            con2.ProductID   = ProductInventory.ProductID;
            con2.WareHouseID = ProductInventory.WareHouseID;
            List <StackInRecord> item2 = new StackInSheetBLL(AppSettings.Current.ConnStr).GetInventoryRecords(con2).QueryObjects;

            List <ProductInventoryRecord> items = new List <ProductInventoryRecord>();

            items.AddRange(item1.Select(item => new ProductInventoryRecord()
            {
                Date = item.LastActiveDate, ProductID = item.ProductID, ProductName = item.Product.Name, Out = item.Count, SheetNo = item.SheetNo
            }));
            items.AddRange(item2.Select(item => new ProductInventoryRecord()
            {
                Date = item.LastActiveDate, ProductID = item.ProductID, ProductName = item.Product.Name, In = item.Count, SheetNo = item.SheetNo
            }));
            items = (from item in items
                     orderby item.Date descending
                     select item).ToList();
            ShowItemsInGrid(items);
        }
Esempio n. 2
0
        protected override List <object> GetDataSource()
        {
            StackInRecordSearchCondition con = new StackInRecordSearchCondition();

            con.LastActiveDate = new DateTimeRange(ucDateTimeInterval1.StartDateTime, ucDateTimeInterval1.EndDateTime);
            con.States         = new List <SheetState>();
            con.States.Add(SheetState.Inventory);
            con.SheetTypes = new List <StackInSheetType>();
            con.SheetTypes.Add(StackInSheetType.InventorySheet);
            if (txtCustomer.Tag != null)
            {
                con.SupplierID = (txtCustomer.Tag as CompanyInfo).ID;
            }
            if (txtProductCategory.Tag != null)
            {
                con.CategoryID = (txtProductCategory.Tag as ProductCategory).ID;
            }
            if (txtProduct.Tag != null)
            {
                con.ProductID = (txtProduct.Tag as Product).ID;
            }
            List <StackInRecord> items = (new StackInSheetBLL(AppSettings.Current.ConnStr)).GetInventoryRecords(con).QueryObjects;

            if (items != null && items.Count > 0)
            {
                return((from item in items orderby item.LastActiveDate ascending, item.ProductID ascending select(object) item).ToList());
            }
            return(null);
        }
        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);
        }