Skip to content

Instantly share code, notes, and snippets.

@dmp3kl

dmp3kl/form4.cs

Created Sep 3, 2019
Embed
What would you like to do?
txt_documentoKeypress
private void txt_documento_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
string var = txt_documento.Text.ToString();
if (var != "" || var !=" ")
{
AbrirConexion();
SqlCommand cdo = new SqlCommand();
cdo.Connection = conexion;
cdo.CommandText = "select Codigo,Descripcion from zf_TipoDoc where Codigo='" + var + "'";
SqlDataReader reader = cdo.ExecuteReader();
while (reader.Read())
{
//cmbbox_documento.SelectedValue = reader[0].ToString();
cmbbox_documento.SelectedItem = new Dato() { Codigo = reader[0].ToString(), Descripcion = reader[1].ToString() };
}
reader.Close();
CerrarConexion();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment