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

ProductInstance grid now uses EnsureColumns to avoid a query where possible

Kenric Nugteren преди 1 година
родител
ревизия
386d01b30a
променени са 2 файла, в които са добавени 11 реда и са изтрити 17 реда
  1. 2 9
      prs.desktop/Panels/Products/Master List/ProductInstanceControl.cs
  2. 9 8
      prs.server/Forms/Deletions/DeletionsGrid.cs

+ 2 - 9
prs.desktop/Panels/Products/Master List/ProductInstanceControl.cs

@@ -61,16 +61,9 @@ public class ProductInstanceControl : DynamicDataGrid<ProductInstance>, IProduct
 
         if(Product.UnitOfMeasure.ID != Guid.Empty)
         {
+            Client.EnsureColumns(Product, new Columns<Product>().AddSubColumns(x => x.UnitOfMeasure, null));
             item.Dimensions.Unit.ID = Product.UnitOfMeasure.ID;
-
-            var unitOfMeasure = Client.Query<ProductDimensionUnit>(
-                new Filter<ProductDimensionUnit>(x => x.ID).IsEqualTo(Product.UnitOfMeasure.ID),
-                null)
-                .ToObjects<ProductDimensionUnit>().FirstOrDefault();
-            if(unitOfMeasure is not null)
-            {
-                item.Dimensions.Unit.Synchronise(unitOfMeasure);
-            }
+            item.Dimensions.Unit.Synchronise(Product.UnitOfMeasure);
         }
         return item;
     }

+ 9 - 8
prs.server/Forms/Deletions/DeletionsGrid.cs

@@ -1,6 +1,7 @@
 using InABox.Core;
 using InABox.Database;
 using InABox.DynamicGrid;
+using InABox.Wpf;
 using InABox.WPF;
 using System;
 using System.Collections.Generic;
@@ -57,16 +58,16 @@ namespace PRSServer.Forms
             if (!rows.Any())
                 return false;
 
-            var result = MessageBox.Show(
+            var recover = MessageWindow.ShowYesNo(
                 "Are you sure you wish to recover these records?",
-                "Confirm Recover", MessageBoxButton.YesNo);
-            if(result == MessageBoxResult.Yes)
+                "Confirm Recover");
+            if(recover)
             {
                 foreach(var row in rows)
                 {
                     DbFactory.Provider.Recover(row.ToObject<Deletion>());
                 }
-                MessageBox.Show("Records recovered");
+                MessageWindow.ShowMessage("Records recovered", "Records recovered");
                 return true;
             }
             return false;
@@ -79,7 +80,7 @@ namespace PRSServer.Forms
                 return;
             else if (rows.Count > 1)
             {
-                MessageBox.Show("Please select only one row");
+                MessageWindow.ShowMessage("Please select only one row", "Error");
                 return; ;
             }
 
@@ -108,10 +109,10 @@ namespace PRSServer.Forms
             if (!rows.Any())
                 return;
 
-            var result = MessageBox.Show(
+            var delete = MessageWindow.ShowYesNo(
                 "Are you sure you wish to permanently delete these records?\n(This cannot be undone.)", 
-                "Confirm Permanent Delete", MessageBoxButton.YesNo);
-            if(result == MessageBoxResult.Yes)
+                "Confirm Permanent Delete");
+            if(delete)
             {
                 DeleteItems(rows);
                 SelectedRows = Array.Empty<CoreRow>();