I am trying to trap the event when a user changes the sell price of an item. All I want to do is capture and display a box that say "Hey dummy, you are trying to change the sell price, do you really want to be doing that???" I am using VS C# and all works well with the exception I do not want this check to occur when the user is entering a new line on the order in the Line Scroll area. What can I use in my code as an indication that this is a new line?
Here is my current code:
/*Register a change event for the Unit Sell Price field of the Line Scroll window on the sales transaction entry window*/ sopEntryWindow.LineScroll.LocalUnitPrice.Change +=
new EventHandler(CheckForLineValueChanges);
/* Check for line value change of the field LocalUnitPrice */
public void CheckForLineValueChanges(object sender, EventArgs e)
{ sopEntryWindow.LineScroll.LocalUnitPrice.LeaveAfterOriginal += new EventHandler(SellPriceChangeNotification);
} /* Notify the user that the sell price has been changed and prompt for confirmation and reason */ public void SellPriceChangeNotification(object sender, EventArgs e)
{ if (SOPCheckSellPriceForm == null)
{ SOPCheckSellPriceForm = new frmSOPCheckSellPrice();
} else { if (SOPCheckSellPriceForm.Created == false)
{ SOPCheckSellPriceForm = new frmSOPCheckSellPrice(LocalUnitSellPrice,UnitSellPrice);
} } /* Display notificaction that user has changed sell price */
SOPCheckSellPriceForm.Show(); SOPCheckSellPriceForm.Activate(); } public void CheckForLineValueChanges(object sender, EventArgs e)
{ sopEntryWindow.LineScroll.LocalUnitPrice.LeaveAfterOriginal += new EventHandler(SellPriceChangeNotification);
} /* Notify the user that the sell price has been changed and prompt for confirmation and reason */ public void SellPriceChangeNotification(object sender, EventArgs e)
{ if (SOPCheckSellPriceForm == null)
{ SOPCheckSellPriceForm = new frmSOPCheckSellPrice();
} else { if (SOPCheckSellPriceForm.Created == false)
{ SOPCheckSellPriceForm = new frmSOPCheckSellPrice(LocalUnitSellPrice,UnitSellPrice);
} } /* Display notificaction that user has changed sell price */
SOPCheckSellPriceForm.Show(); SOPCheckSellPriceForm.Activate(); } public void CheckForLineValueChanges(object sender, EventArgs e)
{ sopEntryWindow.LineScroll.LocalUnitPrice.LeaveAfterOriginal += new EventHandler(SellPriceChangeNotification);
} /* Notify the user that the sell price has been changed and prompt for confirmation and reason */ public void SellPriceChangeNotification(object sender, EventArgs e)
{ if (SOPCheckSellPriceForm == null)
{ SOPCheckSellPriceForm = new frmSOPCheckSellPrice();
} else { if (SOPCheckSellPriceForm.Created == false)
{ SOPCheckSellPriceForm = new frmSOPCheckSellPrice(LocalUnitSellPrice,UnitSellPrice);
} } /* Display notificaction that user has changed sell price */
SOPCheckSellPriceForm.Show(); SOPCheckSellPriceForm.Activate(); }
public void CheckForLineValueChanges(object sender, EventArgs e)
{ sopEntryWindow.LineScroll.LocalUnitPrice.LeaveAfterOriginal += new EventHandler(SellPriceChangeNotification);
} /* Notify the user that the sell price has been changed and prompt for confirmation and reason */ public void SellPriceChangeNotification(object sender, EventArgs e)
{ if (SOPCheckSellPriceForm == null)
{ SOPCheckSellPriceForm = new frmSOPCheckSellPrice();
} else { if (SOPCheckSellPriceForm.Created == false)
{ SOPCheckSellPriceForm = new frmSOPCheckSellPrice(LocalUnitSellPrice,UnitSellPrice);
} } /* Display notificaction that user has changed sell price */
SOPCheckSellPriceForm.Show(); SOPCheckSellPriceForm.Activate(); }
*This post is locked for comments
Richard, Use the ValidateBeforeOriginal or ValidateAfterOriginal events. Those will only run if the user actually tries to change the field. The change event is going to run whenever the field changes whether the user did it or not.
OK, I think the solution is this.
When you go to create a new line in the line scroll area, the line is not added to the SOP line table until you move to the next line. So they way to tell if it is a new line is to check to see if it exists in the SOP10200 table. If it does not, then it is a new line. Now the question is how do you do that using VS C#?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156