Beispiel #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            PrehrambeniProdukt prod = new PrehrambeniProdukt();
            string uneseni = comboprodukti.Text;

            string[] tipovi = Regex.Split(uneseni, " ");

            foreach (PrehrambeniProdukt p in produkti)
            {
                if (p.Tip == tipovi[0])
                    prod = p;
            }

            listaproizvoda.Items.Add(prod);
            kprodukti.Add(prod);

            comboprodukti.SelectedIndex = -1;
        }
Beispiel #2
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            PrehrambeniProduktDao pDAO = new PrehrambeniProduktDao();

            if (Naziv1.Text == String.Empty)
                return;

            PrehrambeniProdukt p = new PrehrambeniProdukt(Naziv1.Text, Convert.ToDouble(Cijena.Text));

            pDAO.create(p);

            ListBox1.ItemsSource = pDAO.getAll();

            ComboBox3.ItemsSource = pDAO.getAll();

            Naziv1.Clear();
            Cijena.Clear();
        }
Beispiel #3
0
        public Racun getById(int id)
        {
            DataSet data = manager.ExecuteSqlCommandToDataSet("SELECT * FROM Racun r, ProdavacHrane ph WHERE r.RacunId = " + id + " and r.ProdavacID = ph.PrehrambeniProduktID ");

            DataSet data2 = manager.ExecuteSqlCommandToDataSet("SELECT * FROM PrehrambeniProdukt ph, RacunProdukt rp, Racun r WHERE rp.RacunId = " + id + " AND rp.ProduktID = ph.Id ");

            List<PrehrambeniProdukt> lista = new List<PrehrambeniProdukt>();
            foreach (DataRow dataRow in data2.Tables[0].Rows)
            {
                PrehrambeniProdukt ph = new PrehrambeniProdukt(
                    Convert.ToInt32(dataRow["PrehrambeniProduktID"]),
                    Convert.ToString(dataRow["Tip"]),
                    Convert.ToDouble(dataRow["Cijena"])
                );

                lista.Add(ph);
            }

            foreach (DataRow dataRow in data.Tables[0].Rows)
            {

                Racun racun = new Racun(
                    Convert.ToInt32(dataRow["RacunId"]),
                     Convert.ToInt32(dataRow["Sifra"]),
                     Convert.ToDateTime(dataRow["Vrijeme"]),
                  new Menadzer(

                  Convert.ToString(dataRow["Telefon"]),
                   Convert.ToString(dataRow["Ime"]),
                     Convert.ToString(dataRow["Prezime"]),
                       Convert.ToString(dataRow["Jmbg"]),
                         Convert.ToInt32(dataRow["UposlenikId"]),
                           Convert.ToDouble(dataRow["Koeficijent"])
                                                               ),
                  new ProdavacHrane(Convert.ToString(dataRow["Pult"]),
                   Convert.ToString(dataRow["Ime"]),
                     Convert.ToString(dataRow["Prezime"]),
                       Convert.ToString(dataRow["Jmbg"]),
                         Convert.ToInt32(dataRow["UposlenikId"]),
                           Convert.ToDouble(dataRow["Koeficijent"])), lista

                );

                return racun;
            }

            return null;
        }
Beispiel #4
0
 /// <summary>
 /// Konstruktor koji prima instancu klase PrehrambeniProdukt
 /// </summary>
 /// <param name="p">Instanca klase</param>
 public PrehrambeniProdukt(PrehrambeniProdukt p)
 {
     this.Id = p.Id;
     this.Tip = p.Tip;
     this.Cijena = p.Cijena;
 }