1 (edited by mathmathou 2015-12-03 02:07:40)

Topic: Curious on how you do things...

Hello Dmitry and all MVD fans,


A question for the whole community, I'll try to be as clear as possible. This is not urgent and this is mostly curiosity on my part.
This question arise from Tcoton's subject on DuplicateCheck, because I wonder if he does all through scripting or not.


In standard use, MVD let us add and edit data from a database with just 2 forms using no scripting at all.
On Form1 with a TableGrid1, we have 2 buttons, pointing to the same Form2, one for adding one for editing.
When we save from the Form2, records are added or modified in database and updated in Form1.TableGrid1 : all we have to do is link the correct action for each button and specify the correct table and fields for the Edit fields.


But that way, what I call "easy auto mode", there is no duplicate check.


For duplicate checking, I go full script.
I have the same Form1 and TableGrid1, Form2 for editing and adding, but the SAVE button on Form2 IS NOT linked to ACTION in MVD Object Inspector : it is fully scripted through OnClick procedure.


Well, this works.


My question is : can we combine the two : "easy auto mode" and script ? I've tried but failed miserably smile


What I mean is this :


First we setup MVD for "full automatic" handling of editing and saving data.


Then, through the OnClick Procedure on the SAVE button we had script to intercept the Action like :


if Form1.dbAction := 'NewRecord' then
     begin
          if bad_condition1 then
               begin
                   Cancel := True;
               end
          if bad_condition2 then
               begin
                   Cancel := True;
               end;
     end;

if Form1.dbAction := 'ShowRecord' then... and so on

What would be the advantages ?


Well, if we can combine the 2, we just have to handle exceptions through the scripting and cancel the action, not the INSERT and UPDATE procedure.


Of course, when you have manually handled all the exceptions, adding the INSERT or UPDATE procedure is just a few more lines, but I am curious.


Thanks in advance to all of you for your ideas on the subject.


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Curious on how you do things...

Maybe I misunderstood the question, but you don't need write INSERT or UPDATE sql queries for record, when you use Cancel := True;

Dmitry.