public static Gestion consultarGestion(string id_gestion) { String dato = ""; int empl_servicio = 0; int empl_solucion = 0; int cliente = 0; int motivo = 0; int estado = 0; Gestion gestion = null; try { using (var conn = new OdbcConnection("dsn=colchoneria")) { OdbcDataReader Reader; conn.Open(); { gestion = new Gestion(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT id_gestion, DATE_FORMAT(fecha,'%d/%m/%Y'), DATE_FORMAT(fecha,'%d/%m/%Y'),estado, prioridad, " + "motivo, descripcion, empl_servicio, empl_solucion, id_cliente" + "FROM tbl_gestion WHERE id_gestion = " + id_gestion + ";"; //validar que exista el registro. Reader = cmd.ExecuteReader(); dato = Reader["id_gestion"].ToString(); gestion.idGestion = Convert.ToInt32(dato); dato = Reader["fecha"].ToString(); gestion.fecha_gestion = Convert.ToDateTime(dato); dato = Reader["estado"].ToString(); estado = Convert.ToInt32(dato); dato = Reader["motivo"].ToString(); motivo = Convert.ToInt32(dato); dato = Reader["descripcion"].ToString(); gestion.descripcion = dato; dato = Reader["empl_servicio"].ToString(); empl_servicio = Convert.ToInt32(dato); dato = Reader["empl_solucion"].ToString(); empl_solucion = Convert.ToInt32(dato); dato = Reader["id_cliente"].ToString(); cliente = Convert.ToInt32(dato); } } conn.Close(); } //Siempre tiene empleado servicio. gestion.empl_servicio = TransaccionEmpleado.consultarEmpleado(empl_servicio); //Empleado solucion si no existe = 0. if (empl_solucion != 0) { gestion.empl_solucion = TransaccionEmpleado.consultarEmpleado(empl_solucion); } else { gestion.empl_solucion = null; } //Cliente gestion.cliente = TransaccionCliente.consultarCliente(cliente); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "ERROR"); } return(gestion); }
private void btnBuscarCliente_Click(object sender, EventArgs e) { this.cliente = TransaccionCliente.consultaGes(txt_dpi.Text); txt_nomCliente.Text = this.cliente.getNombreCompleto(); }