Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changes from one form to another
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01422237
Message ID:
01422317
Vues:
50
>Naomi,
>
>>Well, the second form is dependent on the original form.
>
>If the dependent form is launched from a method on the first form then it should have it's datasession set to default and it'll be running in the parent form's datasession.

I understand that, but then I would have to put some logic into the other form.

Basically, that is the method that calls this form and works OK now
LPARAMETERS tcMode, tnCategoryID, toTextBox
LOCAL loParamObject AS OBJECT, lnSelect AS INTEGER, lcOption, lnTotalAmount, lnSelected, llChanged, lnConfigID

lnConfigID = ConfigHeader.ConfigID
lnSelect = SELECT()
loParamObject = CREATEOBJECT('Empty')
ADDPROPERTY(loParamObject, 'arrConfigFees[1]')
SELECT * FROM ConfigFees WITH (Buffering = .t.) WHERE ConfigID = m.lnConfigID ;
	AND CategoryID = m.tnCategoryID INTO ARRAY loParamObject.arrConfigFees
llChanged = .F.

DO FORM FeesSelector WITH m.tcMode, ConfigHeader.mfgName, ConfigHeader.ConfigID, loParamObject

IF TYPE("loParamObject.arrValues[1]") = "C"
	SELECT 0
	CREATE CURSOR cFees (DESCRIPTION c(40), ;
		Amount N(15,2), ;
		Taxable L, IsSelected L)
	APPEND FROM ARRAY loParamObject.arrValues
	INDEX ON DESCRIPTION TAG DESCRIPT

	COUNT TO lnSelected FOR IsSelected
	GO TOP IN cFees
	IF m.lnSelected > 1
		lcOption = "Multiple Options Selected"
	ELSE
		IF m.lnSelected = 1
			lcOption = cFees.DESCRIPTION
		ENDIF
	ENDIF
	SELECT cFees
	SCAN
		SELECT ConfigFees
		LOCATE FOR ConfigID = m.lnConfigID AND CategoryID = m.tnCategoryID AND DESCRIPTION  = cFees.DESCRIPTION

** New record
		IF NOT FOUND()
			INSERT INTO ConfigFees  (ConfigID, CategoryID, DESCRIPTION, Amount, Taxable, IsSelected) ;
				VALUES (m.lnConfigID, m.tnCategoryID, ;
				cFees.DESCRIPTION, cFees.Amount, cFees.Taxable, cFees.IsSelected)
			llChanged = .T.
		ELSE
			IF NOT (ConfigFees.Amount == cFees.Amount AND ;
					ConfigFees.Taxable = cFees.Taxable AND ConfigFees.IsSelected = cFees.IsSelected)
** Change in the record
				REPLACE Amount WITH cFees.Amount, Taxable WITH cFees.Taxable, IsSelected WITH cFees.IsSelected IN ConfigFees
				llChanged = .T.
			ENDIF
		ENDIF
	ENDSCAN

	SELECT ConfigFees
	SCAN FOR ConfigID = m.lnConfigID AND CategoryID = m.tnCategoryID ;
			AND NOT INDEXSEEK(ConfigFees.DESCRIPTION, .F., "cFees", "Descript")
** record was deleted
		DELETE IN ConfigFees
		llChanged = .T.
	ENDSCAN

** We need to compare values and re-calculate prices
ENDIF

IF m.llChanged
	toTextBox.VALUE = m.lcOption
	THISFORM.TotalsCalc()
ENDIF

RETURN m.llChanged
I could have put logic of updating the ConfigFees table in that form instead and also I would not have to pass the current state of the ConfigFees table.

But I worked backwards (the other form was already created first).

Now, since everything is already programmed I'm a bit lazy to re-do, though on the second thought sharing DS seems like an easier solution.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform