示例#1
0
        public void actualizarVideoJuegos(VideoJuegos p, int id)
        {
            if (p == null)
            {
                throw new Exception("El producto es nulo.");
            }

            string sql = "INSERT OR REPLACE INTO " + SchemaUtil.PRODUCTO_TABLE_NAME + "("
                         + SchemaUtil.PRODUCTO_KEY_ID + ","
                         + SchemaUtil.PRODUCTO_KEY_TIPO + ","
                         + SchemaUtil.PRODUCTO_KEY_TITULO + ","
                         + SchemaUtil.PRODUCTO_KEY_NO_COPIA + ","
                         + SchemaUtil.PRODUCTO_KEY_DISPONIBLE + ","
                         + SchemaUtil.PRODUCTO_KEY_ALQUILADO + ","
                         + SchemaUtil.PRODUCTO_KEY_EXTRAVIDO + ","
                         + SchemaUtil.PRODUCTO_KEY_PLATAFORMA
                         + " )" + "VALUES" + " ("
                         + id + ","
                         + "'" + p.tipo.ToString() + "',"
                         + "'" + p.titulo + "',"
                         + p._noDeCopias + ","
                         + p._disponible + ","
                         + p._alquilado + ","
                         + p._extraviado + ","
                         + "'" + p.plataforma.ToString() + "');";

            Console.WriteLine(sql);

            this.dBHelper.ejecutar(sql);
        }
        private void btnActualizar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                producto = productoService.getProductoConID(productoID);

                if (producto.GetType().Equals(typeof(VideoJuegos)))
                {
                    VideoJuegos v = (VideoJuegos)producto;

                    v.titulo = ValidationUtil.NullOrEmpty(titulo.Text);
                    v.anadirCopias(cantidadAnadir);

                    if (btnPC.IsChecked == true)
                    {
                        v.plataforma = Plataforma.PC;
                    }
                    else if (btnXbox.IsChecked == true)
                    {
                        v.plataforma = Plataforma.Xbox;
                    }
                    else if (btnPS2.IsChecked == true)
                    {
                        v.plataforma = Plataforma.PS2;
                    }
                    else if (btnPS3.IsChecked == true)
                    {
                        v.plataforma = Plataforma.PS3;
                    }
                    else if (btnWii.IsChecked == true)
                    {
                        v.plataforma = Plataforma.Wii;
                    }
                    else
                    {
                        throw new Exception("Plataforma debe ser PC, Xbox, PS2, PS3 or Wii.");
                    }

                    productoService.actualizarVideoJuegos(v, v.productCodigo);
                }
                else
                {
                    Pelicula pe = (Pelicula)producto;

                    pe.titulo = ValidationUtil.NullOrEmpty(titulo.Text);
                    pe.anadirCopias(cantidadAnadir);

                    pe.duracion      = ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(duracion.Text));
                    pe.anoProduccion = ValidationUtil.Ano(ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(anoProduccion.Text)));
                    pe.anoCompra     = ValidationUtil.Ano(ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(anoCompra.Text)));

                    productoService.actualizarPelicula(pe, pe.productCodigo);
                }
                mostrarInfo(productoService.getProductoConID(productoID));
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
示例#3
0
        public int anadirVideoJuegos(VideoJuegos p)
        {
            if (p == null)
            {
                throw new Exception("El producto es nulo.");
            }

            string sql = "INSERT INTO " + SchemaUtil.PRODUCTO_TABLE_NAME + "("
                         + SchemaUtil.PRODUCTO_KEY_TIPO + ","
                         + SchemaUtil.PRODUCTO_KEY_TITULO + ","
                         + SchemaUtil.PRODUCTO_KEY_NO_COPIA + ","
                         + SchemaUtil.PRODUCTO_KEY_DISPONIBLE + ","
                         + SchemaUtil.PRODUCTO_KEY_ALQUILADO + ","
                         + SchemaUtil.PRODUCTO_KEY_EXTRAVIDO + ","
                         + SchemaUtil.PRODUCTO_KEY_PLATAFORMA
                         + " )" + "VALUES" + " (" +
                         "'" + p.tipo.ToString() + "',"
                         + "'" + p.titulo + "',"
                         + p._noDeCopias + ","
                         + p._disponible + ","
                         + p._alquilado + ","
                         + p._extraviado + ","
                         + "'" + p.plataforma.ToString() + "');";

            Console.WriteLine(sql);

            this.dBHelper.ejecutar(sql);

            return(getTodos().Last().productCodigo);
        }
        private void mostrarInfo(Producto p)
        {
            titulo.Text     = p.titulo;
            noDeCopias.Text = p.noDeCopias.ToString();

            if (p.GetType().Equals(typeof(VideoJuegos)))
            {
                VideoJuegos v = (VideoJuegos)p;
                tipo.Text               = v.tipo.ToString();
                duracion.IsEnabled      = false;
                anoProduccion.IsEnabled = false;
                anoCompra.IsEnabled     = false;
                btnPC.IsEnabled         = true;
                btnXbox.IsEnabled       = true;
                btnPS2.IsEnabled        = true;
                btnPS3.IsEnabled        = true;
                btnWii.IsEnabled        = true;
                if (v.plataforma == Plataforma.PC)
                {
                    btnPC.IsChecked = true;
                }
                else if (v.plataforma == Plataforma.Xbox)
                {
                    btnXbox.IsChecked = true;
                }
                else if (v.plataforma == Plataforma.PS2)
                {
                    btnPS2.IsChecked = true;
                }
                else if (v.plataforma == Plataforma.PS3)
                {
                    btnPS3.IsChecked = true;
                }
                else if (v.plataforma == Plataforma.Wii)
                {
                    btnWii.IsChecked = true;
                }
            }
            else
            {
                Pelicula pe = (Pelicula)p;
                tipo.Text               = pe.tipo.ToString();
                btnPC.IsEnabled         = false;
                btnXbox.IsEnabled       = false;
                btnPS2.IsEnabled        = false;
                btnPS3.IsEnabled        = false;
                btnWii.IsEnabled        = false;
                duracion.IsEnabled      = true;
                anoProduccion.IsEnabled = true;
                anoCompra.IsEnabled     = true;
                duracion.Text           = pe.duracion.ToString();
                anoProduccion.Text      = pe.anoProduccion.ToString();
                anoCompra.Text          = pe.anoCompra.ToString();
            }
        }
