private void textNombres_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { var cond = new z_conductores(); cond = cond.getObjectz_conductores(textNombres.Text); switch (cond.id_tipo_conductor) { case 1: z_cuarteleros cuart = new z_cuarteleros().getObjectz_cuarteleros(cond.id_cuart_vol); textNombres.Text = cuart.apellidos + " " + cuart.nombres; listNombres.SelectedItem = cuart.apellidos + " " + cuart.nombres; break; case 2: z_voluntarios vol = new z_voluntarios().getObjectz_voluntarios(cond.id_cuart_vol); textNombres.Text = vol.apellidos + " " + vol.nombres; listNombres.SelectedItem = vol.apellidos + " " + vol.nombres; break; default: break; } } }
protected override void Actualizar() { try { var cuart = new z_cuarteleros().getObjectz_cuarteleros((int)listActuales.SelectedValue); cuart.rut = textRut.Text; cuart.fecha_nacimiento = DateTime.Parse(textFechaNac.Text); cuart.apellidos = textApellidos.Text; cuart.nombres = textNombres.Text; cuart.alergia = textAlergia.Text; cuart.padece = textPadece.Text; cuart.tipo_sangre = textSangre.Text; cuart.telefono = textFono.Text; cuart.celular = textMovil.Text; cuart.id_compania = (int)((DataRowView)comboCompania.SelectedItem).Row["id_compania"]; cuart.modifyz_cuarteleros(cuart); Source = cuart.Getz_cuartelerosLista().Tables[0]; MessageBox.Show("Operación realizada correctamente.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { Log.ShowAndLog(ex); } }
protected override void Insertar() { try { var cuart = new z_cuarteleros { rut = textRut.Text, fecha_nacimiento = DateTime.Parse(textFechaNac.Text), apellidos = textApellidos.Text, nombres = textNombres.Text, alergia = textAlergia.Text, padece = textPadece.Text, tipo_sangre = textSangre.Text, telefono = textFono.Text, celular = textMovil.Text, id_compania = ((int)((DataRowView)comboCompania.SelectedItem).Row["id_compania"]) }; cuart.addz_cuarteleros(cuart); Source = cuart.Getz_cuartelerosLista().Tables[0]; MessageBox.Show("Operación realizada correctamente.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { Log.ShowAndLog(ex); } }
public static string ObtieneNombreDeConductor(int id_conductor, int tipo_conductor) { string NombeConductor = ""; string reqSQL = ""; z_cuarteleros zcuarteleros = new z_cuarteleros(); z_voluntarios zvoluntarios = new z_voluntarios(); var myBase = new CnxBase(); var myD4MCnx = new CnxBase(); if (tipo_conductor == 1) { //reqSQL = "SELECT nombres||' '||apellidos As nombre_completo FROM z_cuarteleros WHERE id_cuartelero=" + id_conductor + ""; reqSQL = "SELECT nombres||' '||apellidos As nombre_completo FROM z_cuarteleros WHERE id_cuartelero IN (SELECT id_cuart_vol FROM z_conductores WHERE id_conductor=" + id_conductor + ")"; } else { reqSQL = "SELECT nombres||' '||apellidos As nombre_completo FROM z_voluntarios WHERE id_voluntario IN (SELECT id_cuart_vol FROM z_conductores WHERE id_conductor=" + id_conductor + ")"; } try { DataSet myResult = myD4MCnx.GetDataSet(reqSQL); foreach (DataRow r_conductor in myResult.Tables[0].Rows) { NombeConductor = Convert.ToString(r_conductor["nombre_completo"]); } } catch (Exception myErr) { throw (new Exception(myErr + reqSQL)); } return(NombeConductor); }
protected override void Eliminar() { try { var cuart = new z_cuarteleros(); cuart.deletez_cuarteleros((int)listActuales.SelectedValue); Source = cuart.Getz_cuartelerosLista().Tables[0]; } catch (Exception ex) { Log.ShowAndLog(ex); } }
private void FillCuarteleros() { var cuart = new z_cuarteleros(); ds = cuart.Getz_cuarteleros(); nombres = new List <object>(); foreach (DataRow dr in ds.Tables[0].Rows) { var p = new KeyValuePair <string, int>((string)dr["apellidos"] + " " + dr["nombres"], (int)dr["id_cuartelero"]); nombres.Add(p); } listNombres.Items.Clear(); listNombres.Items.AddRange(nombres.ToArray()); }
private void AdminCuarteleros_Load(object sender, EventArgs e) { try { DataSet ds = new z_cuarteleros().Getz_cuartelerosLista(); listActuales.DisplayMember = "nombre_completo"; listActuales.ValueMember = "id_cuartelero"; Source = ds.Tables[0]; comboCompania.DisplayMember = "id_compania"; comboCompania.ValueMember = "id_compania"; comboCompania.DataSource = new z_companias().Getz_companias().Tables[0]; } catch (Exception ex) { Log.ShowAndLog(ex); } }
protected override void Mostrar(int id) { try { z_cuarteleros cuart = new z_cuarteleros().getObjectz_cuarteleros(id); textRut.Text = cuart.rut; textFechaNac.Text = cuart.fecha_nacimiento.ToShortDateString(); textApellidos.Text = cuart.apellidos; textNombres.Text = cuart.nombres; textAlergia.Text = cuart.alergia; textPadece.Text = cuart.padece; textSangre.Text = cuart.tipo_sangre; textFono.Text = cuart.telefono; textMovil.Text = cuart.celular; comboCompania.SelectedValue = cuart.id_compania; } catch (Exception ex) { Log.ShowAndLog(ex); } }