|  | @@ -16,14 +16,12 @@ using InABox.Clients;
 | 
	
		
			
				|  |  |  using InABox.Configuration;
 | 
	
		
			
				|  |  |  using InABox.Core;
 | 
	
		
			
				|  |  |  using InABox.DynamicGrid;
 | 
	
		
			
				|  |  | -using InABox.Reports;
 | 
	
		
			
				|  |  |  using InABox.Core.Reports;
 | 
	
		
			
				|  |  |  using InABox.Wpf.Reports;
 | 
	
		
			
				|  |  |  using InABox.WPF;
 | 
	
		
			
				|  |  |  using Motorola.Snapi;
 | 
	
		
			
				|  |  |  using Motorola.Snapi.Constants.Enums;
 | 
	
		
			
				|  |  |  using Motorola.Snapi.EventArguments;
 | 
	
		
			
				|  |  | -using org.apache.commons.io.comparator;
 | 
	
		
			
				|  |  |  using BarcodeType = Comal.Classes.BarcodeType;
 | 
	
		
			
				|  |  |  using Color = System.Drawing.Color;
 | 
	
		
			
				|  |  |  using Image = System.Windows.Controls.Image;
 | 
	
	
		
			
				|  | @@ -35,37 +33,47 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |      /// <summary>
 | 
	
		
			
				|  |  |      ///     Interaction logic for FactoryPanel.xaml
 | 
	
		
			
				|  |  |      /// </summary>
 | 
	
		
			
				|  |  | -    public partial class FactoryPanel : UserControl, IPanel<ManufacturingPacket>
 | 
	
		
			
				|  |  | +    public partial class FactoryPanel : IPanel<ManufacturingPacket>
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  | -        private Button _currentButton;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          private readonly BitmapImage barcode = PRSDesktop.Resources.barcode.AsBitmapImage();
 | 
	
		
			
				|  |  |          private readonly BitmapImage disabled = PRSDesktop.Resources.disabled.AsBitmapImage();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //private Document document = null;
 | 
	
		
			
				|  |  | -        private SetoutDocument[] documents = { };
 | 
	
		
			
				|  |  | +        private readonly BitmapImage speechbubble = PRSDesktop.Resources.speechbubble.AsBitmapImage();
 | 
	
		
			
				|  |  | +        private readonly BitmapImage starred = PRSDesktop.Resources.report.AsBitmapImage(48, 48);
 | 
	
		
			
				|  |  |          private readonly BitmapImage grouped = PRSDesktop.Resources.grouped.AsBitmapImage();
 | 
	
		
			
				|  |  | -        private readonly string NEARLYDUE_COLOR = "Orange";
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        private SetoutDocument[] documents = [];
 | 
	
		
			
				|  |  | +        private readonly List<IMotorolaBarcodeScanner> _scanners = [];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        private readonly string NEARLYDUE_COLOR = "Orange";
 | 
	
		
			
				|  |  |          private readonly string NOTYETDUE_COLOR = "PaleGreen";
 | 
	
		
			
				|  |  |          private readonly string OVERDUE_COLOR = "Salmon";
 | 
	
		
			
				|  |  | -        private PDFEditorControl PDFEditor;
 | 
	
		
			
				|  |  |          private readonly string PRIORITY_COLOR = "Red";
 | 
	
		
			
				|  |  |          private readonly string QA_COLOR = "Silver";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private QAGrid QAGrid;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public List<IMotorolaBarcodeScanner> Scanners = new();
 | 
	
		
			
				|  |  |          private readonly string SELECTED_COLOR = "Yellow";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private FactoryFloorLocalSettings settings;
 | 
	
		
			
				|  |  |          private readonly string SHARED_COLOR = "Lime";
 | 
	
		
			
				|  |  | -        private readonly BitmapImage speechbubble = PRSDesktop.Resources.speechbubble.AsBitmapImage();
 | 
	
		
			
				|  |  | -        private readonly BitmapImage starred = PRSDesktop.Resources.report.AsBitmapImage(48, 48);
 | 
	
		
			
				|  |  |          private readonly string TREATED_COLOR = "DarkOrchid";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        private Button? _currentButton;
 | 
	
		
			
				|  |  | +        private PDFEditorControl? PDFEditor;
 | 
	
		
			
				|  |  | +        private QAGrid? QAGrid;
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        private readonly FactoryFloorLocalSettings _settings;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        private readonly PanelAction _togglePackPanel;
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  |          public FactoryPanel()
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            _settings = new LocalConfiguration<FactoryFloorLocalSettings>().Load();
 | 
	
		
			
				|  |  | +            if (_settings.Section.Equals(CoreUtils.FullGuid) && _settings.Station.Equals(-1))
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                var user = new UserConfiguration<FactoryFloorSettings>().Load();
 | 
	
		
			
				|  |  | +                _settings.Section = user.Section;
 | 
	
		
			
				|  |  | +                _settings.Station = user.Station;
 | 
	
		
			
				|  |  | +                new LocalConfiguration<FactoryFloorLocalSettings>().Save(_settings);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  |              InitializeComponent();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              var CanConfigure = Security.IsAllowed<CanConfigureFactoryFloor>();
 | 
	
	
		
			
				|  | @@ -76,51 +84,66 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              Kanbans = new ObservableCollection<ManufacturingKanban>();
 | 
	
		
			
				|  |  |              RackContents.ItemsSource = rackcontents;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            RackPanel.Visibility = _settings.SidePanel == FactorySidePanel.Racks
 | 
	
		
			
				|  |  | +                ? Visibility.Visible
 | 
	
		
			
				|  |  | +                : Visibility.Collapsed;
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            PackPanel.Visibility = _settings.SidePanel == FactorySidePanel.Packs
 | 
	
		
			
				|  |  | +                ? Visibility.Visible
 | 
	
		
			
				|  |  | +                : Visibility.Collapsed;
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          public bool IsReady { get; set; }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          public void Setup()
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            settings = new LocalConfiguration<FactoryFloorLocalSettings>().Load();
 | 
	
		
			
				|  |  | -            if (settings.Section.Equals(CoreUtils.FullGuid) && settings.Station.Equals(-1))
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                var user = new UserConfiguration<FactoryFloorSettings>().Load();
 | 
	
		
			
				|  |  | -                settings.Section = user.Section;
 | 
	
		
			
				|  |  | -                settings.Station = user.Station;
 | 
	
		
			
				|  |  | -                settings.LineColor = ColorTranslator.ToHtml(Color.Red);
 | 
	
		
			
				|  |  | -                settings.FontSize = 16;
 | 
	
		
			
				|  |  | -                new LocalConfiguration<FactoryFloorLocalSettings>().Save(settings);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            var setups = Client.QueryMultiple(
 | 
	
		
			
				|  |  | -                new KeyedQueryDef<ManufacturingFactory>(),
 | 
	
		
			
				|  |  | -                new KeyedQueryDef<ManufacturingSection>(
 | 
	
		
			
				|  |  | -                    new Filter<ManufacturingSection>(x => x.Hidden).IsEqualTo(false),
 | 
	
		
			
				|  |  | -                    null,
 | 
	
		
			
				|  |  | -                    new SortOrder<ManufacturingSection>(x => x.Factory.Sequence).ThenBy(x => x.Sequence)),
 | 
	
		
			
				|  |  | -                new KeyedQueryDef<ManufacturingTrolley>(),
 | 
	
		
			
				|  |  | -                new KeyedQueryDef<Employee>(
 | 
	
		
			
				|  |  | -                    LookupFactory.DefineFilter<Employee>(),
 | 
	
		
			
				|  |  | -                    new Columns<Employee>(x => x.ID, x => x.Name, x => x.UserLink.ID),
 | 
	
		
			
				|  |  | -                    new SortOrder<Employee>(x => x.Name)),
 | 
	
		
			
				|  |  | -                new KeyedQueryDef<Shipment>(
 | 
	
		
			
				|  |  | -                    LookupFactory.DefineFilter<Shipment>(),
 | 
	
		
			
				|  |  | -                    new Columns<Shipment>(x => x.ID, x => x.Code, x => x.Description, x => x.BarCode),
 | 
	
		
			
				|  |  | -                    null));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            Factories = setups[nameof(ManufacturingFactory)].Rows.Select(x => x.ToObject<ManufacturingFactory>()).ToArray();
 | 
	
		
			
				|  |  | -            Sections = setups[nameof(ManufacturingSection)].Rows.Select(x => x.ToObject<ManufacturingSection>()).ToArray();
 | 
	
		
			
				|  |  | -            Trolleys = setups[nameof(ManufacturingTrolley)].Rows.Select(x => x.ToObject<ManufacturingTrolley>()).ToArray();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            Employees = setups[nameof(Employee)].ToDictionary<Employee, Guid, string>(x => x.ID, x => x.Name);
 | 
	
		
			
				|  |  | -            var myRow = setups[nameof(Employee)].Rows.FirstOrDefault(r => r.Get<Employee, Guid>(c => c.UserLink.ID).Equals(ClientFactory.UserGuid));
 | 
	
		
			
				|  |  | -            myID = myRow != null ? myRow.Get<Employee, Guid>(c => c.ID) : Guid.Empty;
 | 
	
		
			
				|  |  | -            myName = myRow != null ? myRow.Get<Employee, string>(c => c.Name) : "(Unknown Employee)";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            Shipments = setups[nameof(Shipment)];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            CurrentSection = Sections.FirstOrDefault(x => x.ID.Equals(settings.Section))
 | 
	
		
			
				|  |  | +            var setups = new MultiQuery();
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            setups.Add<ManufacturingFactory>();
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            setups.Add(
 | 
	
		
			
				|  |  | +                new Filter<ManufacturingSection>(x => x.Hidden).IsEqualTo(false),
 | 
	
		
			
				|  |  | +                null,
 | 
	
		
			
				|  |  | +                new SortOrder<ManufacturingSection>(x => x.Factory.Sequence).ThenBy(x => x.Sequence)
 | 
	
		
			
				|  |  | +            );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            setups.Add<ManufacturingTrolley>();
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            setups.Add(
 | 
	
		
			
				|  |  | +                LookupFactory.DefineFilter<Employee>(),
 | 
	
		
			
				|  |  | +                new Columns<Employee>(x => x.ID, x => x.Name, x => x.UserLink.ID),
 | 
	
		
			
				|  |  | +                new SortOrder<Employee>(x => x.Name)
 | 
	
		
			
				|  |  | +            );
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            setups.Add(
 | 
	
		
			
				|  |  | +                LookupFactory.DefineFilter<Shipment>(),
 | 
	
		
			
				|  |  | +                new Columns<Shipment>(x => x.ID, x => x.Code, x => x.Description, x => x.BarCode)
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            if (_settings.AreaID != Guid.Empty)
 | 
	
		
			
				|  |  | +                setups.Add(
 | 
	
		
			
				|  |  | +                    new Filter<StockArea>(x=>x.ID).IsEqualTo(_settings.AreaID),
 | 
	
		
			
				|  |  | +                    new Columns<StockArea>(x=>x.ID).Add(x=>x.Code).Add(x=>x.Description)
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            setups.Query();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            Factories = setups.Get<ManufacturingFactory>().Rows.Select(x => x.ToObject<ManufacturingFactory>()).ToArray();
 | 
	
		
			
				|  |  | +            Sections = setups.Get<ManufacturingSection>().Rows.Select(x => x.ToObject<ManufacturingSection>()).ToArray();
 | 
	
		
			
				|  |  | +            Trolleys = setups.Get<ManufacturingTrolley>().Rows.Select(x => x.ToObject<ManufacturingTrolley>()).ToArray();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            Employees = setups.Get<Employee>().ToDictionary<Employee, Guid, string>(x => x.ID, x => x.Name);
 | 
	
		
			
				|  |  | +            var myRow = setups.Get<Employee>().Rows.FirstOrDefault(r => r.Get<Employee, Guid>(c => c.UserLink.ID).Equals(ClientFactory.UserGuid));
 | 
	
		
			
				|  |  | +            myID = myRow?.Get<Employee, Guid>(c => c.ID) ?? Guid.Empty;
 | 
	
		
			
				|  |  | +            myName = myRow?.Get<Employee, string>(c => c.Name) ?? "(Unknown Employee)";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            Shipments = setups.Get<Shipment>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            CurrentSection = Sections.FirstOrDefault(x => x.ID.Equals(_settings.Section))
 | 
	
		
			
				|  |  |                  ?? Sections.FirstOrDefault();
 | 
	
		
			
				|  |  |              var iSection = 0;
 | 
	
		
			
				|  |  |              var iCount = 0;
 | 
	
	
		
			
				|  | @@ -132,16 +155,16 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                      iCount = section.Stations; //Sections[id].Item2;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                Section.Items.Add(string.Format("{0}: {1}", section.Factory.Name, section.Name));
 | 
	
		
			
				|  |  | +                Section.Items.Add($"{section.Factory.Name}: {section.Name}");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              Section.SelectedIndex = iSection;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              Station.Items.Clear();
 | 
	
		
			
				|  |  | -            for (var i = 1; i <= (CurrentSection != null ? CurrentSection.Stations : 0); i++)
 | 
	
		
			
				|  |  | -                Station.Items.Add(string.Format("Station #{0}", i));
 | 
	
		
			
				|  |  | +            for (var i = 1; i <= (CurrentSection?.Stations ?? 0); i++)
 | 
	
		
			
				|  |  | +                Station.Items.Add($"Station #{i}");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            CurrentStation = settings.Station + 1;
 | 
	
		
			
				|  |  | +            CurrentStation = _settings.Station + 1;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (CurrentStation < 1)
 | 
	
		
			
				|  |  |                  CurrentStation = 1;
 | 
	
	
		
			
				|  | @@ -151,6 +174,32 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              Station.SelectedIndex = CurrentStation - 1;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            if (_settings.AreaID != Guid.Empty)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                var area = setups.Get<StockArea>().ToObjects<StockArea>().FirstOrDefault();
 | 
	
		
			
				|  |  | +                if (area != null)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    _packGrid.AreaID = _settings.AreaID;
 | 
	
		
			
				|  |  | +                    _packGrid.AreaDescription = $"{area.Code}: {area.Description}";
 | 
	
		
			
				|  |  | +                    _addPack.IsEnabled = true;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                else
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    _packGrid.AreaID = CoreUtils.FullGuid;
 | 
	
		
			
				|  |  | +                    _packGrid.AreaDescription = "(No Area Selected)";
 | 
	
		
			
				|  |  | +                    _settings.AreaID = Guid.Empty;
 | 
	
		
			
				|  |  | +                    new LocalConfiguration<FactoryFloorLocalSettings>().Save(_settings);
 | 
	
		
			
				|  |  | +                    _addPack.IsEnabled = false;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                _packGrid.AreaID = CoreUtils.FullGuid;
 | 
	
		
			
				|  |  | +                _packGrid.AreaDescription = "(No Area Selected)";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            _packGrid.Refresh(true,true);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              SetupScanner();
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -180,6 +229,24 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |              host.CreatePanelAction(new PanelAction { Caption = "Select Rack", Image = PRSDesktop.Resources.forklift, OnExecute = DoSelectRack });
 | 
	
		
			
				|  |  |              host.CreatePanelAction(new PanelAction { Caption = "Close Rack", Image = PRSDesktop.Resources.forklift, OnExecute = DoCloseRack });
 | 
	
		
			
				|  |  |              host.CreatePanelAction(new PanelAction { Caption = "Scan Barcode", Image = PRSDesktop.Resources.product, OnExecute = DoScanBarcode });
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            host.CreatePanelAction(new PanelAction { Caption = _settings.SidePanel == FactorySidePanel.Packs ? "Hide Stock" : "Show Stock", Image = PRSDesktop.Resources.trolley, OnExecute = TogglePackPanel});
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        private void TogglePackPanel(PanelAction pa)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            RackPanel.Visibility = Visibility.Collapsed;
 | 
	
		
			
				|  |  | +            PackPanel.Visibility = _settings.SidePanel == FactorySidePanel.Packs
 | 
	
		
			
				|  |  | +                ? Visibility.Collapsed
 | 
	
		
			
				|  |  | +                : Visibility.Visible;
 | 
	
		
			
				|  |  | +            _settings.SidePanel = PackPanel.Visibility == Visibility.Visible
 | 
	
		
			
				|  |  | +                ? FactorySidePanel.Packs
 | 
	
		
			
				|  |  | +                : FactorySidePanel.None;
 | 
	
		
			
				|  |  | +            new LocalConfiguration<FactoryFloorLocalSettings>().Save(_settings);
 | 
	
		
			
				|  |  | +            pa.Caption = _settings.SidePanel == FactorySidePanel.Packs
 | 
	
		
			
				|  |  | +                ? "Hide Stock"
 | 
	
		
			
				|  |  | +                : "Show Stock";
 | 
	
		
			
				|  |  | +            _addPack.IsEnabled = _settings.AreaID != Guid.Empty;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          public Dictionary<string, object[]> Selected()
 | 
	
	
		
			
				|  | @@ -241,7 +308,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                      {
 | 
	
		
			
				|  |  |                          var stagerow = Stages.Rows.FirstOrDefault(r => r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(packet.ID)
 | 
	
		
			
				|  |  |                                                                         && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID)
 | 
	
		
			
				|  |  | -                                                                           .Equals(settings.Section));
 | 
	
		
			
				|  |  | +                                                                           .Equals(_settings.Section));
 | 
	
		
			
				|  |  |                          if (stagerow != null)
 | 
	
		
			
				|  |  |                          {
 | 
	
		
			
				|  |  |                              var stage = stagerow.ToObject<ManufacturingPacketStage>();
 | 
	
	
		
			
				|  | @@ -291,7 +358,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              try
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                foreach (var scanner in Scanners) scanner.Actions.ToggleLed(LedMode.GreenOff);
 | 
	
		
			
				|  |  | +                foreach (var scanner in _scanners) scanner.Actions.ToggleLed(LedMode.GreenOff);
 | 
	
		
			
				|  |  |                  BarcodeScannerManager.Instance.DataReceived -= Instance_DataReceived;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  BarcodeScannerManager.Instance.Close();
 | 
	
	
		
			
				|  | @@ -304,7 +371,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          private void SetupScanner()
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            Scanners.Clear();
 | 
	
		
			
				|  |  | +            _scanners.Clear();
 | 
	
		
			
				|  |  |              BarcodeScannerManager.Instance.Open();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              BarcodeScannerManager.Instance.RegisterForEvents(EventType.Barcode, EventType.Pnp, EventType.Image, EventType.Other, EventType.Rmd);
 | 
	
	
		
			
				|  | @@ -312,7 +379,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |              BarcodeScannerManager.Instance.GetDevices();
 | 
	
		
			
				|  |  |              foreach (var scanner in BarcodeScannerManager.Instance.GetDevices())
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                Scanners.Add(scanner);
 | 
	
		
			
				|  |  | +                _scanners.Add(scanner);
 | 
	
		
			
				|  |  |                  scanner.Actions.ToggleLed(LedMode.RedOn);
 | 
	
		
			
				|  |  |                  scanner.Actions.SoundBeeper(BeepPattern.FastWarble);
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -322,7 +389,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          private void Instance_DataReceived(object? sender, BarcodeScanEventArgs e)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            Dispatcher.Invoke(() => { ProcessCode(Scanners[(int)e.ScannerId], e.Data); });
 | 
	
		
			
				|  |  | +            Dispatcher.Invoke(() => { ProcessCode(_scanners[(int)e.ScannerId], e.Data); });
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          private void ProcessCode(IMotorolaBarcodeScanner scanner, string code)
 | 
	
	
		
			
				|  | @@ -358,7 +425,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                              var stagerow = Stages.Rows.FirstOrDefault(r => r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(packet.ID)
 | 
	
		
			
				|  |  |                                                                             && r.Get<ManufacturingPacketStage, Guid>(
 | 
	
		
			
				|  |  |                                                                                     c => c.ManufacturingSectionLink.ID)
 | 
	
		
			
				|  |  | -                                                                               .Equals(settings.Section));
 | 
	
		
			
				|  |  | +                                                                               .Equals(_settings.Section));
 | 
	
		
			
				|  |  |                              pktrow.Set<ManufacturingPacket, string>(x => x.Trolleys, packet.Trolleys);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                              LoadModel(kanban, pktrow, stagerow, true);
 | 
	
	
		
			
				|  | @@ -383,6 +450,9 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                          if (string.Equals(code, rackbarcode))
 | 
	
		
			
				|  |  |                          {
 | 
	
		
			
				|  |  |                              RackPanel.Visibility = Visibility.Collapsed;
 | 
	
		
			
				|  |  | +                            _settings.SidePanel = FactorySidePanel.None;
 | 
	
		
			
				|  |  | +                            new LocalConfiguration<FactoryFloorLocalSettings>().Save(_settings);
 | 
	
		
			
				|  |  | +                            
 | 
	
		
			
				|  |  |                              RackContents.ItemsSource = null;
 | 
	
		
			
				|  |  |                              rackid = Guid.Empty;
 | 
	
		
			
				|  |  |                              rackbarcode = "";
 | 
	
	
		
			
				|  | @@ -399,10 +469,13 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                              rackcontents.AddRange(rows.Select(x => x.ToObject<DeliveryItem>()));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                              RackContents.ItemsSource = rackcontents;
 | 
	
		
			
				|  |  | -                            RackName.Content = string.Format("Rack {0}", shiprow.Get<Shipment, string>(c => c.Code));
 | 
	
		
			
				|  |  | +                            RackName.Content = $"Rack {shiprow.Get<Shipment, string>(c => c.Code)}";
 | 
	
		
			
				|  |  |                              RackCount.Content = rows.Length.ToString();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                            PackPanel.Visibility = Visibility.Collapsed;
 | 
	
		
			
				|  |  |                              RackPanel.Visibility = Visibility.Visible;
 | 
	
		
			
				|  |  | +                            _settings.SidePanel = FactorySidePanel.Racks;
 | 
	
		
			
				|  |  | +                            new LocalConfiguration<FactoryFloorLocalSettings>().Save(_settings);
 | 
	
		
			
				|  |  |                              scanner?.Actions.SoundBeeper(BeepPattern.ThreeHighShort);
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
	
		
			
				|  | @@ -462,7 +535,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                              var stage = Stages.Rows.FirstOrDefault(r => r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(id)
 | 
	
		
			
				|  |  |                                                                          && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID)
 | 
	
		
			
				|  |  | -                                                                            .Equals(settings.Section))?.ToObject<ManufacturingPacketStage>();
 | 
	
		
			
				|  |  | +                                                                            .Equals(_settings.Section))?.ToObject<ManufacturingPacketStage>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                              if (stage == null)
 | 
	
		
			
				|  |  |                                  scanner?.Actions.SoundBeeper(BeepPattern.FourHighShort);
 | 
	
	
		
			
				|  | @@ -509,7 +582,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                  var row = Packets.Rows.FirstOrDefault(r => r.Get<ManufacturingPacket, Guid>(c => c.ID).Equals(pktid));
 | 
	
		
			
				|  |  |                  var stagerow = Stages.Rows.FirstOrDefault(r => r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(pktid)
 | 
	
		
			
				|  |  |                                                                 && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID)
 | 
	
		
			
				|  |  | -                                                                   .Equals(settings.Section));
 | 
	
		
			
				|  |  | +                                                                   .Equals(_settings.Section));
 | 
	
		
			
				|  |  |                  var packet = row.ToObject<ManufacturingPacket>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if (id.Value == Guid.Empty)
 | 
	
	
		
			
				|  | @@ -539,8 +612,8 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                  else
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      PDFEditor = new PDFEditorControl();
 | 
	
		
			
				|  |  | -                    PDFEditor.LineColor = settings.LineColor;
 | 
	
		
			
				|  |  | -                    PDFEditor.TextSize = settings.FontSize;
 | 
	
		
			
				|  |  | +                    PDFEditor.LineColor = _settings.LineColor;
 | 
	
		
			
				|  |  | +                    PDFEditor.TextSize = _settings.FontSize;
 | 
	
		
			
				|  |  |                      //PDFEditor.PrintAllowed = Security.IsAllowed<CanPrintFactoryFloorDrawings>();
 | 
	
		
			
				|  |  |                      PDFEditor.SaveAllowed = Security.IsAllowed<CanSaveFactoryFloorDrawings>();
 | 
	
		
			
				|  |  |                      var document = documents.FirstOrDefault(x => x.DocumentLink.ID.Equals(id));
 | 
	
	
		
			
				|  | @@ -564,14 +637,14 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  var id = dlg.IDs().FirstOrDefault();
 | 
	
		
			
				|  |  |                  var barcode = dlg.Data().Rows.FirstOrDefault(r => r.Get<Shipment, Guid>(c => c.ID).Equals(id))?.Get<Shipment, string>(x => x.BarCode);
 | 
	
		
			
				|  |  | -                ProcessCode(Scanners.FirstOrDefault(), barcode);
 | 
	
		
			
				|  |  | +                ProcessCode(_scanners.FirstOrDefault(), barcode);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          private void DoCloseRack(PanelAction obj)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              if (!string.IsNullOrWhiteSpace(rackbarcode))
 | 
	
		
			
				|  |  | -                ProcessCode(Scanners.FirstOrDefault(), rackbarcode);
 | 
	
		
			
				|  |  | +                ProcessCode(_scanners.FirstOrDefault(), rackbarcode);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -588,7 +661,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                  var id = dlg.IDs().FirstOrDefault();
 | 
	
		
			
				|  |  |                  var barcode = dlg.Data().Rows.FirstOrDefault(r => r.Get<DeliveryItem, Guid>(c => c.ID).Equals(id))
 | 
	
		
			
				|  |  |                      ?.Get<DeliveryItem, string>(x => x.Barcode);
 | 
	
		
			
				|  |  | -                ProcessCode(Scanners.FirstOrDefault(), barcode);
 | 
	
		
			
				|  |  | +                ProcessCode(_scanners.FirstOrDefault(), barcode);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -880,9 +953,9 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              CurrentKanban = null;
 | 
	
		
			
				|  |  |              CurrentStation = station;
 | 
	
		
			
				|  |  | -            settings.Section = section;
 | 
	
		
			
				|  |  | -            settings.Station = CurrentStation - 1;
 | 
	
		
			
				|  |  | -            new LocalConfiguration<FactoryFloorLocalSettings>().Save(settings);
 | 
	
		
			
				|  |  | +            _settings.Section = section;
 | 
	
		
			
				|  |  | +            _settings.Station = CurrentStation - 1;
 | 
	
		
			
				|  |  | +            new LocalConfiguration<FactoryFloorLocalSettings>().Save(_settings);
 | 
	
		
			
				|  |  |              DoRefresh(true);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -894,15 +967,17 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      ButtonStack.Children.Clear();
 | 
	
		
			
				|  |  |                      LoadDrawing(null);
 | 
	
		
			
				|  |  | +                    _packGrid.CurrentPacket = null;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  else if (true) // Kanban has changed - how do we figure this out 
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      var packet = KanbanToPacket(CurrentKanban);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +                    _packGrid.CurrentPacket = packet;
 | 
	
		
			
				|  |  | +                    
 | 
	
		
			
				|  |  |                      //SetoutStage stage = packet.GetCurrentStage();
 | 
	
		
			
				|  |  |                      var row = Stages.Rows.FirstOrDefault(r => r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(packet.ID)
 | 
	
		
			
				|  |  |                                                                && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID)
 | 
	
		
			
				|  |  | -                                                                  .Equals(settings.Section));
 | 
	
		
			
				|  |  | +                                                                  .Equals(_settings.Section));
 | 
	
		
			
				|  |  |                      var station = row != null ? row.Get<ManufacturingPacketStage, int>(c => c.Station) : 0;
 | 
	
		
			
				|  |  |                      var quality = row != null ? row.Get<ManufacturingPacketStage, QualityStatus>(c => c.QualityStatus) : QualityStatus.NotChecked;
 | 
	
		
			
				|  |  |                      var percentage = row != null ? row.Get<ManufacturingPacketStage, double>(c => c.PercentageComplete) : 0.00F;
 | 
	
	
		
			
				|  | @@ -989,6 +1064,8 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                      else
 | 
	
		
			
				|  |  |                          LoadDrawing(null);
 | 
	
		
			
				|  |  |                  } // Kanban has not changed - do nothing
 | 
	
		
			
				|  |  | +                if (_packLinked.IsChecked == true)
 | 
	
		
			
				|  |  | +                    _packGrid.Refresh(false,false);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1107,7 +1184,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                  var qacomplete = true;
 | 
	
		
			
				|  |  |                  var stage = Stages.Rows.FirstOrDefault(r => r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(packet.ID)
 | 
	
		
			
				|  |  |                                                              && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID)
 | 
	
		
			
				|  |  | -                                                                .Equals(settings.Section));
 | 
	
		
			
				|  |  | +                                                                .Equals(_settings.Section));
 | 
	
		
			
				|  |  |                  if (stage != null)
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      var qadata = stage.Get<ManufacturingPacketStage, string>(c => c.FormData);
 | 
	
	
		
			
				|  | @@ -1464,7 +1541,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |              var checkedpackets = Packets.Rows.Where(r => checkedkanbans.Contains(r.Get<ManufacturingPacket, Guid>(c => c.ID)));
 | 
	
		
			
				|  |  |              var checkedstages = Stages.Rows.Where(r => checkedkanbans.Contains(r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID))
 | 
	
		
			
				|  |  |                                                         && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID)
 | 
	
		
			
				|  |  | -                                                           .Equals(settings.Section));
 | 
	
		
			
				|  |  | +                                                           .Equals(_settings.Section));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              // Only if we right-click on a checked packet??
 | 
	
	
		
			
				|  | @@ -1592,7 +1669,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                          var pktrow = Packets.Rows.FirstOrDefault(r => r.Get<ManufacturingPacket, Guid>(c => c.ID).Equals(update.ID));
 | 
	
		
			
				|  |  |                          var stagerow = Stages.Rows.FirstOrDefault(r => r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(update.ID)
 | 
	
		
			
				|  |  |                                                                         && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID)
 | 
	
		
			
				|  |  | -                                                                           .Equals(settings.Section));
 | 
	
		
			
				|  |  | +                                                                           .Equals(_settings.Section));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          //ManufacturingPacketStage stage = Stages.Rows.FirstOrDefault(r => r.Get<ManufacturingPacketStage, Guid>(x => x.Parent.ID).Equals(update.ID))?.ToObject<ManufacturingPacketStage>();
 | 
	
		
			
				|  |  |                          var kanban = Kanbans.FirstOrDefault(x => x.ID.Equals(update.ID.ToString()));
 | 
	
	
		
			
				|  | @@ -1642,7 +1719,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                          var pktrow = Packets.Rows.FirstOrDefault(r => r.Get<ManufacturingPacket, Guid>(c => c.ID).Equals(Guid.Parse(kanban.ID)));
 | 
	
		
			
				|  |  |                          var stagerow = Stages.Rows.FirstOrDefault(r =>
 | 
	
		
			
				|  |  |                              r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(Guid.Parse(kanban.ID))
 | 
	
		
			
				|  |  | -                            && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID).Equals(settings.Section));
 | 
	
		
			
				|  |  | +                            && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID).Equals(_settings.Section));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          var packet = pktrow.ToObject<ManufacturingPacket>();
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1677,7 +1754,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                      var stagerow = Stages.Rows.FirstOrDefault(r =>
 | 
	
		
			
				|  |  |                          r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(Guid.Parse(kanban.ID))
 | 
	
		
			
				|  |  |                          && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID)
 | 
	
		
			
				|  |  | -                            .Equals(settings.Section));
 | 
	
		
			
				|  |  | +                            .Equals(_settings.Section));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      var packet = pktrow.ToObject<ManufacturingPacket>();
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1936,9 +2013,9 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          public void PDFEditorSettingsChanged(object sender, string linecolor, int fontsize)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            settings.LineColor = linecolor;
 | 
	
		
			
				|  |  | -            settings.FontSize = fontsize;
 | 
	
		
			
				|  |  | -            new LocalConfiguration<FactoryFloorLocalSettings>().Save(settings);
 | 
	
		
			
				|  |  | +            _settings.LineColor = linecolor;
 | 
	
		
			
				|  |  | +            _settings.FontSize = fontsize;
 | 
	
		
			
				|  |  | +            new LocalConfiguration<FactoryFloorLocalSettings>().Save(_settings);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          #region Employee Stuff
 | 
	
	
		
			
				|  | @@ -2314,6 +2391,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                          .Add(x => x.BarcodeQty)
 | 
	
		
			
				|  |  |                          .Add(x => x.SetoutLink.ID)
 | 
	
		
			
				|  |  |                          .Add(x => x.SetoutLink.Number)
 | 
	
		
			
				|  |  | +                        .Add(x => x.SetoutLink.JobLink.ID)
 | 
	
		
			
				|  |  |                          .Add(x => x.SetoutLink.JobLink.JobNumber)
 | 
	
		
			
				|  |  |                          .Add(x => x.SetoutLink.JobLink.Name)
 | 
	
		
			
				|  |  |                          .Add(x => x.SetoutLink.Group.ID)
 | 
	
	
		
			
				|  | @@ -2397,7 +2475,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                      var id = pktrow.Get<ManufacturingPacket, Guid>(c => c.ID);
 | 
	
		
			
				|  |  |                      var distributed = pktrow.Get<ManufacturingPacket, bool>(c => c.Distributed);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                    var stageIndex = stages.FindIndex(x => x.Item1 == id && x.Item2 == settings.Section);
 | 
	
		
			
				|  |  | +                    var stageIndex = stages.FindIndex(x => x.Item1 == id && x.Item2 == _settings.Section);
 | 
	
		
			
				|  |  |                      var stageRow = stageIndex >= 0 ? Stages.Rows[stageIndex] : null;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      //this was commented out previously - leading to the distributed packet issue. Uncommented and tested to work by Nick. Was there a reason for commenting this out?
 | 
	
	
		
			
				|  | @@ -2492,7 +2570,7 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                  //var row = Packets.Rows.FirstOrDefault(r => r.Get<ManufacturingPacket, Guid>(c => c.ID).Equals(ck.ID));
 | 
	
		
			
				|  |  |                  var stagerow = Stages.Rows.FirstOrDefault(r => r.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID).Equals(Guid.Parse(ck.ID))
 | 
	
		
			
				|  |  |                                                                 && r.Get<ManufacturingPacketStage, Guid>(c => c.ManufacturingSectionLink.ID)
 | 
	
		
			
				|  |  | -                                                                   .Equals(settings.Section));
 | 
	
		
			
				|  |  | +                                                                   .Equals(_settings.Section));
 | 
	
		
			
				|  |  |                  if (stagerow != null)
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      var stage = stagerow.ToObject<ManufacturingPacketStage>();
 | 
	
	
		
			
				|  | @@ -2577,5 +2655,82 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |              ManufacturingPanelColumn.CreatePickingList(rows!.Select(x => x.ToObject<ManufacturingPacket>()).ToList(), true,
 | 
	
		
			
				|  |  |                  () => new GlobalConfiguration<ManufacturingPanelProperties>().Load());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        private void _selectPackArea_OnClick(object sender, RoutedEventArgs e)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            var dlg = new MultiSelectDialog<StockArea>(
 | 
	
		
			
				|  |  | +                new Filter<StockArea>(x => x.Active).IsEqualTo(true),
 | 
	
		
			
				|  |  | +                new Columns<StockArea>(x => x.ID).Add(x => x.Warehouse.Code).Add(x => x.Code).Add(x => x.Description),
 | 
	
		
			
				|  |  | +                false);
 | 
	
		
			
				|  |  | +            if (dlg.ShowDialog("Select Area"))
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                _settings.AreaID = dlg.IDs().FirstOrDefault();
 | 
	
		
			
				|  |  | +                new LocalConfiguration<FactoryFloorLocalSettings>().Save(_settings);
 | 
	
		
			
				|  |  | +                _packGrid.AreaDescription =
 | 
	
		
			
				|  |  | +                    dlg.Items(new Columns<StockArea>(x => x.Code).Add(x => x.Description))
 | 
	
		
			
				|  |  | +                        .Select(x => $"{x.Code}: {x.Description}").FirstOrDefault() ?? "(No Area Selected)";
 | 
	
		
			
				|  |  | +                _packGrid.AreaID = _settings.AreaID;
 | 
	
		
			
				|  |  | +                _packGrid.Refresh(false,true);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        private void _addPack_OnClick(object sender, RoutedEventArgs e)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            var dlg = new MultiSelectDialog<StockLocation>(
 | 
	
		
			
				|  |  | +                new Filter<StockLocation>(x => x.Area.ID).IsNotEqualTo(_settings.AreaID),
 | 
	
		
			
				|  |  | +                new Columns<StockLocation>(x => x.ID).Add(x => x.Warehouse.Code).Add(x => x.Area.Code).Add(x => x.Code).Add(x => x.Description),
 | 
	
		
			
				|  |  | +                false);
 | 
	
		
			
				|  |  | +            if (dlg.ShowDialog("Select Location"))
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                var location = dlg.Items().FirstOrDefault();
 | 
	
		
			
				|  |  | +                if (location != null)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    location.Area.ID = _settings.AreaID;
 | 
	
		
			
				|  |  | +                    new Client<StockLocation>().Save(location,"Moved To Manufacturing");
 | 
	
		
			
				|  |  | +                    _packGrid.Refresh(false,true);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        private string _packFilter = "";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        private void _packSearch_OnTextChanged(object sender, TextChangedEventArgs e)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            _packGrid.Refresh(false, false);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        private bool _packGrid_OnOnFilterRecord(CoreRow row)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            var result = true;
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            if (_packLinked.IsChecked == true)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                Guid jobid = row.Get<StockHolding, Guid>(x => x.Job.ID);
 | 
	
		
			
				|  |  | +                if (_packGrid.CurrentPacket != null)
 | 
	
		
			
				|  |  | +                    result = jobid == Guid.Empty || jobid == _packGrid.CurrentPacket.SetoutLink.JobLink.ID;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            result = result && (String.IsNullOrWhiteSpace(_packSearch.Text)
 | 
	
		
			
				|  |  | +                 || row.Get<StockHolding, String>(x => x.Product.Code).ToUpper().Contains(_packSearch.Text.ToUpper())
 | 
	
		
			
				|  |  | +                 || row.Get<StockHolding, String>(x => x.Product.Name).ToUpper().Contains(_packSearch.Text.ToUpper())
 | 
	
		
			
				|  |  | +                 || row.Get<StockHolding, String>(x => x.Location.Code).ToUpper().Contains(_packSearch.Text.ToUpper())
 | 
	
		
			
				|  |  | +                 || row.Get<StockHolding, String>(x => x.Style.Code).ToUpper().Contains(_packSearch.Text.ToUpper())
 | 
	
		
			
				|  |  | +                 || row.Get<StockHolding, String>(x => x.Style.Description).ToUpper()
 | 
	
		
			
				|  |  | +                     .Contains(_packSearch.Text.ToUpper())
 | 
	
		
			
				|  |  | +                 || row.Get<StockHolding, String>(x => x.Dimensions.UnitSize).ToUpper()
 | 
	
		
			
				|  |  | +                     .Contains(_packSearch.Text.ToUpper())
 | 
	
		
			
				|  |  | +                 || row.Get<StockHolding, String>(x => x.Job.JobNumber).ToUpper().Contains(_packSearch.Text.ToUpper())
 | 
	
		
			
				|  |  | +                 || row.Get<StockHolding, String>(x => x.Job.Name).ToUpper().Contains(_packSearch.Text.ToUpper()));
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            return result;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        private void _packLinked_OnChecked(object sender, RoutedEventArgs e)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            _packGrid?.Refresh(false, false);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |