Exemple #1
0
        protected void btn_guardarCambios_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                funcionesJuegos fJue = new funcionesJuegos();
                ClaseJuego      jue  = new ClaseJuego();
                Descuento       desc = new Descuento();

                string   aux     = Request.Form["ip_listboxCodigos"].ToString();
                string[] codigos = aux.Split('-');

                lbl_stockActual.Text = (codigos.Length - 1).ToString();

                jue.GenerarCod();
                jue.nombre      = txb_nombre.Text;
                jue.empresa     = txb_empresa.Text;
                jue.tipo        = txb_tipo.Value;
                jue.precio      = Convert.ToDecimal(txb_Precio.Value.Replace(".", ","));
                jue.stock       = Convert.ToInt32(lbl_stockActual.Text);
                jue.consola     = rbl_listaConsolas.SelectedItem.Text;
                jue.descripcion = txb_descripcion.Text;
                jue.requisitos  = txb_requisitos.Text;

                desc.GenerarCod();
                desc.codJuego    = jue.codJuego;
                desc.porcentaje  = Convert.ToInt32(txb_Porcentaje.Value);
                desc.fechaInicio = Convert.ToDateTime(txb_FechaInicio.Value);
                desc.fechaFin    = Convert.ToDateTime(txb_FechaFin.Value);
                desc.estado      = chx_Disponibilidad.Checked;

                fJue.AgregarJuego(jue);
                fJue.AgregarDescuento(desc);

                foreach (string codigo in codigos)
                {
                    if (codigo != string.Empty)
                    {
                        fJue.AgregarCodActivacion(codigo, jue.codJuego);
                    }
                }

                guardarImagenes();

                if (Session["Imagenes"] != null)
                {
                    string[] rutasAux = (string[])Session["Imagenes"];
                    bool     primero  = true;
                    for (int i = 0; i < rutasAux.Length; i++)
                    {
                        if (rutasAux[i] != string.Empty)
                        {
                            fJue.AgregarImagen(GenerarCodImagen(), jue.codJuego, rutasAux[i], primero);
                            primero = false;
                        }
                    }
                }

                limpiarPagina();
            }
        }
        protected void btn_Finalizar_Click(object sender, EventArgs e)
        {
            if (sesionesCreadas())
            {
                if (Page.IsValid)
                {
                    if (lbl_portada.Text != "0")
                    {
                        funcionesJuegos fJue = new funcionesJuegos();
                        ClaseJuego      jue  = new ClaseJuego();
                        cargarClaseJuego(jue);
                        fJue.AgregarJuego(jue);
                        agregarCodigoActivacion(jue);
                        agregarDescuento(jue);

                        agregarImagenAbasededatos();
                        agregarFisicamenteLaImagen();

                        Session["CodigosEliminar"]   = null;
                        Session["Juego"]             = null;
                        Session["Stock"]             = null;
                        Session["CodigosActivacion"] = null;
                        Session["Descuento"]         = null;
                        Session["Imagenes"]          = null;
                        Session["CantImagenes"]      = null;
                        Session["ImagenesAelminiar"] = null;
                        Page.ClientScript.RegisterStartupScript(GetType(), "scripts", "<script>alert('Juego cargado correctamente')</script>");
                        Response.Redirect("Home.aspx");
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(GetType(), "scripts", "<script>alert('Seleccione una imagen de portada')</script>");
                    }
                }
            }
        }