public static int RenameUserCategory(string tableName, int id, string name) { string pinyin = HZ.ToPinYin(name, true); string pinyinabbr = PinYin.GetInitial(name); return(DBH.ExecuteText(QA.DBCS_CMS, "UPDATE " + tableName + " SET name=@name,pinyin=@pinyin,pinyinabbr=@pinyinabbr,ename=@ename WHERE id=@id", new SqlParameter("@name", name), new SqlParameter("@pinyin", pinyin), new SqlParameter("@pinyinabbr", pinyinabbr), new SqlParameter("@ename", pinyin), new SqlParameter("@id", id))); }
public static void DeleteUserCategory(int id, string categoryTable, string entityTable) { int pid = GetUserCategoryPid(id, categoryTable); if (pid >= 0) { if (DBH.ExecuteText(QA.DBCS_CMS, "UPDATE " + entityTable + " SET ucid=@pid WHERE ucid=@id", new SqlParameter("@pid", pid), new SqlParameter("@id", id)) >= 0) { DBH.ExecuteText(QA.DBCS_CMS, "DELETE " + categoryTable + " WHERE id=@id", new SqlParameter("@id", id)); } } }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="www"></param> /// <param name="id"></param> /// <param name="sid"></param> /// <param name="code"></param> internal static void Initialize(string name, string www, int id, string sid, string code) { if (!string.IsNullOrEmpty(code)) { //更新好友数据 string sql = "UPDATE user_status SET invited=invited+1 WHERE id=@id1;UPDATE inviteinfo SET invited_id=@id2 WHERE id=@id1 AND code=@code;"; //id1 邀请 id2 DBH.ExecuteText(QA.DBCS_MAIN, sql, new SqlParameter("@id1", sid), new SqlParameter("@id2", id), new SqlParameter("@code", code)); } //写入用户信息 EB <UserStatusEntity> .Create(QA.DBCS_MAIN, new UserStatusEntity() { id = id, }); }
public static int Operate(int mid, NameValueCollection collection) { int rtn = 0; //get reposity_meta ReposityMeta rm = GetMeta(mid); string sql = null; IList <SqlParameter> spList = new List <SqlParameter>(); if (rm.OP == 0) { rtn = DBH.GetInt32(QA.DBCS_MAIN, CommandType.Text, sql, spList.ToArray <SqlParameter>()); } else if (rm.OP == 2) { rtn = DBH.ExecuteText(QA.DBCS_MAIN, sql, spList.ToArray <SqlParameter>()); } return(rtn); }
/// <summary> /// /// </summary> /// <param name="info"></param> /// <returns></returns> internal static IList <string> SetInviteCode(UserStatusEntity info) { string SQLF = "INSERT INTO inviteinfo(id,code) VALUES('{0}','{1}');"; string sql = string.Empty; IList <string> codeList = new List <string>(); for (int i = info.invited; i < info.maxinvites; i++) { string code = Guid.NewGuid().ToString("N"); codeList.Add(code); sql += string.Format(SQLF, info.id, code); } if (DBH.ExecuteText(QA.DBCS_MAIN, sql, null) > 0) { return(codeList); } else { return(null); } }
public static int DeletePost(int pid) { return(DBH.ExecuteText(QA.DBCS_MAIN, "DELETE forum_post WHERE pid=@pid", new SqlParameter("@pid", pid))); }
public static int DeleteThread(int tid) { return(DBH.ExecuteText(QA.DBCS_MAIN, "DELETE forum_thread WHERE tid=@tid;", new SqlParameter("@tid", tid))); }
/// <summary> /// 设置用户图标 /// </summary> /// <param name="icon"></param> /// <param name="id"></param> public static int SetAvatar(string avatar, int id) { return(DBH.ExecuteText(QA.DBCS_MAIN, "UPDATE user_account SET avatar=@avatar WHERE id=@id", new SqlParameter("@avatar", avatar), new SqlParameter("@id", id))); }
internal static int ChangePassword(int uid, string newpwdmd5) { return(DBH.ExecuteText(QA.DBCS_MAIN, "UPDATE user_account SET passwd=@passwd WHERE id=@id", new SqlParameter("@id", uid), new SqlParameter("@passwd", newpwdmd5))); }
/// <summary> /// uid follow followid /// </summary> /// <param name="uid"></param> /// <param name="followid"></param> /// <returns></returns> public static int Follow(int uid, int followid) { return(DBH.ExecuteText(QA.DBCS_MAIN, "INSERT INTO follow(uid,followid) VALUES(@uid,@followid)", new SqlParameter("@uid", uid), new SqlParameter("@followid", followid))); }
public static int Update(string connectingString, T entity, string tableName = null) { int ret = -1; Type t = entity.GetType(); if (string.IsNullOrEmpty(tableName)) { object[] tables = t.GetCustomAttributes(typeof(TableAttribute), false); if (tables != null && tables.Length == 1) { tableName = (tables[0] as TableAttribute).Name; } } if (tableName != null) { string sql = "UPDATE " + tableName + " SET "; string sets = string.Empty; string where = null; List <SqlParameter> parameters = new List <SqlParameter>(); //遍历字段 FieldInfo[] fields = t.GetFields(); foreach (FieldInfo f in fields) { object[] attrs = f.GetCustomAttributes(typeof(FieldAttribute), false); if (attrs.Length == 1) { FieldAttribute fa = attrs[0] as FieldAttribute; object value = f.GetValue(entity); if (!fa.AllowNulls && value == null) { continue; //非null字段,值为null不更新该字段 } if (value is DateTime && DateTime.MinValue.CompareTo(value) == 0) { continue; } if (fa.AllowNulls && value == null) { value = DBNull.Value; } if (fa.PrimaryKey) { where = " WHERE " + fa.Name + "=@" + fa.Name; } else { if (!string.IsNullOrEmpty(sets)) { sets += ","; } sets += fa.Name + "=@" + fa.Name; } parameters.Add(new SqlParameter("@" + fa.Name, value)); } } //遍历属性 PropertyInfo[] properties = t.GetProperties(); foreach (PropertyInfo f in properties) { object[] attrs = f.GetCustomAttributes(typeof(FieldAttribute), false); if (attrs.Length == 1) { FieldAttribute fa = attrs[0] as FieldAttribute; if (!fa.AllowNulls && f.GetValue(entity, null) == null) { continue; //非null字段,值为null不更新该字段 } if (fa.PrimaryKey) { where = " WHERE " + fa.Name + "=@" + fa.Name; } else { if (!string.IsNullOrEmpty(sets)) { sets += ","; } sets += fa.Name + "=@" + fa.Name; } parameters.Add(new SqlParameter("@" + fa.Name, f.GetValue(entity, null))); } } sql = sql + sets + where; ret = DBH.ExecuteText(connectingString, sql, parameters.ToArray()); } return(ret); }
internal static void Hide(int eid) { DBH.ExecuteText(QA.DBCS_MAIN, "UPDATE event_index SET hide=1 WHERE eid=@eid", new SqlParameter("@eid", eid)); }
internal static void Close(int eid) { DBH.ExecuteText(QA.DBCS_MAIN, "DELETE event_index WHERE eid=@eid", new SqlParameter("@eid", eid)); }
public static int IncCategoryCount(string tableName, int id) { return(DBH.ExecuteText(QA.DBCS_CMS, "UPDATE " + tableName + " SET count=count+1 WHERE id=@id", new SqlParameter("@id", id))); }
public static int ChangeUserCategoryPid(string tableName, int id, int pid) { return(DBH.ExecuteText(QA.DBCS_CMS, "UPDATE " + tableName + " SET pid=@pid WHERE id=@id", new SqlParameter("@pid", pid), new SqlParameter("@id", id))); }