private void btnAgregar_Click(object sender, EventArgs e) { validador.limpiarTexBox(this); validador.habilitarTodo(this, "habilitar"); btnAgregar.Enabled = false; btnModificar.Enabled = false; btnEliminar.Enabled = false; esNuevo = true; }
private void btnAgregar_Click(object sender, EventArgs e) { cmbCuenta.Text = "Paciente"; validador.limpiarTexBox(this); validador.habilitarControles(this, true); validador.manejarBotonesABM(btnAgregar, btnAgregar, btnCancelar, btnModificar, btnEliminar, btnGuardar, btnSalir); txtNumeroPaciente.Focus(); esNuevo = true; }
private Boolean guardarProfesional() { string matricula; if (validador.validarString(txtmatricula, "Ingrese el matricula del profesional", "Atención")) { matricula = txtmatricula.Text.Trim(); } else { return(false); } String nombreprof; if (validador.validarString(txtnombre, "Ingrese el nombre del profesional", "Atención")) { nombreprof = txtnombre.Text.Trim(); } else { return(false); } String apellidoprof; if (validador.validarString(txtapellido, "Ingrese el apellido del profesional", "Atención")) { apellidoprof = txtapellido.Text.Trim(); } else { return(false); } String nrodoc; if (validador.validarString(txtnrodoc, "Ingrese el numero de documento del profesional", "Atención")) { nrodoc = txtnrodoc.Text.Trim(); } else { return(false); } String calleProf; if (validador.validarString(txtcalle, "Ingrese el nombre de la calle del profesional", "Atención")) { calleProf = txtcalle.Text.Trim(); } else { return(false); } String numeroCalleProf; if (validador.validarString(txtnumero, "Ingrese el numero de la calle del profesional", "Atención")) { numeroCalleProf = txtnumero.Text.Trim(); } else { return(false); } DateTime fechaAlta = dtpFechaAlta.Value.Date; DateTime fechanac = dtpfechanac.Value.Date; int idTipoDocProf = Convert.ToInt32(cmbTipoDocumento.SelectedValue); String nombretipoDocProf = cmbTipoDocumento.Text; TipoDocumento tipoDocumentoProf = new TipoDocumento(idTipoDocProf, nombretipoDocProf); int idBarrioProf = Convert.ToInt32(cmbBarrios.SelectedValue); String nombreBarrioProf = cmbBarrios.Text; Barrio barrioProf = new Barrio(idBarrioProf, nombreBarrioProf); String pisoProf = txtpiso.Text.Trim(); String deptoProf = txtdpto.Text.Trim(); String torreProf = txttorre.Text.Trim(); Domicilio domicilioProf = new Domicilio(calleProf, numeroCalleProf, pisoProf, deptoProf, torreProf, barrioProf); List <Correo> correosProf = new List <Correo>(); foreach (Correo correo in lstCorreosElectronicos.Items) { correosProf.Add(correo); } List <Telefono> telefonosProf = new List <Telefono>(); foreach (Telefono telefono in lstTelefonos.Items) { telefonosProf.Add(telefono); } int idSexoProf = Convert.ToInt32(cmbSexo.SelectedValue); String nombreSexoProf = cmbSexo.Text; Sexo sexoProf = new Sexo(idSexoProf, nombreSexoProf); String nombreCuentaProf = cmbCuenta.SelectedItem.ToString(); int idCuentaProf = (int)cmbCuenta.SelectedValue; Cuenta cuentaProf = new Cuenta(idCuentaProf, nombreCuentaProf); String nombreEstadoProf = cmbEstado.SelectedItem.ToString(); int idEstadoProf = (int)cmbEstado.SelectedValue; EstadoUsuario estadoUsuarioProf = new EstadoUsuario(idEstadoProf, nombreEstadoProf); String nombreUsuarioProf = txtusuario.Text.Trim(); String contraseniaProf = txtcontraseña.Text.Trim(); String comentarioUsuarioProf = txtcomentario.Text.Trim(); Usuario usuarioProf = new Usuario(nombreUsuarioProf, contraseniaProf, cuentaProf, comentarioUsuarioProf, estadoUsuarioProf); List <Especialidad> lstespecialidades = new List <Especialidad>(); for (int i = 0; i < grillaespecialidades.Rows.Count; i++) { int id = Convert.ToInt32(grillaespecialidades["idespecialidad", i].Value.ToString()); string nombre = grillaespecialidades["nombre", i].Value.ToString(); string descripcion = grillaespecialidades["descripcion", i].Value.ToString(); Especialidad esp = new Especialidad(id, nombre, descripcion); lstespecialidades.Add(esp); } Profesional prof = new Profesional(nombreprof, apellidoprof, fechaAlta, nrodoc, tipoDocumentoProf, fechanac, telefonosProf, correosProf, domicilioProf, usuarioProf, comentarioUsuarioProf, sexoProf, "", matricula); GestorDePersonas gestorPersonas = new GestorDePersonas(); if (gestorPersonas.tomarProfesional(prof, lstespecialidades)) { Validador val = new Validador(); val.limpiarTexBox(this); grillaespecialidades.DataSource = gestorPersonas.limpiarGrilla(); deshabilitarcampos(); //btnGrabar.Enabled = false; btnAgregarProf.Enabled = true; //btncancelar.Enabled = false; //btneliminar.Enabled = false; //btneditar.Enabled = false; grbProfesionales.Enabled = true; txtbuscarprofesional.Enabled = true; btnBuscarProfesional.Enabled = true; btnsalir.Enabled = true; MessageBox.Show("Profesional guardado", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } else { MessageBox.Show("El profesional ya se encuentra registrado", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } }