public JsonResult SaveRoleUserList(ClientModel client) { int?nRoleID = client.GetInt("nRoleID"); string[] keys = client.GetArray <string>("targetKeys"); try { Db.BeginTransaction(); Db.ExecuteNonQuery("delete Sys_UserInRole where TenantId=@TenantId and nRoleID=@nRoleID", new { TenantId = Auth.TenantId, nRoleID }); List <object> paramsIn = new List <object>(); foreach (var key in keys) { paramsIn.Add(new { TenantId = Auth.TenantId, UserId = key, nRoleID }); } Db.ExecuteNonQuery(@"INSERT INTO Sys_UserInRole (TenantId,UserId,nRoleID) VALUES(@TenantId,@UserId,@nRoleID)", paramsIn); Db.Commit(); return(Json(new { status = 0 })); } catch (Exception ex) { return(Json(new { status = 1, msg = ex.Message })); } }
public JsonResult Delete(ClientModel client) { int[] ids = client.GetArray <int>("delIds"); Db.BeginTransaction(); foreach (var id in ids) { Db.ExecuteNonQuery("DELETE Sys_Module WHERE ID=@ID", new { ID = id }); } Db.Commit(); return(Json(new { status = 0 })); }
public JsonResult Delete(ClientModel client) { int[] ids = client.GetArray <int>("delIds"); Db.BeginTransaction(); foreach (var id in ids) { Db.ExecuteNonQuery("DELETE SYS_ROLE WHERE ID=@ID AND TenantId=@TenantId", new { ID = id, Auth.TenantId }); } Db.Commit(); return(Json(new { status = 0 })); }
public JsonResult ModuleRoleSet(ClientModel clientModel) { int?nRoleID = clientModel.GetInt("roleID"); string[] moduleCodes = clientModel.GetArray <string>("moduleCodeArr"); Db.BeginTransaction(); try { string strSQL = "DELETE Sys_RoleForModule WHERE TenantId=@nCompanyID and nRoleID=@nRoleID"; Db.ExecuteNonQuery(strSQL, new { nCompanyID = Auth.TenantId, nRoleID }); if (moduleCodes != null && moduleCodes.Length > 0) { List <object> insertEntity = new List <object>(); foreach (var item in moduleCodes) { insertEntity.Add(new { nCompanyID = Auth.TenantId, nRoleID, cModuleCode = item }); } strSQL = "INSERT INTO Sys_RoleForModule(TenantId,nRoleID,cModuleCode)VALUES(@nCompanyID,@nRoleID,@cModuleCode)"; Db.ExecuteNonQuery(strSQL, insertEntity); strSQL = @"INSERT INTO Sys_RoleForModule(TenantId,nRoleID,cModuleCode) SELECT DISTINCT @nCompanyID,@nRoleID,cCode FROM Sys_Module WHERE ID in (SELECT nPID From Sys_Module where cCode in @cModuleCode)"; Db.ExecuteNonQuery(strSQL, new { nCompanyID = Auth.TenantId, nRoleID, cModuleCode = moduleCodes }); } Db.Commit(); return(Json(new { status = 0 })); } catch (Exception ex) { Db.Rollback(); return(Json(new { status = 1, msg = ex.Message })); } //return Json(new { status=0}); }
public JsonResult ButtonRoleSet(ClientModel clientModel) { int?nRoleID = clientModel.GetInt("roleID"); string[] fieldCodes = clientModel.GetArray <string>("fieldArr"); string cModuleCode = clientModel.GetString("cModuleCode"); Db.BeginTransaction(); try { string strSQL = "DELETE Sys_RoleForButton WHERE TenantId=@TenantId and nRoleID=@nRoleID and cModuleCode=@cModuleCode"; Db.ExecuteNonQuery(strSQL, new { TenantId = Auth.TenantId, nRoleID, cModuleCode }); if (fieldCodes != null && fieldCodes.Length > 0) { List <object> insertEntity = new List <object>(); foreach (var item in fieldCodes) { insertEntity.Add(new { TenantId = Auth.TenantId, nRoleID, cModuleCode, cField = item }); } strSQL = "INSERT INTO Sys_RoleForButton(TenantId,nRoleID,cModuleCode,cButtonID)VALUES(@TenantId,@nRoleID,@cModuleCode,@cField)"; Db.ExecuteNonQuery(strSQL, insertEntity); } Db.Commit(); return(Json(new { status = 0 })); } catch (Exception ex) { Db.Rollback(); return(Json(new { status = 1, msg = ex.Message })); } }