QuoteContracts.xaml.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 QuoteContracts.xaml
  12. /// </summary>
  13. public partial class QuoteContracts : UserControl, IQuotePage, IPanel<Quote>
  14. {
  15. public QuoteContracts()
  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 Contracts";
  25. public DataModel DataModel(Selection selection)
  26. {
  27. var ids = Contracts.ExtractValues(x => x.ID, selection).ToArray();
  28. return new BaseDataModel<QuoteContract>(new Filter<QuoteContract>(x => x.ID).InList(ids));
  29. }
  30. public void Heartbeat(TimeSpan time)
  31. {
  32. }
  33. public void Refresh()
  34. {
  35. Contracts.Refresh(false, true);
  36. }
  37. public Dictionary<string, object[]> Selected()
  38. {
  39. return new Dictionary<string, object[]>();
  40. }
  41. public void Setup()
  42. {
  43. Contracts.Refresh(true, false);
  44. Proposals.Refresh(true, false);
  45. Contracts.OnSelectItem += Contracts_OnSelectItem;
  46. }
  47. public void Shutdown()
  48. {
  49. }
  50. public Guid ParentID
  51. {
  52. get => Contracts.QuoteID;
  53. set
  54. {
  55. Contracts.QuoteID = value;
  56. Proposals.QuoteID = value;
  57. }
  58. }
  59. public Dictionary<Type, CoreTable> DataEnvironment()
  60. {
  61. return new Dictionary<Type, CoreTable>();
  62. }
  63. private void Contracts_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
  64. {
  65. var row = e.Rows?.FirstOrDefault();
  66. Proposals.ContractID = row != null ? row.Get<QuoteProposal, Guid>(x => x.ID) : CoreUtils.FullGuid;
  67. Proposals.QuoteID = ParentID;
  68. }
  69. }
  70. }