Example #1
0
 /// <summary>
 /// Carga todos los datos de la fuente seleccionada en sus correspondientes componentes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonSeleccionarFuente_Click(object sender, EventArgs e)
 {
     if (dataGridViewFuentes.CurrentRow.Index != -1)
     {
         if (comboBoxTipoFuente.Text == "RSS")
         {
             FuenteRSS mFuente = new FuenteRSS {
                 Id = Convert.ToInt32(dataGridViewFuentes["Id", dataGridViewFuentes.CurrentRow.Index].Value)
             };
             mFuente = cFachada.GetFuenteRSS(mFuente);
             textBoxTituloFuente.Text = mFuente.Titulo;
             textBoxValorFuente.Text  = mFuente.Valor;
             textBoxId.Text           = mFuente.Id.ToString();
         }
         else
         {
             FuenteTextoFijo mFuente = new FuenteTextoFijo {
                 Id = Convert.ToInt32(dataGridViewFuentes["Id", dataGridViewFuentes.CurrentRow.Index].Value)
             };
             mFuente = cFachada.GetFuenteTXT(mFuente);
             textBoxTituloFuente.Text = mFuente.Titulo;
             textBoxValorFuente.Text  = mFuente.Valor;
             textBoxId.Text           = mFuente.Id.ToString();
         }
     }
 }
Example #2
0
        /// <summary>
        /// Traduce los argumentos seleccionados del GroupBox filtro a un diccionario
        /// </summary>
        /// <returns>Arguementos para filtrar los Elementos a mostrar</returns>
        private Dictionary <Type, Object> ArgumentosSelccionados()
        {
            Dictionary <Type, object> argumentos = new Dictionary <Type, object>();
            string nombre = "";

            if (this.checkBox_Nombre.Checked)
            {
                nombre = this.textBox_Nombre.Text;
            }
            argumentos.Add(nombre.GetType(), nombre);
            if (this.checkBox_Tipo.Checked)
            {
                IFuente fuenteTipo;
                if (this.radioButton_RSS.Checked)
                {
                    fuenteTipo = new FuenteRSS();
                }
                else
                {
                    fuenteTipo = new FuenteTextoFijo();
                }
                argumentos.Add(typeof(IFuente), fuenteTipo);
            }
            if (this.checkBox_RangoFechas.Checked)
            {
                RangoFecha pRangoFecha = new RangoFecha()
                {
                    FechaInicio = this.dateTimePicker_FechaDesde.Value,
                    FechaFin    = this.dateTimePicker_FechaHasta.Value
                };
                argumentos.Add(pRangoFecha.GetType(), pRangoFecha);
            }
            return(argumentos);
        }
Example #3
0
        /// <summary>
        /// Crea una fuente Texto Fijo
        /// </summary>
        /// <param name="pCodigo">Código de la fuente Texto Fijo</param>
        /// <param name="pValor">Valor de la fuente Texto Fijo</param>
        /// <returns>Tipo de dato fuente Texto fijo que representa el creado</returns>
        private FuenteTextoFijo CrearFuenteTextoFijo(int pCodigo, string pValor)
        {
            FuenteTextoFijo pFuenteTextoFijo = new FuenteTextoFijo()
            {
                Codigo = pCodigo,
                Valor  = pValor
            };

            return(pFuenteTextoFijo);
        }
