private void SetProcessDelegate() { BalanceFilter filter = Filter.Current; bool depriciate = filter.Action == BalanceFilter.action.Depreciate; Balances.SetProcessDelegate(delegate(List <FABookBalance> list) { if (PXLongOperation.GetTaskList().Where(_ => _.Screen == "FA.50.20.00").ToArray().Length > 1) { throw new PXException(Messages.AnotherDeprRunning); } List <FABookBalance> balances = GetProcessableRecords(list); if (depriciate) { AssetProcess.DepreciateAsset(balances, null, filter.PeriodID, true); } else { AssetProcess.CalculateAsset(balances, filter.PeriodID); } }); bool canDepreciate = !string.IsNullOrEmpty(filter.PeriodID) && fasetup.Current.UpdateGL == true; PXUIFieldAttribute.SetEnabled <BalanceFilter.action>(Filter.Cache, filter, canDepreciate); if (!canDepreciate) { filter.Action = BalanceFilter.action.Calculate; } }
protected virtual void BalanceFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { if (e.Row != null) { BalanceFilter filter = Filter.Current; if (Depreciate) { Balances.SetProcessDelegate(delegate(List <FABookBalance> list) { if (PXLongOperation.GetTaskList().Where(_ => _.Screen == "FA.50.20.00").ToArray().Count() > 1) { throw new PXException(Messages.AnotherDeprRunning); } AssetProcess.DepreciateAsset(list, null, filter.PeriodID, true); }); } else { Balances.SetProcessDelegate(delegate(List <FABookBalance> list) { if (PXLongOperation.GetTaskList().Where(_ => _.Screen == "FA.50.20.00").ToArray().Count() > 1) { throw new PXException(Messages.AnotherDeprRunning); } AssetProcess.CalculateAsset(list, filter.PeriodID); }); } Balances.SetProcessVisible(false); Balances.SetProcessAllVisible(false); PXButtonState pstate = Actions["Process"].GetState(e.Row) as PXButtonState; PXButtonState pastate = Actions["ProcessAll"].GetState(e.Row) as PXButtonState; bool penabled = pstate == null || pstate.Enabled; bool paenabled = pastate == null || pastate.Enabled; Calculate.SetEnabled(penabled); CalculateAll.SetEnabled(paenabled); CalcDepr.SetEnabled(!string.IsNullOrEmpty(filter.PeriodID) && fasetup.Current.UpdateGL == true && penabled); CalcDeprAll.SetEnabled(!string.IsNullOrEmpty(filter.PeriodID) && fasetup.Current.UpdateGL == true && paenabled); } }