| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Windows;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- public class CustomerContactGrid : DynamicDataGrid<CustomerContact>, ICustomerGrid
- {
- public CustomerContactGrid()
- {
- ParentID = CoreUtils.FullGuid;
- Options.AddRange(
- DynamicGridOption.AddRows,
- DynamicGridOption.EditRows,
- DynamicGridOption.SelectColumns,
- DynamicGridOption.DeleteRows
- );
- }
- public Guid ParentID { 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(ParentID));
- base.Reload(criteria, columns, ref sort, action);
- }
- protected override CustomerContact CreateItem()
- {
- var result = base.CreateItem();
- result.Customer.ID = ParentID;
- 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 (ParentID == Guid.Empty)
- MessageBox.Show("Please select a Customer first!");
- else
- base.DoAdd();
- }
- }
- }
|