EditingMaterialWindow.xaml.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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.Media.Media3D;
  14. using System.Windows.Shapes;
  15. using wpf_connection3.model;
  16. namespace wpf_connection3.Windows
  17. {
  18. public partial class EditingMaterialWindow : Window
  19. {
  20. public List<model.Material> MaterialList { get; set; }
  21. public int ID { get; set; }
  22. public EditingMaterialWindow(int currentProductID)
  23. {
  24. InitializeComponent();
  25. ID = currentProductID;
  26. DataContext = this;
  27. MaterialList = Globals.dataProvider.getMaterials();
  28. }
  29. private void SaveButton_Click(object sender, RoutedEventArgs e)
  30. {
  31. try
  32. {
  33. var material = new ProductMaterial();
  34. material.ProductId = ID;
  35. material.Count = Convert.ToInt32(CountTextBox.Text);
  36. material.MaterialId = (MaterialTypeComboBox.SelectedItem as model.Material).ID;
  37. Globals.dataProvider.addProductMaterial(material);
  38. DialogResult = true;
  39. }
  40. catch (Exception ex)
  41. {
  42. MessageBox.Show(ex.Message);
  43. }
  44. }
  45. }
  46. }