示例#5
0
        private void btnAlquiler_Click(object sender, RoutedEventArgs e)
        {
            VideoJuegos selectedVideoJuegos = VideoJuegosGrid.SelectedItem as VideoJuegos;

            if (selectedVideoJuegos != null)
            {
                AnadirAlquilerPagina page = new AnadirAlquilerPagina(selectedVideoJuegos.productCodigo);
                this.NavigationService.Navigate(page);
            }
            else
            {
                AnadirAlquilerPagina page = new AnadirAlquilerPagina(0);
                this.NavigationService.Navigate(page);
            }
        }
示例#6
0
        private VideoJuegos getVideoJuegosDeRow(DataRow row)
        {
            VideoJuegos p = new VideoJuegos();

            p.productCodigo = ValidationUtil.NumeroInteger(row[SchemaUtil.PRODUCTO_KEY_ID].ToString());
            p.tipo          = Tipo.VideoJuegos;
            p.titulo        = row[SchemaUtil.PRODUCTO_KEY_TITULO].ToString();
            p.noDeCopias    = ValidationUtil.NumeroInteger(row[SchemaUtil.PRODUCTO_KEY_NO_COPIA].ToString());
            p.disponible    = ValidationUtil.NumeroInteger(row[SchemaUtil.PRODUCTO_KEY_DISPONIBLE].ToString());
            p.alquilado     = ValidationUtil.NumeroInteger(row[SchemaUtil.PRODUCTO_KEY_ALQUILADO].ToString());
            p.extraviado    = ValidationUtil.NumeroInteger(row[SchemaUtil.PRODUCTO_KEY_EXTRAVIDO].ToString());

            string tempPlataforma = row[SchemaUtil.PRODUCTO_KEY_PLATAFORMA].ToString();

            if (tempPlataforma == "PC")
            {
                p.plataforma = Plataforma.PC;
            }
            else if (tempPlataforma == "PS2")
            {
                p.plataforma = Plataforma.PS2;
            }
            else if (tempPlataforma == "PS3")
            {
                p.plataforma = Plataforma.PS3;
            }
            else if (tempPlataforma == "Xbox")
            {
                p.plataforma = Plataforma.Xbox;
            }
            else if (tempPlataforma == "Wii")
            {
                p.plataforma = Plataforma.Wii;
            }

            return(p);
        }
示例#7
0
        private void btnAnadir_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (btnPelicula.IsSelected == true)
                {
                    Pelicula pe = new Pelicula();
                    pe.tipo = Tipo.Pelicula;

                    pe.titulo     = ValidationUtil.NullOrEmpty(titulo.Text);
                    pe.noDeCopias = ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(noDeCopias.Text));

                    pe.duracion      = ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(duracion.Text));
                    pe.anoProduccion = ValidationUtil.Ano(ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(anoProduccion.Text)));
                    pe.anoCompra     = ValidationUtil.Ano(ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(anoCompra.Text)));

                    id.Text = productoService.anadirPelicula(pe).ToString();
                }
                else if (btnVideoJuegos.IsSelected == true)
                {
                    VideoJuegos v = new VideoJuegos();
                    v.tipo = Tipo.VideoJuegos;

                    v.titulo     = ValidationUtil.NullOrEmpty(titulo.Text);
                    v.noDeCopias = ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(noDeCopias.Text));

                    if (btnPC.IsChecked == true)
                    {
                        v.plataforma = Plataforma.PC;
                    }
                    else if (btnXbox.IsChecked == true)
                    {
                        v.plataforma = Plataforma.Xbox;
                    }
                    else if (btnPS2.IsChecked == true)
                    {
                        v.plataforma = Plataforma.PS2;
                    }
                    else if (btnPS3.IsChecked == true)
                    {
                        v.plataforma = Plataforma.PS3;
                    }
                    else if (btnWii.IsChecked == true)
                    {
                        v.plataforma = Plataforma.Wii;
                    }
                    else
                    {
                        throw new Exception("Plataforma debe ser PC, Xbox, PS2, PS3 or Wii.");
                    }

                    id.Text = productoService.anadirVideoJuegos(v).ToString();
                }
                else
                {
                    throw new Exception("Eligir un tipo de el producto.");
                }
                mostrarInfo(productoService.getProductoConID(Int32.Parse(id.Text)));
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
示例#8
0
 public void actualizarVideoJuegos(VideoJuegos p, int id)
 {
     productoRepo.actualizarVideoJuegos(p, id);
 }
示例#9
0
 public int anadirVideoJuegos(VideoJuegos p)
 {
     return(productoRepo.anadirVideoJuegos(p));
 }