/// <summary> /// 更新一条数据 /// </summary> public static bool Update(Model.RoleSysModule roleSysModule) { StringBuilder strSql = new StringBuilder(); strSql.Append("update roleSysModule set "); strSql.Append("sysModuleId=?sysModuleId,"); strSql.Append("roleId=?roleId,"); strSql.Append("roleSysModuleState=?roleSysModuleState"); strSql.Append("updt=?updt"); strSql.Append("upUsrId=?upUsrId"); strSql.Append(" where roleSysModuleId=?roleSysModuleId"); DynamicParameters parameters = new DynamicParameters(); parameters.Add("?roleSysModuleId", roleSysModule.RoleSysModuleId); parameters.Add("?sysModuleId", roleSysModule.SysModuleId); parameters.Add("?roleId", roleSysModule.RoleId); parameters.Add("?roleSysModuleState", roleSysModule.RoleSysModuleState); parameters.Add("?updt", roleSysModule.Updt); parameters.Add("?upUsrId", roleSysModule.UpUsrId); int rows = mysql.ExcuteNonQuery <Model.RoleSysModule>(DapperMySQLHelper.ConnectionString, strSql.ToString(), parameters, false); return(rows > 0); }
/// <summary> /// 新增用户角色关系 /// </summary> /// <param name="strRoleId"></param> /// <param name="strUsrId"></param> /// <param name="strRoleIdList"></param> /// <param name="iRoleSysModuleState"></param> /// <param name="strCrUsrId"></param> /// <returns></returns> public static bool Add(string strRoleId, int?iRoleSysModuleState, string strSysModuleId, string strCrUsrId) { Model.RoleSysModule roleSysModule = new Model.RoleSysModule() { Crdt = DateTime.Now, CrUsrId = strCrUsrId, RoleSysModuleId = Guid.NewGuid().ToString(), RoleId = strRoleId, RoleSysModuleState = iRoleSysModuleState, SysModuleId = strSysModuleId, Updt = DateTime.Now, UpUsrId = strCrUsrId }; return(Repository.RoleSysModule.Add(roleSysModule)); }
public static bool Set(string strRoleId, int?iRoleSysModuleState, string strCrUsrId, string[] sysModuleList) { Model.RoleSysModule roleSysModule = new Model.RoleSysModule() { Crdt = DateTime.Now, CrUsrId = strCrUsrId, RoleSysModuleId = Guid.NewGuid().ToString(), RoleId = strRoleId, RoleSysModuleState = iRoleSysModuleState, Updt = DateTime.Now, UpUsrId = strCrUsrId }; return(Repository.RoleSysModule.Set(roleSysModule, sysModuleList)); }
public static bool Set(Model.RoleSysModule roleSysModule, string[] roleSysModuleList) { List <CmdParams> parameters = new List <CmdParams>(); /*先清空原有关系*/ CmdParams cpDel = new CmdParams { cmd = "delete from roleSysModule where roleId=?roleId", param = new DynamicParameters() }; cpDel.param.Add("?roleId", roleSysModule.RoleId); parameters.Add(cpDel); /*批量更新到最新关系*/ foreach (var item in roleSysModuleList) { CmdParams cp = new CmdParams { cmd = "insert into roleSysModule(roleSysModuleId,sysModuleId,roleId,roleSysModuleState,crdt,crUsrId,updt,upUsrId) values (?roleSysModuleId,?sysModuleId,?roleId,?roleSysModuleState,?crdt,?crUsrId,?updt,?upUsrId)", param = new DynamicParameters() }; cp.param.Add("?roleSysModuleId", Guid.NewGuid().ToString()); cp.param.Add("?sysModuleId", item); cp.param.Add("?roleId", roleSysModule.RoleId); cp.param.Add("?roleSysModuleState", roleSysModule.RoleSysModuleState); cp.param.Add("?crdt", roleSysModule.Crdt); cp.param.Add("?crUsrId", roleSysModule.CrUsrId); cp.param.Add("?updt", roleSysModule.Updt); cp.param.Add("?upUsrId", roleSysModule.UpUsrId); parameters.Add(cp); } /*调用事务处理*/ int rows = mysql.ExcuteNonQueryTransaction <Model.RoleSysModule>(DapperMySQLHelper.ConnectionString, parameters, false); return(rows > 0); }
public static bool Add(Model.RoleSysModule roleSysModule) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into roleSysModule ("); strSql.Append("roleSysModuleId,sysModuleId,roleId,roleSysModuleState,crdt,crUsrId,updt,upUsrId) "); strSql.Append(" values ("); strSql.Append("?roleSysModuleId,?sysModuleId,?roleId,?roleSysModuleState,?crdt,?crUsrId,?updt,?upUsrId)"); DynamicParameters parameters = new DynamicParameters(); parameters.Add("?roleSysModuleId", roleSysModule.RoleSysModuleId); parameters.Add("?sysModuleId", roleSysModule.SysModuleId); parameters.Add("?roleId", roleSysModule.RoleId); parameters.Add("?roleSysModuleState", roleSysModule.RoleSysModuleState); parameters.Add("?crdt", roleSysModule.Crdt); parameters.Add("?crUsrId", roleSysModule.CrUsrId); parameters.Add("?updt", roleSysModule.Updt); parameters.Add("?upUsrId", roleSysModule.UpUsrId); int rows = mysql.ExcuteNonQuery <Model.RoleSysModule>(DapperMySQLHelper.ConnectionString, strSql.ToString(), parameters, false); return(rows > 0); }