| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Threading;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.Wpf;
- namespace PRSDesktop
- {
- public class QuoteProposalGrid : DynamicDataGrid<QuoteProposal>, IMasterDetailControl<Quote,QuoteProposal>
- {
-
- public Quote? Master { get; set; }
- public Filter<QuoteProposal> MasterDetailFilter => Master != null && Master.ID != Guid.Empty
- ? new Filter<QuoteProposal>(x => x.Quote.ID).IsEqualTo(Master.ID)
- : new Filter<QuoteProposal>().None();
-
- public QuoteProposalGrid()
- {
- HiddenColumns.Add(x => x.Quote.ID);
- HiddenColumns.Add(x => x.ID);
- HiddenColumns.Add(x => x.Preamble);
- HiddenColumns.Add(x => x.Summary);
- HiddenColumns.Add(x => x.ExTax);
- HiddenColumns.Add(x => x.TaxCode.ID);
- HiddenColumns.Add(x => x.IncTax);
- }
-
- protected override void DoReconfigure(DynamicGridOptions options)
- {
- base.DoReconfigure(options);
- options.RecordCount = true;
- options.SelectColumns = true;
- }
- protected override void Reload(
- Filters<QuoteProposal> criteria, Columns<QuoteProposal> columns, ref SortOrder<QuoteProposal>? sort,
- CancellationToken token, Action<CoreTable?, Exception?> action)
- {
- criteria.Add(MasterDetailFilter);
- base.Reload(criteria, columns, ref sort, token, action);
- }
- protected override bool CanCreateItems()
- {
- return base.CanCreateItems() && (Master?.ID ?? Guid.Empty) != Guid.Empty;
- }
- public override QuoteProposal CreateItem()
- {
- var result = base.CreateItem();
- result.Quote.ID = Master?.ID ?? Guid.Empty;
- result.Quote.Synchronise(Master ?? new Quote());
- return result;
- }
- }
- }
|