public List <tipo_soporte> ObtenerTodos()
        {
            List <tipo_soporte> lista = new List <tipo_soporte>();
            tipo_soporte        entidad;

            try
            {
                AbrirConexion();
                StringBuilder CadenaSql = new StringBuilder();

                SqlCommand comandoSelect = new SqlCommand();

                comandoSelect.Connection  = Conexion;
                comandoSelect.CommandType = CommandType.StoredProcedure;
                comandoSelect.CommandText = "DML_Tipo_Soporte";
                comandoSelect.Parameters.AddWithValue("@Sentencia", "Select");
                using (var dr = comandoSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        entidad = new tipo_soporte();
                        entidad.id_tipo_soporte = int.Parse(dr["id_tipo_soporte"].ToString());
                        entidad.descripcion     = dr["descripcion"].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 tipo_soporte";
                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 tipo_soporte";
                throw excepcion;
            }
            finally
            {
                CerrarConexion();
            }
            return(lista);
        }
Exemple #2
0
        public ActionResult Guardar(tipo_soporte entidad)
        {
            try
            {
                var r = entidad.id_tipo_soporte > 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, "TipoSoporte", "Create")));
            }
        }
        public bool Update(tipo_soporte entidad)
        {
            SqlCommand cmd       = new SqlCommand();
            bool       respuesta = false;

            try
            {
                AbrirConexion();
                cmd.Connection  = Conexion;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "DML_Tipo_Soporte";
                cmd.Parameters.AddWithValue("@Sentencia", "Update");
                cmd.Parameters.AddWithValue("@Idtipo_soporte", entidad.id_tipo_soporte);
                cmd.Parameters.AddWithValue("@descripcion", entidad.descripcion);
                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 tipo_soporte";
                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 tipo_soporte";
                throw excepcion;
            }
            finally
            {
                CerrarConexion();
                cmd = null;
            }
            return(respuesta);
        }
Exemple #4
0
 public bool Actualizar(tipo_soporte Entidad)
 {
     return(PerTipoSoporte.Update(Entidad));
 }
Exemple #5
0
 public bool Insertar(tipo_soporte Entidad)
 {
     return(PerTipoSoporte.Insertar(Entidad));
 }