Esempio n. 1
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            btnModificar.Enabled = false;
            btnBuscar.Enabled    = false;
            btnCancelar.Visible  = true;
            habilitarCampos();

            try
            {
                if (validarVacios())
                {
                    if (validarEntero())
                    {
                        if (!Page.IsValid)
                        {
                            return;
                        }
                        AccesoLogica negocio   = new AccesoLogica();
                        int          rut       = Convert.ToInt32(txtRut.Text);
                        string       nombre    = txtNombre.Text;
                        string       apellido  = txtApellido.Text;
                        string       calle     = txtCalle.Text;
                        string       comuna    = txtComuna.Text;
                        int          numero    = Convert.ToInt32(txtNumero.Text);
                        int          resultado = negocio.InsertPersona(rut, nombre, apellido, calle, numero, comuna);
                        if (resultado == 1)
                        {
                            btnCancelar.Text   = "LIMPIAR";
                            btnGuardar.Enabled = false;
                            lblSucess.Visible  = true;
                            lblError.Visible   = false;
                            lblSucess.Text     = "Nuevo Registro Agregado Satisfactoriamente.";
                        }
                        negocio = null;
                    }
                }
            }
            catch (Exception exception)
            {
                lblError.Visible = true;
                lblError.Text    = "El registro a ingresar ya se encuentra en nuestras bases.";
            }
        }