| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Windows;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- public class CustomerContactGrid : DynamicDataGrid<CustomerContact>, ICustomerGrid
- {
-
- protected override void DoReconfigure(FluentList<DynamicGridOption> options)
- {
- base.DoReconfigure(options);
- options.AddRange(
- DynamicGridOption.AddRows,
- DynamicGridOption.EditRows,
- DynamicGridOption.SelectColumns,
- DynamicGridOption.DeleteRows
- );
- }
- public Customer Customer { get; set; }
- protected override void Reload(Filters<CustomerContact> criteria, Columns<CustomerContact> columns, ref SortOrder<CustomerContact> sort,
- Action<CoreTable, Exception> action)
- {
- criteria.Add(new Filter<CustomerContact>(x => x.Customer).LinkValid(Customer.ID));
- base.Reload(criteria, columns, ref sort, action);
- }
- protected override CustomerContact 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();
- }
- }
- }
|