| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System;
- using System.Linq;
- using System.Threading;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.Wpf;
- namespace PRSDesktop
- {
- public class JobOrderGrid : DynamicDataGrid<PurchaseOrderItem>, IMasterDetailControl<Job,PurchaseOrderItem>, IDataModelSource
- {
-
- public Job? Master { get; set; }
- public Filter<PurchaseOrderItem> MasterDetailFilter => (Master?.ID ?? Guid.Empty) != Guid.Empty
- ? new Filter<PurchaseOrderItem>(x => x.Job.ID).IsEqualTo(Master.ID)
- : new Filter<PurchaseOrderItem>().None();
-
- public JobOrderGrid()
- {
- ColumnsTag = "JobOrders";
- HiddenColumns.Add(x => x.PurchaseOrderLink.SupplierLink.ID);
- HiddenColumns.Add(x => x.PurchaseOrderLink.Category.ID);
- HiddenColumns.Add(x => x.ID);
- HiddenColumns.Add(x => x.Product.ID);
- HiddenColumns.Add(x => x.Product.Code);
- HiddenColumns.Add(x => x.Product.Name);
- HiddenColumns.Add(x => x.Description);
- HiddenColumns.Add(x => x.TaxCode.ID);
- HiddenColumns.Add(x => x.TaxCode.Code);
- HiddenColumns.Add(x => x.TaxCode.Description);
- HiddenColumns.Add(x => x.TaxCode.Rate);
- HiddenColumns.Add(x => x.TaxRate);
- HiddenColumns.Add(x => x.ExTax);
- HiddenColumns.Add(x => x.Tax);
- HiddenColumns.Add(x => x.IncTax);
- HiddenColumns.Add(x => x.BillLine.ID);
- HiddenColumns.Add(x => x.Consignment.ID);
- HiddenColumns.Add(x => x.Product.DigitalForm.ID);
- HiddenColumns.Add(x => x.Product.DigitalForm.Description);
- HiddenColumns.Add(x => x.PurchaseOrderLink.SupplierLink.Code);
- HiddenColumns.Add(x => x.PurchaseOrderLink.SupplierLink.Name);
- }
- protected override void DoReconfigure(DynamicGridOptions options)
- {
- base.DoReconfigure(options);
- options.RecordCount = true;
- options.SelectColumns = true;
- options.FilterRows = true;
- options.MultiSelect = true;
- options.ExportData = true;
- }
- public event DataModelUpdateEvent? OnUpdateDataModel;
- public string SectionName => "Job Orders";
- public DataModel DataModel(Selection selection)
- {
- var ids = ExtractValues(x => x.ID, selection).ToArray();
- return new BaseDataModel<PurchaseOrderItem>(new Filter<PurchaseOrderItem>(x => x.ID).InList(ids));
- }
-
- protected override void Reload(
- Filters<PurchaseOrderItem> criteria, Columns<PurchaseOrderItem> columns, ref SortOrder<PurchaseOrderItem>? sort,
- CancellationToken token, Action<CoreTable?, Exception?> action)
- {
- criteria.Add(MasterDetailFilter);
- base.Reload(criteria, columns, ref sort, token, action);
- }
- }
- }
|