private void button1_Click(object sender, RoutedEventArgs e)
        {
            //try
            //{
                using (pisModelDataContext cont = new pisModelDataContext())
                {
                    racun_od_dobavljaca racun = new racun_od_dobavljaca
                    {
                        datum = Convert.ToDateTime(datumBox.Text),
                        adresa = adresaBox.Text
                    };
                    cont.racun_od_dobavljacas.InsertOnSubmit(racun);
                    cont.SubmitChanges();
                    var entry = (from ee in cont.racun_od_dobavljacas
                                 select ee).OrderByDescending(ee => ee.br_racuna).FirstOrDefault();
                    id = entry.br_racuna;
                    iznos.tempID = entry.br_racuna;
                }
                updateListBox();

                //MessageBox.Show(id.ToString());
                stavkeRacunaOdDobPage stavke = new stavkeRacunaOdDobPage();
                stavke.idBoxx.Text = id.ToString();
                //MessageBox.Show(iznos.tempID.ToString());
                stavke.ShowDialog();

            //}

            //catch (Exception ex)
            //{
               // MessageBox.Show("Dogodila se pogreška!!!\n" + ex.Message.ToString());
            //}
        }
 private void saveButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (pisModelDataContext cont = new pisModelDataContext())
         {
             var query = from c in cont.racun_od_dobavljacas
                         where c.br_racuna == Convert.ToInt32(idBox.Text)
                         select c;
             foreach (var ord in query)
             {
                 ord.datum = Convert.ToDateTime(datumBox.Text);
                 ord.adresa = adresaBox.Text;
             }
             cont.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Dogodila se pogreška!!!" + ex.Message.ToString());
     }
     stavkeRacunaOdDobPage stavke = new stavkeRacunaOdDobPage();
     stavke.idBoxx.Text = idBox.Text.ToString();
     iznos.tempID = Convert.ToInt32(idBox.Text);
     stavke.ShowDialog();
     this.Close();
 }