12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Linq;
- using System.Windows;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- public class JobTimesheetGrid : TimesheetGrid, IJobControl, IDataModelSource
- {
- public JobTimesheetGrid()
- {
- Options.AddRange(
- DynamicGridOption.RecordCount,
- DynamicGridOption.FilterRows,
- DynamicGridOption.MultiSelect,
- DynamicGridOption.EditRows
- );
- }
- public event DataModelUpdateEvent OnUpdateDataModel;
- public string SectionName => "Job Timesheets";
- public DataModel DataModel(Selection selection)
- {
- var ids = ExtractValues(x => x.ID, selection).ToArray();
- return new BaseDataModel<TimeSheet>(new Filter<TimeSheet>(x => x.ID).InList(ids));
- }
- public Guid ParentID { get; set; }
-
- public JobPanelSettings Settings { get; set; }
- protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
- {
- if (ParentID.Equals(Guid.Empty) || ParentID.Equals(CoreUtils.FullGuid))
- MessageBox.Show("Please select a Job first!");
- else
- base.DoAdd();
- }
- protected override TimeSheet CreateItem()
- {
- var result = base.CreateItem();
- result.JobLink.ID = ParentID;
- return result;
- }
- protected override void Reload(Filters<TimeSheet> criteria, Columns<TimeSheet> columns, ref SortOrder<TimeSheet> sort,
- Action<CoreTable, Exception> action)
- {
- criteria.Add(new Filter<TimeSheet>(x => x.JobLink.ID).IsEqualTo(ParentID));
- base.Reload(criteria, columns, ref sort, action);
- }
- }
- }
|