Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
9
Erster Beitrag:
vor 6 Jahren, 3 Monaten
Letzter Beitrag:
vor 6 Jahren, 3 Monaten
Beteiligte Autoren:
DarrenF, Paulo Oliveira, Peter H. , Steve Hodgman.pcs.crosspost, Allard

[WD16] Updating records of a Table Control that is populated via a query

Startbeitrag von DarrenF am 24.02.2012 08:33

Hi,

I'm just starting out using a queries to populate Table Controls. I managed to get the query populating the Table Control - no problem.

This Table Control is on a window that is used to modify records from a file. The previous Table Control would update a record simply by moving away from the edited row. How is this add/modify/delete processing best controlled when the Table Control is populated by an external (not embedded) query?

Thanks in advance...

Antworten:

It depends.
The query only uses one file? If so check the help for hexecutequery and in the mode use hModifyFile.
If not, dot it yourself by code.

http://doc.windev.com/en-US/?3044080&name=hexecutequery-function

von Paulo Oliveira - am 24.02.2012 10:03

Re: [WD16] Updating records of a Table Control that is populated

In the "Row Exit" Event/Section you can put code that directly updates
the records using HReadSeekFirst(...) etc

You will need to have the unique key to the record in the Table Query.
Possibly in a column that is hidden?
---
Steve Hodgman

On 24/02/2012 7:47 PM, DarrenF wrote:
> Hi,
>
> I'm just starting out using a queries to populate Table Controls. I managed to get the query populating the Table Control - no problem.
>
> This Table Control is on a window that is used to modify records from a file. The previous Table Control would update a record simply by moving away from the edited row. How is this add/modify/delete processing best controlled when the Table Control is populated by an external (not embedded) query?
>
> Thanks in advance...
>
Message forwarded from pcsoft.us.windev

von Steve Hodgman.pcs.crosspost - am 24.02.2012 10:55
Thanks guys...

@Paulo, sorry - forgot to mention, it joins several files. Some are UPDATEable and some are read only. I'll read the HExecuteQuery stuff - but I fear I need the next step - the "how to update" bit?

@Steve, Okay, yes - I already have the ID's of the files I need to update, so, if I need to explicitly issue a HMODIFY - I can do that.

von DarrenF - am 24.02.2012 14:31
With joins use the steve solution or something similiar like mark the changed row in one hiden column and at the end go thru all the lines in the table and if it was changed hreadseek & hmodify/hadd/hdelete.

von Paulo Oliveira - am 24.02.2012 14:38
Hi

You are populating a table based on a query. The table is filled . Now you want to add rows based on several files . Onely 1 files changes . The other files are used to complete the line that is added ( selection combo) or something like that ?

Add the file that changes with Hadd() or H modify() The files that are read onely are used to fill the table They are not saved In the file that changes the key to those files is saved.

Next time you load your table use the query to load it.

von Allard - am 28.02.2012 10:06
Hi Allard,

Thanks for your comment...

Now that I'm handling the movement of the user around the Table control, the exiting of a row when mandatory fields fail validation, exiting the window during the editing of a row etc...etc... (wouldn't it be great if WD could handle this OutOfTheBox?), I'm just about to start the coding of the adding/updating bit, so if I use the Query to populate the Table control (by 1 or many files), and I Hadd or Hmodify - I assume I need to do a HReadSeekFirst before I can modify the record?

So it would be:
1) Query populates the Table control
2) User selects and adds/amends a row of the Table control
3) On exit of row, do HAdd ...or... HReadSeekFirst followed by HModify
[[5]]

von DarrenF - am 28.02.2012 10:32
Hi,

I have an example in an OO way where the table is linked to an array of objects.
Only the columns that are updateable (linked to the file that needs to be updated in the join) are enabled for the user.

You can perfectly do the same using classical hxxx functions in the table row exited event. However, it is likely that doing so will create duplicate (validation and db management) logic which is not a good design principle...

Here's the principle:


### FILL THE TABLE - Button bRefreshParticipants ###
HourGlass()
Qry_Generic_Participant.pQuoteId_List=Qte.QuoteID
IF HExecuteQuery(Qry_Generic_Participant,hQueryDefault) THEN
FileToArray(PrtLst.ParticipantList,Qry_Generic_Participant)
TableDisplay(Table_Participant,taInit)
HFreeQuery(Qry_Generic_Participant)
END
HourGlass(False)

### ROW IS EXITED EVENT ###
IF MySelf..Modified THEN
//If the user didn't enter a first name and last name on a new row skip the entry
IF Table_Participant.ParticipantID


von Peter H. - am 28.02.2012 10:41
Cheers Peter - that's great!

von DarrenF - am 28.02.2012 11:20
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.