/// <summary> /// Inserts this instance. /// </summary> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool Insert() { string sql = string.Format("INSERT INTO role (NAME) VALUES ('{0}')", this.Name); Sqlite sqlite = new Sqlite(); return(sqlite.ExecuteNonQuery(sql)); }
/// <summary> /// 更新当前权限项 /// </summary> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool Update() { string strSql = string.Format("update auth set name='{0}', roleid='{1}' where id={2}", this.Name, this.Role.Id, this.Id); Sqlite sqlite = new Sqlite(); return(sqlite.ExecuteNonQuery(strSql)); }
/// <summary> /// Inserts this instance. /// </summary> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool Insert() { string sql = string.Format("INSERT INTO user (USERNAME,PASSWORD,ROLEID) VALUES ('{0}','{1}',{2})", this.UserName, this.Password, this.RoleId); Sqlite sqlite = new Sqlite(); return(sqlite.ExecuteNonQuery(sql)); }
/// <summary> /// Deletes this instance. /// </summary> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool Delete() { string sql = "delete from user where id=" + this.Id; Sqlite sqlite = new Sqlite(); return(sqlite.ExecuteNonQuery(sql)); }
/// <summary> /// Updates the specified is need update password. /// </summary> /// <param name="isNeedUpdatePwd">if set to <c>true</c> [is need update password].</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool Update(bool isNeedUpdatePwd = true) { string empty = string.Empty; empty = string.Format("update user set username='******', password='******',roleid={2} where id={3}", this.UserName, this.Password, this.RoleId, this.Id); Sqlite sqlite = new Sqlite(); return(sqlite.ExecuteNonQuery(empty)); }
/// <summary> /// 记录操作日志到sqlite. /// </summary> /// <param name="log">The log.</param> public static void Log2Sqlite(Log log) { if (log != null) { try { string strSql = string.Format("INSERT INTO log (loglevel,logtime,message,eventtype,user) VALUES ('{0}','{1}','{2}','{3}','{4}');", log.LogLevel, log.LogTime.ToString(ConstDef.longDate), log.Message, log.EventType, log.User); Sqlite sqlite = new Sqlite(); sqlite.ExecuteNonQuery(strSql); sqlite.Close(); } catch (Exception ex) { Log2File(null, ex); } } }