private void CargarVista() { DataTable vResultados = new DataTable(); Negocio.Clases.Promocion vPrx = new Negocio.Clases.Promocion(); List <Comunes.Filtros.Filtro> vFiltros = new List <Comunes.Filtros.Filtro>(); ListViewItem vItem = new ListViewItem(); try { vResultados = vPrx.Selecccionar(vFiltros); ltvInformacion.Items.Clear(); foreach (DataRow vRow in vResultados.Rows) { vItem = ltvInformacion.Items.Add(vRow["IdPromocion"].ToString()); vItem.SubItems.Add(vRow["IdPelicula"].ToString()); vItem.SubItems.Add(vRow["IdTipoPromocion"].ToString()); vItem.SubItems.Add(String.Format("{0:yyyy/MM/dd}", vRow["FechaInicio"])); vItem.SubItems.Add(String.Format("{0:yyyy/MM/dd}", vRow["FechaFinal"])); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
private void btnAceptar_Click(object sender, EventArgs e) { Comunes.Estructuras.Promocion vEstructura = new Comunes.Estructuras.Promocion(); Negocio.Clases.Promocion vNegocio = new Negocio.Clases.Promocion(); List <Comunes.Filtros.Filtro> vFiltros = new List <Comunes.Filtros.Filtro>(); try { if (Validar() == false) { vEstructura = new Comunes.Estructuras.Promocion() { IdPelicula = Convert.ToInt32(cboPelicula.SelectedValue.ToString()), IdTipoPromocion = Convert.ToInt32(cboTipoPromocion.SelectedValue.ToString()), FechaFinal = dtpFechaFinal.Value, FechaInicio = dtpFechaInicio.Value }; switch (vModo) { case "A": vEstructura.IdPromocion = 0; vNegocio.Insertar(vEstructura); break; case "M": vEstructura.IdPromocion = Convert.ToInt32(lblId.Text); vFiltros.Add(new Comunes.Filtros.Filtro("IdPromocion", "=", Convert.ToInt32(lblId.Text))); vNegocio.Actualizar(vEstructura, vFiltros); tbpLista.Parent = tbcInformacion; tbcInformacion.SelectedTab = tbpLista; tspBarraMenu.Visible = true; tbpInformacion.Parent = null; vModo = string.Empty; CargarVista(); break; default: vFiltros.Add(new Comunes.Filtros.Filtro("IdPromocion", "=", Convert.ToInt32(lblId.Text))); vNegocio.Eliminar(vFiltros); tbpLista.Parent = tbcInformacion; tbcInformacion.SelectedTab = tbpLista; tspBarraMenu.Visible = true; tbpInformacion.Parent = null; vModo = string.Empty; CargarVista(); gboDescripcion.Enabled = true; break; } MessageBox.Show("El proceso a finalizado con éxito", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); CargarVista(); lblId.Text = string.Empty; cboTipoPromocion.SelectedIndex = 0; cboPelicula.SelectedIndex = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }