private void LoadData() { SqlParameter par = new SqlParameter("@groupID", _id); DataTable dt = DB.TableFromProcedure("getGroup", new SqlParameter[1] { par }); if (dt == null || dt.Rows.Count == 0) { _id = 0; return; } DataRow row = dt.Rows[0]; _name = row["g_name"].ToString(); _creator = row["g_user_name"].ToString(); _category = new Category(); _category.ID = (int)row["_id"]; _category.Name = row["_name"].ToString(); _description = row["g_description"].ToString(); _gonggao = row["g_gonggao"].ToString(); _tags = row["g_tags"].ToString(); _uptime = (DateTime)row["g_uptime"]; if (!int.TryParse(row["g_redu"].ToString(), out _redu)) { _redu = 0; } }
public static DataTable GetPagingData(string tablename, string fieldlist, string orderfield, string keyfield, int pageIndex, int pageSize, string where, bool desc) { SqlParameter[] pars = new SqlParameter[8]; pars[0] = new SqlParameter("@tablename", tablename); pars[1] = new SqlParameter("@fieldlist", fieldlist); pars[2] = new SqlParameter("@orderfield", orderfield); pars[3] = new SqlParameter("@keyfield", keyfield); pars[4] = new SqlParameter("@pageindex", pageIndex); pars[5] = new SqlParameter("@pagesize", pageSize); pars[6] = new SqlParameter("@strwhere", where); pars[7] = new SqlParameter("@ordertype", desc ? "1" : "0"); return(DB.TableFromProcedure("GetPagingData", pars)); }
/// <summary> /// 获取一些随机人气群组 /// </summary> /// <param name="size">要获取的群组数</param> /// <param name="cat">所属类别</param> /// <returns></returns> public static DataTable GetHotGroup(int size, int cat) { if (cat < 11) { cat = 0; } int max = size * 2; max = new Random().Next(size, max); SqlParameter[] pars = new SqlParameter[3]; pars[0] = new SqlParameter("@size", size); pars[1] = new SqlParameter("@max", max); pars[2] = new SqlParameter("@cat", cat); return(DB.TableFromProcedure("getHotGroup", pars)); }