public IEnumerable <PurchaseContractDto> GetPageList(Pager page, SearchSupplierContract condition) { dynamic param = new ExpandoObject(); string where = ""; if (!string.IsNullOrEmpty(condition.ProductCodeOrBarCode)) { where += @"and t0.Id in (select i.purchasecontractId from purchasecontractitem i left join product p on i.ProductId = p.Id where (p.BarCode=@ProductCodeOrBarCode or p.`Code`=@ProductCodeOrBarCode )) "; param.ProductCodeOrBarCode = condition.ProductCodeOrBarCode; } if (!string.IsNullOrEmpty(condition.Code)) { where += "and t0.Code=@Code "; param.Code = condition.Code; } if (condition.SupplierId > 0) { where += "and t0.SupplierId=@SupplierId "; param.SupplierId = condition.SupplierId; } if (condition.StoreId > 0) { where += "and FIND_IN_SET(@StoreId,t0.StoreIds) "; param.StoreId = condition.StoreId; } if (condition.Status != 0) { where += "and t0.Status=@Status "; param.Status = condition.Status; } string sql = @"select t0.Id,t0.Name,t0.Code,t0.SupplierId,t0.Contact,t0.StartDate,t0.EndDate,t0.Status,t0.Remark,t1.Code as SupplierCode,t1.Name as SupplierName from PurchaseContract t0 left join supplier t1 on t0.SupplierId = t1.Id 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 <PurchaseContractDto>(sql, param); page.Total = this._query.Count <PurchaseContract>(where, param); return(rows); }
public JsonResult LoadData(Pager page, SearchSupplierContract condition) { var rows = _purchaseContractQuery.GetPageList(page, condition); return(Json(new { success = true, data = rows, total = page.Total }, JsonRequestBehavior.AllowGet)); }