using System; using System.Collections.Generic; using System.Linq; using System.Windows; using System.Windows.Controls; using Comal.Classes; using FastReport.DevComponents.WinForms.Drawing; using InABox.Core; using InABox.DynamicGrid; namespace PRSDesktop { public class SupplierPurchaseOrderItemOneToMany : DynamicOneToManyGrid { private readonly Button bill; public SupplierPurchaseOrderItemOneToMany() : base() { HiddenColumns.Add(x => x.BillLine.ID); HiddenColumns.Add(x => x.BillLine.Deleted); bill = AddButton("Enter Bill", null, SupplierPurchaseOrderItems.EnterBill); bill.IsEnabled = false; } protected override void SelectItems(CoreRow[]? rows) { bill.IsEnabled = rows != null && !rows.Any(r => r.IsEntityLinkValid(x => x.BillLine)); base.SelectItems(rows); } protected override void OnAfterEditorValueChanged(DynamicEditorGrid grid, PurchaseOrderItem[] items, string columnnname, Dictionary changes) { base.OnAfterEditorValueChanged(grid, items, columnnname, changes); if (columnnname.Equals("Product.ID") || columnnname.Equals("Job.ID") || columnnname.StartsWith("Dimensions.")) { PurchaseOrder.UpdateCosts( items, Item.SupplierLink.ID, changes ); } } protected override Dictionary EditorValueChanged(IDynamicEditorForm editor, PurchaseOrderItem[] items, string name, object value) { var results = base.EditorValueChanged(editor, items, name, value); if (name.Equals("ProductLink.TaxCode.ID")) DynamicGridUtils.UpdateEditorValue(items, "TaxCode.ID", (Guid)value, results); return results; } } }