private void btnEditar_Click(object sender, EventArgs e) { try { if (this.txtRut.Text == "") { MessageBox.Show("Debe ingresar un Rut"); } else { if (MessageBox.Show("Estas Seguro de actualizar ", "sistema", MessageBoxButtons.YesNo) == DialogResult.Yes) { ServiceConductor.WebServiceMantenedorConductorSoapClient auxServiceConductor = new ServiceConductor.WebServiceMantenedorConductorSoapClient(); ServiceConductor.Conductor auxConductor2 = new ServiceConductor.Conductor(); auxConductor2.Rut = this.txtRut.Text; auxConductor2.Nombres = this.txtNombre.Text; auxConductor2.Apellido_paterno = this.txtApPaterno.Text; auxConductor2.Apellido_materno = this.txtApMaterno.Text; if (this.rbFemenino.Checked == true) { auxConductor2.Sexo = this.rbFemenino.Text; } else if (this.rbMasculino.Checked == true) { auxConductor2.Sexo = this.rbMasculino.Text; } auxConductor2.Telefono = Convert.ToInt32(this.txtTelefono.Text); auxServiceConductor.actualizarConductorService(auxConductor2); MessageBox.Show("Datos Actualizados Exitosamente ", "Sistema"); this.btnGuardar.Enabled = true; this.btnEditar.Enabled = false; this.btnEliminar.Enabled = false; this.desHabilitar(); this.limpiar(); this.btnGuardar.Text = "Nuevo"; this.btnBuscar.Enabled = true; this.btnSalir.Text = "Salir"; txtRut.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnBuscar_Click(object sender, EventArgs e) { ServiceConductor.WebServiceMantenedorConductorSoapClient auxServiceConductor = new ServiceConductor.WebServiceMantenedorConductorSoapClient(); ServiceConductor.Conductor auxConductor = new ServiceConductor.Conductor(); if (String.IsNullOrEmpty(txtRut.Text)) { MessageBox.Show("Debe ingresar un Rut"); } else { if (String.IsNullOrEmpty(auxServiceConductor.buscarConductorService(this.txtRut.Text).Rut)) { MessageBox.Show("El Rut ingresado no existe"); } else { auxConductor = auxServiceConductor.buscarConductorService(txtRut.Text); this.txtRut.Text = auxConductor.Rut; this.txtNombre.Text = auxConductor.Nombres; this.txtApPaterno.Text = auxConductor.Apellido_paterno; this.txtApMaterno.Text = auxConductor.Apellido_paterno; if (this.rbFemenino.Text == auxConductor.Sexo) { this.rbFemenino.Checked = true; } else { this.rbMasculino.Checked = true; } this.txtTelefono.Text = Convert.ToString(auxConductor.Telefono); this.btnGuardar.Enabled = false; this.btnEditar.Enabled = true; this.btnEliminar.Enabled = true; this.habilitar(); } } }
private void btnGuardar_Click(object sender, EventArgs e) { if (this.btnGuardar.Text.Equals("Nuevo")) { this.habilitar(); this.limpiar(); this.btnGuardar.Text = "Guardar"; this.btnSalir.Text = "Cancelar"; } else { try { if (String.IsNullOrEmpty(txtRut.Text) && String.IsNullOrEmpty(txtNombre.Text) && String.IsNullOrEmpty(txtApMaterno.Text) && String.IsNullOrEmpty(txtApPaterno.Text) && String.IsNullOrEmpty(txtTelefono.Text) && this.rbFemenino.Checked == false && rbMasculino.Checked == false) { MessageBox.Show("Debe completar la información"); } else { ServiceConductor.WebServiceMantenedorConductorSoapClient auxServiceConductor = new ServiceConductor.WebServiceMantenedorConductorSoapClient(); ServiceConductor.Conductor auxConductor = new ServiceConductor.Conductor(); if (String.IsNullOrEmpty(auxServiceConductor.buscarConductorService(auxConductor.Rut).Rut)) { auxConductor.Rut = this.txtRut.Text; auxConductor.Nombres = this.txtNombre.Text; auxConductor.Apellido_paterno = this.txtApPaterno.Text; auxConductor.Apellido_materno = this.txtApMaterno.Text; auxConductor.Telefono = Convert.ToInt32(this.txtTelefono.Text); if (this.rbFemenino.Checked == true) { auxConductor.Sexo = this.rbFemenino.Text; } else if (this.rbMasculino.Checked == true) { auxConductor.Sexo = this.rbMasculino.Text; } auxServiceConductor.insertarConductorService(auxConductor); MessageBox.Show("Datos Guardados ", "Sistema"); this.limpiar(); this.desHabilitar(); } else { MessageBox.Show("Conductor ya existe ", "Sistema"); } this.limpiar(); this.btnGuardar.Text = "Nuevo"; this.btnBuscar.Enabled = true; this.btnSalir.Text = "Salir"; } } catch (Exception ex) { MessageBox.Show("Error al guardar " + ex.Message, "Sistema"); } } }