AWGMappingWindow.xaml.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.GetDiscounts(_discountCallback);
  55. ViewModel.GetParts(_partsCallback,_labourCallback);
  56. DialogResult = true;
  57. }
  58. public void GetParts<TProfile, TGasket, TComponent, TGlass, TLabour>(
  59. IEnumerable<TProfile>? profiles,
  60. IEnumerable<TGasket>? gaskets,
  61. IEnumerable<TComponent>? components,
  62. IEnumerable<TGlass>? glasses,
  63. IEnumerable<TLabour>? labour,
  64. Action<ProductLink, ProductStyleLink?, IBaseDimensions, double, double>? productCallback,
  65. Action<ActivityLink, TimeSpan, double>? labourCallback)
  66. where TProfile : IAwgProfile
  67. where TGasket : IAwgGasket
  68. where TComponent : IAwgComponent
  69. where TGlass : IAwgGlass
  70. where TLabour : IAwgLabour
  71. {
  72. ViewModel.GetParts(profiles, gaskets, components, glasses, labour, productCallback, labourCallback);
  73. }
  74. private void BaseDynamicGrid_OnOnChanged(object? sender, EventArgs e)
  75. {
  76. ViewModel.CheckChanged();
  77. }
  78. }