123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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<PurchaseOrder,PurchaseOrderItem>
- {
- 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<PurchaseOrderItem, BillLineLink>(x => x.BillLine));
- base.SelectItems(rows);
- }
- protected override void OnAfterEditorValueChanged(DynamicEditorGrid grid, PurchaseOrderItem[] items, string columnnname, Dictionary<string, object?> 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<string, object?> 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;
- }
- }
- }
|