Exemple #1
0
        public static List <Border> VratiListuBordera()
        {
            List <Border>      listaBordera     = new List <Border>();
            List <Fotografija> listaFotografija = FotografijaDal.VratiFotografije();

            if (listaFotografija != null)
            {
                foreach (Fotografija f in listaFotografija)
                {
                    BitmapImage bmp  = KreirajBitMapuIzMemorije(f.BinarniPodaci);
                    Image       img1 = new Image();
                    img1.Source  = bmp;
                    img1.Stretch = Stretch.Fill;

                    Border b = new Border {
                        Width           = 80,
                        Height          = 60,
                        BorderBrush     = new SolidColorBrush(Colors.Black),
                        BorderThickness = new System.Windows.Thickness(1),
                        Margin          = new System.Windows.Thickness(5),
                        Tag             = f
                    };

                    b.Child = img1;
                    listaBordera.Add(b);
                }
                return(listaBordera);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        //PROMENI
        private void Promeni(int promeniSliku = 0)
        {
            if (indeks < 0)
            {
                return;
            }

            if (!Validacija())
            {
                return;
            }

            Border b = WrapPanel1.Children[indeks] as Border;

            Fotografija selFotografija = b.Tag as Fotografija;

            selFotografija.Naziv = TextBoxNaziv.Text;
            selFotografija.Datum = DatePicker1.SelectedDate.Value;
            selFotografija.Opis  = TextBoxOpis.Text;

            if (promeniSliku == 0)
            {
                int rez = FotografijaDal.PromeniFotografiju1(selFotografija);

                if (rez == 0)
                {
                    SelektujBroder(b);
                    MessageBox.Show("Podaci promenjeni");
                    DozvoliIzmenu(false);
                }
            }

            if (promeniSliku == 1)
            {
                Uri         adresa = new Uri(odabranaSlika, UriKind.Absolute);
                BitmapImage bmp    = SlikaHelper.KreirajBitMapu(adresa);
                selFotografija.BinarniPodaci = SlikaHelper.KreirajNizBajtova(bmp);

                int rez = FotografijaDal.PromeniFotografiju2(selFotografija);

                if (rez == 0)
                {
                    PrikaziFotografije();
                    Border b1 = WrapPanel1.Children[indeks] as Border;
                    SelektujBroder(b1);

                    DozvoliIzmenu(false);
                    MessageBox.Show("Podaci promenjeni");
                }
                else
                {
                    MessageBox.Show("Greska pri promeni");
                }
            }
        }
Exemple #3
0
        //UBACI
        private void Ubaci()
        {
            if (!Validacija())
            {
                DozvoliIzmenu(true);
                return;
            }

            if (string.IsNullOrWhiteSpace(odabranaSlika))
            {
                MessageBox.Show("Odaberi sliku");
                return;
            }

            Fotografija f = new Fotografija();

            f.Naziv = TextBoxNaziv.Text;
            f.Datum = DatePicker1.SelectedDate.Value;
            f.Opis  = TextBoxOpis.Text;

            Uri         adresa = new Uri(odabranaSlika, UriKind.Absolute);
            BitmapImage bmp    = SlikaHelper.KreirajBitMapu(adresa);

            f.BinarniPodaci = SlikaHelper.KreirajNizBajtova(bmp);

            int rez = FotografijaDal.UbaciFotografiju(f);

            if (rez == 0)
            {
                PrikaziFotografije();
                odabranaSlika = "";
                indeks        = WrapPanel1.Children.Count - 1;
                Border b = WrapPanel1.Children[indeks] as Border;

                SelektujBroder(b);
                DozvoliIzmenu(false);
                MessageBox.Show("Slika sacuvana");
            }
            else
            {
                MessageBox.Show("Greska pri cuvanju");
            }
        }
Exemple #4
0
        private void ButtonObrisi_Click(object sender, RoutedEventArgs e)
        {
            if (indeks > -1)
            {
                Border b = WrapPanel1.Children[indeks] as Border;

                Fotografija f = b.Tag as Fotografija;

                int rez = FotografijaDal.ObrisiFotografiju(f.FotografijaId);

                if (rez == 0)
                {
                    PrikaziFotografije();
                    Resetuj();
                    ResetujBordere();
                    DozvoliIzmenu(false);
                    MessageBox.Show("Podaci obrisani");
                }
                else
                {
                    MessageBox.Show("Greska pri brisanju podataka");
                }
            }
        }