AerolineaFrba.Compra.Form2.button1_Click C# (CSharp) Method

button1_Click() private method

private button1_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void button1_Click(object sender, EventArgs e)
        {
            Boolean validacion = false;
            validacion = Validacion.esVacio(txtDni, "DNI", true) || validacion;
            validacion = Validacion.esVacio(txtApe, "Apellido", true) || validacion;

            validacion = !Validacion.esNumero(txtDni, "DNI", true) || validacion;
            validacion = !Validacion.esSoloTexto(txtApe, "Apellido", true) || validacion;

            validacion = !Validacion.estaEntreLimites(txtDni, 1, 999999999, false, "DNI") || validacion;

            if (validacion)
            {
                return;
            }

            txtDire.Enabled = true;
            dp.Enabled = true;
            txtNom.Enabled = true;
            txtTel.Enabled = true;
            txtMail.Enabled = true;
            button2.Enabled = true;

            SQLManager.ejecutarQuery("select * from [ABSTRACCIONX4].buscarCliente('" + txtDni.Text + "', '" + txtApe.Text + "')", dgCliente);

            if (dgCliente.RowCount == 1)
            {
                encontroCliente = true;

                txtDire.Text = dgCliente.Rows[0].Cells["CLI_DIRECCION"].Value.ToString();
                dp.Value = (DateTime)dgCliente.Rows[0].Cells["CLI_FECHA_NAC"].Value;
                txtNom.Text = dgCliente.Rows[0].Cells["CLI_NOMBRE"].Value.ToString();
                txtTel.Text = dgCliente.Rows[0].Cells["CLI_TELEFONO"].Value.ToString();
                txtMail.Text = dgCliente.Rows[0].Cells["CLI_MAIL"].Value.ToString();

                codigoCliente = (int)dgCliente.Rows[0].Cells["CLI_COD"].Value;
                txtDni.Enabled = false;
            }
            else
            {

                SqlDataReader varCli = tieneDocumento(txtDni.Text);

                varCli.Read();

                if (varCli.HasRows)
                {
                    button2.Enabled = false;
                    txtDire.Enabled = false;
                    dp.Enabled = false;
                    txtNom.Enabled = false;
                    txtTel.Enabled = false;
                    txtMail.Enabled = false;
                    MessageBox.Show("Dni inválido. Ya existe un Cliente con ese DNI", "Error cliente", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("No se encuentra cargado el cliente en la BD. Por favor, ingresar los datos para darle de alta", "Cliente no encontrado", MessageBoxButtons.OK);
                }

            }
        }