Преглед на файлове

Fixed ManagedProblem handlers in V6, Logikal and Factory modules

frankvandenbos преди 10 месеца
родител
ревизия
8e24700155

+ 10 - 29
prs.desktop/Panels/Factory/FactoryPanel.xaml.cs

@@ -1864,40 +1864,21 @@ namespace PRSDesktop
             var updates = new List<ManufacturingPacket>();
             var rows = (sender as MenuItem).Tag as IEnumerable<CoreRow>;
             var pkts = rows.Select(x => x.ToObject<ManufacturingPacket>()).ToArray();
-            if (new DynamicIssuesEditor(pkts, true).ShowDialog() == true)
+            if (pkts.Length != 1)
+            {
+                MessageWindow.ShowMessage("You can only edit one packet at a time", "Error");
+                return;
+            }
+
+            var pkt = pkts.First();
+            var _grid = DynamicGridUtils.CreateDynamicGrid(typeof(DynamicItemsListGrid<>), pkt.Problem.GetType());
+            if (_grid.EditItems(new object[] { pkt.Problem }))
             {
                 Progress.ShowModal("Updating Issues", progress => { new Client<ManufacturingPacket>().Save(pkts, "Updated Issues"); });
                 Refresh();
             }
+            
 
-            // String[] issues = rows.Select(r => r.Get<ManufacturingPacket, String>(c => c.Issues)).Distinct().ToArray();
-            // if (issues.Length > 1)
-            // {
-            //     if (MessageBox.Show(
-            //             "Multiple Issues found! If you continue, these may be lost.\n\nAre you sure you wish to continue?",
-            //             "Multiple Issues",
-            //             MessageBoxButton.YesNo) != MessageBoxResult.Yes)
-            //         return;
-            // }
-            //
-            // string issue = issues.Length > 0 ? issues.First() : "";
-            // if (!TextBoxDialog.Execute("Edit Issues", ref issue))
-            //     return;
-            //
-            // foreach (var row in rows)
-            // {
-            //     ManufacturingPacket packet = row.ToObject<ManufacturingPacket>();
-            //     packet.Issues = issue;
-            //     updates.Add(packet);
-            // }
-            // if (updates.Any())
-            // {
-            //     using (new WaitCursor())
-            //     {
-            //         new Client<ManufacturingPacket>().Save(updates, "Updated Issues");
-            //         Refresh();
-            //     }
-            // }
         }
 
         private void SetHold_Click(object sender, RoutedEventArgs e)

+ 11 - 5
prs.desktop/Panels/Manufacturing/ManufacturingPanelColumn.xaml.cs

@@ -1168,21 +1168,27 @@ namespace PRSDesktop
             var item = (MenuItem)sender;
             var model = (ManufacturingKanban)item.Tag;
             var pkts = GetSelectedPackets(model.ID).ToArray();
-            if (new DynamicIssuesEditor(pkts, true).ShowDialog() == true)
+            if (pkts.Length != 1)
+            {
+                MessageWindow.ShowMessage("You can only edit one packet at a time", "Error");
+                return;
+            }
+
+            var pkt = pkts.First();
+            var _grid = DynamicGridUtils.CreateDynamicGrid(typeof(DynamicItemsListGrid<>), pkt.Problem.GetType());
+            if (_grid.EditItems(new object[] { pkt.Problem }))
             {
                 Progress.ShowModal("Updating Issues", progress => { new Client<ManufacturingPacket>().Save(pkts, "Updated Issues"); });
                 ClearSelectedKanbans();
                 OnChanged?.Invoke(this, new EventArgs());
             }
         }
-
-
+        
         private void SetHold_Click(object sender, RoutedEventArgs e)
         {
             UpdateHold(sender, true);
         }
-
-
+        
         private void ClearHold_Click(object sender, RoutedEventArgs e)
         {
             UpdateHold(sender, false);

+ 11 - 12
prs.desktop/Utils/LogikalUtils/LogikalCommon.cs

@@ -279,9 +279,9 @@ namespace PRSDesktop.Utils.LogikalUtils
                             var _newprofile = new Product()
                             {
                                 Code = _missingProfile.Code ?? "",
-                                Name = _missingProfile.Description ?? "",
-                                Problem = new ManagedProblem() { Notes = new string[] { "Created by Logikal Import" } }
+                                Name = _missingProfile.Description ?? ""
                             };
+                            _newprofile.Problem.Notes = new string[] { "Created by Logikal Import" };
                             _newprofile.UnitOfMeasure.CopyFrom(LogikalCommon.ProfileUOM);
                             _newProfiles.Add(_newprofile);
                         }
@@ -299,8 +299,8 @@ namespace PRSDesktop.Utils.LogikalUtils
                             {
                                 Code = _missingComponent.Code ?? "",
                                 Name = _missingComponent.Description ?? "",
-                                Problem = new ManagedProblem() { Notes = new string[] { "Created by Logikal Import" } }
                             };
+                            _newComponent.Problem.Notes = new string[] { "Created by Logikal Import" }; 
                             _newComponent.UnitOfMeasure.CopyFrom(LogikalCommon.ComponentUOM);
                             _newComponents.Add(_newComponent);
                         }
@@ -318,8 +318,8 @@ namespace PRSDesktop.Utils.LogikalUtils
                             {
                                 Code = _missingGlass.Code ?? "",
                                 Name = _missingGlass.Description ?? "",
-                                Problem = new ManagedProblem() { Notes = new string[] { "Created by Logikal Import" } }
                             };
