QuoteProposals.xaml.cs 2.0 KB

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