private void putPriceToDatabase(object sender, RoutedEventArgs e) { string nameofpaper = comboBox.Text.ToString(); int priceofpaper = Convert.ToInt32(textBoxcompaperPrice.Text); MessageBox.Show(nameofpaper + "\n" + priceofpaper + "\n" + todayDate + "\n" + todayTime); RateTable actual = new RateTable(); actual.NameOfpaper = nameofpaper; actual.Price = priceofpaper; actual.DateOf = todayDate; actual.TimeOf = todayTime; DB.RateTable.Add(actual); DB.SaveChanges(); dataGridRate.ItemsSource = DB.RateTable.ToList(); }
private void deletePrice(object sender, RoutedEventArgs e) { int id = 0; try { id = (dataGridRate.SelectedItem as RateTable).Id; RateTable torlendo = new RateTable(); torlendo = DB.RateTable.Where(d => d.Id == id).First(); DB.RateTable.Remove(torlendo); DB.SaveChanges(); dataGridRate.ItemsSource = DB.RateTable.ToList(); } catch { MessageBox.Show("Hiba, jelölje ki a torolni kivánt sort."); } }