It's actually a bit tricky because the line is added, THEN serials are asked for. I can cancel my way out of the serial dialog by adding the line:
- Code: Select all
serialDialog.DialogResult = System.Windows.Forms.DialogResult.Cancel;
Just before your exception throw line:
- Code: Select all
throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();
Here is the modified plugin:
HOWEVER this has the affect of keeping the line, but putting the quantity on back order. Because remember, we have already added the line, it is the setting of the Quantity Ordered which triggers the serial selection dialog to display.
I think a better approach might be to LOCK the "Unit Quantity" cell on the serial dialog for rows which are not allowed to be selected. If you need to explain to the user why the cell is locked, use an error provider on the cell. Let me know if you need help doing this.