Пример #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 actualizarCodigoActivacion(ClaseJuego jue)
        {
            if (Session["CodigosActivacion"] != null)
            {
                DataTable codActivacion = (DataTable)Session["CodigosActivacion"];

                funcionesJuegos fJue = new funcionesJuegos();

                foreach (DataRow row in codActivacion.Rows)
                {
                    if (!(bool)row[3])
                    {
                        fJue.AgregarCodActivacion(row[0].ToString(), row[1].ToString());
                    }
                }
            }

            if (Session["CodigosEliminar"] != null)
            {
                DataTable       codEliminar = (DataTable)Session["CodigosEliminar"];
                FuncionesCompra fCompra     = new FuncionesCompra();

                foreach (DataRow row in codEliminar.Rows)
                {
                    fCompra.darBajaCodActivacion(row[0].ToString(), jue.codJuego);
                }
            }
        }
 protected void agregarCodigoActivacion(ClaseJuego jue)
 {
     if (jue.stock > 0)
     {
         funcionesJuegos fJue  = new funcionesJuegos();
         DataTable       tabla = (DataTable)Session["CodigosActivacion"];
         foreach (DataRow row in tabla.Rows)
         {
             fJue.AgregarCodActivacion(row[0].ToString(), row[1].ToString());
         }
     }
 }