I’m currently using the BeforeToolClick method to perform some actions when the Save button is pressed. I have recently been asked to put a check in to make sure certain requirements are met before a save can be allowed. I’ve got everything set up with a basic Yes/No dialog box but the problem is I can’t seem to figure out how to cancel the update from here. Any suggestions would be appreciated.
Can you post your code?
If I recall, you should be able to do something like:
args.Cancel = true;
Otherwise, you can go the BPM route. Set up a pre processing on the Update BO, call a BPM Data Form with a yes/no, then have a condition that checks the value of the button returned and raise an exception if necessary.
Sure. As I said it’s literally just the basic Dialog Box code:
private void RcptToInvForm_BeforeToolClick(object sender, Ice.Lib.Framework.BeforeToolClickEventArgs args)
{
switch(args.Tool.Key)
{
case "SaveTool":
DialogResult dialogResult = EpiMessageBox.Show("Weight/Length is out of range. Continue?", "Continue", MessageBoxButtons.YesNo);
if ((dialogResult == DialogResult.No))
{
//Cancel Save;
}
else
{
//All the other code
}
In the BeforeAdapterMethod event on Update I could just use args.Cancel = true as @hmwillett suggested but ToolClickEventArgs does not seem to include a Cancel arg.
Are you hell bent on doing this through the UI?
With Kinetic out, I would recommend doing it through a BPM as that’s one less item you will have to manually upgrade.
It might be an enumeration instead of a property, I will need to take a look
I use the BeforeAdapterMethod to catch an Update event and cancel it after checking info.
that works.
I also use to catch those actions on the menu to perform other tasks:
private void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
{
switch(args.Tool.Key)
{
}
}
But there is no cancel in the args.
What does your debugger indicates as value of dialogResult ?
Pierre
Thanks to everyone for the replies. I found the following bit on another post and it seems to have done the trick to cancel the save:
args.Handled = true;