/// <summary> /// 更新基础数据代码值 /// </summary> /// <param name="model"></param> /// <returns></returns> public int UpdateCode(BaseCodeModel model) { var sql = new StringBuilder("update `base_code` set "); sql.Append(Helper.CreateField(model).Trim().TrimEnd(',')); sql.Append(" where innerid = @innerid"); int result; try { result = Helper.Execute(sql.ToString(), model); } catch (Exception ex) { result = 0; } return result; }
/// <summary> /// 添加基础数据代码值 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddCode(BaseCodeModel model) { const string sql = @"INSERT INTO `base_code` (`innerid`,`codevalue`,`codename`,`sort`,`typekey`,`remark`,`isenabled`) VALUES (@innerid,@codevalue,@codename,@sort,@typekey,@remark,@isenabled);"; using (var conn = Helper.GetConnection()) { var tran = conn.BeginTransaction(); try { conn.Execute(sql, model, tran); tran.Commit(); return 1; } catch (Exception ex) { tran.Rollback(); return 0; } } }