+                            _newGlass.Problem.Notes = new string[] { "Created by Logikal Import" };
                             _newGlass.UnitOfMeasure.CopyFrom(LogikalCommon.GlassUOM);
                             _newGlasses.Add(_newGlass);
                         }
@@ -333,14 +333,13 @@ namespace PRSDesktop.Utils.LogikalUtils
                         List<Comal.Classes.Activity> _newActivities = new();
                         foreach (var _missingActivity in _missingActivities)
                         {
-                            _newActivities.Add(
-                                new Comal.Classes.Activity()
-                                {
-                                    Code = _missingActivity.Code,
-                                    Description = _missingActivity.Description,
-                                    Problem = new ManagedProblem() { Notes = new string[] { "Created by Logikal Import" } }
-                                }
-                            );
+                            var _newActivity = new Comal.Classes.Activity()
+                            {
+                                Code = _missingActivity.Code,
+                                Description = _missingActivity.Description,
+                            };
+                            _newActivity.Problem.Notes = new string[] { "Created by Logikal Import" };
+                            _newActivities.Add(_newActivity);
                         }
                         Client.Save(_newActivities, "Created By LogikalImport");
                         Activities.AddRange(_newActivities);

+ 9 - 9
prs.desktop/Utils/MicrosoftSQL/V6Utils/V6ProjectImport.xaml.cs

@@ -483,7 +483,7 @@ public partial class V6ProjectImport : Window
                 var _activity = new Activity();
                 _activity.Code = _missing.Code;
                 _activity.Description = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_missing.Code.ToLower());
-                _activity.Problem = new ManagedProblem() { Notes = new string[] { "Created by V6 Import" } };
+                _activity.Problem.Notes = new string[] { "Created by V6 Import" };
                 _updates.Add(_activity);
             }
         }
@@ -503,7 +503,7 @@ public partial class V6ProjectImport : Window
                 var _productstyle = new ProductStyle();
                 _productstyle.Code = _missingitem;
                 _productstyle.Description = _missingitem;
-                _productstyle.Problem = new ManagedProblem() { Notes = new string[] { "Created by V6 Import" } };
+                _productstyle.Problem.Notes = new string[] { "Created by V6 Import" };
                 _updates.Add(_productstyle);
             }
         }
@@ -524,7 +524,7 @@ public partial class V6ProjectImport : Window
                 _product.UnitOfMeasure.CopyFrom(uom);
                 _product.Code = _missingitem.Code;
                 _product.Name = _missingitem.Description;
-                _product.Problem = new ManagedProblem() { Notes = new string[] { "Created by V6 Import" } };
+                _product.Problem.Notes = new string[] { "Created by V6 Import" };
                 _product.TaxCode.CopyFrom(tax);
                 _updates.Add(_product);
             }
@@ -636,14 +636,14 @@ public partial class V6ProjectImport : Window
                 _bomitem.Dimensions.Length = _profile.Length;
             }
             else
-                _bomitem.Problem  = new ManagedProblem() { Notes = new string[] { $"Unable to Locate Product: {_profile.Quantity} x {_profile.Code}: {_profile.Description} ({_profile.Length})" } };
+                _bomitem.Problem.Notes = new string[] { $"Unable to Locate Product: {_profile.Quantity} x {_profile.Code}: {_profile.Description} ({_profile.Length})" };
 
             if (!string.IsNullOrWhiteSpace(_profile.Finish))
             {
                 if (_styles.FirstOrDefault(x => x.Code == _profile.Finish) is { } _s)
                     _bomitem.Style.CopyFrom(_s);
                 else
-                    _bomitem.Problem  = new ManagedProblem() { Notes = new string[] { $"Unable to Locate Style: {_profile.Finish}" } };
+                    _bomitem.Problem.Notes = new string[] { $"Unable to Locate Style: {_profile.Finish}" };
             }
 
             _bomitem.Quantity = _profile.Quantity;
@@ -665,7 +665,7 @@ public partial class V6ProjectImport : Window
                 _bomitems.Add(_bomitem);
             }
             else
-                _bomitem.Problem  = new ManagedProblem() { Notes = new string[] { $"Unable to Locate Product: {_component.Quantity} x {_component.Code}: {_component.Description} ({_component.PackSize})" } };
+                _bomitem.Problem.Notes = new string[] { $"Unable to Locate Product: {_component.Quantity} x {_component.Code}: {_component.Description} ({_component.PackSize})" };
             
             _bomitem.Quantity = _component.Quantity * _component.PackSize;
             _bomitem.UnitCost = _component.Cost;
@@ -686,15 +686,15 @@ public partial class V6ProjectImport : Window
                 _bomitems.Add(_bomitem);
             }
             else
-                _bomitem.Problem  = new ManagedProblem() { Notes = new string[] { 
-                    $"Unable to Locate Product: {_glass.Code}: {_glass.Description} ({_glass.Height} x {_glass.Width})" } };
+                _bomitem.Problem.Notes = new string[] { 
+                    $"Unable to Locate Product: {_glass.Code}: {_glass.Description} ({_glass.Height} x {_glass.Width})" };
 
             if (!string.IsNullOrWhiteSpace(_glass.Treatment))
             {
                 if (_styles.FirstOrDefault(x => x.Code == _glass.Treatment) is { } _s)
                     _bomitem.Style.CopyFrom(_s);
                 else
-                    _bomitem.Problem  = new ManagedProblem() { Notes = new string[] { $"Unable to Locate Style: {_glass.Treatment})" } };
+                    _bomitem.Problem.Notes = new string[] { $"Unable to Locate Style: {_glass.Treatment})" };
             }
 
             _bomitem.Quantity = _glass.Quantity;