public ActionResult GetPrioridad(int IdPlaza) { ConexionController c = new ConexionController(); SqlCommand comandoSql; List <prioridad> lista = new List <prioridad>(); SqlConnection conexionSQL = new SqlConnection(c.DameConexion(IdPlaza)); try { conexionSQL.Open(); } catch { } try { comandoSql = new SqlCommand("select * from tblPrioridadQueja"); comandoSql.Connection = conexionSQL; SqlDataReader reader = comandoSql.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { prioridad clasificacion = new prioridad(); clasificacion.clvPrioridadQueja = Int32.Parse(reader[0].ToString()); clasificacion.Descripcion = reader[1].ToString(); lista.Add(clasificacion); } } } catch { } return(Json(lista, JsonRequestBehavior.AllowGet)); }
public List <prioridad> ObtenerTodos() { List <prioridad> lista = new List <prioridad>(); prioridad entidad; try { AbrirConexion(); StringBuilder CadenaSql = new StringBuilder(); SqlCommand comandoSelect = new SqlCommand(); comandoSelect.Connection = Conexion; comandoSelect.CommandType = CommandType.StoredProcedure; comandoSelect.CommandText = "DML_Prioridad"; comandoSelect.Parameters.AddWithValue("@Sentencia", "Select"); using (var dr = comandoSelect.ExecuteReader()) { while (dr.Read()) { entidad = new prioridad(); entidad.id_prioridad = int.Parse(dr["id_prioridad"].ToString()); entidad.nombre = dr["nombre"].ToString(); lista.Add(entidad); } } } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de conversión de tipos con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insertar prioridad"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insertar prioridad"; throw excepcion; } finally { CerrarConexion(); } return(lista); }
public ActionResult Guardar(prioridad entidad) { try { var r = entidad.id_prioridad > 0 ? control.Actualizar(entidad) : control.Insertar(entidad); if (!r) { return(Json("Error al realizar la operacion", JsonRequestBehavior.AllowGet)); } return(Json("Realizado", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Prioridad", "Create"))); } }
public bool Update(prioridad entidad) { SqlCommand cmd = new SqlCommand(); bool respuesta = false; try { AbrirConexion(); cmd.Connection = Conexion; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DML_Prioridad"; cmd.Parameters.AddWithValue("@Sentencia", "Update"); cmd.Parameters.AddWithValue("@IdPrioridad", entidad.id_prioridad); cmd.Parameters.AddWithValue("@nombre", entidad.nombre); cmd.ExecuteNonQuery(); respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de conversión de tipos con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insertar prioridad"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insertar prioridad"; throw excepcion; } finally { CerrarConexion(); cmd = null; } return(respuesta); }
public bool Actualizar(prioridad Entidad) { return(PerPrioridad.Update(Entidad)); }
public bool Insertar(prioridad Entidad) { return(PerPrioridad.Insertar(Entidad)); }