public DataTable GetDataTable(int pageIndex, int pageSize, out int recordCount) { string funMsg = "function: GetDataTable(int pageIndex, int pageSize, out int recordCount)" + FileUtility.NewLine + _classMsg; var strSql = new StringBuilder(); strSql.Append("select count(1) from [centabldg]"); recordCount = DbUtility.ExecuteScalar <int>(strSql.ToString(), AppSettings.DbConn); strSql.Clear(); strSql.AppendFormat("select top {0} * from [centabldg]", pageSize); if (pageIndex > 1) { strSql.AppendFormat(" where CentaBuildId not in (select top {0} CentaBuildId from [centabldg])", (pageIndex - 1) * pageSize); } return(DbUtility.GetDataTable(strSql.ToString(), AppSettings.DbConn)); }
public DataTable GetDataTable(CentaBuildType model, int pageIndex, int pageSize, out int recordCount) { string funMsg = "function: GetDataTable(CentaBuildType model,int pageIndex, int pageSize, out int recordCount)" + FileUtility.NewLine + _classMsg; var param = new StringBuilder(); if (!string.IsNullOrEmpty(model.centaest)) { param.AppendFormat("centaest like '%{0}%'", model.centaest); } if (!string.IsNullOrEmpty(model.cestcode)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("cestcode like '%{0}%'", model.cestcode); } if (!string.IsNullOrEmpty(model.centabldg)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("centabldg like '%{0}%'", model.centabldg); } if (!string.IsNullOrEmpty(model.cblgcode)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("cblgcode like '%{0}%'", model.cblgcode); } if (model.lpt_x > 0) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("lpt_x={0}", model.lpt_x); } if (model.lpt_y > 0) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("lpt_y={0}", model.lpt_y); } if (!string.IsNullOrEmpty(model.usage)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("usage like '%{0}%'", model.usage); } if (!string.IsNullOrEmpty(model.c_estate)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("c_estate like '%{0}%'", model.c_estate); } if (!string.IsNullOrEmpty(model.e_estate)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("e_estate like '%{0}%'", model.e_estate); } if (!string.IsNullOrEmpty(model.c_phase)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("c_phase like '%{0}%'", model.c_phase); } if (!string.IsNullOrEmpty(model.e_phase)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("e_phase like '%{0}%'", model.e_phase); } if (!string.IsNullOrEmpty(model.c_property)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("c_property like '%{0}%'", model.c_property); } if (!string.IsNullOrEmpty(model.pc_addr1)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("pc_addr1 like '%{0}%'", model.pc_addr1); } if (!string.IsNullOrEmpty(model.pc_addr2)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("pc_addr2 like '%{0}%'", model.centaest); } if (!string.IsNullOrEmpty(model.pe_addr)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("pe_addr like '%{0}%'", model.pe_addr); } if (!string.IsNullOrEmpty(model.opdate)) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("opdate ='{0}'", model.opdate); } if (model.unit_cnt > 0) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("unit_cnt={0}", model.unit_cnt); } if (model.x_cnt > 0) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("x_cnt={0}", model.x_cnt); } if (model.y_cnt > 0) { if (param.Length > 0) { param.Append(" and "); } param.AppendFormat("y_cnt={0}", model.y_cnt); } var strSql = new StringBuilder(); strSql.Append("select count(1) from [centabldg]"); if (param.Length > 0) { strSql.AppendFormat(" where {0}", param.ToString()); } recordCount = DbUtility.ExecuteScalar <int>(strSql.ToString(), AppSettings.DbConn); strSql.Clear(); if (param.Length > 0) { strSql.AppendFormat("select top {0} * from [centabldg]", pageSize); if (pageIndex > 1) { strSql.AppendFormat( " where CentaBuildId not in (select top {0} CentaBuildId from [centabldg] where {1}) and {1}", (pageIndex - 1) * pageSize, param.ToString()); } else { strSql.AppendFormat(" where {0}", param.ToString()); } } else { strSql.AppendFormat("select top {0} * from [centabldg]", pageSize); if (pageIndex > 1) { strSql.AppendFormat(" where CentaBuildId not in (select top {0} CentaBuildId from [centabldg])", (pageIndex - 1) * pageSize); } } return(DbUtility.GetDataTable(strSql.ToString(), AppSettings.DbConn)); }