AerolineaFrba.Compra.Form6.button2_Click C# (CSharp) Method

button2_Click() private method

private button2_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void button2_Click(object sender, EventArgs e)
        {
            bool huboError = this.hacerValidacionesDeTipo();

            if (!this.encontroCliente)
            {
                if (txtDni.Text.Length > 0 && txtApe.Text.Length > 0)
                {
                    SqlDataReader varCli = this.tieneDocumento(txtDni.Text);
                    varCli.Read();
                    if (varCli.HasRows)
                    {
                        MessageBox.Show("Dni inválido. Ya existe un Cliente con ese DNI", "Error cliente", MessageBoxButtons.OK);
                        huboError = true;
                    }
                }
            }

            if (!huboError)
            {

                if (sePuedeEfectuarLaCompra())
                {

                    string codigoPNR = CreatePNR(10);
                    cargarDatosDeCompra(codigoPNR);

                    this.Close();

                }
                else
                {
                    MessageBox.Show("Los datos ingresados de la tarjeta no coinciden con los datos registrados", "Compra de pasajes y/o encomiendas", MessageBoxButtons.OK);
                }

            }
        }