Exemplo n.º 1
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                int id;

                try
                {
                    id = Convert.ToInt32(txtId.Text);
                }
                catch
                {
                    throw new ExcepcionPresentacion("El ID no es un número entero válido.");
                }
                limpiarFormulario();
                Periodista periodista = LogicaFuente.BuscarPeriodista(id);

                txtId.Text        = periodista.Id.ToString();
                txtDireccion.Text = periodista.Direccion;
                txtNombre.Text    = periodista.Nombre;
                txtDocumento.Text = periodista.DocumentoIdentidad;
                txtTelefono.Text  = periodista.Telefono;

                lblMensaje.Text = "☺¡Periodista encontrado!";
            }
            catch (ExcepcionSistema ex)
            {
                lblMensaje.Text = ex.Message;
            }
            catch (Exception ex)
            {
                lblMensaje.Text = "¡Error! no se encontró el periodista";
            }
        }
Exemplo n.º 2
0
        protected void btnBaja_Click(object sender, EventArgs e)
        {
            try
            {
                int id;

                try
                {
                    id = Convert.ToInt32(txtId.Text);
                }
                catch
                {
                    throw new ExcepcionPresentacion("El ID no es un número entero válido.");
                }

                LogicaFuente.BajaPeriodista(id);

                limpiarFormulario();
                lblMensaje.Text = "☺¡Periodista borrado!";
            }
            catch (ExcepcionSistema ex)
            {
                lblMensaje.Text = ex.Message;
            }
            catch (Exception ex)
            {
                lblMensaje.Text = "¡Error! No se pudo dar de baja el Periodista";
            }
        }
Exemplo n.º 3
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                int id;

                try
                {
                    id = Convert.ToInt32(txtId.Text);
                }
                catch
                {
                    throw new ExcepcionPresentacion("El número no es un número entero válido.");
                }
                limpiarFormulario();
                Agencia agencia = LogicaFuente.BuscarAgencia(id);

                txtId.Text           = agencia.Id.ToString();
                txtNombre.Text       = agencia.Nombre;
                txtPaisDeOrigen.Text = agencia.PaisOrigen;

                lblMensaje.Text = "☺¡Agencia encontrada!";
            }
            catch (ExcepcionSistema ex)
            {
                lblMensaje.Text = ex.Message;
            }
            catch (Exception ex)
            {
                lblMensaje.Text = "¡Error! No se pudo buscar la Agencia.";
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    ddlFuente.DataSource     = LogicaFuente.ListarFuentes();
                    ddlFuente.DataTextField  = "Nombre";
                    ddlFuente.DataValueField = "Id";
                    ddlFuente.DataBind();

                    if (ddlFuente.Items.Count == 0)
                    {
                        lblMensaje.Text = "¡Atención! No hay fuentes disponibles.";
                    }
                }

                ddlFuente.Focus();
            }
            catch (ExcepcionSistema ex)
            {
                lblMensaje.Text = ex.Message;
            }
            catch (Exception ex)
            {
                lblMensaje.Text = "¡Error! Ocurrió un error al cargar la página.";
            }
        }
Exemplo n.º 5
0
        protected void btnModificar_Click(object sender, EventArgs e)
        {
            try
            {
                int id;

                try
                {
                    id = Convert.ToInt32(txtId.Text);
                }
                catch (Exception ex)
                {
                    throw new ExcepcionPresentacion("El Id no es un número entero válido.");
                }

                Fuente fuente            = LogicaFuente.BuscarFuente(Convert.ToInt32(ddlFuente.SelectedValue));
                string seccion           = txtSeccion.Text;
                bool   imagenIlustrativa = chkImagenIlustrativa.Checked;

                decimal costo;

                try
                {
                    costo = Convert.ToDecimal(txtCosto.Text);
                }
                catch (Exception ex)
                {
                    throw new ExcepcionPresentacion("El Costo no es un número decimal válido.");
                }

                string contenido = txtContenido.Text;

                Articulo articulo = new Articulo(id, seccion, imagenIlustrativa, costo, contenido, fuente);

                LogicaArticulo.ModificarArticulo(articulo);

                limpiarFormulario();

                lblMensaje.Text = "☺¡Artículo modificado con éxito!";
            }
            catch (ExcepcionSistema ex)
            {
                lblMensaje.Text = ex.Message;
            }
            catch (Exception ex)
            {
                lblMensaje.Text = "¡Error! Ocurrió un error al modificar el artículo.";
            }
        }
Exemplo n.º 6
0
        protected void btnDarAlta_Click(object sender, EventArgs e)
        {
            try
            {
                Fuente fuente            = LogicaFuente.BuscarFuente(Convert.ToInt32(ddlFuente.SelectedValue));
                string seccion           = txtSeccion.Text;
                bool   imagenIlustrativa = chkImagenIlustrativa.Checked;

                decimal costo;

                try
                {
                    costo = Convert.ToDecimal(txtCosto.Text);
                }
                catch (Exception ex)
                {
                    throw new ExcepcionPresentacion("El Costo no es un número decimal válido.");
                }

                string contenido = txtContenido.Text;

                Articulo articulo = new Articulo(0, seccion, imagenIlustrativa, costo, contenido, fuente);

                int id;
                LogicaArticulo.DarAltaArticulo(articulo, out id);

                limpiarFormulario();
                txtId.Text      = id.ToString();
                lblMensaje.Text = "☺¡Artículo dado de alta con éxito con Id: " + id + "!";
                txtId.Focus();
            }
            catch (ExcepcionSistema ex)
            {
                lblMensaje.Text = ex.Message;
            }
            catch (Exception ex)
            {
                lblMensaje.Text = "¡Error! Ocurrió un error al dar de alta el artículo.";
            }
        }