Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Common;
using PX.Data;
using PX.Data.EP;
using PX.Objects;
using PX.Objects.RQ;
using PX.Objects.PO;
using PX.Objects.EP;
using System.Reflection;
namespace PX.Objects.PO
{
public class MyApprovalAutomation
: EPApprovalAutomation<POOrder, POOrder.approved, POOrder.rejected, POOrder.hold, POSetupApproval>
{
public MyApprovalAutomation(PXGraph graph, Delegate @delegate)
: base(graph, @delegate)
{
}
public MyApprovalAutomation(PXGraph graph)
: base(graph)
{
}
public override void Reset(POOrder source)
{
base.Reset(source);
}
protected override void Approved_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e)
{
try
{
base.Approved_FieldVerifying(cache, e);
}
catch
{
e.NewValue = false;
throw;
}
}
}
public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
{
#region DataViews
[PXViewName(Messages.Approval)]
public MyApprovalAutomation Approval;
#endregion
#region Initialise
public override void Initialize()
{
base.Initialize();
MethodInfo mi = null;
Type type = Base.Approval.GetType();
//Removing events from base ApprovalAutomation view.
mi = type.GetMethod("Approved_FieldUpdated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
Base.FieldUpdated.RemoveHandler(BqlCommand.GetItemType(typeof(POOrder.approved)), typeof(POOrder.approved).Name,
(PXFieldUpdated)mi.CreateDelegate(typeof(PXFieldUpdated), Base.Approval));
mi = type.GetMethod("Approved_FieldVerifying", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
Base.FieldVerifying.RemoveHandler(BqlCommand.GetItemType(typeof(POOrder.approved)), typeof(POOrder.approved).Name,
(PXFieldVerifying) mi.CreateDelegate(typeof(PXFieldVerifying), Base.Approval));
mi = type.GetMethod("Approved_FieldDefaulting", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
Base.FieldDefaulting.RemoveHandler(BqlCommand.GetItemType(typeof(POOrder.approved)), typeof(POOrder.approved).Name,
(PXFieldDefaulting) mi.CreateDelegate(typeof(PXFieldDefaulting), Base.Approval));
mi = type.GetMethod("Rejected_FieldUpdated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
Base.FieldUpdated.RemoveHandler(BqlCommand.GetItemType(typeof(POOrder.rejected)), typeof(POOrder.rejected).Name,
(PXFieldUpdated) mi.CreateDelegate(typeof(PXFieldUpdated), Base.Approval));
mi = type.GetMethod("Rejected_FieldVerifying", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
Base.FieldVerifying.RemoveHandler(BqlCommand.GetItemType(typeof(POOrder.rejected)), typeof(POOrder.rejected).Name,
(PXFieldVerifying) mi.CreateDelegate(typeof(PXFieldVerifying), Base.Approval));
mi = type.GetMethod("Hold_FieldDefaulting", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
Base.FieldDefaulting.RemoveHandler(BqlCommand.GetItemType(typeof(POOrder.hold)), typeof(POOrder.hold).Name,
(PXFieldDefaulting) mi.CreateDelegate(typeof(PXFieldDefaulting), Base.Approval));
mi = type.GetMethod("RowUpdated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
Base.RowUpdated.RemoveHandler(typeof(POOrder), (PXRowUpdated) mi.CreateDelegate(typeof(PXRowUpdated), Base.Approval));
mi = type.GetMethod("OnPersisted", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
Base.RowPersisted.RemoveHandler(typeof(POOrder), (PXRowPersisted)mi.CreateDelegate(typeof(PXRowPersisted), Base.Approval));
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.