Browse Source

DESKTOP - added grid for staging packet components, moving files to correct folder

Nick-PRSDigital@bitbucket.org 2 years ago
parent
commit
3e830ae376

+ 8 - 1
prs.desktop/ManufacturingPacketApprovalControl.xaml → prs.desktop/Panels/Staging/Manufacturing/ManufacturingPacketApprovalControl.xaml

@@ -20,7 +20,14 @@
         </Border>
 
         <Border Grid.Row="1">
-            <Label Content="Components" HorizontalAlignment="Center" FontWeight="DemiBold"/>
+            <Grid>
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="auto"/>
+                    <RowDefinition Height="*"/>
+                </Grid.RowDefinitions>
+                <Label Grid.Row="0" Content="Components" HorizontalAlignment="Center" FontWeight="DemiBold"/>
+                <local:StagingManufacturingPacketComponentGrid Grid.Row="1" x:Name="componentsGrid"/>
+            </Grid>
         </Border>
 
     </Grid>

+ 11 - 1
prs.desktop/ManufacturingPacketApprovalControl.xaml.cs → prs.desktop/Panels/Staging/Manufacturing/ManufacturingPacketApprovalControl.xaml.cs

@@ -31,6 +31,7 @@ namespace PRSDesktop
             {
                 stagingsetout = value;
                 packetGrid.StagingSetout = value;
+                componentsGrid.Packet = new StagingManufacturingPacket();
             }
         }
 
@@ -40,12 +41,21 @@ namespace PRSDesktop
         {
             if (StagingSetout != null)
                 if (StagingSetout.ID != Guid.Empty)
+                {
                     packetGrid.Refresh(false, true);
+                    componentsGrid.Packet = new StagingManufacturingPacket();
+                }
         }
-        
+
         public ManufacturingPacketApprovalControl()
         {
             InitializeComponent();
+            packetGrid.OnSelectItem += PacketGrid_OnSelectItem;
+        }
+
+        private void PacketGrid_OnSelectItem(object sender, InABox.DynamicGrid.DynamicGridSelectionEventArgs e)
+        {
+            componentsGrid.Packet = packetGrid.SelectedRows.FirstOrDefault().ToObject<StagingManufacturingPacket>();
         }
 
         private void CreatePacketButton_Click(object sender, RoutedEventArgs e)

+ 69 - 0
prs.desktop/Panels/Staging/Manufacturing/StagingManufacturingPacketComponentGrid.cs

@@ -0,0 +1,69 @@
+using Comal.Classes;
+using InABox.Core;
+using InABox.DynamicGrid;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PRSDesktop
+{
+    public class StagingManufacturingPacketComponentGrid : DynamicDataGrid<StagingManufacturingPacketComponent>
+    {
+        private StagingManufacturingPacket packet;
+        public StagingManufacturingPacket Packet
+        {
+            get => packet;
+            set
+            {
+                packet = value;
+                if (value.ID != Guid.Empty)
+                {
+                    Options.Add(DynamicGridOption.AddRows);
+                    Options.Add(DynamicGridOption.DeleteRows);
+                    Options.Add(DynamicGridOption.FilterRows);
+                    Options.Add(DynamicGridOption.SelectColumns);
+                    Options.Add(DynamicGridOption.EditRows);
+                }
+                else
+                {
+                    Options.Remove(DynamicGridOption.AddRows);
+                    Options.Remove(DynamicGridOption.DeleteRows);
+                    Options.Remove(DynamicGridOption.FilterRows);
+                    Options.Remove(DynamicGridOption.SelectColumns);
+                    Options.Remove(DynamicGridOption.EditRows);
+                }
+                Refresh(false, true);
+            }
+        }
+
+        public StagingManufacturingPacketComponentGrid()
+        {
+            Packet = new StagingManufacturingPacket();
+            Options.Remove(DynamicGridOption.ImportData);
+            Options.Remove(DynamicGridOption.ExportData);
+            
+            Refresh(true, true);
+        }
+
+        protected override void Reload(Filters<StagingManufacturingPacketComponent> criteria, Columns<StagingManufacturingPacketComponent> columns, ref SortOrder<StagingManufacturingPacketComponent>? sort, Action<CoreTable?, Exception?> action)
+        {
+            if (Packet.ID == Guid.Empty)
+                criteria.Add(new Filter<StagingManufacturingPacketComponent>(x => x.ID).IsEqualTo(Guid.Empty));
+
+            else
+                criteria.Add(new Filter<StagingManufacturingPacketComponent>(x => x.StagingPacket.ID).IsEqualTo(Packet.ID));
+
+            base.Reload(criteria, columns, ref sort, action);
+        }
+
+        protected override StagingManufacturingPacketComponent CreateItem()
+        {
+            var item = base.CreateItem();
+            item.StagingPacket.ID = Packet.ID;
+
+            return item;
+        }
+    }
+}

+ 1 - 7
prs.desktop/Panels/Staging/StagingManufacturingPacketGrid.cs → prs.desktop/Panels/Staging/Manufacturing/StagingManufacturingPacketGrid.cs

@@ -5,10 +5,6 @@ using InABox.DynamicGrid;
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows.Controls;
 
 namespace PRSDesktop.Panels.Staging
 {
@@ -30,8 +26,6 @@ namespace PRSDesktop.Panels.Staging
             }
         }
 
-        public IEnumerable<DynamicGridColumn> Columns => throw new NotImplementedException();
-
         public StagingManufacturingPacketGrid()
         {
             Options.Add(DynamicGridOption.SelectColumns);
@@ -80,7 +74,7 @@ namespace PRSDesktop.Panels.Staging
                     var values = row.ToDictionary(new[] { "Display" });
                     row["Display"] =
                         LookupFactory.FormatLookup(typeof(JobITP), values,
-                            new string[] { }); //String.Join(" / ", values.Where(x => (x != null) && !String.IsNullOrWhiteSpace(x.ToString())));
+                            new string[] { });
                 }
                 itp.LoadLookups(table);
             }

+ 5 - 5
prs.desktop/Grids/StagingSetoutGrid.cs → prs.desktop/Panels/Staging/Setouts/StagingSetoutGrid.cs

@@ -116,7 +116,7 @@ namespace PRSDesktop
         {
             Stream stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
             byte[] pdfData = new byte[stream.Length];
-            stream.Read(pdfData, 0, System.Convert.ToInt32(pdfData.Length));
+            stream.Read(pdfData, 0, Convert.ToInt32(pdfData.Length));
             stream.Dispose();
             return pdfData;
         }
@@ -177,15 +177,15 @@ namespace PRSDesktop
             {
                 var file = GetFiles().FirstOrDefault(x => x.Name == document.DocumentLink.FileName);
                 if (file.Exists)
-                {   
+                {
                     file.Attributes = FileAttributes.Normal;
                     file.Delete();
                 }
-                    
+
             }
-            catch (Exception ex) 
+            catch (Exception ex)
             {
-                
+
             }
         }
     }