Browse Source

PRS Desktop - bug fix to Purchase Orders and Stock take

Nick-PRSDigital@bitbucket.org 2 years ago
parent
commit
82c0896509

+ 3 - 0
prs.desktop/Panels/Products/Locations/StockTakeWindow.xaml.cs

@@ -68,11 +68,14 @@ namespace PRSDesktop
             Holdings.Options.Remove(DynamicGridOption.DeleteRows);
             Holdings.Options.Remove(DynamicGridOption.ImportData);
             Holdings.Options.Remove(DynamicGridOption.ExportData);
+            Holdings.Options.Remove(DynamicGridOption.SelectColumns);
             Holdings.Options.Add(DynamicGridOption.RecordCount);
             Holdings.Options.Add(DynamicGridOption.AddRows);
 
             Holdings.Options.Add(DynamicGridOption.DirectEdit);
 
+            
+
             Holdings.OnCustomiseEditor += Page_OnCustomiseEditor;
             Holdings.OnValidate += Page_OnValidate;
             Holdings.OnBeforeSave += Page_OnSave;

+ 57 - 53
prs.desktop/Panels/Suppliers/SupplierPurchaseOrders.cs

@@ -37,60 +37,64 @@ namespace PRSDesktop
         private Dictionary<string, object> SupplierPurchaseOrders_OnEditorValueChanged(object sender, string name, object value)
         {
             Dictionary<string, object> result = new Dictionary<string, object>();
-            var form = sender as DynamicEditorForm;
-            var itemspage = form?.Pages.FirstOrDefault(x => x is DynamicOneToManyGrid<PurchaseOrder, PurchaseOrderItem>) as DynamicOneToManyGrid<PurchaseOrder, PurchaseOrderItem>;
-            if ((itemspage == null) || (itemspage.Items.Count == 0))
-                return result;
-            
-            if (name.Equals("DueDate") && (MessageBox.Show("Update Due Date on existing items?", "Alert", MessageBoxButton.YesNo) == MessageBoxResult.Yes))
-            {
-                foreach (var item in itemspage.Items)
-                    item.DueDate = Convert.ToDateTime(value);
-                itemspage.Refresh(false, true);
-            }
-            else if (name.Equals("SupplierLink.ID") &&
-                     (MessageBox.Show("Update Supplier Pricing to existihg items?", "Alert", MessageBoxButton.YesNo) == MessageBoxResult.Yes))
-            {
-                PurchaseOrder.UpdateCosts(itemspage.Items, (Guid)value, null);
-                // var productids = itemspage.Items.Where(x => x.Product.ID != Guid.Empty).Select(x => x.Product.ID).ToArray();
-                // MultiQuery query = new MultiQuery();
-                // query.Add(
-                //     new Filter<SupplierProduct>(x=>x.SupplierLink.ID).IsEqualTo(value).And(x=>x.ProductLink.ID).InList(productids),
-                //     new Columns<SupplierProduct>(x=>x.ProductLink.ID).Add(x=>x.Job.ID).Add(x=>x.CostPrice)
-                // );
-                // query.Add(
-                //     new Filter<Product>(x=>x.ID).InList(productids),
-                //     new Columns<Product>(x=>x.ID).Add(x=>x.NettCost)
-                // );
-                // query.Query();
-                //
-                // foreach (var item in itemspage.Items)
-                // {
-                //     CoreRow? row = query.Get<SupplierProduct>()?.Rows.FirstOrDefault(r =>
-                //         (r.Get<SupplierProduct, Guid>(c => c.ProductLink.ID) == item.Product.ID)
-                //         && (r.Get<SupplierProduct, Guid>(c => c.Job.ID) == item.Job.ID)
-                //     );
-                //     if (row == null)
-                //         row = query.Get<SupplierProduct>()?.Rows.FirstOrDefault(r =>
-                //             (r.Get<SupplierProduct, Guid>(c => c.ProductLink.ID) == item.Product.ID)
-                //             && (r.Get<SupplierProduct, Guid>(c => c.Job.ID) == Guid.Empty)
-                //         );
-                //     if (row != null)
-                //         item.Cost = row.Get<SupplierProduct, double>(c => c.CostPrice);
-                //     else
-                //     {
-                //         row = query.Get<Product>()?.Rows.FirstOrDefault(r =>
-                //             (r.Get<Product, Guid>(c => c.ID) == item.Product.ID)
-                //         );
-                //         if (row != null)
-                //             item.Cost = row.Get<Product, double>(c => c.NettCost);
-                //     }
-                //
-                // }
-                
-                itemspage.Refresh(false, true);
+            //try
+            //{               
+            //    var form = sender as DynamicEditorForm;
+            //    var itemspage = form?.Pages.FirstOrDefault(x => x is DynamicOneToManyGrid<PurchaseOrder, PurchaseOrderItem>) as DynamicOneToManyGrid<PurchaseOrder, PurchaseOrderItem>;
+            //    if ((itemspage == null) || (itemspage.Items.Count == 0))
+            //        return result;
 
-            }
+            //    if (name.Equals("DueDate") && (MessageBox.Show("Update Due Date on existing items?", "Alert", MessageBoxButton.YesNo) == MessageBoxResult.Yes))
+            //    {
+            //        foreach (var item in itemspage.Items)
+            //            item.DueDate = Convert.ToDateTime(value);
+            //        itemspage.Refresh(false, true);
+            //    }
+            //    else if (name.Equals("SupplierLink.ID") &&
+            //             (MessageBox.Show("Update Supplier Pricing to existihg items?", "Alert", MessageBoxButton.YesNo) == MessageBoxResult.Yes))
+            //    {
+            //        PurchaseOrder.UpdateCosts(itemspage.Items, (Guid)value, null);
+            //        // var productids = itemspage.Items.Where(x => x.Product.ID != Guid.Empty).Select(x => x.Product.ID).ToArray();
+            //        // MultiQuery query = new MultiQuery();
+            //        // query.Add(
+            //        //     new Filter<SupplierProduct>(x=>x.SupplierLink.ID).IsEqualTo(value).And(x=>x.ProductLink.ID).InList(productids),
+            //        //     new Columns<SupplierProduct>(x=>x.ProductLink.ID).Add(x=>x.Job.ID).Add(x=>x.CostPrice)
+            //        // );
+            //        // query.Add(
+            //        //     new Filter<Product>(x=>x.ID).InList(productids),
+            //        //     new Columns<Product>(x=>x.ID).Add(x=>x.NettCost)
+            //        // );
+            //        // query.Query();
+            //        //
+            //        // foreach (var item in itemspage.Items)
+            //        // {
+            //        //     CoreRow? row = query.Get<SupplierProduct>()?.Rows.FirstOrDefault(r =>
+            //        //         (r.Get<SupplierProduct, Guid>(c => c.ProductLink.ID) == item.Product.ID)
+            //        //         && (r.Get<SupplierProduct, Guid>(c => c.Job.ID) == item.Job.ID)
+            //        //     );
+            //        //     if (row == null)
+            //        //         row = query.Get<SupplierProduct>()?.Rows.FirstOrDefault(r =>
+            //        //             (r.Get<SupplierProduct, Guid>(c => c.ProductLink.ID) == item.Product.ID)
+            //        //             && (r.Get<SupplierProduct, Guid>(c => c.Job.ID) == Guid.Empty)
+            //        //         );
+            //        //     if (row != null)
+            //        //         item.Cost = row.Get<SupplierProduct, double>(c => c.CostPrice);
+            //        //     else
+            //        //     {
+            //        //         row = query.Get<Product>()?.Rows.FirstOrDefault(r =>
+            //        //             (r.Get<Product, Guid>(c => c.ID) == item.Product.ID)
+            //        //         );
+            //        //         if (row != null)
+            //        //             item.Cost = row.Get<Product, double>(c => c.NettCost);
+            //        //     }
+            //        //
+            //        // }
+
+            //        itemspage.Refresh(false, true);
+            //    }
+            //}
+            //catch
+            //{ }
             return result;
             
         }