AWGMappingWindow.xaml.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using Comal.Classes;
  8. using InABox.Core;
  9. using InABox.Integration.Awg;
  10. using InABox.Integration.Logikal;
  11. using PRSDesktop.Integrations.Logikal;
  12. namespace PRSDesktop.Integrations.Common;
  13. public partial class AWGMappingWindow : Window
  14. {
  15. private readonly Action<ProductLink,ProductStyleLink?,IBaseDimensions,double,double>? _partsCallback;
  16. private readonly Action<ActivityLink,TimeSpan, double>? _labourCallback;
  17. private readonly Action<SupplierDiscountGroupLink, double>? _discountCallback;
  18. public AWGMappingWindow(
  19. IntegrationSourceType sourceType,
  20. IEnumerable<IAwgStyle> styles,
  21. IEnumerable<IAwgGroup> groups,
  22. IEnumerable<IAwgSupplier> suppliers,
  23. IEnumerable<IAwgDiscount> discounts,
  24. IEnumerable<IAwgProfile> profiles,
  25. IEnumerable<IAwgGasket> gaskets,
  26. IEnumerable<IAwgComponent> components,
  27. IEnumerable<IAwgGlass> glass,
  28. IEnumerable<IAwgLabour> labour,
  29. Action<SupplierDiscountGroupLink,double>? discountCallback,
  30. Action<ProductLink,ProductStyleLink?,IBaseDimensions,double,double>? partsCallback,
  31. Action<ActivityLink,TimeSpan, double>? labourCallback)
  32. {
  33. InitializeComponent();
  34. _discountCallback = discountCallback;
  35. _partsCallback = partsCallback;
  36. _labourCallback = labourCallback;
  37. ViewModel.SourceType = sourceType;
  38. ViewModel.Styles = styles;
  39. ViewModel.Groups = groups;
  40. ViewModel.Suppliers = suppliers;
  41. ViewModel.Discounts = discounts;
  42. ViewModel.Profiles = profiles;
  43. ViewModel.Gaskets = gaskets;
  44. ViewModel.Components = components;
  45. ViewModel.Glass = glass;
  46. ViewModel.Labour = labour;
  47. }
  48. private void CancelClick(object sender, RoutedEventArgs e)
  49. {
  50. DialogResult = false;
  51. }
  52. private void OKClick(object sender, RoutedEventArgs e)
  53. {
  54. ViewModel.CheckUpdates();
  55. ViewModel.GetDiscounts(_discountCallback);
  56. ViewModel.GetParts(_partsCallback,_labourCallback);
  57. DialogResult = true;
  58. }
  59. public void GetParts<TProfile, TGasket, TComponent, TGlass, TLabour>(
  60. IEnumerable<TProfile>? profiles,
  61. IEnumerable<TGasket>? gaskets,
  62. IEnumerable<TComponent>? components,
  63. IEnumerable<TGlass>? glasses,
  64. IEnumerable<TLabour>? labour,
  65. Action<ProductLink, ProductStyleLink?, IBaseDimensions, double, double>? productCallback,
  66. Action<ActivityLink, TimeSpan, double>? labourCallback)
  67. where TProfile : IAwgProfile
  68. where TGasket : IAwgGasket
  69. where TComponent : IAwgComponent
  70. where TGlass : IAwgGlass
  71. where TLabour : IAwgLabour
  72. {
  73. ViewModel.GetParts(profiles, gaskets, components, glasses, labour, productCallback, labourCallback);
  74. }
  75. private void BaseDynamicGrid_OnOnChanged(object? sender, EventArgs e)
  76. {
  77. ViewModel.CheckChanged();
  78. }
  79. }