private void AddLek() { Lek noviLek = new Lek(); Console.WriteLine(SifraTb.Text); noviLek.Sifra = Int32.Parse(SifraTb.Text); noviLek.Naziv = NazivTb.Text as string; noviLek.Kolicina = Convert.ToInt32(KolicinaTb.Text); noviLek.Tip = TipTb.SelectedItem as string; noviLek.RokTrajanja = (DateTime)RokTb.SelectedDate; noviLek.Sastav = (List <string>)listBox2.ItemsSource; noviLek.Proizvodjac = ProizvodjacTb.Text as string; Lekovi.Add(noviLek); Drug newDrug = new Drug(); newDrug.Name = noviLek.Naziv; newDrug.Id = noviLek.Sifra; newDrug.Quantity = noviLek.Kolicina; newDrug.ExpirationDate = noviLek.RokTrajanja; newDrug.Producer = noviLek.Proizvodjac; List <DrugType> types = dt.ViewDrugTypes(); foreach (DrugType d in types) { if (noviLek.Tip.Equals(d.Type)) { newDrug.drugType = d; } } List <Ingredient> myIngredients = new List <Ingredient>(); List <Ingredient> ingredients = dt.ViewIngridients(); foreach (Ingredient i in ingredients) { foreach (string s in newIngredients) { if (s.Equals(i.Name)) { myIngredients.Add(i); } } } newDrug.ingredient = myIngredients; dc.AddDrug(newDrug); // Resetujemo polja ClearFields(); UpdateTempLek(); }