コード例 #1
0
 public MostrarConsolas(List <PS> list)
 {
     InitializeComponent();
     foreach (PS g in list)
     {
         rtbConsolas.Text = PS.MostrarDatosPS(list);
     }
 }
コード例 #2
0
        private void btnGenerarFactura_Click(object sender, EventArgs e)
        {
            ArchivoTexto        texto      = new ArchivoTexto();
            ArchivosXml <Games> xmlGames   = new ArchivosXml <Games>();
            ArchivosXml <PS>    xmlConsola = new ArchivosXml <PS>();

            foreach (Games g in games.ListaJuegos)
            {
                texto.GuardarArchivoTexto("FacturaJuegos.txt", Games.MostrarDatos(games.ListaJuegos), false);
                xmlGames.Guardar("Juegos.xml", g);
            }
            foreach (PS p in ps.ListaJuegosPSVenta)
            {
                texto.GuardarArchivoTexto("FacturaConsolas.txt", PS.MostrarDatosPS(ps.ListaJuegosPSVenta), false);
                xmlConsola.Guardar("Consola.xml", p);
            }
            MessageBox.Show("Factura creada con exito");
        }
コード例 #3
0
        private void btnCarritoConsola_Click(object sender, EventArgs e)
        {
            bool   valor          = false;
            string almacenamiento = cmbPS.Text;
            int    almac;

            int.TryParse(almacenamiento, out almac);
            string modelo = "";

            if (rdbPS1.Checked)
            {
                modelo = "PS1";
            }
            if (rdbPS2.Checked)
            {
                modelo = "PS2";
            }
            if (rdbPS3.Checked)
            {
                modelo = "PS3";
            }
            if (rdbPS4.Checked)
            {
                modelo = "PS4";
            }

            foreach (PS p in ps.ListConsolasStock)
            {
                if (p.Modelo == modelo && ps.ValidarAlcenamiento(modelo, almac))
                {
                    PS polastation = new PS(p.Precio, almac, modelo, p.Codigo, p.Lanzamiento);
                    ps.ListaJuegosPSVenta.Add(polastation);
                    rtb2.Text = (PS.MostrarDatosPS(ps.ListaJuegosPSVenta));
                    valor     = true;
                    break;
                }
            }
            if (valor == false)
            {
                MessageBox.Show("El almacenamiento indicado para esta consola no esta disponible");
            }
        }
コード例 #4
0
        //PROGRAMA DE CONSOLA PARA PROBAR FUNCIONALIDADES
        static void Main(string[] args)
        {
            GamesDAO     gamesDAO    = new GamesDAO(); //CREO INSTANCIA DE CLASE ENCARGADA DE CONECTAR CON LA BD
            ConsolasDAO  consolasDAO = new ConsolasDAO();
            Games        juegos      = new Games();
            PS           ps          = new PS();
            List <Games> listGames   = gamesDAO.List();    //OBTENGO UNA LISTA DE JUEGOS DE LA BD
            List <PS>    listPs      = consolasDAO.List(); //OBETENGO UNA LISTA DE CONSOLA DE LA BD

            juegos.CargarStock();                          // CARGA DATOS DE LA TABLA DE JUEGOS
            ps.CargarStockPS();                            //CARGA DATOS DE LA TABLA DE CONSOLAS

            //EJEMPLO DE CARGA DE DATOS POR MODELO
            List <PS> PS1 = new List <PS>();

            PS1 = ps.StockConsolaPS1(ps);
            Console.WriteLine(PS.MostrarDatosPS(PS1));
            Console.WriteLine("Juegos agregados correctamente");
            //VENTA DE JUEGO
            try
            {
                Games venta = new Games(2100, 2008, "Uncharted 3", 83, Games.EFormato.Fisico, "PS5"); //DATOS INVALIDOS PARA PROBAR EXCEPCIONES
            }
            catch (PlataformaInvalidaException ex)
            {
                Console.WriteLine("Exception Games " + ex.Message);
            }

            //VENTA DE CONSOLA

            PS ventaps = new PS(10000, 500, "PS1", 1, 2013);

            //CARGA DE CLIENTES

            try
            {
                Cliente cli = new Cliente("45Elpepe", "42568956", EMedioDePago.efectivo, 12000);
            }
            catch (NombreInvalidoException e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Cliente cliente = new Cliente("Elpepe", "425615sadf", EMedioDePago.efectivo, 12000);
            }

            catch (DniInvalidoException ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("DESERIALIZACION\n");

            ///PRUEBA DE SERIALIZACION
            ArchivosXml <List <Games> > xml = new ArchivosXml <List <Games> >();

            xml.Guardar("ArchivoXmlGamesPrueba.txt", listGames);
            List <Games> datos;

            xml.Leer("ArchivoXmlGamesPrueba.txt", out datos);
            Console.WriteLine(Games.MostrarDatos(datos));

            //PRUEBA DE ARCHIVO DE TEXTO

            ArchivoTexto t = new ArchivoTexto();

            t.GuardarArchivoTexto("ArchivoTexTest.txt", Games.MostrarDatos(datos), false);

            //

            Console.ReadKey();
        }