Ejemplo n.º 1
0
        private void btnCargarPaciente_Click(object sender, EventArgs e)
        {
            try
            {
                AccionesTerminal at = new AccionesTerminal();
                int rut             = int.Parse(txtRutPaciente_Pac.Text);
                rutBuscar = int.Parse(txtRutPaciente_Pac.Text);
                string verificar = txtVerificador_Pac.Text;
                verificarBuscar = txtVerificador_Pac.Text;

                PACIENTE p1 = at.buscarPaciente(rut, verificar);
                txtNombres_Pac.Text            = p1.NOMBRES_PACIENTE;
                txtApellidos_Pac.Text          = p1.APELLIDOS_PACIENTE;
                txtEmail_Pac.Text              = p1.EMAIL_PACIENTE;
                txtRutCargado_Pac.Text         = p1.RUT.ToString();
                txtVerificadorCargado_Pac.Text = p1.DIGITO_VERIFICADOR;

                if (p1.SEXO.ToUpper() == "M")
                {
                    cbSexo_Pac.SelectedIndex = 0;
                }
                else if (p1.SEXO.ToUpper() == "F")
                {
                    cbSexo_Pac.SelectedIndex = 1;
                }

                dtpFechaNac_Pac.Text = p1.FEC_NAC.ToString();

                btnRegistrar_Pac.Enabled = false;
                btnGuardar.Enabled       = true;
                btnEliminar.Enabled      = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al cargar paciente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void btnCrear_Click(object sender, EventArgs e)
        {
            string mensajeCorrecto = "Paciente creado correctamente";
            string mensajeError    = string.Empty;

            try
            {
                if (dtFechaNacimiento.Value.Date > DateTime.Today.Date)
                {
                    mensajeError = "Fecha de nacimiento inválida";
                }
                else if (!Util.rutValido(int.Parse(txtRut.Text), txtDv.Text))
                {
                    mensajeError = "RUT no válido";
                }
                else if (!Util.isEmailValido(txtCorreo.Text))
                {
                    mensajeError = "Correo no válido";
                }
                else if (!Util.isObjetoNulo(at.buscarPaciente(int.Parse(txtRut.Text), txtDv.Text)))
                {
                    mensajeError = "Paciente ya ingresado";
                }
                else
                {
                    lblError.Visible   = true;
                    lblError.Text      = "Creando paciente...";
                    lblError.ForeColor = System.Drawing.Color.Violet;
                    btnCrear.Enabled   = false;

                    PACIENTE paciente = new PACIENTE();

                    paciente.NOMBRES_PACIENTE   = txtNombres.Text;
                    paciente.APELLIDOS_PACIENTE = txtApellidos.Text;
                    paciente.RUT = int.Parse(txtRut.Text);
                    paciente.DIGITO_VERIFICADOR = txtDv.Text;
                    paciente.EMAIL_PACIENTE     = txtCorreo.Text;
                    paciente.SEXO    = ((ComboboxItem)cmbSexo.SelectedItem).Value;
                    paciente.FEC_NAC = dtFechaNacimiento.Value;

                    if (!at.nuevoPaciente(paciente))
                    {
                        mensajeError = "Error al crear paciente";
                    }
                }
            }
            catch (Exception ex)
            {
                mensajeError = "Error al crear paciente";
            }
            if (mensajeError == string.Empty)
            {
                MessageBox.Show(mensajeCorrecto, "Creada", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                MessageBox.Show(mensajeError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            btnCrear.Enabled = true;
            lblError.Visible = false;
        }