| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Threading;
- using System.Windows;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- public class CustomerProductGrid : DynamicDataGrid<CustomerProduct>, ICustomerGrid
- {
- protected override void DoReconfigure(DynamicGridOptions options)
- {
- base.DoReconfigure(options);
- options.AddRows = true;
- options.EditRows = true;
- options.SelectColumns = true;
- options.DeleteRows = true;
- }
- public Customer Customer { get; set; }
- protected override void Reload(
- Filters<CustomerProduct> criteria, Columns<CustomerProduct> columns, ref SortOrder<CustomerProduct>? sort,
- CancellationToken token, Action<CoreTable?, Exception?> action)
- {
- criteria.Add(new Filter<CustomerProduct>(x => x.Customer).LinkValid(Customer.ID));
- base.Reload(criteria, columns, ref sort, token, action);
- }
- public override CustomerProduct CreateItem()
- {
- var result = base.CreateItem();
- result.Customer.ID = Customer.ID;
- result.Customer.Synchronise(Customer);
- return result;
- }
- protected override BaseEditor? GetEditor(object item, DynamicGridColumn column)
- {
- if (column.ColumnName.Equals("Customer.ID"))
- return new NullEditor();
- return base.GetEditor(item, column);
- }
- protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
- {
- if (Customer.ID == Guid.Empty)
- MessageBox.Show("Please select a Customer first!");
- else
- base.DoAdd();
- }
- }
- }
|