/// <summary> /// 获得数据List /// </summary> public Dat_WebLogList GetDataList(Dat_WebLogQueryCondition QueryCondition) { SqlParameter[] sqlParams; StringBuilder strSqlOption = new StringBuilder(); QueryCondition.OutPut(out strSqlOption, out sqlParams); StringBuilder strSql = new StringBuilder(); if (QueryCondition.page == 0) { strSql.Append("select * "); strSql.Append(" FROM VIEW_WebPlatForm_WebLog where 1=1 " + strSqlOption.ToString()); }else { strSql.Append(@"select top "+QueryCondition.rows.ToString() + " * from VIEW_WebPlatForm_WebLog where 1 = 1 "+ strSqlOption.ToString() + " and nID not in ( select top " + (QueryCondition.page - 1) * QueryCondition.rows + " nID from VIEW_WebPlatForm_WebLog where 1=1 " + strSqlOption.ToString() + " order by dtPostTime desc) order by dtPostTime desc"); } DataTable dt = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0]; Dat_WebLogList list = new Dat_WebLogList(); foreach (DataRow dr in dt.Rows) { Dat_WebLog _Dat_WebLog = new Dat_WebLog(); DataRowToModel(_Dat_WebLog,dr); list.Add(_Dat_WebLog); } return list; }
/// <summary> /// 获得记录总数 /// </summary> public int GetDataCount(Dat_WebLogQueryCondition QueryCondition) { SqlParameter[] sqlParams; StringBuilder strSqlOption = new StringBuilder(); QueryCondition.OutPut(out strSqlOption, out sqlParams); StringBuilder strSql = new StringBuilder(); strSql.Append("select count(*) "); strSql.Append(" FROM VIEW_WebPlatForm_WebLog where 1=1" + strSqlOption.ToString()); return ObjectConvertClass.static_ext_int(SqlHelper.ExecuteScalar(ConnectionString, CommandType.Text, strSql.ToString(), sqlParams)); }
/// <summary> /// 获得一个实体对象 /// </summary> public Dat_WebLog GetModel(Dat_WebLogQueryCondition QueryCondition) { SqlParameter[] sqlParams; StringBuilder strSqlOption = new StringBuilder(); QueryCondition.OutPut(out strSqlOption, out sqlParams); StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * "); strSql.Append(" FROM VIEW_WebPlatForm_WebLog where 1=1 " + strSqlOption.ToString()); DataTable dt = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0]; Dat_WebLog _Dat_WebLog = null; if (dt.Rows.Count > 0) { _Dat_WebLog = new Dat_WebLog(); DataRowToModel(_Dat_WebLog,dt.Rows[0]); } return _Dat_WebLog; }
/// <summary> /// 获得数据DataTable /// </summary> public DataTable GetDataTable(Dat_WebLogQueryCondition QueryCondition) { SqlParameter[] sqlParams; StringBuilder strSqlOption = new StringBuilder(); QueryCondition.OutPut(out strSqlOption, out sqlParams); StringBuilder strSql = new StringBuilder(); if (QueryCondition.page == 0) { strSql.Append("select * "); strSql.Append(" FROM VIEW_WebPlatForm_WebLog where 1=1 " + strSqlOption.ToString()); }else { strSql.Append(@"select top "+QueryCondition.rows.ToString() + " * from VIEW_WebPlatForm_WebLog where 1 = 1 "+ strSqlOption.ToString() + " and nID not in ( select top " + (QueryCondition.page - 1) * QueryCondition.rows + " nID from VIEW_WebPlatForm_WebLog where 1=1 " + strSqlOption.ToString() + " order by dtPostTime desc) order by dtPostTime desc"); } return SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0]; }