Esempio n. 1
0
        void AlmacenaDatos()
        {
            if (this.IsValid)
            {
                string       mensaje      = " ";
                BLAdicciones bLAdicciones = new BLAdicciones();
                bool         resultado    = false;

                try
                {
                    resultado = bLAdicciones.InsertaAdiccion(
                        this.txtNombreAdiccion.Text,
                        this.txtCodigoAdiccion.Text);
                }
                catch (Exception exepcionCapturada)
                {
                    mensaje += $"Ocurrio un error: { exepcionCapturada.Message}";
                }
                finally
                {
                    if (resultado)
                    {
                        mensaje += $"El Registro Fue Insertado ";
                    }
                }


                //mostrar el mensaje
                Response.Write("<script>alert('" + mensaje + "')</script>");;
            }
        }
        void agregrarAdiccion()
        {
            if (this.IsValid)
            {
                string mensaje = "";

                BLAdicciones oInserta = new BLAdicciones();

                bool resultado = false;

                try
                {
                    ///Aquí se va a optener los datos para ingresar la información a la BD

                    string nombre = this.txtNombre.Text;

                    string codigo = this.txtCodigo.Text;


                    /// se llama al procedimiento almacenado para ingresar la información

                    resultado = oInserta.InsertaAdiccion(nombre, codigo);
                }
                catch (Exception excepcionCapturada)
                {
                    mensaje += $"Ocurrió un error: {excepcionCapturada.Message} ";
                }
                finally
                {
                    /// si la variable resultado es verdadera implica que no hubo errores

                    if (resultado)
                    {
                        mensaje += "El registro fue insertado";
                    }
                }

                ///motrar el mensaje

                Response.Write("<script>alert('" + mensaje + "')</script>");
            }
        }