private void saveButton_Click(object sender, RoutedEventArgs e) { try { using (pisModelDataContext cont = new pisModelDataContext()) { var query = from c in cont.nalog_za_nabavus where c.id == Convert.ToInt32(idBox.Text) select c; foreach (var ord in query) { ord.datum = Convert.ToDateTime(datumPicker.Text); ord.vrijeme = vrijemeBox.Text; } cont.SubmitChanges(); } stavkeNalogZaNabavu stavke = new stavkeNalogZaNabavu(); stavke.idBoxx.Text = idBox.Text.ToString(); iznos.tempNalogZaNabavuID = Convert.ToInt32(idBox.Text); //MessageBox.Show(iznos.TempnalogZaNabavuID.ToString()); stavke.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show("Dogodila se pogreška!!!" + ex.Message.ToString()); } }
private void saveButton_Click(object sender, RoutedEventArgs e) { try { int id; using (pisModelDataContext cont = new pisModelDataContext()) { nalog_za_nabavu art = new nalog_za_nabavu { datum = Convert.ToDateTime(datumPicker.Text), vrijeme = vrijemeBox.Text }; cont.nalog_za_nabavus.InsertOnSubmit(art); cont.SubmitChanges(); var entry = (from ee in cont.nalog_za_nabavus select ee).OrderByDescending(ee => ee.id).FirstOrDefault(); id = entry.id; iznos.tempNalogZaNabavuID = id; } updateListBox(); //MessageBox.Show(id.ToString()); stavkeNalogZaNabavu stavke = new stavkeNalogZaNabavu(); 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()); } }