Example #4
0
        ///Métodos de Fuentes

        /// <summary>
        /// Agrega una fuente de texto fijo
        /// </summary>
        ///
        public void AddFuenteTXT(FuenteTextoFijo pFuenteTextoFijo)
        {
            if (cRepositoryBaseTXT.Filter(x => x.Titulo == pFuenteTextoFijo.Titulo) != null)
            {
                cRepositoryBaseTXT.Add(pFuenteTextoFijo);
                cRepositoryBaseTXT.SaveChanges();
            }
            else
            {
                throw new Exception("Ya existe una fuente con ese nombre.");
            }
        }
 /// <summary>
 /// guarda una fuente en la base de datos
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnFuenteGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         //se realizan controles de valor nulo y de url valida
         if (textBoxTitulo.Text == "")
         {
             throw new Exception("Por favor, ingrese un titulo para la fuente.");
         }
         else
         {
             if (radioButtonRSS.Checked)
             {
                 if (!Utilidades.UrlValida(textBoxURLfuente.Text))
                 {
                     throw new Exception("La URL no es válida. Por favor verifíquela.");
                 }
                 else
                 {
                     FuenteRSS mFuenteRSS = new FuenteRSS {
                         Titulo = textBoxTitulo.Text, URL = textBoxURLfuente.Text
                     };
                     string mCadena = "Se agregó la fuente: Id " + mFuenteRSS.Id + ", Título: " + mFuenteRSS.Titulo;
                     cLogger.Debug(mCadena);
                     cFachada.AddFuenteRSS(mFuenteRSS);
                     MessageBox.Show("La fuente RSS se agregó con éxito");
                 }
             }
             else
             {
                 FuenteTextoFijo mFuenteTextoFijo = new FuenteTextoFijo {
                     Titulo = textBoxTitulo.Text, Valor = textBoxTextoFijo.Text
                 };
                 string mCadena = "Se agregó la fuente: Id " + mFuenteTextoFijo.Id + ", Título: " + mFuenteTextoFijo.Titulo;
                 cLogger.Debug(mCadena);
                 cFachada.AddFuenteTXT(mFuenteTextoFijo);
                 MessageBox.Show("La fuente se agregó con éxito");
             }
         }
     }
     catch (Exception mException)
     {
         MessageBox.Show(mException.Message);
         cLogger.Debug(mException.ToString());
     }
 }
