Beispiel #1
0
        public JsonResult LoadDataBatch(Pager page, SearchStoreInventoryBatch condition)
        {
            if (string.IsNullOrEmpty(condition.StoreId) || condition.StoreId == "0")
            {
                condition.StoreId = _context.CurrentAccount.CanViewStores;
            }
            var rows = _storeInventoryQuery.GetPageList(page, condition);

            return(Json(new { success = true, data = rows, total = page.Total }));
        }
Beispiel #2
0
        public IEnumerable <StoreInventoryBatchQueryDto> GetPageList(Pager page, SearchStoreInventoryBatch condition)
        {
            dynamic param = new ExpandoObject();

            string where = "";
            if (condition.SupplierId > 0)
            {
                where           += "and t0.SupplierId=@SupplierId ";
                param.SupplierId = condition.SupplierId;
            }
            if (!string.IsNullOrEmpty(condition.BatchNo))
            {
                where        += "and t0.BatchNo=@BatchNo ";
                param.BatchNo = condition.BatchNo;
            }
            if (!string.IsNullOrEmpty(condition.StoreId) && condition.StoreId != "0")
            {
                where        += "and t0.StoreId in @StoreId ";
                param.StoreId = condition.StoreId.Split(',').ToIntArray();;
            }

            if (!string.IsNullOrEmpty(condition.ProductCodeOrBarCode))
            {
                where += "and (t1.Code=@ProductCodeOrBarCode or t1.BarCode=@ProductCodeOrBarCode) ";
                param.ProductCodeOrBarCode = condition.ProductCodeOrBarCode;
            }
            if (!string.IsNullOrEmpty(condition.CategoryId))
            {
                where           += "and t4.Id like @CategoryId ";
                param.CategoryId = string.Format("{0}%", condition.CategoryId);
            }
            if (!string.IsNullOrEmpty(condition.Operate))
            {
                where         += string.Format("and t0.Quantity {0} @Quantity ", condition.Operate);
                param.Quantity = condition.Quantity;
            }
            string sql = @"select t0.*,t1.`Code` as ProductCode ,t1.`Name` as ProductName,t1.BarCode,t1.Specification,t2.`name` as StoreName,t3.`Name` as SupplierName,t4.FullName as CategoryName 
from storeinventorybatch t0 left join product t1 on t0.productId = t1.Id 
left join store t2 on t2.Id = t0.StoreId 
left join supplier t3 on t3.Id = t0.SupplierId  
left join category t4 on t4.Id = t1.CategoryId  
where 1=1 {0} ORDER BY t0.Id desc LIMIT {1},{2}";

            //rows = this._query.FindPage<ProductDto>(page.PageIndex, page.PageSize).Where<Product>(where, param);
            sql = string.Format(sql, where, (page.PageIndex - 1) * page.PageSize, page.PageSize);
            var rows = this._query.FindAll <StoreInventoryBatchQueryDto>(sql, param);

            // page.Total = this._query.Count<StoreInventory>(where, param);
            page.Total = this._query.Count <StoreInventoryBatch>();

            return(rows);
        }