public List<CategoryInfo> Getlist(int cid, int pid, ListOptions options, out int numResults) { try { List<CategoryInfo> arr = null; using (iSqlConnection iConn = HELPER.getConnect(HELPER.SQL_SYSTEM)) { string SQL = SQL_GETIFOPAGING.Replace(Queryparam.Varstring.VAR_SORTEXPRESSION, CFunctions.Expression_GetSort(options.SortExp, options.SortDir)); SQL += " AND A.status<>" + (int)CConstants.State.Status.Waitactive; SQL += " AND A.status<>" + (int)CConstants.State.Status.Disabled; SQL += options.Markas == (int)CConstants.State.MarkAs.None ? "" : " AND A.markas=" + options.Markas; SQL += cid == 0 ? "" : " AND A.cid=" + cid; SQL += pid == -1 ? "" : " AND A.pid=" + pid; SQL = "SELECT * FROM(" + SQL + ") AS T WHERE id<>0 " + CFunctions.Expression_GetLimit(options.PageIndex, options.PageSize); using (iSqlDataReader dar = HELPER.executeReader(iConn, SQL)) { while (dar.Read()) { CategoryInfo info = this.getDataReader(dar); if (arr == null) arr = new List<CategoryInfo>(); arr.Add(info); } dar.Close(); } numResults = this.Getlistcount(iConn, cid, pid); if(arr != null) { foreach (var cate in arr) { if (cate.Pid == 61) { CNews news = new CNews("vn"); cate.dictCount = news.GetDictCount(iConn, cate.Id.ToString()); } } } iConn.Close(); } return arr; } catch (Exception ex) { throw ex; } }
public CategoryInfo Getinfo(int id) { if (id == -1) return null; try { CategoryInfo info = null; using (iSqlConnection iConn = HELPER.getConnect(HELPER.SQL_SYSTEM)) { string SQL = SQL_GETIFO + " AND A.id=@ID"; SQL += " AND A.status<>" + (int)CConstants.State.Status.Waitactive; SQL += " AND A.status<>" + (int)CConstants.State.Status.Disabled; iSqlParameter[] parms = new iSqlParameter[]{ new iSqlParameter(PARM_ID, iSqlType.Field_tInterger), }; int i = -1; parms[++i].Value = id; using (iSqlDataReader dar = HELPER.executeReader(iConn, iCommandType.Text, SQL, parms)) { if (dar.Read()) { info = this.getDataReader(dar); } } if(info != null) { CNews news = new CNews("vn"); info.dictCount = news.GetDictCount(iConn,info.Id.ToString()); } iConn.Close(); } return info; } catch (Exception ex) { throw ex; } }