Example #6
0
        public void Banner2Actualizar()
        {
            List <RangoFecha> listaRangosFecha = new List <RangoFecha>();
            FuenteTextoFijo   pTextoFijo       = this.CrearFuenteTextoFijo(31, "dsad");
            Banner            pBanner          = new Banner()
            {
                Codigo        = 31,
                Nombre        = "Prueba",
                Fuente        = pTextoFijo,
                Fuente_Codigo = pTextoFijo.Codigo
            };

            listaRangosFecha.Add(this.CrearRangoFecha(31, DateTime.Now.AddDays(2800), pBanner));
            listaRangosFecha.Add(this.CrearRangoFecha(12, DateTime.Now.AddDays(2800), pBanner));
            pBanner.RangosFecha = listaRangosFecha;
            Persistencia.FachadaPersistencia fachada = new Persistencia.FachadaPersistencia();
            fachada.ActualizarBanner(pBanner);
        }
 /// <summary>
 /// Borra una fuente.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnBorrar_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridViewEliminar.CurrentRow.Index != -1)
         {
             if (radioButtonRSS.Checked)
             {
                 FuenteRSS mFuenteRSS = new FuenteRSS {
                     Id = Convert.ToInt32(dataGridViewEliminar["Id", dataGridViewEliminar.CurrentRow.Index].Value)
                 };
                 DialogResult mMessageBoxResultado = MessageBox.Show("¿Desea borrar la Fuente?", "Borrar Fuente", MessageBoxButtons.YesNo);
                 if (mMessageBoxResultado == DialogResult.Yes)
                 {
                     string mCadena = "Se borra la fuente: Id: " + mFuenteRSS.Id;
                     cLogger.Debug(mCadena);
                     cFachada.DeleteFuenteRSS(mFuenteRSS);
                     radioButtonRSS_CheckedChanged(sender, e);
                     MessageBox.Show("La fuente se ha borrado exitosamente");
                 }
             }
             else
             {
                 FuenteTextoFijo mFuenteTXT = new FuenteTextoFijo {
                     Id = Convert.ToInt32(dataGridViewEliminar["Id", dataGridViewEliminar.CurrentRow.Index].Value)
                 };
                 DialogResult mMessageBoxResultado = MessageBox.Show("¿Desea borrar la Fuente?", "Borrar Fuente", MessageBoxButtons.YesNo);
                 if (mMessageBoxResultado == DialogResult.Yes)
                 {
                     string mCadena = "Se borra la fuente: Id: " + mFuenteTXT.Id;
                     cLogger.Debug(mCadena);
                     cFachada.DeleteFuenteTXT(mFuenteTXT);
                     radioButtonTXT_CheckedChanged(sender, e);
                     MessageBox.Show("La fuente se ha borrado exitosamente");
                 }
             }
         }
     }
     catch (Exception mException)
     {
         cLogger.Debug(mException.Message);
         MessageBox.Show("Ocurrio un error: " + mException.Message);
     }
 }
        /// <summary>
        /// Constructor de la ventana de Texto Fijo
        /// </summary>
        /// <param name="pFuente">Fuente de Texto Fijo a modificar</param>
        internal Form_FuenteTextoFijo(FuenteTextoFijo pFuente = null)
        {
            InitializeComponent();
            bool auxiliar = pFuente != null;

            if (auxiliar)
            {
                this.textBox_ValorTextoFijo.Text = pFuente.Valor;
                this.iFuenteTextoFijo            = pFuente;
            }
            else
            {
                this.iFuenteTextoFijo = new FuenteTextoFijo()
                {
                    Codigo = 0, Valor = ""
                };
            }
            this.button_Aceptar.Enabled = auxiliar;
            this.CampoCompleto(this.pictureBox_ComprobacionValorTF, auxiliar);
        }
 /// <summary>
 /// Carga una fuente seleccionada y muestra los datos de la misma.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonCargar_Click(object sender, EventArgs e)
 {
     if (dataGridViewModificar.CurrentRow.Index != -1)
     {
         if (radioButtonRSS.Checked)
         {
             FuenteRSS mFuenteRSS = new FuenteRSS {
                 Id = Convert.ToInt32(dataGridViewModificar["Id", dataGridViewModificar.CurrentRow.Index].Value)
             };
             cFuenteRSS            = cFachada.GetFuenteRSS(mFuenteRSS);
             textBoxTitulo.Text    = cFuenteRSS.Titulo;
             textBoxURLfuente.Text = cFuenteRSS.URL;
         }
         else
         {
             FuenteTextoFijo mFuenteTXT = new FuenteTextoFijo {
                 Id = Convert.ToInt32(dataGridViewModificar["Id", dataGridViewModificar.CurrentRow.Index].Value)
             };
             cFuenteTXT            = cFachada.GetFuenteTXT(mFuenteTXT);
             textBoxTitulo.Text    = cFuenteTXT.Titulo;
             textBoxTextoFijo.Text = cFuenteTXT.Valor;
         }
     }
 }
