Welcome! Log In Create A New Profile

Advanced

WD 24 query on internal windows

Posted by PETER ZHOU 
PETER ZHOU
WD 24 query on internal windows
July 27, 2020 04:30PM
Hi,


How do i refresh the query in the combo list (or any function to auto-refresh ) within any internal windows ?

Currently, any update to the database in 1 internal window, data are not "refresh" in the combo using query in another internal window unless i "forced" the refresh.

Regards,

PETER ZHOU
Re: WD 24 query on internal windows
July 28, 2020 08:23AM
Dear Peter,

Open the PC Soft's Unit Example "Sales Management".
In this example you can find how they implement the Gobal Procedure COL_Notification, wich updates from one Internal Window (e.g. Form), another Internal Window (Table).
I use this technique in my projects with several many Internal Windows and dynamic Tabs.

I hope toy help you.

Regards

Vassilis Boutsikas
PETER ZHOU
Re: WD 24 query on internal windows
August 01, 2020 06:28PM
Dear Vassilis,

Hows does it work ?

For example,under the customer table tab, if delete a customer record, it will have Notify("Delete.Customer")

What happened after this deletion ?

Regards,

PETER ZHOU
tbh
Re: WD 24 query on internal windows
August 04, 2020 10:35PM
Hi,

You can use a delete trigger on the table and post events when a record is deleted.

I Use this technique in my Audit-trail class smiling smiley

Cheers
Tor-Bjarne
Re: WD 24 query on internal windows
August 05, 2020 06:47AM
Dear Peter,

Sorry to answer that late, but I was very busy. So, in the "End of initialization code" of internal window wich contains the "customers" table you can add:
DeclareNotificationProcedure("Delete.customers", OnDelete)

	INTERNAL PROCEDURE OnDelete(ParameterNotif <useful>)
		Table_customers.Display(taInit)
		Table_customers.ExecuteProcess(trtSelection)
	END

By this way, when you delete customers record and then call Notify("Delete.customers") from another Internal Window, the above procedure will be run.


P.S.
I'm allways using query based tables.
Regards

Vassilis Boutsikas
PETER ZHOU
Re: WD 24 query on internal windows
August 06, 2020 03:52PM
Dear Vassilis,

I will try it out.

thank you so much for your help !

Regards,

PETER ZHOU
Re: WD 24 query on internal windows
August 07, 2020 07:24AM
Hi Peter,

These are some examples of Add, Modify, Delete of "customers" Table.

1. Using independed queries:
DeclareNotificationProcedure("Add.customers", OnAdd)

	INTERNAL PROCEDURE OnAdd(ParameterNotif <useful>)
		Table_customers.Display(taInit)
	END

DeclareNotificationProcedure("Modif.customers", OnModification)

	INTERNAL PROCEDURE OnModification(ParameterNotif <useful>)
		Table_customers.Display(taCurrentRecord)
	END

DeclareNotificationProcedure("Delete.customers", OnDelete)

	INTERNAL PROCEDURE OnDelete(ParameterNotif <useful>)
		Table_customers.Display(taInit)
END

2. Using embedded queries:
DeclareNotificationProcedure("Add.customers", OnAdd)

	INTERNAL PROCEDURE OnAdd(ParameterNotif <useful>)
		Table_customers.Display(taReExecuteQuery)
	END

DeclareNotificationProcedure("Modif.customers", OnModification)

	INTERNAL PROCEDURE OnModification(ParameterNotif <useful>)
		Table_customers.Display(taCurrentRecord)

	END

DeclareNotificationProcedure("Delete.customers", OnDelete)

	INTERNAL PROCEDURE OnDelete(ParameterNotif <useful>)
		Table_customers.Display(taReExecuteQuery)
	END

In the Internal Window (e.g. Form) when adds some customers record you can write:

IF HAdd(customers) THEN
Notify("Add.customers")
END

When Modifies some record:

IF HModify(customers) THEN
Notify("Modif.customers", customers.customersID)
END

Finaly, when Deletes some record:

IF HDelete(customers) THEN
Notify("Delete.customers")
END

This method is very efficient.

Regards

Vassilis Boutsikas
PETER ZHOU
Re: WD 24 query on internal windows
August 10, 2020 03:39PM
Hi Vassilis,


Not sure whether the notify is working as i cannot see the trace when i Notify("Add.customers") in the form.

DeclareNotificationProcedure("Add.customers", OnAdd)

INTERNAL PROCEDURE OnAdd(ParameterNotif <useful>)
Trace("Add Customer")
Table_customers.Display(taReExecuteQuery)
END

DeclareNotificationProcedure("Modif.customers", OnModification)


Regards,

PETER ZHOU
Re: WD 24 query on internal windows
August 12, 2020 08:46AM
Hi Peter,

You have to do some checks:
1. Check out the Internal Windows parameters. I'm allways use "Independed HFSQL context" enabled.
2. The declaration of notifications must be placed in the "End of Initialization" of window wich contains the tables to update.
3. Check out how the DeclareNotificationProcedure is declared.
3.1. Create a SET of Global procedure GP_Notification. In the declaration of GP_Notification add:
eP_CallBack is associative array (WithDuplicates) of procedure
3.2. Create a Global procedure DeclareNotificationProcedure wich belongs to the above set:
PROCEDURE DeclareNotificationProcedure(Notification is string, CallBack is procedure)

eP_CallBack[Notification] = CallBack
3.3. Create a Global procedure Notify wich belongs to the same set:
PROCEDURE Notify(Notification is string, ParameterNotif = "")

FOR i = 1 _TO_ eP_CallBack[Notification]..Count
	ProcCallBack is procedure <- eP_CallBack[Notification, i]
	ProcCallBack(ParameterNotif)
END

After all that the Notify("Add.xxxxx") works fine as in my Project.

Regards

Vassilis Boutsikas
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: