1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.Linq;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- public class JobGrid : DynamicDataGrid<Job>
- {
- private Guid _statusid = Guid.Empty;
- public JobGrid()
- {
- Options.AddRange(
- DynamicGridOption.RecordCount,
- DynamicGridOption.SelectColumns,
- DynamicGridOption.FilterRows
- );
- HiddenColumns.Add(x => x.Customer.ID);
- HiddenColumns.Add(x => x.ID);
- HiddenColumns.Add(x => x.JobStatus.Active);
- ActionColumns.Add(new DynamicMapColumn<Job>(this, x => x.SiteAddress.Location));
- }
- public Guid StatusID
- {
- get => _statusid;
- set
- {
- _statusid = value;
- Refresh(false, true);
- }
- }
- protected override void Reload(Filters<Job> criteria, Columns<Job> columns, ref SortOrder<Job> sort, Action<CoreTable, Exception> action)
- {
- if (_statusid != Guid.Empty)
- criteria.Add(new Filter<Job>(x => x.JobStatus.ID).IsEqualTo(_statusid));
- sort = new SortOrder<Job>(x => x.JobNumber, SortDirection.Descending);
- base.Reload(criteria, columns, ref sort, action);
- }
- public override DynamicEditorPages LoadEditorPages(Job item)
- {
- var pages = new DynamicEditorPages(new IDynamicEditorPage[]
- {
- new DynamicManyToManyGrid<JobDocument,Job>(),
- new DynamicManyToManyGrid<JobStyle,Job>(),
- new DynamicOneToManyGrid<Job,JobDocumentSetTag>(),
- new JobFormDefinitionGrid()
- });
- return pages;
- }
- protected override Job CreateItem()
- {
- var result = base.CreateItem();
- var defstatus = new Client<JobStatus>().Query(new Filter<JobStatus>(x => x.Default).IsEqualTo(true));
- if (defstatus.Rows.Any())
- result.JobStatus.ID = defstatus.Rows.First().Get<JobStatus, Guid>(x => x.ID);
- return result;
- }
- }
- }
|