Ejemplo n.º 1
0
        private void btnAddPhoto_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Filter = "All Files(*.*)|*.*";
            if (open.ShowDialog() == DialogResult.OK)
            {
                string result   = Path.GetFileName(open.FileName);
                string ext      = Path.GetExtension(open.FileName);
                string fullpath = Path.Combine("Images", Guid.NewGuid().ToString() + "." + ext);

                File.Copy(open.FileName, fullpath);

                Image      img = Image.FromFile(fullpath);
                PictureBox p   = new PictureBox();
                p.Width  = 110;
                p.Height = 120;


                p.Image = ResizeImage.FixedSize(img, p.Width, p.Height, true);

                flowPanelPhoto.Controls.Add(p);

                context.Photos.Local.Add(new Photo()
                {
                    GoodId    = (bsGood.Current as Good).GoodId,
                    PhotoPath = fullpath
                });
            }
        }
Ejemplo n.º 2
0
        private void GetGoodShow(int GoodId)
        {
            GoodInfo good = GetGoodInfo(GoodId);

            lblNameGood.Text      = good.GoodName;
            lblMaunufacturer.Text = good.ManufacturerName;
            lblPrice.Text         = good.Price.ToString();
            lblCount.Text         = good.GoodCount.ToString();

            Image img = Image.FromFile(good.PhotoPath);

            pictureGood.Image = ResizeImage.FixedSize(img, pictureGood.Width, pictureGood.Height, true);;
        }
Ejemplo n.º 3
0
        private void dgvGood_SelectionChanged(object sender, EventArgs e)
        {
            flowPanelPhoto.Controls.Clear();
            flowPanelPhoto.Update();

            var list = context.Photos.
                       Local.Where(g => g.GoodId == (bsGood.Current as Good).GoodId)
                       .ToList();

            foreach (var item in list)
            {
                Image      img = Image.FromFile(item.PhotoPath);
                PictureBox p   = new PictureBox();
                p.Width  = 110;
                p.Height = 120;


                p.Image = ResizeImage.FixedSize(img, p.Width, p.Height, true);

                flowPanelPhoto.Controls.Add(p);
            }
        }