|  | @@ -0,0 +1,47 @@
 | 
	
		
			
				|  |  | +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);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 |