public IEnumerable <AdjustContractPriceDto> GetPageList(Pager page, SearchAdjustContractPrice condition) { dynamic param = new ExpandoObject(); string where = ""; if (!string.IsNullOrEmpty(condition.ProductCodeOrBarCode)) { where += @"and a.Id in( select i.AdjustContractPriceId from adjustcontractpriceitem i left join product p on p.id = i.ProductId where (p.`Code`=@ProductCodeOrBarCode or p.BarCode=@ProductCodeOrBarCode) )"; param.ProductCodeOrBarCode = condition.ProductCodeOrBarCode; } if (!string.IsNullOrEmpty(condition.Code)) { where += "and a.Code=@Code "; param.Code = condition.Code; } if (condition.SupplierId > 0) { where += "and a.SupplierId=@SupplierId "; param.SupplierId = condition.SupplierId; } if (condition.StoreId > 0) { where += "and a.StoreId=@StoreId "; param.StoreId = condition.StoreId; } if (condition.Status != 0) { where += "and a.Status=@Status "; param.Status = condition.Status; } string sql = @"select a.*,c.NickName,r.`Name` as StoreName ,s.`Name` as SupplierName,s.`Code` as SupplierCode from adjustcontractprice a left join account c on c.Id = a.CreatedBy left join Supplier s on s.Id = a.SupplierId left join store r on r.Id = a.StoreId where 1=1 {0} ORDER BY a.Id desc LIMIT {1},{2}"; string sqlCount = @"select count(*) from adjustcontractprice a left join account c on c.Id = a.CreatedBy left join Supplier s on s.Id = a.SupplierId left join store r on r.Id = a.StoreId where 1=1 {0} "; sql = string.Format(sql, where, (page.PageIndex - 1) * page.PageSize, page.PageSize); sqlCount = string.Format(sqlCount, where); var rows = this._query.FindAll <AdjustContractPriceDto>(sql, param); page.Total = this._query.Context.ExecuteScalar <int>(sqlCount, param); return(rows); }
public JsonResult LoadData(Pager page, SearchAdjustContractPrice condition) { var rows = _adjustContractPriceQuery.GetPageList(page, condition); return(Json(new { success = true, data = rows, total = page.Total }, JsonRequestBehavior.AllowGet)); }