|
@@ -84,29 +84,26 @@ namespace PRSDesktop
|
|
|
{
|
|
|
var row = e.Rows?.FirstOrDefault();
|
|
|
Items.Master = e.Rows?.FirstOrDefault()?.ToObject<QuoteCostSheet>();
|
|
|
-
|
|
|
+ Items.Refresh(false,true);
|
|
|
}
|
|
|
|
|
|
- private Guid[] costsheetids;
|
|
|
+ private Dictionary<Guid,Guid> costsheetids = null;
|
|
|
|
|
|
private void CostSheets_OnBeforeSave(IDynamicEditorForm editor, BaseObject[] items)
|
|
|
{
|
|
|
- costsheetids = items.Cast<QuoteCostSheet>().Select(x => x.CostSheet.GetOriginalValue(c => c.ID)).ToArray();
|
|
|
+ costsheetids = new Dictionary<Guid, Guid>(
|
|
|
+ items.Cast<QuoteCostSheet>().Select(x => new KeyValuePair<Guid, Guid>(x.ID,x.CostSheet.GetOriginalValue(c => c.ID)))
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
private void CostSheets_OnAfterSave(IDynamicEditorForm editor, BaseObject[] items)
|
|
|
{
|
|
|
- for (var i = 0; i < items.Length; i++)
|
|
|
+ foreach (var qcs in items.OfType<QuoteCostSheet>())
|
|
|
{
|
|
|
- var qcs = items[i] as QuoteCostSheet;
|
|
|
- if (qcs != null)
|
|
|
- {
|
|
|
- if (qcs.CostSheet.IsValid() && costsheetids[i] == Guid.Empty)
|
|
|
- Items.SetupCostSheet(qcs.ID, qcs.CostSheet.ID);
|
|
|
- }
|
|
|
+ costsheetids.TryGetValue(qcs.ID, out Guid oldcostsheetid);
|
|
|
+ if (qcs.CostSheet.ID != oldcostsheetid)
|
|
|
+ Items.SetupCostSheet(qcs.ID, qcs.CostSheet.ID);
|
|
|
}
|
|
|
-
|
|
|
- costsheetids = null;
|
|
|
}
|
|
|
}
|
|
|
}
|