public JsonResult AgregarActualizarRol(BeEcRol obj) { ecRolService = new EcRolService(); ResponseViewModel res = new ResponseViewModel(); string mensaje = ""; string tipo = ""; try { if (obj.rol_id == 0) { bool valida = ecRolService.InsertarRoles(obj, ref mensaje, ref tipo); res.Tipo = tipo; res.Mensaje = mensaje; } else { bool valida = ecRolService.EditarRoles(obj, ref mensaje, ref tipo); res.Tipo = tipo; res.Mensaje = mensaje; } } catch (Exception e) { res.Tipo = Configuration.SI_MSJ_TIP_ERROR; res.Mensaje = e.Message; } return(Json(res)); }
public List <BeEcRol> ConsultarRoles(BeEcRol obj, ref string mensaje, ref string tipo) { string sqlquery = "USP_Consultar_Rol"; List <BeEcRol> list = null; try { using (SqlConnection cn = new SqlConnection(Conexion)) { if (cn.State == 0) { cn.Open(); } using (SqlCommand cmd = new SqlCommand(sqlquery, cn)) { cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@rol_id", obj.rol_id); cmd.Parameters.AddWithValue("@rol_nombre", obj.rol_nombre); cmd.Parameters.AddWithValue("@rol_descripcion", obj.rol_descripcion); SqlDataReader dr = cmd.ExecuteReader(); list = new List <BeEcRol>(); if (dr.HasRows) { int posId = dr.GetOrdinal("rol_id"); int posNombre = dr.GetOrdinal("rol_nombre"); int posDescripcion = dr.GetOrdinal("rol_descripcion"); while (dr.Read()) { BeEcRol rol = new BeEcRol(); rol.rol_id = dr.GetDecimal(posId); rol.rol_nombre = (dr.IsDBNull(posNombre)) ? "" : dr.GetString(posNombre); rol.rol_descripcion = (dr.IsDBNull(posDescripcion)) ? "" : dr.GetString(posDescripcion); list.Add(rol); } } } } } catch (Exception e) { mensaje = Configuration.SI_MSJ_DES_ERROR + "\n\n" + "Detalle de Error: " + e.Message; tipo = Configuration.SI_MSJ_TIP_ERROR; list = null; } mensaje = Configuration.SI_MSJ_DES_EXITO; tipo = Configuration.SI_MSJ_TIP_EXITO; return(list); }
public List <BeEcFuncion> get_lista(BeEcRol obj, ref string mensaje, ref string tipo) { string sqlquery = "USP_Leer_Funcion_Roles"; List <BeEcFuncion> list = null; try { using (SqlConnection cn = new SqlConnection(Conexion)) { if (cn.State == 0) { cn.Open(); } using (SqlCommand cmd = new SqlCommand(sqlquery, cn)) { cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@rol_id", obj.rol_id); SqlDataReader dr = cmd.ExecuteReader(); list = new List <BeEcFuncion>(); if (dr.HasRows) { while (dr.Read()) { int posId = dr.GetOrdinal("fun_id"); int posNombre = dr.GetOrdinal("fun_nombre"); int posOrden = dr.GetOrdinal("fun_orden"); BeEcFuncion fila = new BeEcFuncion(); fila.fun_id = dr.GetDecimal(posId); fila.fun_nombre = dr.GetString(posNombre); fila.fun_orden = dr.GetDecimal(posOrden); list.Add(fila); } } } } } catch (Exception e) { mensaje = Configuration.SI_MSJ_DES_ERROR + "\n\n" + "Detalle de Error: " + e.Message; tipo = Configuration.SI_MSJ_TIP_ERROR; list = null; } mensaje = Configuration.SI_MSJ_DES_EXITO; tipo = Configuration.SI_MSJ_TIP_EXITO; return(list); }
public List <BeEcRol> get_lista() { List <BeEcRol> list = null; string sqlquery = "USP_Leer_Roles"; try { using (SqlConnection cn = new SqlConnection(Conexion)) { if (cn.State == 0) { cn.Open(); } using (SqlCommand cmd = new SqlCommand(sqlquery, cn)) { cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { list = new List <BeEcRol>(); while (dr.Read()) { int posId = dr.GetOrdinal("rol_id"); int posNombre = dr.GetOrdinal("rol_nombre"); int posDescripcion = dr.GetOrdinal("rol_descripcion"); while (dr.Read()) { BeEcRol rol = new BeEcRol(); rol.rol_id = dr.GetDecimal(posId); rol.rol_nombre = (dr.IsDBNull(posNombre)) ? "" : dr.GetString(posNombre); rol.rol_descripcion = (dr.IsDBNull(posDescripcion)) ? "" : dr.GetString(posDescripcion); list.Add(rol); } } } } } } catch (Exception) { list = null; } return(list); }
public JsonResult BuscarRolFuncion(BeEcRol obj) { ecRolFuncionService = new EcRolFuncionService(); ResponseViewModel res = new ResponseViewModel(); string mensaje = ""; string tipo = ""; try { List <BeEcFuncion> lst = ecRolFuncionService.get_lista(obj, ref mensaje, ref tipo); res.Tipo = tipo; res.Mensaje = mensaje; res.Lista = lst.OrderBy(x => x.fun_orden); } catch (Exception e) { res.Tipo = Configuration.SI_MSJ_TIP_ERROR; res.Mensaje = e.Message; } return(Json(res)); }
public Boolean EditarRoles(BeEcRol obj, ref string mensaje, ref string tipo) { Boolean valida = false; string sqlquery = "USP_Modificar_Roles"; try { using (SqlConnection cn = new SqlConnection(Conexion)) { if (cn.State == 0) { cn.Open(); } using (SqlCommand cmd = new SqlCommand(sqlquery, cn)) { cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@rol_id", obj.rol_id); cmd.Parameters.AddWithValue("@rol_nombre", obj.rol_nombre); cmd.Parameters.AddWithValue("@rol_descripcion", obj.rol_descripcion); cmd.ExecuteNonQuery(); valida = true; } } } catch (Exception e) { mensaje = Configuration.SI_MSJ_DES_ERROR + "\n\n" + "Detalle de Error: " + e.Message; tipo = Configuration.SI_MSJ_TIP_ERROR; valida = false; } mensaje = Configuration.SI_MSJ_DES_EXITO; tipo = Configuration.SI_MSJ_TIP_EXITO; return(valida); }
public List <BeEcFuncion> get_lista(BeEcRol obj, ref string mensaje, ref string tipo) { return(ecRolFuncionDAO.get_lista(obj, ref mensaje, ref tipo)); }
public List <BeEcRol> ConsultarRoles(BeEcRol obj, ref string mensaje, ref string tipo) { return(ecRolDAO.ConsultarRoles(obj, ref mensaje, ref tipo)); }
public Boolean EditarRoles(BeEcRol obj, ref string mensaje, ref string tipo) { return(ecRolDAO.EditarRoles(obj, ref mensaje, ref tipo)); }