public bool actualizarParentesco(clsParentesco objParentesco)
        {
            clsConexion clsConexion = new clsConexion();

            try
            {
                string sql = "update PARENTEZCO set " +
                             "NOMBREPARENTEZCO='" + objParentesco.NombreParentesco + "' where IDPARENTEZCO=" + objParentesco.Codigo;
                SqlCommand comando = new SqlCommand(sql, clsConexion.Conexion);

                clsConexion.abrirConexion();

                comando.ExecuteNonQuery();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                clsConexion.cerrarConexion();
            }
        }
        public bool eliminarParentesco(int id)
        {
            clsParentesco objParentesco = new clsParentesco();

            objParentesco.Codigo = id;

            try
            {
                clsConexion.abrirConexion();

                string query = "delete from PARENTEZCO where IDPARENTEZCO=" + objParentesco.Codigo;

                SqlCommand comando = new SqlCommand(query, clsConexion.Conexion);

                comando.ExecuteNonQuery();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                clsConexion.cerrarConexion();
            }
        }
        static clsParentesco transformar(PARENTEZCO newParentesco)
        {
            clsParentesco parentesco = new clsParentesco();

            parentesco.Codigo           = newParentesco.IDPARENTEZCO;
            parentesco.NombreParentesco = newParentesco.NOMBREPARENTEZCO;
            return(parentesco);
        }
        protected void ddlParentesco_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtNombreParentesco.Enabled = true;
            btnActualizar.Enabled       = true;

            try
            {
                objParentesco            = objDatosParentesco.obtenerParentesco(Convert.ToInt32(ddlParentesco.SelectedValue.ToString()));
                txtNombreParentesco.Text = objParentesco.NombreParentesco;
            }
            catch (Exception)
            {
                string script = "alert(\"Error al cargar los datos!\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
            }
        }
        public clsParentesco obtenerParentesco(int id)
        {
            clsConexion clsConexion = new clsConexion();

            string     sql     = "select * from PARENTEZCO where IDPARENTEZCO=" + id;
            SqlCommand comando = new SqlCommand(sql, clsConexion.conexion);

            clsConexion.abrirConexion();

            SqlDataReader lector = comando.ExecuteReader();

            clsParentesco objParentesco = new clsParentesco();

            while (lector.Read())
            {
                objParentesco.Codigo           = lector.GetInt32(0);
                objParentesco.NombreParentesco = lector.GetString(1);
            }

            clsConexion.cerrarConexion();
            return(objParentesco);
        }
        public bool ingresarParentesco(clsParentesco objParentesco)
        {
            try
            {
                clsConexion.abrirConexion();

                string cadena = "insert into PARENTEZCO (NOMBREPARENTEZCO) values ('" + objParentesco.NombreParentesco + "')";

                SqlCommand comando = new SqlCommand(cadena, clsConexion.Conexion);

                comando.ExecuteNonQuery();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                clsConexion.cerrarConexion();
            }
        }