Browse Source

Added equipment fuel type class.

Kenric Nugteren 5 months ago
parent
commit
ba9c1fba6b

+ 22 - 42
prs.classes/Entities/Equipment/Equipment.cs

@@ -5,37 +5,9 @@ using InABox.Core;
 
 namespace Comal.Classes
 {
-    public class EquipmentDocumentCount : CoreAggregate<Equipment, EquipmentDocument, Guid>, IExportable, IImportable, IMergeable
-    {
-        public override Expression<Func<EquipmentDocument, Guid>> Aggregate => x => x.ID;
-
-        public override AggregateCalculation Calculation => AggregateCalculation.Count;
-
-        public override Dictionary<Expression<Func<EquipmentDocument, object>>, Expression<Func<Equipment, object>>> Links =>
-            new Dictionary<Expression<Func<EquipmentDocument, object>>, Expression<Func<Equipment, object>>>()
-            {
-                { EquipmentDocument => EquipmentDocument.EntityLink.ID, Equipment => Equipment.ID }
-            };
-    }
-    
-    public class EquipmentKanbanCount : CoreAggregate<Equipment, Kanban, Guid>, IExportable, IImportable, IMergeable
-    {
-        public override Expression<Func<Kanban, Guid>> Aggregate => x => x.ID;
-
-        public override AggregateCalculation Calculation => AggregateCalculation.Count;
-
-        public override Dictionary<Expression<Func<Kanban, object>>, Expression<Func<Equipment, object>>> Links =>
-            new Dictionary<Expression<Func<Kanban, object>>, Expression<Func<Equipment, object>>>()
-            {
-                { Kanban => Kanban.Equipment.ID, Equipment => Equipment.ID }
-            };
-    }
-
     [UserTracking("Equipment")]
     public class Equipment : Entity, IPersistent, IRemotable, ISchedulable, ILicense<EquipmentLicense>, IEquipment, IExportable, IImportable, IOneToMany<Customer>
     {
-        
-        
         [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
         [EditorSequence(1)]
         public string Code { get; set; }
@@ -77,49 +49,44 @@ namespace Comal.Classes
         public string SerialNumber { get; set; }
 
         [Obsolete("Replaced with ManufacturedDate")]
-        [EditorSequence(12)]
+        [NullEditor]
         public int YearOfManufacture { get; set; }
 
         [DateEditor]
-        [EditorSequence(13)]
+        [EditorSequence(12)]
         public DateTime ManufacturedDate { get; set; }
 
-        [EditorSequence(14)]
+        [EditorSequence(13)]
         public CustomerLink Customer { get; set; }
         
-        [CheckBoxEditor]
-        [EditorSequence(15)]
+        [EditorSequence(14)]
         public bool Private { get; set; }
 
+        [EditorSequence(15)]
+        public EquipmentFuelTypeLink FuelType { get; set; }
+
         [EntityRelationship(DeleteAction.SetNull)]
         [EditorSequence("Counters", 1)]
         public GPSTrackerLink TrackerLink { get; set; }
 
-        [DoubleEditor]
         [EditorSequence("Counters", 2)]
         public double Hours { get; set; }
 
-        [DoubleEditor]
         [EditorSequence("Counters", 3)]
         public double Distance { get; set; }
 
-        [DoubleEditor]
         [EditorSequence("Counters", 4)]
         public double Counter1 { get; set; }
 
-        [DoubleEditor]
         [EditorSequence("Counters", 5)]
         public double Counter2 { get; set; }
 
-        [DoubleEditor]
         [EditorSequence("Counters", 6)]
         public double Counter3 { get; set; }
 
-        [DoubleEditor]
         [EditorSequence("Counters", 7)]
         public double Counter4 { get; set; }
 
-        [DoubleEditor]
         [EditorSequence("Counters", 8)]
         public double Counter5 { get; set; }
 
@@ -134,11 +101,24 @@ namespace Comal.Classes
         [IntegerEditor(Editable = Editable.Hidden)]
         public int ActiveSchedules { get; set; }
         
-        [Aggregate(typeof(EquipmentDocumentCount))]
+        private class DocumentCountFormula : ComplexFormulaGenerator<Equipment, int>
+        {
+            public override IComplexFormulaNode<Equipment, int> GetFormula() =>
+                Count<EquipmentDocument, Guid>(
+                    x => x.Property(x => x.ID))
+                .WithLink(x => x.EntityLink.ID, x => x.ID);
+        }
+        [ComplexFormula(typeof(DocumentCountFormula))]
         [IntegerEditor(Editable = Editable.Hidden)]
         public int Documents { get; set; }
         
-        [Aggregate(typeof(EquipmentKanbanCount))]
+        private class KanbanCountFormula : ComplexFormulaGenerator<Equipment, int>
+        {
+            public override IComplexFormulaNode<Equipment, int> GetFormula() =>
+                Count<Kanban, Guid>(x => x.Property(x => x.ID))
+                .WithLink(x => x.Equipment.ID, x => x.ID);
+        }
+        [ComplexFormula(typeof(KanbanCountFormula))]
         [IntegerEditor(Editable = Editable.Hidden)]
         public int Kanbans { get; set; }
 

+ 31 - 0
prs.classes/Entities/Equipment/EquipmentFuelType.cs

@@ -0,0 +1,31 @@
+using InABox.Core;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Comal.Classes
+{
+    public class EquipmentFuelType : Entity, IRemotable, IPersistent
+    {
+        [UniqueCodeEditor]
+        public string Code { get; set; } = "";
+
+        public string Description { get; set; } = "";
+
+        static EquipmentFuelType()
+        {
+            DefaultColumns.Add<EquipmentFuelType>(x => x.Code);
+            DefaultColumns.Add<EquipmentFuelType>(x => x.Description);
+        }
+    }
+
+    public class EquipmentFuelTypeLink : EntityLink<EquipmentFuelType>
+    {
+        [CodePopupEditor(typeof(EquipmentFuelType))]
+        public override Guid ID { get; set; }
+
+        public string Code { get; set; } = "";
+
+        public string Description { get; set; } = "";
+    }
+}

+ 243 - 245
prs.desktop/Panels/Equipment/EquipmentPanel.xaml.cs

@@ -16,318 +16,316 @@ using InABox.DynamicGrid;
 using InABox.WPF;
 using InABox.Wpf;
 
-namespace PRSDesktop
+namespace PRSDesktop;
+
+public class EquipmentPanelSettings : BaseObject, IGlobalConfigurationSettings
+{
+    public bool CustomerFilterEnabled { get; set; }
+
+    public EquipmentPanelSettings()
+    {
+        CustomerFilterEnabled = false;
+    }
+}
+
+/// <summary>
+///     Interaction logic for EquipmentPanel.xaml
+/// </summary>
+public partial class EquipmentPanel : UserControl, IPanel<Equipment>
 {
+
+    private EquipmentPanelSettings _settings = null;
     
+    private String _searchfilter = "";
     
-    public class EquipmentPanelSettings : BaseObject, IGlobalConfigurationSettings
-    {
-        public bool CustomerFilterEnabled { get; set; }
+    public ObservableCollection<Tuple<string, Guid, BitmapImage>> GroupList { get; private set; }
 
-        public EquipmentPanelSettings()
-        {
-            CustomerFilterEnabled = false;
-        }
+    public bool IsReady { get; set; }
+
+    private String _customercode = "";
+    private List<Tuple<Guid, String, String>> _customers;
+
+    public EquipmentPanel()
+    {
+        GroupList = new ObservableCollection<Tuple<string, Guid, BitmapImage>>();
+        
+        InitializeComponent();
     }
     
-    /// <summary>
-    ///     Interaction logic for EquipmentPanel.xaml
-    /// </summary>
-    public partial class EquipmentPanel : UserControl, IPanel<Equipment>
+    public Type DataType()
     {
+        return typeof(Equipment);
+    }
 
-        private EquipmentPanelSettings _settings = null;
-        
-        private String _searchfilter = "";
-        
-        public ObservableCollection<Tuple<string, Guid, BitmapImage>> GroupList { get; private set; }
 
-        public bool IsReady { get; set; }
+    public event DataModelUpdateEvent? OnUpdateDataModel;
 
-        private String _customercode = "";
-        private List<Tuple<Guid, String, String>> _customers;
+    public Dictionary<string, object[]> Selected()
+    {
+        return new Dictionary<string, object[]> { { typeof(Equipment).EntityName(), _Equipment.SelectedRows } };
+    }
 
-        public EquipmentPanel()
-        {
-            GroupList = new ObservableCollection<Tuple<string, Guid, BitmapImage>>();
+    public void Setup()
+    {
+        
+        _Equipment.CustomerID = Guid.Empty;
+        _Equipment.GroupID = CoreUtils.FullGuid;
+        
+        _settings = new GlobalConfiguration<EquipmentPanelSettings>().Load();
+        ReconfigurePanel();
+        
+        _Equipment.Refresh(true, false);
+        
+        GroupList.Add(new Tuple<string, Guid, BitmapImage>("All Items", CoreUtils.FullGuid, PRSDesktop.Resources.edit.AsBitmapImage()));
+        var groups = new Client<EquipmentGroup>().Query(
+            null,
+            Columns.None<EquipmentGroup>().Add(x=>x.ID)
+                .Add(x=>x.Description)
+                .Add(x=>x.Thumbnail.ID),
+            new SortOrder<EquipmentGroup>(x => x.Code)
+        );
             
-            InitializeComponent();
-        }
+        var ids = groups.ExtractValues<EquipmentGroup, Guid>(c => c.Thumbnail.ID).Distinct().Where(x => x != Guid.Empty).ToArray();
+        var Images = ids.Any()
+            ? new Client<Document>().Load(new Filter<Document>(x=>x.ID).InList(ids))
+            : new Document[] { };
         
-        public Type DataType()
-        {
-            return typeof(Equipment);
-        }
-
-
-        public event DataModelUpdateEvent? OnUpdateDataModel;
-
-        public Dictionary<string, object[]> Selected()
+        foreach (var row in groups.Rows)
         {
-            return new Dictionary<string, object[]> { { typeof(Equipment).EntityName(), _Equipment.SelectedRows } };
-        }
-
-        public void Setup()
-        {
-            
-            _Equipment.CustomerID = Guid.Empty;
-            _Equipment.GroupID = CoreUtils.FullGuid;
-            
-            _settings = new GlobalConfiguration<EquipmentPanelSettings>().Load();
-            ReconfigurePanel();
-            
-            _Equipment.Refresh(true, false);
-            
-            GroupList.Add(new Tuple<string, Guid, BitmapImage>("All Items", CoreUtils.FullGuid, PRSDesktop.Resources.edit.AsBitmapImage()));
-            var groups = new Client<EquipmentGroup>().Query(
-                null,
-                Columns.None<EquipmentGroup>().Add(x=>x.ID)
-                    .Add(x=>x.Description)
-                    .Add(x=>x.Thumbnail.ID),
-                new SortOrder<EquipmentGroup>(x => x.Code)
+            var image = Images.FirstOrDefault(x => x.ID.Equals(row.Get<EquipmentGroup,Guid>(c=>c.Thumbnail.ID)));
+            var img = ImageUtils.LoadImage(image?.Data) ?? PRSDesktop.Resources.specifications.AsBitmapImage();
+
+            GroupList.Add(
+                new Tuple<string, Guid, BitmapImage>(
+                    row.Get<EquipmentGroup,String>(c=>c.Description), 
+                    row.Get<EquipmentGroup,Guid>(c=>c.ID), 
+                    img
+                )
             );
-                
-            var ids = groups.ExtractValues<EquipmentGroup, Guid>(c => c.Thumbnail.ID).Distinct().Where(x => x != Guid.Empty).ToArray();
-            var Images = ids.Any()
-                ? new Client<Document>().Load(new Filter<Document>(x=>x.ID).InList(ids))
-                : new Document[] { };
-            
-            foreach (var row in groups.Rows)
-            {
-                var image = Images.FirstOrDefault(x => x.ID.Equals(row.Get<EquipmentGroup,Guid>(c=>c.Thumbnail.ID)));
-                var img = ImageUtils.LoadImage(image?.Data) ?? PRSDesktop.Resources.specifications.AsBitmapImage();
-
-                GroupList.Add(
-                    new Tuple<string, Guid, BitmapImage>(
-                        row.Get<EquipmentGroup,String>(c=>c.Description), 
-                        row.Get<EquipmentGroup,Guid>(c=>c.ID), 
-                        img
-                    )
-                );
-            }
-            
-            Groups.Visibility = groups.Rows.Any() ? Visibility.Visible : Visibility.Collapsed;
-            Groups.ItemsSource = GroupList;
-            Groups.SelectedIndex = 0;
         }
+        
+        Groups.Visibility = groups.Rows.Any() ? Visibility.Visible : Visibility.Collapsed;
+        Groups.ItemsSource = GroupList;
+        Groups.SelectedIndex = 0;
+    }
 
-        public void Shutdown(CancelEventArgs? cancel)
-        {
-        }
-
-        public void CreateToolbarButtons(IPanelHost host)
-        {
-            EquipmentSetupActions.TrackerTypes(host);
-            EquipmentSetupActions.WebStickers(host);
-            EquipmentSetupActions.DigitalKeys(host);
-            EquipmentSetupActions.EquipmentGroups(host);
-
-            host.CreateSetupSeparator();
+    public void Shutdown(CancelEventArgs? cancel)
+    {
+    }
 
-            host.CreateSetupAction(new PanelAction() { Caption = "Equipment Settings", Image = PRSDesktop.Resources.specifications, OnExecute = EquipmentSettingsClick });
-            host.CreateSetupAction(new PanelAction() { Caption = "EditGeofences", Image = PRSDesktop.Resources.map, OnExecute = EditGeofencesClick});
-        }
+    public void CreateToolbarButtons(IPanelHost host)
+    {
+        EquipmentSetupActions.TrackerTypes(host);
+        EquipmentSetupActions.WebStickers(host);
+        EquipmentSetupActions.DigitalKeys(host);
+        EquipmentSetupActions.EquipmentGroups(host);
+        EquipmentSetupActions.FuelTypes(host);
 
-        private void EditGeofencesClick(PanelAction obj)
-        {
-            new MasterList(typeof(GeoFence)).ShowDialog();
-        }
+        host.CreateSetupSeparator();
 
-        private void EquipmentSettingsClick(PanelAction obj)
-        {
-            var pages = new DynamicEditorPages();
-            var buttons = new DynamicEditorButtons();
-            buttons.Add(
-                "",
-                PRSDesktop.Resources.help.AsBitmapImage(),
-                _settings,
-                (f, i) =>
-                {
-                    Process.Start(new ProcessStartInfo("https://prsdigital.com.au/wiki/index.php/" + typeof(Equipment).Name.SplitCamelCase().Replace(" ", "_"))
-                        { UseShellExecute = true });
-                }
-            );
-            var propertyEditor = new DynamicEditorForm(typeof(EquipmentPanelSettings), pages, buttons);
+        host.CreateSetupAction("Equipment Settings", PRSDesktop.Resources.specifications, EquipmentSettingsClick);
+        host.CreateSetupAction("Edit Geofences", PRSDesktop.Resources.map, EditGeofencesClick);
+    }
 
-            propertyEditor.Items = new BaseObject[] { _settings };
+    private void EditGeofencesClick(PanelAction obj)
+    {
+        new MasterList(typeof(GeoFence)).ShowDialog();
+    }
 
-            if (propertyEditor.ShowDialog() == true)
+    private void EquipmentSettingsClick(PanelAction obj)
+    {
+        var pages = new DynamicEditorPages();
+        var buttons = new DynamicEditorButtons();
+        buttons.Add(
+            "",
+            PRSDesktop.Resources.help.AsBitmapImage(),
+            _settings,
+            (f, i) =>
             {
-                new GlobalConfiguration<EquipmentPanelSettings>().Save(_settings);
-                ReconfigurePanel();
+                Process.Start(new ProcessStartInfo("https://prsdigital.com.au/wiki/index.php/" + typeof(Equipment).Name.SplitCamelCase().Replace(" ", "_"))
+                    { UseShellExecute = true });
             }
+        );
+        var propertyEditor = new DynamicEditorForm(typeof(EquipmentPanelSettings), pages, buttons);
 
-        }
+        propertyEditor.Items = new BaseObject[] { _settings };
 
-        private void ReconfigurePanel()
+        if (propertyEditor.ShowDialog() == true)
         {
-            CustomerLabel.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
-            Customer.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
-            CustomerSearch.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
-            CustomerName.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
-            
-            if (!_settings.CustomerFilterEnabled)
-            {
-                _Equipment.CustomerID = CoreUtils.FullGuid;
-                _customercode = "";
-                Customer.Text = "";
-                CustomerName.Text = "";
-            }
-            else if (_Equipment.CustomerID == CoreUtils.FullGuid)
-                    _Equipment.CustomerID = Guid.Empty;
-            
-            if (IsReady)
-                _Equipment.Refresh(false,true);
+            new GlobalConfiguration<EquipmentPanelSettings>().Save(_settings);
+            ReconfigurePanel();
         }
 
+    }
 
-        public void Refresh()
+    private void ReconfigurePanel()
+    {
+        CustomerLabel.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
+        Customer.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
+        CustomerSearch.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
+        CustomerName.Visibility = _settings.CustomerFilterEnabled ? Visibility.Visible : Visibility.Collapsed;
+        
+        if (!_settings.CustomerFilterEnabled)
         {
-            _Equipment.Refresh(false, true);
+            _Equipment.CustomerID = CoreUtils.FullGuid;
+            _customercode = "";
+            Customer.Text = "";
+            CustomerName.Text = "";
         }
+        else if (_Equipment.CustomerID == CoreUtils.FullGuid)
+                _Equipment.CustomerID = Guid.Empty;
+        
+        if (IsReady)
+            _Equipment.Refresh(false,true);
+    }
 
-        public string SectionName => "Equipment";
 
-        public DataModel DataModel(Selection selection)
-        {
-            var ids = _Equipment?.ExtractValues(x => x.ID, selection)?.ToArray() ?? new Guid[] { };
-            return new BaseDataModel<Equipment>(new Filter<Equipment>(x => x.ID).InList(ids));
-        }
+    public void Refresh()
+    {
+        _Equipment.Refresh(false, true);
+    }
 
-        public void Heartbeat(TimeSpan time)
-        {
-        }
-        
-        
-        private bool _Equipment_OnFilterRecord(CoreRow row)
+    public string SectionName => "Equipment";
+
+    public DataModel DataModel(Selection selection)
+    {
+        var ids = _Equipment?.ExtractValues(x => x.ID, selection)?.ToArray() ?? new Guid[] { };
+        return new BaseDataModel<Equipment>(new Filter<Equipment>(x => x.ID).InList(ids));
+    }
+
+    public void Heartbeat(TimeSpan time)
+    {
+    }
+    
+    
+    private bool _Equipment_OnFilterRecord(CoreRow row)
+    {
+        if (!string.IsNullOrWhiteSpace(_searchfilter))
         {
-            if (!string.IsNullOrWhiteSpace(_searchfilter))
+            for (int i=0; i<row.Table.Columns.Count; i++)
             {
-                for (int i=0; i<row.Table.Columns.Count; i++)
+                if ((row.Table.Columns[i].DataType == typeof(String)))
                 {
-                    if ((row.Table.Columns[i].DataType == typeof(String)))
-                    {
-                        var value = row.Values[i] as string;
-                        if (!string.IsNullOrEmpty(value) && value.ToUpper().Contains(_searchfilter.ToUpper()))
-                            return true;
-                    }
+                    var value = row.Values[i] as string;
+                    if (!string.IsNullOrEmpty(value) && value.ToUpper().Contains(_searchfilter.ToUpper()))
+                        return true;
                 }
-
-                return false;
             }
-            
-            return true;
 
+            return false;
         }
+        
+        return true;
 
-        private void Groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            var sCur = _Equipment.GroupID;
-            if (e.AddedItems.Count == 0 || Groups.SelectedIndex == 0)
-            {
-                _Equipment.GroupID = CoreUtils.FullGuid;
-            }
-            else
-            {
-                var selected = (Tuple<string, Guid, BitmapImage>)e.AddedItems[0];
-                _Equipment.GroupID = selected.Item2;
-            }
+    }
 
-            if (sCur != _Equipment.GroupID)
-                _Equipment.Refresh(false, true);
+    private void Groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
+    {
+        var sCur = _Equipment.GroupID;
+        if (e.AddedItems.Count == 0 || Groups.SelectedIndex == 0)
+        {
+            _Equipment.GroupID = CoreUtils.FullGuid;
         }
-        
-        private void Search_OnTextChanged(object sender, TextChangedEventArgs e)
+        else
         {
-            if (string.IsNullOrEmpty(Search.Text)  && !string.Equals(Search.Text, _searchfilter))
-            {
-                _searchfilter = "";
-                _Equipment.Refresh(false, false);
-            }
+            var selected = (Tuple<string, Guid, BitmapImage>)e.AddedItems[0];
+            _Equipment.GroupID = selected.Item2;
         }
 
-        private void Search_OnKeyUp(object sender, KeyEventArgs e)
+        if (sCur != _Equipment.GroupID)
+            _Equipment.Refresh(false, true);
+    }
+    
+    private void Search_OnTextChanged(object sender, TextChangedEventArgs e)
+    {
+        if (string.IsNullOrEmpty(Search.Text)  && !string.Equals(Search.Text, _searchfilter))
         {
-            if (new Key[] { Key.Enter, Key.Return }.Contains(e.Key) && !String.Equals(Search.Text, _searchfilter))
-            {
-                _searchfilter = Search.Text;
-                _Equipment.Refresh(false, false);
-            }
+            _searchfilter = "";
+            _Equipment.Refresh(false, false);
         }
+    }
 
-        private void CheckCustomerCache()
+    private void Search_OnKeyUp(object sender, KeyEventArgs e)
+    {
+        if (new Key[] { Key.Enter, Key.Return }.Contains(e.Key) && !String.Equals(Search.Text, _searchfilter))
         {
-            if (_customers == null)
-            {
-                _customers = new Client<Customer>().Query(
-                    null,
-                    Columns.None<Customer>().Add(x => x.ID).Add(x => x.Code).Add(x => x.Name),
-                    new SortOrder<Customer>(x => x.Name)
-                ).ToTuples<Customer,Guid,String,String>(x =>x.ID,x=>x.Code,x=>x.Name).ToList();
-            }
+            _searchfilter = Search.Text;
+            _Equipment.Refresh(false, false);
         }
-        
-        private void DoSearchCustomers()
+    }
+
+    private void CheckCustomerCache()
+    {
+        if (_customers == null)
         {
-            var dlg = new MultiSelectDialog<Customer>(
+            _customers = new Client<Customer>().Query(
                 null,
-                Columns.None<Customer>().Add(x => x.ID).Add(x => x.Code).Add(x => x.Name), false);
-            if (dlg.ShowDialog("Code",Customer.Text))
-            {
-                var customer = dlg.Items().First();
-                _customercode = customer.Code;
-                Customer.Text = customer.Code;
-                CustomerName.Text = customer.Name;
-                _Equipment.CustomerID = customer.ID;
-            }
-            else
-            {
-                _customercode = "";
-                Customer.Text = "";
-                CustomerName.Text = "";
-                _Equipment.CustomerID = Guid.Empty;
-            }
-
-            _Equipment.Refresh(false, true);
+                Columns.None<Customer>().Add(x => x.ID).Add(x => x.Code).Add(x => x.Name),
+                new SortOrder<Customer>(x => x.Name)
+            ).ToTuples<Customer,Guid,String,String>(x =>x.ID,x=>x.Code,x=>x.Name).ToList();
         }
-        
-        private void CustomerSearch_OnClick(object sender, RoutedEventArgs e)
+    }
+    
+    private void DoSearchCustomers()
+    {
+        var dlg = new MultiSelectDialog<Customer>(
+            null,
+            Columns.None<Customer>().Add(x => x.ID).Add(x => x.Code).Add(x => x.Name), false);
+        if (dlg.ShowDialog("Code",Customer.Text))
         {
-            DoSearchCustomers();
+            var customer = dlg.Items().First();
+            _customercode = customer.Code;
+            Customer.Text = customer.Code;
+            CustomerName.Text = customer.Name;
+            _Equipment.CustomerID = customer.ID;
+        }
+        else
+        {
+            _customercode = "";
+            Customer.Text = "";
+            CustomerName.Text = "";
+            _Equipment.CustomerID = Guid.Empty;
         }
 
-        
-        private void Customer_OnKeyUp(object sender, KeyEventArgs e)
+        _Equipment.Refresh(false, true);
+    }
+    
+    private void CustomerSearch_OnClick(object sender, RoutedEventArgs e)
+    {
+        DoSearchCustomers();
+    }
+
+    
+    private void Customer_OnKeyUp(object sender, KeyEventArgs e)
+    {
+        if (new Key[] { Key.Enter, Key.Return }.Contains(e.Key))
         {
-            if (new Key[] { Key.Enter, Key.Return }.Contains(e.Key))
-            {
 
-                if (!String.Equals(Customer.Text, _customercode))
+            if (!String.Equals(Customer.Text, _customercode))
+            {
+                CheckCustomerCache();
+                var lookup = _customers.FirstOrDefault(x => String.Equals(x.Item2, Customer.Text));
+                if (lookup != null)
                 {
-                    CheckCustomerCache();
-                    var lookup = _customers.FirstOrDefault(x => String.Equals(x.Item2, Customer.Text));
-                    if (lookup != null)
-                    {
-                        _customercode = lookup.Item2;
-                        CustomerName.Text = lookup.Item3;
-                        _Equipment.CustomerID = lookup.Item1;
-                        _Equipment.Refresh(false, true);
-                    }
-                    else
-                        DoSearchCustomers();
+                    _customercode = lookup.Item2;
+                    CustomerName.Text = lookup.Item3;
+                    _Equipment.CustomerID = lookup.Item1;
+                    _Equipment.Refresh(false, true);
                 }
+                else
+                    DoSearchCustomers();
             }
         }
+    }
 
-        private void Customer_OnTextChanged(object sender, TextChangedEventArgs e)
+    private void Customer_OnTextChanged(object sender, TextChangedEventArgs e)
+    {
+        if (String.IsNullOrEmpty(Customer.Text)  && !String.Equals(Customer.Text, _customercode))
         {
-            if (String.IsNullOrEmpty(Customer.Text)  && !String.Equals(Customer.Text, _customercode))
-            {
-                _Equipment.CustomerID = Guid.Empty;
-                _customercode = "";
-                CustomerName.Text = "";
-                _Equipment.Refresh(false, true);
-            }
+            _Equipment.CustomerID = Guid.Empty;
+            _customercode = "";
+            CustomerName.Text = "";
+            _Equipment.Refresh(false, true);
         }
     }
 }

+ 31 - 31
prs.desktop/Panels/EquipmentPlanner/EquipmentPlannerPanel.cs

@@ -6,40 +6,40 @@ using InABox.Core;
 using InABox.Wpf;
 using Microsoft.Exchange.WebServices.Data;
 
-namespace PRSDesktop
+namespace PRSDesktop;
+
+public class EquipmentPlannerPanel : EquipmentPlanner, IPanel<Assignment>
 {
-    public class EquipmentPlannerPanel : EquipmentPlanner, IPanel<Assignment>
-    {
 
-        public EquipmentPlannerPanel()
-        {
-            SectionName = nameof(EquipmentPlannerPanel);
-            LoadSettings += (sender) => new UserConfiguration<EquipmentPlannerProperties>(nameof(EquipmentPlannerPanel)).Load();
-            SaveSettings += (sender, properties) => new UserConfiguration<EquipmentPlannerProperties>(nameof(EquipmentPlannerPanel)).Save(properties);
-        }
-        
-        public string SectionName { get; }
-        
-        public DataModel DataModel(Selection selection)
-        {
-            return new AutoDataModel<Assignment>(new Filter<Assignment>(x=>x.ID).IsEqualTo(Guid.Empty));
-        }
+    public EquipmentPlannerPanel()
+    {
+        SectionName = nameof(EquipmentPlannerPanel);
+        LoadSettings += (sender) => new UserConfiguration<EquipmentPlannerProperties>(nameof(EquipmentPlannerPanel)).Load();
+        SaveSettings += (sender, properties) => new UserConfiguration<EquipmentPlannerProperties>(nameof(EquipmentPlannerPanel)).Save(properties);
+    }
+    
+    public string SectionName { get; }
+    
+    public DataModel DataModel(Selection selection)
+    {
+        return new AutoDataModel<Assignment>(new Filter<Assignment>(x=>x.ID).IsEqualTo(Guid.Empty));
+    }
 
-        public event DataModelUpdateEvent? OnUpdateDataModel;
-        
-        public bool IsReady { get; set; }
-        
-        public void CreateToolbarButtons(IPanelHost host)
-        {
-            EquipmentSetupActions.TrackerTypes(host);
-            EquipmentSetupActions.WebStickers(host);
-            EquipmentSetupActions.DigitalKeys(host);
-            EquipmentSetupActions.EquipmentGroups(host);
-        }
+    public event DataModelUpdateEvent? OnUpdateDataModel;
+    
+    public bool IsReady { get; set; }
+    
+    public void CreateToolbarButtons(IPanelHost host)
+    {
+        EquipmentSetupActions.TrackerTypes(host);
+        EquipmentSetupActions.WebStickers(host);
+        EquipmentSetupActions.DigitalKeys(host);
+        EquipmentSetupActions.EquipmentGroups(host);
+        EquipmentSetupActions.FuelTypes(host);
+    }
 
-        public Dictionary<string, object[]> Selected()
-        {
-            return new Dictionary<string, object[]>();
-        }
+    public Dictionary<string, object[]> Selected()
+    {
+        return new Dictionary<string, object[]>();
     }
 }

+ 10 - 0
prs.desktop/Setups/EquipmentSetupActions.cs

@@ -40,6 +40,16 @@ public static class EquipmentSetupActions
         list.ShowDialog();
     }
 
+    public static void FuelTypes(IPanelHost host)
+    {
+        host.CreateSetupActionIfCanView<EquipmentFuelType>("Equipment Fuel Types", PRSDesktop.Resources.specifications, EquipmentFuelTypeList_Click);
+    }
+    private static void EquipmentFuelTypeList_Click(PanelAction action)
+    {
+        var list = new MasterList(typeof(EquipmentFuelType));
+        list.ShowDialog();
+    }
+
     public static void EquipmentGroups(IPanelHost host)
     {
         host.CreateSetupActionIfCanView<EquipmentGroup>("Equipment Groups", PRSDesktop.Resources.specifications, EquipmentGroupList_Click);