public int getCount(string key, MaterielLookUpArgs args) { string sql = "SELECT Count(*) FROM materiel where isActive = 1 "; string select = ""; string filter = ""; if (key != "") { select += " and num like '%" + key + "%' or name like '%" + key + "%'"; } if (args.ids.Count > 0) { filter += " and id not in ("; for (int i = 0; i < args.ids.Count; i++) { if (i == 0) { filter += args.ids[i]; } else { filter += "," + args.ids[i]; } } filter += ")"; sql += filter; } sql += select; if (args.bom == false) { sql += " and bom = 0 "; } if (args.type != "" && args.type != null) { sql += " and type = '" + args.type + "' "; } DataTable dt = h.ExecuteQuery(sql, CommandType.Text); int count = Convert.ToInt32(dt.Rows[0][0]); return(count); }
public DataTable getFilterListLimit(int pageIndex, int pageSize, string keyword, int category, MaterielLookUpArgs args) { string areaids = ""; if (category > 0) { string sqlarea = "select queryChildrenAreaInfo('" + category + "');"; DataTable dtarea = h.ExecuteQuery(sqlarea, CommandType.Text); areaids = dtarea.Rows[0][0].ToString(); } string sql = "SELECT * FROM materiel where isActive = 1 "; string select = ""; string filter = ""; if (keyword != "") { select += " and (num like '%" + keyword + "%' or name like '%" + keyword + "%')"; } if (areaids != "") { select += " AND category in (" + areaids + ") "; } sql += select; if (args.ids.Count > 0) { filter += " and id not in ("; for (int i = 0; i < args.ids.Count; i++) { if (i == 0) { filter += args.ids[i]; } else { filter += "," + args.ids[i]; } } filter += ")"; sql += filter; } if (args.bom == false) { sql += " and bom = 0"; } if (args.type != "" && args.type != null) { sql += " and type = '" + args.type + "' "; } if (pageIndex < 1) { pageIndex = 1; } sql += " LIMIT " + (pageIndex - 1) * pageSize + "," + pageSize; DataTable dt = h.ExecuteQuery(sql, CommandType.Text); return(dt); }