InsertScholarshipWindow.xaml.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. namespace ProjectAnalogParus
  15. {
  16. /// <summary>
  17. /// Логика взаимодействия для InsertScholarshipWindow.xaml
  18. /// </summary>
  19. public partial class InsertScholarshipWindow : Window
  20. {
  21. gr672_bdaEntities db = new gr672_bdaEntities();
  22. public InsertScholarshipWindow()
  23. {
  24. InitializeComponent();
  25. }
  26. private void Insert_Click(object sender, RoutedEventArgs e)
  27. {
  28. if (txtAmount != null && txtName != null)
  29. {
  30. Scholarship scholarship = new Scholarship();
  31. scholarship.NameScholarship = txtName.Text;
  32. scholarship.Amount = Convert.ToDecimal(txtAmount.Text);
  33. db.Scholarship.Add(scholarship);
  34. db.SaveChanges();
  35. MessageBox.Show("Новая запись добавлена");
  36. }
  37. else
  38. {
  39. MessageBox.Show("Не все поля заполнены!");
  40. }
  41. }
  42. private void Cancel_Click(object sender, RoutedEventArgs e)
  43. {
  44. this.Close();
  45. FramePage.MainFrame.Navigate(new ScholarshipsPage());
  46. }
  47. }
  48. }