QuoteProposals.xaml.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Windows.Controls;
  6. using Comal.Classes;
  7. using InABox.Core;
  8. using InABox.DynamicGrid;
  9. namespace PRSDesktop
  10. {
  11. /// <summary>
  12. /// Interaction logic for QuoteProposals.xaml
  13. /// </summary>
  14. public partial class QuoteProposals : UserControl, IQuotePage, IPanel<Quote>
  15. {
  16. public QuoteProposals()
  17. {
  18. InitializeComponent();
  19. }
  20. public bool IsReady { get; set; }
  21. public event DataModelUpdateEvent? OnUpdateDataModel;
  22. public void CreateToolbarButtons(IPanelHost host)
  23. {
  24. }
  25. public string SectionName => "Quote Proposals";
  26. public DataModel DataModel(Selection selected)
  27. {
  28. var ids = Proposals.ExtractValues(x => x.ID, selected).ToArray();
  29. return new QuoteProposalDataModel(new Filter<QuoteProposal>(x => x.ID).InList(ids));
  30. }
  31. public void Heartbeat(TimeSpan time)
  32. {
  33. }
  34. public void Refresh()
  35. {
  36. Proposals.Refresh(false,true);
  37. Details.Refresh(false, true);
  38. }
  39. public Dictionary<string, object[]> Selected()
  40. {
  41. return new Dictionary<string, object[]>();
  42. }
  43. public void Setup()
  44. {
  45. Proposals.Refresh(true, false);
  46. Details.Refresh(true, false);
  47. }
  48. public void Shutdown(CancelEventArgs? cancel)
  49. {
  50. }
  51. public Quote Quote
  52. {
  53. get => Proposals.Quote;
  54. set
  55. {
  56. Details.Proposal = null;
  57. Proposals.Quote = value;
  58. }
  59. }
  60. private void Proposals_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
  61. {
  62. var row = e.Rows?.FirstOrDefault();
  63. Details.Proposal = row?.ToObject<QuoteProposal>();
  64. }
  65. }
  66. }