1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Linq.Expressions;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- public class EmployeeJobGrid : DynamicCrossJoinGrid<JobEmployee,Employee>
- {
- public override Expression<Func<JobEmployee, Guid>> LeftMapping => x => x.EmployeeLink.ID;
- public override Expression<Func<Employee, Guid>> LeftProperty => x => x.ID;
-
- private Button _status;
- private bool _activeonly = true;
-
- public EmployeeJobGrid()
- {
- _status = AddButton("Show All", null, ToggleActive);
- _status.Width = 80;
- }
-
- protected override void GenerateColumns(DynamicGridColumns columns)
- {
- columns.Add<JobEmployee, String>(x => x.JobLink.JobNumber, 70, "Job", "", Alignment.MiddleCenter);
- columns.Add<JobEmployee, String>(x => x.JobLink.Name, 0, "Job Name", "", Alignment.MiddleLeft);
- columns.Add<JobEmployee, DateTime>(x => x.Inducted, 70, "Inducted", "dd MMM yy", Alignment.MiddleCenter);
- columns.Add<JobEmployee, bool>(x => x.Active, 25, "Act", "", Alignment.MiddleCenter);
- }
- private bool ToggleActive(Button arg1, CoreRow[] arg2)
- {
- _activeonly = !_activeonly;
- UpdateButton(_status,null,_activeonly ? "Show All" : "Active Only");
- return true;
- }
- protected override void Reload(Filters<JobEmployee> criteria, Columns<JobEmployee> columns, ref SortOrder<JobEmployee>? sort, Action<CoreTable?, Exception?> action)
- {
- if (_activeonly)
- criteria.Add(new Filter<JobEmployee>(x => x.Active).IsEqualTo(true).And(x=>x.JobLink.JobStatus.Active).IsEqualTo(true));
- base.Reload(criteria, columns, ref sort, action);
- }
- }
- }
|