/// <summary> /// Constructor /// </summary> /// <param name="pControladorDominio">controlador de dominio</param> /// <param name="pCodigoBanner">codigo de un banner</param> public VBannerModificar(ref ControladorDominio pControladorDominio, int pCodigoBanner) : base(ref pControladorDominio) { InitializeComponent(); try { this.iBanner = this.iControladorDominio.BuscarBannerPorId(pCodigoBanner); this.textBoxTitulo.Text = this.iBanner.Descripcion; if (this.iBanner.Tipo == TipoBanner.Rss) { this.iFuenteActual = this.iControladorDominio.BuscarFuenteRssPorId((int)this.iBanner.FuenteRssId); this.textBoxFuente.Text = this.iFuenteActual.Titulo; this.radioButtonFuenteRss.Select(); List <FuenteRss> listaDeFuentes = this.iControladorDominio.ObtenerTodasLasFuentes(); this.listView1.FocusedItem = this.listView1.Items.Find(this.iFuenteActual.Url, true).ToList()[0]; this.radioButtonTextoPlano.Enabled = false; } else //this.iBanner.Tipo == TipoBanner.TextoPano { this.radioButtonTextoPlano.Select(); this.radioButtonFuenteRss.Enabled = false; for (int i = 1; i <= this.iBanner.PasoBanners.ToList().Count; i++) { PasoBanner pB = this.iBanner.PasoBanners.First(x => x.Orden == i); this.listBoxPasosBanners.Items.Add(pB); } } this.iPasoBannersABorrar = new List <PasoBanner>(); } catch (ExcepcionErrorEnLaBusqueda ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
/// <summary> /// Evento que se activa cuando se hace click en una fuente en el listView1 /// </summary> private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { //foreach (var item in (IEnumerable<String>)this.listView1.SelectedItems[0]) //{ // item.ToString(); //} string urlFuenteABuscar = this.listView1.SelectedItems[0].SubItems[1].Text; FuenteRss fuenteAMostrar = this.iControladorDominio.ObtenerTodasLasFuentes().FirstOrDefault(x => x.Url == urlFuenteABuscar); this.iIdFuenteNuevaSeleccionada = fuenteAMostrar.FuenteRssId; this.textBoxFuente.Text = fuenteAMostrar.Titulo; //var selectedItem = (dynamic)this.listView1.SelectedItems[0]; //this.textBoxFuente.Text = selectedItem.Text; //this.textBoxFuente.Text = this.listView1.SelectedItems[0].SubItems[0].Text; this.listView1.Visible = false; }
/// <summary> /// Evento que se activa cuando se hace click en el botón guardar nuevo banner /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void buttonGuardar_Click(object sender, EventArgs e) { //EXCEPCIONES: try { this.ValidarTodoCompleto(); this.iBanner = new Banner(); this.iBanner.Descripcion = this.textBoxTitulo.Text; this.iBanner.FechaInicio = this.dateTimePickerInicio.Value.Date; this.iBanner.FechaFin = this.dateTimePickerFin.Value.Date; this.iBanner.HoraInicio = new TimeSpan(Convert.ToInt16(this.comboBoxH1.SelectedItem), Convert.ToInt16(this.comboBoxM1.SelectedItem), 0); if (Convert.ToInt16(this.comboBoxH2.SelectedItem) == 0 && Convert.ToInt16(this.comboBoxM2.SelectedItem) == 0) { this.iBanner.HoraFin = new TimeSpan(23, 59, 59); } else { this.iBanner.HoraFin = new TimeSpan(Convert.ToInt16(this.comboBoxH2.SelectedItem), Convert.ToInt16(this.comboBoxM2.SelectedItem), 0); } if (this.iBanner.HoraInicio >= this.iBanner.HoraFin) { throw new ExcepcionHoraInicioMayorAHoraFin("La hora de inicio debe ser menor que la hora de fin"); } if (this.radioButtonFuenteRss.Checked) { this.iBanner.Tipo = TipoBanner.Rss; if (this.listView1.SelectedItems.Count == 0) { throw new ExcepcionCampoSinCompletar("Debe completar con una fuente rss"); } string urlABuscar = (this.listView1.SelectedItems[0].SubItems[1].Text).ToString(); FuenteRss fuente = this.iControladorDominio.ObtenerTodasLasFuentes().FirstOrDefault(x => x.Url == urlABuscar); fuente.Banners.Add(this.iBanner); this.iControladorDominio.ModificarFuente(fuente); } else //this.radioButtonTextoPlano.Checked { this.iBanner.Tipo = TipoBanner.TextoPlano; if (this.listBoxPasosBanners.Items.Count == 0) { throw new ExcepcionCampoSinCompletar("Debe cargar al menos un Texto plano"); } else { List <PasoBanner> listaPasosBanners = new List <PasoBanner>(); PasoBanner pasoBanner; for (int i = 1; i <= this.listBoxPasosBanners.Items.Count; i++) { object item = this.listBoxPasosBanners.Items[i - 1]; pasoBanner = new PasoBanner(); pasoBanner.Texto = item.ToString(); pasoBanner.Orden = i; listaPasosBanners.Add(pasoBanner); } this.iBanner.PasoBanners = listaPasosBanners; this.iControladorDominio.AgregarBanner(this.iBanner); } } this.iControladorDominio.GuardarCambios(); this.Close(); } catch (ExcepcionCampoSinCompletar ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (ExcepcionHoraInicioMayorAHoraFin ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (ExcepcionErrorAlGuardar ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (ExcepcionAlCargarPantalla ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }