Revert sales order line changed to original value
Hi,
I have a custom field on Staff Maintenance which says what the allowable discount is when entering/editing sales order lines.
The plugin works well...almost.
If the allowable discount has been exceeded, I just need the price to revert back to what it was prior to the edit.
This is my code so far
Can you advise how I can put the line values back to what they were prior to the price change?
Cheers
I have a custom field on Staff Maintenance which says what the allowable discount is when entering/editing sales order lines.
The plugin works well...almost.
If the allowable discount has been exceeded, I just need the price to revert back to what it was prior to the edit.
This is my code so far
- Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
Dim SalesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(JiwaForm, JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
AddHandler salesOrderForm.SalesOrder.SalesOrderLines.Changed, AddressOf SOLineDiscount_Changed
End Sub
Private Sub SOLineDiscount_Changed(item As JiwaSales.SalesOrder.SalesOrderLine, e As System.ComponentModel.PropertyChangedEventArgs)
Dim MyStaff As JiwaApplication.JiwaStaff.clsStaff =JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaApplication.JiwaStaff.clsStaff)(Nothing)
MyStaff.Read(JiwaApplication.Manager.Instance.Staff.RecID)
Dim DiscPcnt As Integer
For Each customFieldValue As JiwaApplication.CustomFields.CustomFieldValue In JiwaApplication.Manager.Instance.Staff.CustomFieldValues
If customFieldValue.CustomField.PluginCustomField.Name = "DISC" Then
Integer.TryParse(customFieldValue.Contents, DiscPcnt)
Exit For
End If
Next
msgbox(DiscPcnt)
If item.DiscountPercentage > DiscPcnt Then
MessageBox.Show("You don't have authority for this discount.", "Verify allowed discount")
Throw New JiwaApplication.Exceptions.ClientCancelledException
End If
End Sub
Can you advise how I can put the line values back to what they were prior to the price change?
Cheers