Exemplo n.º 1
0
        private void dgvPutinRecord_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            PutInListOrderEnum orderBy = PutInListOrderEnum.PutInTime;

            switch (e.ColumnIndex)
            {
            case 2:
                orderBy = PutInListOrderEnum.BarCode;
                break;

            case 3:
                orderBy = PutInListOrderEnum.PutInUserName;
                break;

            case 4:
                orderBy = PutInListOrderEnum.Place;
                break;

            case 5:
                orderBy = PutInListOrderEnum.PutInTime;
                break;
            }
            if (_currentOrderBy == orderBy)
            {
                _ascding = !_ascding;
            }
            else
            {
                _ascding = true;
            }
            _currentOrderBy = orderBy;
            customPageControl.MannuleClickGo();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获得库存信息
        /// </summary>
        /// <param name="totalCount"></param>
        /// <param name="searchName"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="orderEnum"></param>
        /// <param name="ascending"></param>
        /// <returns></returns>
        public CResult <List <WebPutInWarehouseRecord> > GetWarehouseInfoList(out int totalCount, string searchName = "", int pageIndex = 1, int pageSize = 100, PutInListOrderEnum orderEnum = PutInListOrderEnum.PutInTime, bool ascending = false, DateTime?searchStartTime = null,
                                                                              DateTime?searchEndTime = null)
        {
            totalCount = 0;
            using (var db = new WarehouseContext())
            {
                Expression <Func <WarehouseM, bool> > filter = r => r.StateID == (int)RecordState.Show;
                if (!string.IsNullOrWhiteSpace(searchName))
                {
                    filter = filter.And(r => r.PutInUserName.Contains(searchName) ||
                                        r.BarCode.Contains(searchName) ||
                                        r.Place.Contains(searchName));
                }
                if (searchStartTime.HasValue)
                {
                    filter = filter.And(r => r.WarehouseTime >= searchStartTime.Value);
                }
                if (searchEndTime.HasValue)
                {
                    searchEndTime = searchEndTime.Value.AddDays(1);
                    filter        = filter.And(r => r.WarehouseTime <= searchEndTime);
                }

                var warehouseIQueary = RepositoryIoc.GetWarehouseMRepository(db).LazyGet(out totalCount, filter, CommonHelper.GetPropName <PutInWarehouseRecord>(r => r.WarehouseM));
                switch (orderEnum)
                {
                case PutInListOrderEnum.BarCode:
                    if (ascending)
                    {
                        warehouseIQueary = warehouseIQueary.OrderBy(r => r.BarCode);
                    }
                    else
                    {
                        warehouseIQueary = warehouseIQueary.OrderByDescending(r => r.BarCode);
                    }
                    break;

                case PutInListOrderEnum.Place:
                    if (ascending)
                    {
                        warehouseIQueary = warehouseIQueary.OrderBy(r => r.Place);
                    }
                    else
                    {
                        warehouseIQueary = warehouseIQueary.OrderByDescending(r => r.Place);
                    }
                    break;

                case PutInListOrderEnum.PutInTime:
                    if (ascending)
                    {
                        warehouseIQueary = warehouseIQueary.OrderBy(r => r.WarehouseTime);
                    }
                    else
                    {
                        warehouseIQueary = warehouseIQueary.OrderByDescending(r => r.WarehouseTime);
                    }
                    break;

                case PutInListOrderEnum.PutInUserName:
                    if (ascending)
                    {
                        warehouseIQueary = warehouseIQueary.OrderBy(r => r.PutInUserName);
                    }
                    else
                    {
                        warehouseIQueary = warehouseIQueary.OrderByDescending(r => r.PutInUserName);
                    }
                    break;
                }
                warehouseIQueary = warehouseIQueary.Page(out totalCount, null, true, pageIndex, pageSize);
                var result = (from f in warehouseIQueary
                              select new WebPutInWarehouseRecord()
                {
                    BarCode = f.BarCode,
                    PutInTime = f.WarehouseTime,
                    PutInUserName = f.PutInUserName,
                    Place = f.Place,
                    WarehouseID = f.WarehouseID,
                }).ToList();
                return(new CResult <List <WebPutInWarehouseRecord> >(result));
            }
        }