Exemple #1
0
        //Handles the different image inputs and manages image related errors (and replaces image with image related to error)
        private void DoImage(string thisImage, bool error)
        {
            try
            {
                Image     image   = Image.FromFile(@thisImage);
                Rectangle newRect = ImageHandling.GetScaledRectangle(image, imageP.ClientRectangle);


                imageP.Image = ImageHandling.GetResizedImage(image, newRect);
            }
            catch (ArgumentException ae)
            {
                dm.GE.GlobalTryCatch(ae, thisImage);
                if (error)
                {
                    DoImage(@"Images\bigError.png", true);
                }
                else
                {
                    DoImage(@"Images\argumentError.png", true);
                }
            }
            catch (FileNotFoundException fnfe)
            {
                dm.GE.GlobalTryCatch(fnfe, thisImage);
                if (error)
                {
                    DoImage(@"Images\bigError.png", true);
                }
                else
                {
                    DoImage(@"Images\fileNotFound.png", true);
                }
            }
        }
Exemple #2
0
        public void editItem(info editMovie)
        {
            this.index             = DataManager.getIndexOf(editMovie);
            this.selected          = DataManager.getMovie(index);
            titleT.Text            = editMovie.getTitle();
            fileLocationT.Text     = editMovie.File;
            genreCB.SelectedIndex  = (int)editMovie.Genre;
            ratingCB.SelectedIndex = (int)editMovie.Rating;
            movieData               = DataManager.getdata(editMovie.File);
            yearT.Text              = movieData.Year.ToString();
            imageT.Text             = movieData.Image;
            actors                  = movieData.getActors();
            actorListBox.DataSource = actors;
            descriptionT.Text       = movieData.Description.Replace("\n", "\r\n");
            if (movieData.Image != "")
            {
                try
                {
                    Image     image   = Image.FromFile(@movieData.Image);
                    Rectangle newRect = ImageHandling.GetScaledRectangle(image, imageP.ClientRectangle);
                    imageP.MaximumSize = imageP.Size;


                    imageP.Image = ImageHandling.GetResizedImage(image, newRect);
                }
                catch (ArgumentException ae)
                {
                    DataManager.GE.GlobalTryCatch(ae, movieData.Image);
                }
                catch (FileNotFoundException fnfe)
                {
                    DataManager.GE.GlobalTryCatch(fnfe, movieData.Image);
                }
            }
            else
            {
            }
        }
Exemple #3
0
        private void lbProductos_SelectedIndexChanged(object sender, EventArgs e)
        {
            LogicaGo logica = new LogicaGo();

            lblId.Text = lbProductos.SelectedValue.ToString();
            producto   = logica.ObtenerProducto(lblId.Text);
            if (producto == null)
            {
                return;
            }

            lblId.Text          = producto.IdProducto;
            lblNombre.Text      = producto.Nombre;
            lblDescripcion.Text = "Descripción: " + producto.Descripcion;

            Double value;

            if (Double.TryParse(producto.Precio.ToString(), out value))
            {
                lblPrecio.Text = "Precio: " + String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C2}", value);
            }
            else
            {
                lblPrecio.Text = "Precio: " + String.Empty;
            }
            cbUnidades.Value = 1;
            if (!producto.Servicio)
            {
                cbUnidades.Maximum = producto.Existencias;
            }
            else
            {
                cbUnidades.Maximum = 1000;
            }
            lblMaxUnidades.Text             = "Max: " + producto.Existencias + " unidades";
            lblTipo.Text                    = "Tipo: " + producto.Tipo;
            txtCbEstado.SelectedValue       = producto.IdEstado;
            txtCbCategoria.SelectedValue    = producto.Categoria;
            txtCbSubCategoria.SelectedValue = producto.Subcategoria;
            lblEstado.Text                  = "Estado: " + txtCbEstado.Text;
            lblFecha.Text                   = "Fecha Ingreso: " + producto.Fecha.ToString();
            lblCategoria.Text               = "Categoria: " + txtCbCategoria.Text;
            lblSubCategoria.Text            = "SubCategoria: " + txtCbSubCategoria.Text;
            if (producto.RutaImagen != "")
            {
                string rutaArchivo = ConfigurationManager.AppSettings["rutaImagenes"];
                Image  image;
                if (File.Exists(rutaArchivo + producto.RutaImagen))
                {
                    image = Image.FromFile(rutaArchivo + producto.RutaImagen);
                }
                else
                {
                    image = Image.FromFile(rutaArchivo + @"Images\Productos\default_product.png");
                }
                Rectangle newRect = ImageHandling.GetScaledRectangle(image, pictureBox1.ClientRectangle);
                pictureBox1.Image  = ImageHandling.GetResizedImage(image, newRect);
                pictureBox1.Height = 120;
                pictureBox1.Width  = 120;
            }
            else
            {
                pictureBox1.Image = null;
            }
        }