예제 #1
0
        /// <summary>
        /// Habilita, Modifica o Elimina el recinto seleccionado
        /// </summary>
        protected void grvEventos_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            RecintoBLL recBLL = new RecintoBLL();

            if (e.CommandName.Equals("modificar"))
            {
                Response.Redirect(string.Format("AgregarRecinto.aspx?id={0}", e.CommandArgument.ToString()), false);
            }
            else if (e.CommandName.Equals("Eliminar"))
            {
                recBLL.eliminarRecinto(Int32.Parse(e.CommandArgument.ToString()));
                grvEventos.DataSource = recBLL.traerRecintos();
                grvEventos.DataBind();
            }
            else if (e.CommandName.Equals("habilitar"))
            {
                RecintoBEL rec = recBLL.traerRecintoPorId(Int32.Parse(e.CommandArgument.ToString()));
                rec.IdEstado = 1;
                recBLL.editarRecinto(rec);
                grvEventos.DataSource = recBLL.traerRecintos();
                grvEventos.DataBind();
            }
            else if (e.CommandName.Equals("asiento"))
            {
                Response.Redirect(string.Format("Asientos.aspx?id={0}", e.CommandArgument.ToString()), false);
            }
            else if (e.CommandName.Equals("ver"))
            {
                Response.Redirect(string.Format("verRecinto.aspx?id={0}", e.CommandArgument.ToString()), false);
            }
        }
예제 #2
0
        /// <summary>
        /// Guarda los datos entregados por el usuario
        /// </summary>
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            if (validaImagen(subirImagen.PostedFile.FileName))
            {
                String strFileName, strFilePath, strFolderSave, strFileSave;
                strFolderSave = Server.MapPath("../img/Recintos/");
                strFileName   = subirImagen.PostedFile.FileName;
                strFilePath   = "/img/Recintos/";
                strFileSave   = "/img/Recintos/" + strFileName;
                if (strFileName != "")
                {
                    strFileName = Path.GetFileName(strFileName);
                    strFilePath = strFolderSave + strFileName;
                    subirImagen.PostedFile.SaveAs(strFilePath);
                }
                RecintoBEL recinto = new RecintoBEL();
                recinto.DireccionRecinto = txtDireccion.Text;
                recinto.IdComuna         = Int32.Parse(ddlComuna.SelectedItem.Value);
                recinto.ImagenRecinto    = strFileSave;
                recinto.NombreRecinto    = txtNombre.Text;

                RecintoBLL recbll = new RecintoBLL();
                if (lblTitulo.Text.CompareTo("Modificar Recinto") == 0)
                {
                    recinto.IdRecinto = Int32.Parse(idRecinto.Text);
                    recinto.IdEstado  = Int32.Parse(lblEstado.Text);
                    recbll.editarRecinto(recinto);
                    Response.Write("<script>alert('Datos modificados correctamente');window.location='Recintos.aspx';</script>");
                }
                else
                {
                    recbll.agregarRecinto(recinto);
                    Response.Write("<script>alert('Se agregó correctamente');window.location='Recintos.aspx';</script>");
                    txtNombre.Text    = String.Empty;
                    txtDireccion.Text = String.Empty;
                    idRecinto.Text    = String.Empty;
                }
            }
        }