Example #10
0
        /// <summary>
        /// Verifica los datos y guarda el nuevo banner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBannerGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                //Verifia si tiene nombre
                if (textBoxBannerNombre.Text == "")
                {
                    throw new Exception("Falta ingresar el nombre del Banner");
                }

                //Verifica si las fechas forman un rango aceptable
                if (dateTimePickerBannerFechaInicio.Value.Date < DateTime.Now.Date)
                {
                    throw new Exception("No se admiten Fechas de Inicios pasadas");
                }

                if (dateTimePickerBannerFechaFin.Value.Date < dateTimePickerBannerFechaInicio.Value.Date)
                {
                    throw new Exception("La Fecha Final debe ser mayor a la Fecha de Inicio");
                }

                //Verifica si se han seleccionado imágenes
                if (dataGridViewFuentes.CurrentRow.Index < 0)
                {
                    throw new Exception("Debe seleccionar al menos una fuente");
                }

                //Pasa la info del datePicker y el combo a una sola variable
                DateTime mFechaInicio = new DateTime(
                    dateTimePickerBannerFechaInicio.Value.Year,
                    dateTimePickerBannerFechaInicio.Value.Month,
                    dateTimePickerBannerFechaInicio.Value.Day,
                    Convert.ToInt32(comboBoxBannerHoraInicio.Text),
                    0,
                    0);
                DateTime mFechaFin = new DateTime(
                    dateTimePickerBannerFechaFin.Value.Year,
                    dateTimePickerBannerFechaFin.Value.Month,
                    dateTimePickerBannerFechaFin.Value.Day,
                    Convert.ToInt32(comboBoxBannerHoraFin.Text),
                    0,
                    0);

                Banner mBanner = new Banner();
                mBanner.Nombre      = textBoxBannerNombre.Text;
                mBanner.FechaInicio = mFechaInicio;
                mBanner.FechaFin    = mFechaFin;

                //Verifica si la hora seleccionada está disponible
                Dictionary <string, List <Banner> > mDiccionario = cFachada.AvailableTimesBanner(dateTimePickerBannerFechaInicio.Value, dateTimePickerBannerFechaFin.Value);
                bool mDisponible = cFachada.AvailableHoursBanner(mBanner, mDiccionario);
                if (!mDisponible)
                {
                    throw new Exception("El horario seleccionado no está disponible");
                }

                if (comboBoxTipoFuente.Text == "RSS")
                {
                    FuenteRSS mFuente = new FuenteRSS {
                        Id = Convert.ToInt32(textBoxId.Text)
                    };
                    mFuente        = cFachada.GetFuenteRSS(mFuente);
                    mBanner.Fuente = mFuente;
                }
                else
                {
                    FuenteTextoFijo mFuente = new FuenteTextoFijo {
                        Id = Convert.ToInt32(textBoxId.Text)
                    };
                    mFuente        = cFachada.GetFuenteTXT(mFuente);
                    mBanner.Fuente = mFuente;
                }
                string mCadena = "Se agregó el Banner: Id " + mBanner.Id + ", Nombre: " + mBanner.Nombre + ", Fecha y Hora de inicio: " + mBanner.FechaInicio + ", Fecha y Hora de fin: " + mBanner.FechaFin + " Y la Fuente: " + mBanner.Fuente.Titulo;
                cLogger.Debug(mCadena);
                cFachada.AddBanner(mBanner);
                MessageBox.Show("El Banner se ha guardado con éxito");
            }
            catch (Exception mExcepcion)
            {
                MessageBox.Show(mExcepcion.Message);
                cLogger.Debug(mExcepcion.Message);
            }
        }
        /// <summary>
        /// Verifica si están todos los datos necesarios cargados y guarda el banner que se modificó
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (cBanner != null)
                {
                    //Verifia si tiene nombre
                    if (textBoxNombreBanner.Text == "")
                    {
                        throw new Exception("Falta ingresar el nombre del Banner");
                    }

                    //Verifica si la hora de inicio está en el rango aceptado
                    if ((Convert.ToInt32(comboBoxHoraInicioBanner.Text) < 0) ||
                        (Convert.ToInt32(comboBoxHoraInicioBanner.Text) > 23))
                    {
                        throw new Exception("La hora de inicio ingresada no es válida");
                    }

                    //Verifica si la hora de fin está en el rango aceptado
                    if ((Convert.ToInt32(comboBoxHoraFinBanner.Text) < 0) ||
                        (Convert.ToInt32(comboBoxHoraFinBanner.Text) > 23))
                    {
                        throw new Exception("La hora de fin ingresada no es válida");
                    }

                    //Verifica si las fechas forman un rango aceptable
                    if (dateTimePickerBannerFechaInicio.Value.Date < DateTime.Now.Date)
                    {
                        throw new Exception("No se admiten Fechas de Inicios pasadas");
                    }

                    if (dateTimePickerBannerFechaFin.Value.Date < dateTimePickerBannerFechaInicio.Value.Date)
                    {
                        throw new Exception("La Fecha Final debe ser mayor a la Fecha de Inicio");
                    }

                    //Pasa la info del datePicker y el combo a una sola variable
                    DateTime mFechaInicio = new DateTime(
                                                        dateTimePickerBannerFechaInicio.Value.Year,
                                                        dateTimePickerBannerFechaInicio.Value.Month,
                                                        dateTimePickerBannerFechaInicio.Value.Day,
                                                        Convert.ToInt32(comboBoxHoraInicioBanner.Text),
                                                        0,
                                                        0);
                    DateTime mFechaFin = new DateTime(
                                                     dateTimePickerBannerFechaFin.Value.Year,
                                                     dateTimePickerBannerFechaFin.Value.Month,
                                                     dateTimePickerBannerFechaFin.Value.Day,
                                                     Convert.ToInt32(comboBoxHoraFinBanner.Text),
                                                     0,
                                                     0);

                    Banner mBanner = new Banner();
                    mBanner.Id = cBanner.Id;
                    mBanner.FechaInicio = cBanner.FechaInicio;
                    mBanner.FechaFin = cBanner.FechaFin;
                    //Verifica si la hora seleccionada está disponible
                    Dictionary<string, List<Banner>> mDiccionario = cFachada.AvailableTimesBanner(dateTimePickerBannerFechaInicio.Value, dateTimePickerBannerFechaFin.Value);
                    bool mDisponible = cFachada.AvailableHoursBanner(mBanner, mDiccionario);
                    if (!mDisponible)
                    {
                        throw new Exception("El horario seleccionado no está disponible");
                    }

                    cBanner.Nombre = textBoxNombreBanner.Text;
                    cBanner.FechaInicio = mFechaInicio;
                    cBanner.FechaFin = mFechaFin;

                    if (comboBoxTipoFuente.Text == "RSS")
                    {
                        FuenteRSS mFuente = new FuenteRSS { Id = Convert.ToInt32(textBoxId.Text) };
                        mFuente = cFachada.GetFuenteRSS(mFuente);
                        cBanner.Fuente = mFuente;
                    }
                    else
                    {
                        FuenteTextoFijo mFuente = new FuenteTextoFijo { Id = Convert.ToInt32(textBoxId.Text) };
                        mFuente = cFachada.GetFuenteTXT(mFuente);
                        cBanner.Fuente = mFuente;
                    }
                    DialogResult mMessageBoxResultado = MessageBox.Show("¿Desea modificar el Banner?", "Modificar Banner", MessageBoxButtons.YesNo);
                    if (mMessageBoxResultado == DialogResult.Yes)
                    {
                        cFachada.UpdateBanner(cBanner);
                        MessageBox.Show("El Banner se ha modificado con éxito");
                        dataGridViewBanners.DataSource = cFachada.GetAllBanner();
                        string mCadena = "Se modificó el Banner: Id: " + cBanner.Id + " Nombre: " + cBanner.Nombre + " Fecha y Hora de inicio: " + cBanner.FechaInicio + " Fecha y Hora de fin: " + cBanner.FechaFin + " Y la fuente; " + cBanner.Fuente.Titulo;
                        cLogger.Debug(mCadena);
                    }
                }
                else
                {
                    throw new Exception("No hay modificaciones para guardar");
                }
            }
            catch (Exception mExcepcion)
            {
                MessageBox.Show(mExcepcion.Message);
                cLogger.Debug(mExcepcion.Message);
            }
        }
Example #12
0
 /// <summary>
 /// Actualiza una fuente TXT
 /// </summary>
 /// <param name="pFuenteTXT"></param>
 public void UpdateFuenteTXT(FuenteTextoFijo pFuenteTXT)
 {
     cRepositoryBaseTXT.Update(pFuenteTXT);
     cRepositoryBaseTXT.SaveChanges();
 }
Example #13
0
 /// <summary>
 /// Obtiene una fuente TXT dado el ID
 /// </summary>
 /// <param name="pFuenteTXT"></param>
 /// <returns></returns>
 public FuenteTextoFijo GetFuenteTXT(FuenteTextoFijo pFuenteTXT)
 {
     return(cRepositoryBaseTXT.GetById(pFuenteTXT.Id));
 }
Example #14
0
 /// <summary>
 /// Borra una fuente TXT
 /// </summary>
 /// <param name="pFuenteTXT"></param>
 public void DeleteFuenteTXT(FuenteTextoFijo pFuenteTXT)
 {
     cRepositoryBaseTXT.DeleteById(pFuenteTXT.Id);
     cRepositoryBaseTXT.SaveChanges();
 }