protected void agregarImagenAbasededatos()
        {
            funcionesJuegos fJue  = new funcionesJuegos();
            DataTable       tabla = (DataTable)Session["Imagenes"];
            DataTable       DT    = (DataTable)Session["Juego"];

            foreach (DataRow row in tabla.Rows)
            {
                if (Session["Modificar"] == null)
                {
                    fJue.AgregarImagen(GenerarCodImagen(), DT.Rows[0][0].ToString(), row[1].ToString(), (bool)row[2]);
                }
                else
                {
                    if (row[0].ToString() == "null")
                    {
                        fJue.AgregarImagen(GenerarCodImagen(), DT.Rows[0][0].ToString(), row[1].ToString(), (bool)row[2]);
                    }
                    else
                    {
                        if (!(bool)row[2])
                        {
                            fJue.cambiarEstadoImagen(row[0].ToString(), DT.Rows[0][0].ToString(), "false");
                        }
                        else
                        {
                            fJue.cambiarEstadoImagen(row[0].ToString(), DT.Rows[0][0].ToString(), "true");
                        }
                    }
                }
            }
        }
Пример #2
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();
            }
        }