فهرست منبع

DEKTOP - requi item grid select holdings improvements

Nicholas Tan 2 سال پیش
والد
کامیت
0a3137e753
1فایلهای تغییر یافته به همراه59 افزوده شده و 46 حذف شده
  1. 59 46
      prs.desktop/Panels/Requisitions/RequisitionItemGrid.cs

+ 59 - 46
prs.desktop/Panels/Requisitions/RequisitionItemGrid.cs

@@ -8,6 +8,7 @@ using InABox.Core;
 using InABox.DynamicGrid;
 using InABox.WPF;
 using Microsoft.Office.Interop.Outlook;
+using Syncfusion.Windows.Tools.Controls;
 using Exception = System.Exception;
 
 namespace PRSDesktop
@@ -45,7 +46,7 @@ namespace PRSDesktop
             HiddenColumns.Add(x => x.Product.Dimensions.Weight);
             HiddenColumns.Add(x => x.Product.Dimensions.UnitSize);
             HiddenColumns.Add(x => x.Product.Dimensions.Value);
-            HiddenColumns.Add(x => x.Product.Dimensions.Unit.HasQuantity); 
+            HiddenColumns.Add(x => x.Product.Dimensions.Unit.HasQuantity);
             HiddenColumns.Add(x => x.Product.Dimensions.Unit.HasLength);
             HiddenColumns.Add(x => x.Product.Dimensions.Unit.HasWidth);
             HiddenColumns.Add(x => x.Product.Dimensions.Unit.HasWeight);
@@ -62,57 +63,69 @@ namespace PRSDesktop
             HiddenColumns.Add(x => x.Style.Code);
             HiddenColumns.Add(x => x.Picked);
             ActionColumns.Add(new DynamicMenuColumn(SelectHolding,
-                (row) => (row.Get<RequisitionItem,Guid>(c=>c.Product.ID) == Guid.Empty) || row.Get<RequisitionItem, bool>(c => c.Product.NonStock) == true
-                    ? DynamicMenuStatus.Hidden 
+                (row) => (row.Get<RequisitionItem, Guid>(c => c.Product.ID) == Guid.Empty) || row.Get<RequisitionItem, bool>(c => c.Product.NonStock) == true
+                    ? DynamicMenuStatus.Hidden
                     : DynamicMenuStatus.Enabled)
             );
         }
 
         private void SelectHolding(DynamicMenuColumn column, CoreRow? row)
         {
-            using (new WaitCursor())
+            List<Guid> locations = new List<Guid>();
+            var holdings = new Client<StockHolding>().Query(
+                new Filter<StockHolding>(x => x.Product.ID).IsEqualTo(row.Get<RequisitionItem, Guid>(c => c.Product.ID)),
+                new Columns<StockHolding>(x => x.Location.ID)
+                    .Add(x => x.Units));
+
+            foreach (var holding in holdings.Rows)
             {
-                var holdings = new Client<StockHolding>().Query(
-                    new Filter<StockHolding>(x => x.Product.ID).IsEqualTo(row.Get<RequisitionItem, Guid>(c => c.Product.ID)),
-                    new Columns<StockHolding>(x => x.Location.ID)
-                        .Add(x => x.Location.Code)
-                        .Add(x => x.Style.ID)
-                        .Add(x => x.Style.Code)
-                        .Add(x => x.Job.ID)
-                        .Add(x => x.Job.JobNumber)
-                        .Add(x => x.Dimensions.Unit.ID)
-                        .Add(x => x.Dimensions.Length)
-                        .Add(x => x.Dimensions.Width)
-                        .Add(x => x.Dimensions.Height)
-                        .Add(x => x.Dimensions.Weight)
-                        .Add(x => x.Dimensions.UnitSize)
-                        .Add(x => x.Dimensions.Value)
-                        .Add(x => x.Dimensions.Unit.HasQuantity)
-                        .Add(x => x.Dimensions.Unit.HasLength)
-                        .Add(x => x.Dimensions.Unit.HasWidth)
-                        .Add(x => x.Dimensions.Unit.HasWeight)
-                        .Add(x => x.Dimensions.Unit.HasHeight)
-                        .Add(x => x.Dimensions.Unit.Formula)
-                        .Add(x => x.Dimensions.Unit.Format)
-                        .Add(x => x.Units),
-                    new SortOrder<StockHolding>(x => x.Location.Code).ThenBy(x => x.Style.Code).ThenBy(x => x.Dimensions.UnitSize)
-                );
-
-                foreach (var holding in holdings.Rows)
-                {
-                    var qty = holding.Get<StockHolding, double>(c => c.Units);
-                    if (!CoreUtils.IsEffectivelyEqual(qty, 0.0F))
-                    {
-                        String text =
-                            $"Location: {holding.Get<StockHolding, String>(c => c.Location.Code)}, Qty: {holding.Get<StockHolding, double>(c => c.Units)} @ {holding.Get<StockHolding, String>(c => c.Dimensions.UnitSize)}";
-                        String style = holding.Get<StockHolding, String>(c => c.Style.Code);
-                        if (!String.IsNullOrWhiteSpace(style))
-                            text = $"{text} (Style code: {style})";
-                        column.AddItem(text, null, (sel) => SelectLocation(holding, sel));
-                    }
-                }
+                var qty = holding.Get<StockHolding, double>(c => c.Units);
+                if (!CoreUtils.IsEffectivelyEqual(qty, 0.0F) && qty > 0)
+                    locations.Add(holding.Get<StockHolding, Guid>(x => x.Location.ID));
             }
-            
+
+            if (locations.Count == 0)
+            {
+                MessageBox.Show("No valid holdings found for product");
+                return;
+            }
+
+            var selection = new MultiSelectDialog<StockHolding>
+                (
+                    new Filter<StockHolding>(x => x.Product.ID).IsEqualTo(row.Get<RequisitionItem, Guid>(c => c.Product.ID))
+                    .And(x => x.Location.ID).InList(locations.ToArray())
+                    ,
+                    new Columns<StockHolding>(
+                        x => x.Job.Name,
+                        x => x.Job.JobNumber,
+                        x => x.Units,
+                        x => x.Dimensions.UnitSize,
+                        x => x.Dimensions.Height,
+                        x => x.Dimensions.Width,
+                        x => x.Dimensions.Weight,
+                        x => x.Dimensions.Quantity,
+                        x => x.Dimensions.Length,
+                        x => x.Dimensions.Unit.ID,
+                        x => x.Dimensions.Unit.Format,
+                        x => x.Dimensions.Unit.Formula,
+                        x => x.Dimensions.Unit.HasHeight,
+                        x => x.Dimensions.Unit.HasWeight,
+                        x => x.Dimensions.Unit.HasWidth,
+                        x => x.Dimensions.Unit.HasQuantity,
+                        x => x.Dimensions.Unit.HasLength,
+                        x => x.Style.ID,
+                        x => x.Style.Code,
+                        x => x.Style.Description,
+                        x => x.Location.ID,
+                        x => x.Location.Code,
+                        x => x.Location.Description,
+                        x => x.Location.Area.Code,
+                        x => x.Location.Area.Description
+                ), false);
+
+            if (selection.ShowDialog("Units", "0") == true)
+                SelectLocation(selection.Data().Rows.FirstOrDefault(), row);
+
         }
 
         private void SelectLocation(CoreRow holdingrow, CoreRow itemrow)
@@ -217,7 +230,7 @@ namespace PRSDesktop
             base.DoAdd();
 
         }
-        
-        
+
+
     }
 }