| class Dpk_VendTableEventHandlerClass |
| { |
|
|
| /// <summary> |
| /// |
| /// </summary> |
| /// <param name="sender"></param> |
| /// <param name="e"></param> |
| [DataEventHandler(tableStr(VendTable), DataEventType::InitializedRecord)] |
| public static void VendTable_onInitializedRecord(Common sender, DataEventArgs e) |
| { |
| VendTable vendTable = sender as VendTable; |
| vendTable.VendGroup = "VG001"; //Change this value |
| //Add business logic |
|
|
| } |
|
|
| /// <summary> |
| /// |
| /// </summary> |
| /// <param name="sender"></param> |
| /// <param name="e"></param> |
| [DataEventHandler(tableStr(VendTable), DataEventType::Inserted)] |
| public static void VendTable_onInserted(Common sender, DataEventArgs e) |
| { |
| VendTable vendTable = sender as VendTable; |
| if(!vendTable.YourAccountNum) |
| { |
| //Add business logic |
|
|
| vendTable.YourAccountNum = "This is event handler example"; |
| } |
|
|
| } |
|
|
| /// <summary> |
| /// |
| /// </summary> |
| /// <param name="sender"></param> |
| /// <param name="e"></param> |
| [DataEventHandler(tableStr(VendTable), DataEventType::Deleted)] |
| public static void VendTable_onDeleted(Common sender, DataEventArgs e) |
| { |
| VendTable vendTable = sender as VendTable; |
|
|
| //Add business logic |
|
|
| if (box::yesNo(strFmt('The selected vendor with Rating %1 will be deleted, are you sure ?', vendTable.CreditRating), dialogButton::Yes, 'Confirmation') == dialogButton::Yes) |
| { |
| Info("Operation successfull"); |
| } |
|
|
| } |
|
|
| /// <summary> |
| /// |
| /// </summary> |
| /// <param name="sender"></param> |
| /// <param name="e"></param> |
| [DataEventHandler(tableStr(VendTable), DataEventType::ValidatingWrite)] |
| public static void VendTable_onValidatingWrite(Common sender, DataEventArgs e) |
| { |
| VendTable vendTable = sender as VendTable; |
|
|
| //Add business logic |
|
|
| if((vendTable.CreditMax && !vendTable.CreditRating) |
| || (!vendTable.CreditMax && vendTable.CreditRating)) |
| { |
| warning("Credit rating must filled for credit limit"); |
| } |
|
|
| } |
|
|
| /// <summary> |
| /// |
| /// </summary> |
| /// <param name="sender"></param> |
| /// <param name="e"></param> |
| [DataEventHandler(tableStr(VendTable), DataEventType::ModifiedField)] |
| public static void VendTable_onModifiedField(Common sender, DataEventArgs e) |
| { |
| ModifyFieldEventArgs event = e as ModifyFieldEventArgs; |
| VendTable vendTable = sender as VendTable; |
| FieldId fieldId = event.parmFieldId(); |
|
|
| switch(fieldId) |
| { |
| //Add business logic |
|
|
| case fieldNum(VendTable, PaymMode): |
| Info("Business logic for PaymMode"); |
| break; |
|
|
| default: |
| break; |
| } |
| } |
|
|
| /// <summary> |
| /// |
| /// </summary> |
| /// <param name="sender"></param> |
| /// <param name="e"></param> |
| [DataEventHandler(tableStr(VendTable), DataEventType::ValidatingField)] |
| public static void VendTable_onValidatingField(Common sender, DataEventArgs e) |
| { |
| VendTable vendTable = sender as VendTable; |
| ValidateFieldEventArgs validateFieldEventArgs = e as ValidateFieldEventArgs ; |
| boolean ret = validateFieldEventArgs.parmValidateResult(); |
|
|
| if(ret) |
| { |
| switch(validateFieldEventArgs.parmFieldId()) |
| { |
| //Add business logic |
|
|
| case fieldNum(VendTable, CreditMax): |
| if(vendTable.CreditRating == "Amber" && vendTable.CreditMax > 10000) |
| { |
| vendTable.CreditMax = 0; |
| Error("Credit can not exceed more than 10K for Amber rating"); |
| ret = false; |
| } |
| break; |
| } |
| } |
| |
| validateFieldEventArgs.parmValidateResult(ret); |
| } |
|
|
| } |