1 (edited by bibif 2016-09-10 21:40:57)

Topic: Little Help for..Saving new record line :)

Hello Guys,

I'm using two Grids (linked to two Tables of my database) to copy a complete line (4 columns) from Grid A to Grid B
with the following script. The results displays correctly in Grid B at first,

Now : I would like to know the WAY TO SAVE THE NEW LINE CONTENT of Grid B. ? smile !!

Does one have to use the SAVE ACTION on the same DEFVALUE button and place my Code on a distinct EVENT
(like before saving...) ?
..or is there another function (?) I can add at the END of my script to  SAVE the changes ?


 procedure Form_DEFVALUE_OnClick (Sender: string; var Cancel: boolean);
begin
        Fvol.GRIDB.AddRow;
        Fvol.GRIDB.selectedrow:= 0;
        Fvol.GRIDB.Cells[0,0]:= Fvol.GRIDA.Cells[1,1];
        Fvol.GRIDB.Cells[1,0]:= Fvol.GRIDA.Cells[2,1];
end;

..also this code works WELL overwriting an existing content (when GRID B is displaying existing records)
...but if it does not copy succesfully the content from Grid A when Grid B "loads empty" (not showing any existing records).
As a result I would get a bunch of "1" in each column.

Thanks for your advices !

I tried using

: Fvol.GRIDB.dbUpdate;   

  but it seems that it is NOT the right command to save the line content..

Rien ne sert de courir, mieux vaut savoir dans quelle direction aller,, smile

Re: Little Help for..Saving new record line :)

Salut Bibif,


A en juger par ta signature, je dirais que je ne prends pas un gros risque en passant au français :-)


En ce qui concerne le dbUpdate, le seul effet que cela a est de recharger le contenu de la table dans la TableGrid sur la base de la requête initiale attachée à cette TableGrid, pas de sauvegarder la ligne ajoutée "manuellement".


De manière à pouvoir t'assister efficacement dans to projet, verrais-tu un inconvénient à l'attacher à ta réponse ?


Un bon week-end l'ami


Mathias

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

Zaza Gabor

3 (edited by bibif 2016-09-11 03:27:43)

Re: Little Help for..Saving new record line :)

Salut Matthias,

Pas de probleme c est une fenetre remplie de bouttons qui me servent pour chacun de mes test...
OK, le bouton ou je teste le code copie Grid a Grid     est en jaune.

le fichier de 4000KB est trop gros pour l upload ?!!!
sad..

je tente avec cela, je ne sait pas si cela serait exploitable

Post's attachments

Attachment icon exportgrid.vdb 35 b, 587 downloads since 2016-09-11 

Rien ne sert de courir, mieux vaut savoir dans quelle direction aller,, smile

Re: Little Help for..Saving new record line :)

Salut bibig,


Le fichier .vdb n'est pas exploitable seul.

Ce que tu peux faire c'est zipper tout le répertoire de ton projet APRES avoir supprimé l’exécutable compilé. Avec tout le répretoire (sans l'exe) n'importe qui ici peut compiler ton projet et le passer en revue.


A très vite


Math

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

Zaza Gabor

Re: Little Help for..Saving new record line :)

Hello,


Component TableGrid uses only to display data from database, if you change some data directly in the TableGrid it's not mean that you changed data in a database. I think you have wrong database structure.


I can suggest for you study some material for beginners:
http://myvisualdatabase.com/forum/viewtopic.php?id=2694
http://myvisualdatabase.com/forum/viewtopic.php?id=986

Dmitry.

Re: Little Help for..Saving new record line :)

Thanks for advising Dimitry,
then I should need to create/open an Input Windows for any necessary line modifications...if I got it right ?
(* it would be nice to have this feature integrated in the Datagrid someday)

What if I want to select a each line from Grid A, and apply process to each, (i.e Change some values) and then copy each modified line to Grid B ?

Should I just use an Off the screen process - Virtual process - and then Write all results to a file, and only then display the resulting values of the Target Grid, once alll line have been processed ?


As for any DB wrong structure, can you specify what error you did find for instance ?
and can it be solved by modifying Fields name only ?

It happens that I had created the project in the Document folder and had to move it to another folder to just Zip what was necessary, meanwhile I also did rename several Tables and objects, fields, Forms, etc...

Rien ne sert de courir, mieux vaut savoir dans quelle direction aller,, smile

7 (edited by bibif 2016-09-12 23:31:45)

Re: Little Help for..Saving new record line :)

@Matthias,
Dimitry semble dire qu il n est pas possible d utiliser une TableGrid pour operer des modif. sur une ligne.
(Modif  ? ou "bien aussi creation neuve" ?)

en fait, plus q'une modif de ligne existante, c est simplement un ajout de nouvelle ligne "calculee" et pas a pas que je souhaite faire,..
(pas simplement une bete copie)

Je yeute les exemples tout fait,  et ton exemple LINK me semble pourtant bien utiliser 2 Grids - pour ajouter de nouveaux enregistrements - ou me  trompe je ? smile

Le traitement exacte consiste a selectionner des candidats, suivant leur jour et heure disponible GRID-A pour leur "assigner" un jour/heure correspondant a un Agenda (GRID-B) pouvant s etandre de 1 a 6 semaines tout en "incrementant" leur valeur de Quota de participation afin de permetre a la boucle de calculer une repartition des candidats par semaine la plus equitable possible.. Ceux qui passent le plus, laisseraient le champs a ceux qui passent moins souvent, lors de la prochaine execution de la boucle. Celle-ci s arrete a la date definie comme Date Finale.

J'espere que mon idee reste claire comme de l eau de roche !
smile

Okay,  I messed up with the SCRIPT FOLDER (while cleaning...)
Here is the full Project with the corresponding SCRIPT joined..Sorry for that people !

Post's attachments

Attachment icon GRID WITH GOOD SCRIPT.zip 333.12 kb, 481 downloads since 2016-09-13 

Rien ne sert de courir, mieux vaut savoir dans quelle direction aller,, smile