本帖最后由 鲜学良 于 2012-12-20 22:00 编辑
/// <param name="total">总条数</param> 总条数总是不能获取,谁帮忙看看嘛!
代码如下:
#region 报表查询
/// <summary>
/// 报表查询
/// </summary>
/// <param name="flag">0查询成功</param>
/// <param name="PageCount">总条数</param>
/// <param name="PageIndex">第几页</param>
/// <param name="total">总条数</param>
/// <returns></returns>
public static List<CWSub> GetCW3(string sNbid, int iSub, DateTime strtime, DateTime endtime, int PageIndex, int PageCount, out int flag, out int total)
{
List<CWSub> list = new List<CWSub>();
SqlParameter[] pars = new SqlParameter[]
{
new SqlParameter("@OV_iReturnValue", SqlDbType.Int),
new SqlParameter("@OV_iTotalRow", SqlDbType.Int),
new SqlParameter("@V_PageIndex", PageIndex),
new SqlParameter("@V_PageCount", PageCount),
new SqlParameter("@V_iSub", iSub),
new SqlParameter("@V_snbid", sNbid),
new SqlParameter("@V_dtStart", strtime),
new SqlParameter("@V_dtEnd", endtime)
};
pars[0].Direction = ParameterDirection.Output;
pars[1].Direction = ParameterDirection.Output;
using (SqlDataReader sdr = DBHelp.QueryByProc("Asset.UP_Get_tPayList_3", DBHelp.Employeestr, pars))
{
while (sdr.Read())
{
CWSub cw3 = new CWSub();
cw3.sDocumen = sdr["sDocumen"].ToString();
cw3.sContent = sdr["sContent"].ToString();
cw3.iPrice = Convert.ToDecimal(sdr["iPrice"]);
cw3.dtTime = Convert.ToDateTime(sdr["dtTime"]);
list.Add(cw3);
}
flag = Convert.ToInt32(pars[0].Value);
total = Convert.ToInt32(pars[1].Value);
}
return list;
}
#endregion
public static SqlDataReader QueryByProc(string procName, params SqlParameter[] spms)
{
return Query(CommandType.StoredProcedure, procName, spms);
}
private static SqlDataReader Query(CommandType type, string commandText, string conne, SqlParameter[] spms)
{
SqlDataReader reader = null;
try
{
SqlConnection conn = new SqlConnection(conne);
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, conn, null, type, commandText, spms);
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
cmd.Parameters.Clear();
}
catch (Exception ex)
{
int flag = 0;
WriteLogToDB(commandText, ex.Message, flag);
}
return reader;
} |