Ejemplo n.º 1
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            #region Acciones Campos y botones
            btnModificar.Enabled     = false;
            btnBuscarPatente.Enabled = false;
            btnBuscarDueño.Enabled   = false;
            btnCancelar.Visible      = true;
            habilitarCampos();
            #endregion

            try
            {
                if (validarVacios())
                {
                    if (validarEntero())
                    {
                        if (validarPatente())
                        {
                            if (!Page.IsValid)
                            {
                                return;
                            }
                            AccesoLogica negocio   = new AccesoLogica();
                            int          rut       = Convert.ToInt32(txtDueño.Text);
                            string       patente   = txtPatente.Text;
                            string       marca     = txtMarca.Text;
                            string       modelo    = txtModelo.Text;
                            int          annio     = Convert.ToInt32(txtAño.Text);
                            string       color     = txtColor.Text;
                            int          resultado = negocio.InsertVehiculo(patente, marca, modelo, annio, color, rut);
                            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    = "Ya existe un vehículo con la patente ingresada, o el rut del dueño no existe en nuestros registros.";
            }
        }