12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System;
- using System.Linq;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.Wpf;
- namespace PRSDesktop
- {
- public class QuoteTakeoffs : DynamicDataGrid<QuoteTakeoff>, IMasterDetailControl<Quote,QuoteTakeoff>, IDataModelSource
- {
-
- public Quote? Master { get; set; }
- public Filter<QuoteTakeoff> MasterDetailFilter => Master != null && Master.ID != Guid.Empty
- ? new Filter<QuoteTakeoff>(x => x.Quote.ID).IsEqualTo(Master.ID)
- : new Filter<QuoteTakeoff>().None();
-
- protected override void DoReconfigure(FluentList<DynamicGridOption> options)
- {
- base.DoReconfigure(options);
- options.AddRange(
- DynamicGridOption.RecordCount,
- DynamicGridOption.AddRows,
- DynamicGridOption.EditRows,
- DynamicGridOption.DeleteRows,
- DynamicGridOption.SelectColumns,
- DynamicGridOption.MultiSelect
- );
- }
- public event DataModelUpdateEvent? OnUpdateDataModel;
- public string SectionName => "Quote Takeoffs";
- public DataModel DataModel(Selection selection)
- {
- var ids = ExtractValues(x => x.ID, selection).ToArray();
- return new BaseDataModel<QuoteTakeoff>(new Filter<QuoteTakeoff>(x => x.ID).InList(ids));
- }
-
- protected override void Reload(Filters<QuoteTakeoff> criteria, Columns<QuoteTakeoff> columns, ref SortOrder<QuoteTakeoff>? sort, Action<CoreTable?, Exception?> action)
- {
- criteria.Add(MasterDetailFilter);
- base.Reload(criteria, columns, ref sort, action);
- }
- protected override bool CanCreateItems()
- {
- return base.CanCreateItems() && (Master?.ID ?? Guid.Empty) != Guid.Empty;
- }
- protected override QuoteTakeoff CreateItem()
- {
- var result = base.CreateItem();
- result.Quote.ID = Master?.ID ?? Guid.Empty;
- result.Quote.Synchronise(Master ?? new Quote());
- return result;
- }
- }
- }
|