dataQuery=$@"SELECT * FROM {tableName} WHERE AllotId = @AllotId and `核算单元` = @accountingUnit and `核算单元类型` in @unitType order by `核算单元类型`,`核算单元` LIMIT {(pageIndex-1)*pageSize},{pageSize} ";
countQuery=$@"SELECT COUNT(*) FROM {tableName} WHERE AllotId = @AllotId and `核算单元` = @accountingUnit and `核算单元类型` in @unitType ";
}
varresult=newCustonPagingData();
stringsql,Query;
//添加查询条件
if(string.IsNullOrEmpty(request.QuerySearch))
Query=" 1=1 ";
else
{
dataQuery=$@"SELECT * FROM {tableName} WHERE AllotId = @AllotId and AccountingUnit = @accountingUnit and UnitType in @unitType order by UnitType,AccountingUnit LIMIT {(pageIndex-1)*pageSize},{pageSize} ";
countQuery=$@"SELECT COUNT(*) FROM {tableName} WHERE AllotId = @AllotId and AccountingUnit = @accountingUnit and UnitType in @unitType ";
column=$@"{column} OR {item} like '%{request.QuerySearch}%'";
}
Query=column;
}
//查询数据
if(string.IsNullOrEmpty(request.QuerySearch))
sql=$@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId and AccountingUnit = @accountingUnit and UnitType in @unitType order by UnitType,AccountingUnit LIMIT {(request.PageIndex-1)*request.PageSize},{request.PageSize} ";
else
sql=$@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId and AccountingUnit = @accountingUnit and UnitType in @unitType AND({Query}) order by UnitType,AccountingUnit LIMIT {(request.PageIndex-1)*request.PageSize},{request.PageSize} ";
// dataQuery = $@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId and `核算单元` = @accountingUnit and `核算单元类型` in @unitType order by `核算单元类型`,`核算单元` LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize} ";
// countQuery = $@"SELECT COUNT(*) FROM {request.TableName} WHERE AllotId = @AllotId and `核算单元` = @accountingUnit and `核算单元类型` in @unitType ";
//}
//else
//{
// dataQuery = $@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId and AccountingUnit = @accountingUnit and UnitType in @unitType order by UnitType,AccountingUnit LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize} ";
// countQuery = $@"SELECT COUNT(*) FROM {request.TableName} WHERE AllotId = @AllotId and AccountingUnit = @accountingUnit and UnitType in @unitType ";
sql=$@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId ";
{
varcolumn="";
foreach(varitemincolumns)
{
if(string.IsNullOrEmpty(column))
column=$@"{item} like '%{request.QuerySearch}%'";
else
sql=$@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId {Query} order by {order} LIMIT {(request.PageIndex-1)*request.PageSize},{request.PageSize} ";
column=$@"{column} OR {item} like '%{request.QuerySearch}%'";
}
Query=column;
}
//查询数据
if(string.IsNullOrEmpty(request.QuerySearch))
sql=$@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId LIMIT {(request.PageIndex-1)*request.PageSize},{request.PageSize}";
else
sql=$@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId AND({Query})LIMIT {(request.PageIndex-1)*request.PageSize},{request.PageSize} ";