protected void Page_Load(object sender, EventArgs e) { /// <summary> /// Carga los datos si se requiere actualiar o editar /// </summary> if (!IsPostBack) { TipoAsientoBLL tipBLL = new TipoAsientoBLL(); if (Request.QueryString["id"] != null) { AsientoBLL asBLL = new AsientoBLL(); AsientoBEL asiento = asBLL.traerAsientoPorId(Int32.Parse(Request.QueryString["id"].ToString())); idAsiento.Text = Request.QueryString["id"].ToString(); txtNumeroInicio.Text = asiento.Numero.ToString(); txtNumeroFin.Visible = false; lblEstado.Text = asiento.Estado; lblTitulo.Text = "Editar Asiento"; } ddlTipoAsiento.DataSource = tipBLL.traerTiposAsientos(); ddlTipoAsiento.DataValueField = "IdTipoAsiento"; ddlTipoAsiento.DataTextField = "Nombre"; ddlTipoAsiento.DataBind(); ddlTipoAsiento.Items.Insert(0, new ListItem("..Seleccione..", "-1")); } }
/// <summary> /// Guarda los datos entregados por el usuario /// </summary> protected void btnGuardar_Click(object sender, EventArgs e) { AsientoBLL asientoBLL = new AsientoBLL(); int numeroInicio, numeroFin, i; numeroInicio = Int32.Parse(txtNumeroInicio.Text); numeroFin = Int32.Parse(txtNumeroFin.Text); String idRecinto = Session["idRecinto"].ToString(); if (lblTitulo.Text.CompareTo("Editar Asiento") == 0) { AsientoBEL asBEL = new AsientoBEL(); asBEL.IdAsiento = //asBEL.IdRecinto = Int32.Parse(idRecinto); asBEL.IdTipoAsiento = Int32.Parse(ddlTipoAsiento.SelectedItem.Value); asBEL.Numero = numeroInicio; asBEL.Estado = lblEstado.Text; asientoBLL.modificarAsiento(asBEL); } else { i = 0; for (i = numeroInicio; i <= numeroFin; i++) { AsientoBEL asBEL = new AsientoBEL(); //asBEL.IdRecinto = Int32.Parse(idRecinto); asBEL.IdTipoAsiento = Int32.Parse(ddlTipoAsiento.SelectedItem.Value); asBEL.Numero = i; asientoBLL.agregarAsientos(asBEL); } Response.Write(string.Format("<script>alert('Se agregó correctamente');window.location='asientos.aspx?id={0}';</script></script>", idRecinto)); } }
protected void ddlTipoEntrada_SelectedIndexChanged(object sender, EventArgs e) { Session["event_controle"] = ((DropDownList)sender); lblselect.Visible = false; if (ddlTipoEntrada.SelectedItem.Value.Equals("-1")) { txtPrecio.Text = "0"; txtTotal.Text = "0"; return; } int idTipoTicket = Int32.Parse(ddlTipoEntrada.SelectedItem.Value); int idEvento = Int32.Parse(lblIdEvento.Text); TiposTicketBLL bllTipos = new TiposTicketBLL(); TiposTicketBEL tipo = bllTipos.traerTiposTicketPorId(idTipoTicket); txtPrecio.Text = tipo.Precio.ToString(); int cant = Int32.Parse(txtCantEntradas.Text); txtTotal.Text = (tipo.Precio * cant).ToString(); AsientoBLL bllAsiento = new AsientoBLL(); ddlAsientos.DataSource = bllAsiento.traerAsientos(idEvento, tipo.IdTipoAsiento); ddlAsientos.DataValueField = "IdAsiento"; ddlAsientos.DataTextField = "Numero"; ddlAsientos.DataBind(); ddlAsientos.Items.Insert(0, new ListItem("..Seleccione..", "-1")); btnAgregarAsiento.Enabled = true; }
protected void txtCantEntradas_TextChanged(object sender, EventArgs e) { AsientoBLL bllAsiento = new AsientoBLL(); int precio = Int32.Parse(txtPrecio.Text); int cant = Int32.Parse(txtCantEntradas.Text); int IdTipoTicket = Int32.Parse(ddlTipoEntrada.SelectedItem.Value); if (IdTipoTicket == -1) { lblselect.Text = "Seleccione Tipo"; lblselect.Visible = true; return; } else { lblselect.Visible = false; int IdEvento = Int32.Parse(lblIdEvento.Text); TiposTicketBLL bllTipos = new TiposTicketBLL(); TiposTicketBEL tipo = bllTipos.traerTiposTicketPorId(IdTipoTicket); int cantMax = bllAsiento.traerAsientos(IdEvento, tipo.IdTipoAsiento).Count(); if (cant > cantMax) { txtCantEntradas.Text = "1"; lblErrCant.Text = "La cantidad ingresada no es valida"; lblErrCant.Visible = true; return; } else { lblErrCant.Visible = false; } if (Session["listaAsientos"] != null) { this.listaAsientos = (ArrayList)Session["listaAsientos"]; this.listaGrilla = (ArrayList)Session["listaGrilla"]; } else { this.listaAsientos = new ArrayList(); this.listaGrilla = new ArrayList(); } int indice = this.listaAsientos.Count; if (indice == 0 || indice <= cant) { txtTotal.Text = (precio * cant).ToString(); ddlAsientos.Visible = true; btnAgregarAsiento.Visible = true; } else { txtCantEntradas.Text = (cant - 1).ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { /// <summary> /// Carga la pagina con los datos del evento a comprar /// </summary> if (!IsPostBack) { TiposTicketBLL bllTipos = new TiposTicketBLL(); EventoBLL bllEvento = new EventoBLL(); RecintoBLL bllRecinto = new RecintoBLL(); AsientoBLL bllAsiento = new AsientoBLL(); /// <summary> /// El usuario debe estar registrado para comprar entradas /// </summary> if (Request.QueryString["evento"] != null) { if (Session["usuarioConectado"] == null) { Response.Write("<script>alert('Necesitas iniciar sesión para comprar');window.location='Registro.aspx';</script>"); return; } int idEvento = Int32.Parse(Request.QueryString["evento"].ToString()); EventoBEL evento = bllEvento.traerEventoId(idEvento); RecintoBEL recinto = bllRecinto.traerRecintoPorId(evento.IdRecinto); this.listaAsientos = new ArrayList(); this.listaGrilla = new ArrayList(); Session["listaAsientos"] = this.listaAsientos; Session["listaGrilla"] = this.listaGrilla; ddlTipoEntrada.DataSource = bllTipos.traerTiposTicket(idEvento); ddlTipoEntrada.DataValueField = "IdTipoTicket"; ddlTipoEntrada.DataTextField = "Descripcion"; ddlTipoEntrada.DataBind(); ddlTipoEntrada.Items.Insert(0, new ListItem("..Seleccione..", "-1")); lblTitulo.Text = evento.Nombre; imgEvento.ImageUrl = evento.Imagen; lblContenido.Text = evento.Descripcion; imgRecinto.ImageUrl = recinto.ImagenRecinto; lblIdEvento.Text = idEvento.ToString(); lblIdRecinto.Text = evento.IdRecinto.ToString(); btnAgregarAsiento.Enabled = false; btnPagar.Enabled = false; lblErrCant.Visible = false; lblselect.Visible = false; } else { Response.Redirect("EventosSemana.aspx"); } } }
/// <summary> /// Modifica o elimina el asiento seleccionado en la grilla /// </summary> protected void grvAsientos_RowCommand(object sender, GridViewCommandEventArgs e) { AsientoBLL asBLL = new AsientoBLL(); if (e.CommandName.Equals("modificar")) { Response.Redirect(string.Format("AgregarAsiento.aspx?id={0}", e.CommandArgument.ToString()), false); } else if (e.CommandName.Equals("Eliminar")) { asBLL.eliminarAsiento(Int32.Parse(e.CommandArgument.ToString())); grvAsientos.DataSource = asBLL.traerAsientos(); grvAsientos.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { /// <summary> /// Carga la grilla con todos los asientos registrados de un Evento /// </summary> if (!IsPostBack) { if (Request.QueryString["id"] != null) { Session["idRecinto"] = Request.QueryString["id"].ToString(); } else { Response.Redirect("Recintos.aspx"); return; } AsientoBLL asBLL = new AsientoBLL(); grvAsientos.DataSource = asBLL.traerAsientos(); grvAsientos.DataBind(); } }