private void btnModificar_Click(object sender, EventArgs e)
        {
            DateTime hoy  = DateTime.Now;
            DateTime fech = DateTime.Now;

            if (int.Parse(txtmes.Text) == 2 && int.Parse(txtdia.Text) > 29)
            {
                MessageBox.Show("Fecha invalida: no existe el dia");
                return;
            }
            if ((int.Parse(txtmes.Text) == 4 && int.Parse(txtdia.Text) > 30) || (int.Parse(txtmes.Text) == 6 && int.Parse(txtdia.Text) > 30) || (int.Parse(txtmes.Text) == 9 && int.Parse(txtdia.Text) > 30) || (int.Parse(txtmes.Text) == 11 && int.Parse(txtdia.Text) > 30))
            {
                MessageBox.Show("Fecha invalida: no existe el dia");
                return;
            }
            if (!string.IsNullOrEmpty(txtnom1.Text) == false)
            {
                MessageBox.Show("Llene todos los campos obligatorios");
                return;
            }
            if (!string.IsNullOrEmpty(txtape1.Text) == false)
            {
                MessageBox.Show("Llene todos los campos obligatorios");
                return;
            }
            if (!string.IsNullOrEmpty(txtlugar.Text) == false)
            {
                MessageBox.Show("Llene todos los campos obligatorios");
                return;
            }

            if (rdf.Checked == false && rdm.Checked == false)
            {
                MessageBox.Show("Llene todos los campos obligatorios");
                return;
            }
            if (!string.IsNullOrEmpty(txtid.Text) == false)
            {
                MessageBox.Show("Llene todos los campos obligatorios");
                return;
            }
            if (txtid.TextLength < 13)
            {
                MessageBox.Show("El campo de de identidad debe ser de 13 digitos");
                return;
            }

            if (!string.IsNullOrEmpty(txtdia.Text) == false)
            {
                MessageBox.Show("Llene todos los campos obligatorios");
                return;
            }
            if (!string.IsNullOrEmpty(txtmes.Text) == false)
            {
                MessageBox.Show("Llene todos los campos obligatorios");
                return;
            }
            if (!string.IsNullOrEmpty(txtanio.Text) == false)
            {
                MessageBox.Show("Llene todos los campos obligatorios");
                return;
            }

            if ((int.Parse(txtdia.Text)) <= 0 || (int.Parse(txtdia.Text)) > 31)
            {
                MessageBox.Show("El dia tiene que ser 1-31");
                return;
            }
            if ((int.Parse(txtmes.Text)) <= 0 || (int.Parse(txtmes.Text)) > 12)
            {
                MessageBox.Show("El mes tiene que ser 1-12");
                return;
            }
            //if ((int.Parse(txtanio.Text)) < 1900 || (int.Parse(txtanio.Text)) > 2018)
            if ((hoy.Year - (int.Parse(txtanio.Text)) > 100) || (int.Parse(txtanio.Text)) > int.Parse(fech.Year.ToString()))
            {
                MessageBox.Show("El año tiene que ser " + (hoy.Year - 100) + "-" + fech.Year.ToString());
                return;
            }

            int b = Base_de_datos.validarIDp2(txtid.Text, txtExpediente.Text);

            if (b == 0)
            {
                MessageBox.Show("Identidad ya existente");
                return;
            }


            if ((int.Parse(txtanio.Text)) < 1900 || (int.Parse(txtanio.Text)) > int.Parse(fech.Year.ToString()))
            {
                MessageBox.Show("El año tiene que ser 1900-" + fech.Year.ToString());
                return;
            }
            DateTime actual = DateTime.Now;
            DateTime compar = Convert.ToDateTime((txtdia.Text + "/" + txtmes.Text + "/" + txtanio.Text).Trim(), new CultureInfo("en-GB"));

            if (compar > actual)
            {
                MessageBox.Show("La fecha no puede ser mayor a la actual");
                return;
            }
            if (txttel.TextLength < 8 && (!string.IsNullOrEmpty(txttel.Text) == true))
            {
                MessageBox.Show("El campo de telefono debe ser de 8 digitos");
                return;
            }
            if (txtTelEmer.TextLength < 8 && (!string.IsNullOrEmpty(txtTelEmer.Text) == true))
            {
                MessageBox.Show("El campo de telefono de emergencia debe ser de 8 digitos");
                return;
            }
            string estado;

            if (cmbestado.Text == "Activo")
            {
                estado = "ACT";
            }

            else
            {
                estado = "INC";
            }

            Base_de_datos.Actualizar_P(int.Parse(txtExpediente.Text), txtnom1.Text.ToUpper(), txtnom2.Text.ToUpper(), txtape1.Text.ToUpper(), txtape2.Text.ToUpper(), txtlugar.Text, txtdia.Text + "/" + txtmes.Text + "/" + txtanio.Text, txtpadre.Text, txtmadre.Text, txtid.Text, sexo, riesgo, txtOcupacion.Text.ToUpper(), txtLugarTrabajo.Text.ToUpper(), txtDireccion.Text.ToUpper(), txttel.Text.ToUpper(), txtTelEmer.Text.ToUpper(), estado);

            MessageBox.Show("Expediente modificado.");

            txtnom1.Enabled         = false;
            txtnom2.Enabled         = false;
            txtape1.Enabled         = false;
            txtape2.Enabled         = false;
            groupBox1.Enabled       = false;
            txtid.Enabled           = false;
            txtlugar.Enabled        = false;
            txtdia.Enabled          = false;
            txtmes.Enabled          = false;
            txtanio.Enabled         = false;
            txtmadre.Enabled        = false;
            txtpadre.Enabled        = false;
            txtriesgo.Enabled       = false;
            txtOcupacion.Enabled    = false;
            txtDireccion.Enabled    = false;
            txttel.Enabled          = false;
            txtTelEmer.Enabled      = false;
            txtlugar.Enabled        = false;
            txtLugarTrabajo.Enabled = false;

            btnModificar.Enabled = false;

            txtnom1.Clear();
            txtnom2.Clear();
            txtape1.Clear();
            txtape2.Clear();
            txtid.Clear();
            txtlugar.Clear();
            txtdia.Clear();
            txtmes.Clear();
            txtanio.Clear();
            txtmadre.Clear();
            txtpadre.Clear();
            txtOcupacion.Clear();
            txtDireccion.Clear();
            txttel.Clear();
            txtTelEmer.Clear();
            txtlugar.Clear();
            txtLugarTrabajo.Clear();

            this.Hide();
        }