protected void agregarDescuento(ClaseJuego jue)
        {
            Descuento       desc = new Descuento();
            funcionesJuegos fJue = new funcionesJuegos();

            if (Session["Descuento"] != null)
            {
                DataTable tabla = (DataTable)Session["Descuento"];

                foreach (DataRow row in tabla.Rows)
                {
                    desc.codDescuento = row[0].ToString();
                    desc.codJuego     = row[1].ToString();
                    desc.porcentaje   = (int)row[2];
                    desc.fechaInicio  = (DateTime)row[3];
                    desc.fechaFin     = (DateTime)row[4];
                    desc.estado       = (bool)row[5];

                    fJue.AgregarDescuento(desc);
                }
            }
            else
            {
                desc.GenerarCod();
                desc.codJuego    = jue.codJuego;
                desc.porcentaje  = 0;
                desc.fechaInicio = DateTime.Now;
                desc.fechaFin    = DateTime.Now;
                desc.estado      = false;

                fJue.AgregarDescuento(desc);
            }
        }
Пример #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();
            }
        }