Combining OnValidate and OnBeforePost?

As an example, I have a form with DBNavigator and several DBEdits.

enter image description here

I want to achieve the following results:

  • When a user enters something wrong in DBEdit and wants to switch to another control, a warning should be displayed, but it can continue to work.
  • When a user wants to publish a dataset, the message will be rejected and the warning will be displayed again.

The problem is that OnValidate is just TFieldNotifyEvent and therefore cannot tell the application if the editing was valid, so there is no way to check if everything was valid before publication.

I tried the following:

Idea 1: let OnBeforePost check and throw an exception

  • Pro:
    • Invalid data will not be published.
    • DBNavigator, .
  • Contra:
    • , DBEdit
    • ( ) . Object Orientated , TField.

2: OnValidate

  • Pro:
    • .
  • Contra:
    • , - (, , ), "" DBNavigator! , , .

3: ( ) OnValidate OnBeforePost ( )

  • Pro:
    • , .
  • Contra:
    • ( ), , . , , .
    • "Post-Button", DBEdit, ( DBEdit , )
    • , (, - , ), ( )

?

+4
2

, - ( ) (OnValidate). . - . , MVC. DB- ORM framework + LiveBindings.

+1

Source: https://habr.com/ru/post/1626129/


All Articles