|
@@ -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;
|
|
|
|
|
|
}
|