Demo entry 6347703

vfp

   

Submitted by vfp on Feb 16, 2017 at 10:57
Language: FoxPro. Code size: 78.4 kB.

#Define _SUCCESS_OK 0

Do getdate
Do Case
Case Isnull(gcDate)
	??Chr(7)
	Messagebox("Null not acceptable for POSTED field",16,"Error Found")
	Return
Case Empty(gcDate)
	??Chr(7)
	Messagebox("Empty POSTED field not acceptable",16,"Error Found")
	Return
Case Isnull(gcUser)
	??Chr(7)
	Messagebox("Null not acceptable for POSTED_BY field",16,"Error Found")
	Return
Case Empty(gcUser)
	??Chr(7)
	Messagebox("Empty POSTED_BY field not acceptable",16,"Error Found")
	Return
Case Len(gcUser) <= 2
	??Chr(7)
	Messagebox("Invalid LOGIN name found,["+Alltrim(gcUser)+"] not acceptable",16,"Error Found")
	Return
Endcase

Do Case
	*!*	Case gcChoice='newpr'	&&CODE DECOMISSIONED 8/1/2007 see genpayreq module found in new button
	*!*		Sele pr_entr
	*!*		Repl All posted With gcDate,posted_by With gcUser
	*!*		Wait Window Nowait 'Computing Db/Cr...pls wait..'
	*!*		Sum amount To lnAmount
	*!*	*	Sum amount To lnAmount For drcrcode='C'
	*!*		Sum amount To lnAmountc For drcrcode='C'				&&mina 62507
	*!*		Sele pr_info
	*!*	*	Repl loa_amt With lnAmountc,posted With gcDate,posted_by With gcUser
	*!*		Replace amount With lnAmountc,posted With gcDate,posted_by With gcUser			&&mina 62507
	*!*		Wait Clear
Case gcButtonSelection = "EDIT"	&&gcChoice='editpr'
	Set Step On
	Select pr_entr
	Go Top
	Do While !Eof()
		lcChangeStat=""
		Do Case
		Case Getfldstate("loa","pr_entr")		=1	&&no change
			lcChangeStat=""
		Case Getfldstate("loa","pr_entr")		=2	&&edited old row
			lcChangeStat="2"
		Case Getfldstate("loa","pr_entr")		=3	&&insert new row
			lcChangeStat="3"
		Case Getfldstate("loa","pr_entr")		=4 	&&edited new row
			lcChangeStat="4"
		Endcase
		Do Case
		Case lcChangeStat="2"
			??Chr(7)
			Messagebox("Sorry editing LOA# is not allowed",0+16,"Fatal Error")
			Return
		Endcase
		*!*			If Left(pr_entr.Code,3)='DR-' And Year(Thisform.text2.Value)>2013	&&adjusted after 2013 to accomodate transition
		*!*				??Chr(7)
		*!*				Messagebox("Sorry please use PRC number",0+16,"Fatal Error")    && comment due to incomplete prc data
		*!*				Return
		*!*			Endif
		Select pr_entr
		Skip
	Enddo

	Select pr_entr
	Replace All edited With gcDate,edited_by With gcUser

	************************************************************************
	************************************************************************
	**** VALIDATE FOR BALANCED DEBIT/CREDIT
	************************************************************************
	Select pr_entr
	Count To cntRec
	If cntRec <= 0
		??Chr(7)
		Messagebox("Sorry but deletion of entries is not allowed",0+16,"Fatal Error")
		Return
	Endif
	*!* INTELLICARE CHART OF ACCOUNTS
	*!*	*210012		A/P - COST OF SERVICE
	*!*	21001201	A/P - MEDICAL SUPPLIES (COS)

	*!*	*210013		A/P - PROFESSIONAL FEE (COS

	*!*	21001402   A/P - ASO - MEDICAL SUPPLIES			*210014		A/P - TPA
	*!*	21001401   A/P - ASO - COS 						*210014		A/P - TPA
	*!*	21001403   A/P - ASO - PF						*210014		A/P - TPA
	*!*	21001404   A/P - ASO - PF DENTAL				*210014		A/P - TPA

	*!*	*210015		A/P - ADVANCES TO O/E
	*!*	*210016		A/P - INCREMENTAL COST
	*!*	*210017   	A/P - A/R-OTHERS
	*!* *210002   	A/P OTHERS
	*!* *210018    	A/P - A/R-FUTURE COMMISSION

	*!* *801031   	DISCOUNT - COS
	*!* *801032   	DISCOUNT - TA

	*!* 801039 		DISCOUNT - ASO
	*!* 801040 		DISCOUNT - A/R
	*!* 801041  	DISCOUNT - ADVANCES

	*!* *801013	MISCELLANEOUS INCOME
	*!* *114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST

	Go Top
	barcnt			= 0
	lnDB			= 0
	lnCR			= 0
	lnAP_HMS		= 0	&&*!*	*210012		A/P - COST OF SERVICE
	lnAP_HMS_MEDSP	= 0 &&*!*	21001201	A/P - MEDICAL SUPPLIES (COS)

	lnAP_PF			= 0	&&*!*	*210013		A/P - PROFESSIONAL FEE (COS

	lnAP_TPA		= 0	&&*!*	*210014		A/P - TPA
	lnAP_TPA_MEDSP	= 0 &&*!*	21001402   A/P - ASO - MEDICAL SUPPLIES
	lnAP_TPA_COS	= 0 &&*!*	21001401   A/P - ASO - COS
	lnAP_TPA_PF		= 0 &&*!*	21001403   A/P - ASO - PF			(lnAP_TPA_PF + lnAP_TPA_OTHER)
	lnAP_TPA_OTHER 	= 0 &&*!*	*210002   	A/P OTHERS				(lnAP_TPA_PF + lnAP_TPA_OTHER)
	lnAP_TPA_PFDN	= 0 &&*!*	21001404   A/P - ASO - PF DENTAL

	lnAP_TPA_ADV	= 0	&&*!*	*210015		A/P - ADVANCES TO O/E
	lnAP_TPA_AR		= 0	&&*!*	*210016		A/P - INCREMENTAL COST
	lnAP_TPA_OT		= 0	&&*!*	*210017   	A/P - A/R-OTHERS
	lnAP_FCOMM		= 0	&&*!*	*210018    	A/P - A/R-FUTURE COMMISSION

	lnAP_HMS_DSC	= 0	&&*!*	*801031   	DISCOUNT - COS

	*!*	OLD DISCOUNT ACCTCODE *!*
	lnAP_TPA_DSC	= 0	&&*!*	*801032   	DISCOUNT - TA	(FOR TPA)
	lnAP_AR_DSC		= 0	&&*!*	*801032   	DISCOUNT - TA	(FOR AR)
	lnAP_ADV_DSC	= 0	&&*!*	*801032   	DISCOUNT - TA	(FOR ADV-OE)

	*!*	NEW DISCOUNT ACCTCODE *!*
	lnAP_TPA_DSC	= 0	&&*!*	*801039    DISCOUNT - ASO	(FOR TPA)
	lnAP_AR_DSC		= 0	&&*!*	*801040    DISCOUNT - A/R	(FOR AR)
	lnAP_ADV_DSC	= 0	&&*!*	*801041    DISCOUNT - ADVANCES	(FOR ADV-OE)

	*	------------ OFFSET APPLY TO AP-COS ----------------
	lnAP_OFFSET = 0	&&*!*	*114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
	*				  *!*	*801013	MISCELLANEOUS INCOME                        CREDIT
	*	------------ OFFSET APPLY TO AP-COS ----------------

	*	------------ OFFSET APPLY TO AP-TPA ----------------
	lnAP_OFFSET_TPA = 0	&&	*!*	*114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
	*				  		*!*	*801013	MISCELLANEOUS INCOME                        CREDIT
	*	------------ OFFSET APPLY TO AP-TPA ----------------

	Do While !Eof()
		barcnt = barcnt+1
		Wait Window Nowait "Checking DEBIT/CREDIT ["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
		lcMSG_acctcode = pr_entr.acctcode
		lcMSG_loa	   = Alltrim(pr_entr.loa)+'/'+Alltrim(Str(pr_entr.loa_no))
		Do Case
		Case Isnull(pr_entr.Code)
			??Chr(7)
			Messagebox("Invalid Null in CODE ["+lcMSG_acctcode+"] for LOA:["+lcMSG_loa+"]",0+16,"Fatal Error")
			Return
		Case Empty(pr_entr.Code)
			??Chr(7)
			Messagebox("Invalid Empty CODE ["+lcMSG_acctcode+"] for LOA:["+lcMSG_loa+"]",0+16,"Fatal Error")
			Return
		Case Len(pr_entr.Code) <= 5
			??Chr(7)
			Messagebox("Invalid CODE ["+lcMSG_acctcode+"] for LOA:["+lcMSG_loa+"]",0+16,"Fatal Error")
			Return
		Case Isnull(pr_entr.acctcode)
			??Chr(7)
			Messagebox("Invalid Null in ACCTCODE ["+lcMSG_acctcode+"] for LOA:["+lcMSG_loa+"]",0+16,"Fatal Error")
			Return
		Case Empty(pr_entr.acctcode)
			??Chr(7)
			Messagebox("Invalid Empty ACCTCODE ["+lcMSG_acctcode+"] for LOA:["+lcMSG_loa+"]",0+16,"Fatal Error")
			Return
		Case Len(pr_entr.acctcode) < 4
			??Chr(7)
			Messagebox("Invalid ACCTCODE ["+lcMSG_acctcode+"] for LOA:["+lcMSG_loa+"]",0+16,"Fatal Error")
			Return
		Case pr_entr.drcrcode='D'
			lnDB	= lnDB + pr_entr.amount
		Case pr_entr.drcrcode='C'
			lnCR	= lnCR + pr_entr.amount
		Otherwise
			??Chr(7)
			Messagebox("Invalid DRCRCODE ["+lcMSG_acctcode+"] for LOA:["+lcMSG_loa+"]",0+16,"Fatal Error")
			Return
		Endcase
		If Alltrim(pr_entr.acctcode) # '210012' And Alltrim(pr_entr.acctcode) # '210013' And ;
				Alltrim(pr_entr.acctcode) # '210014' And Alltrim(pr_entr.acctcode) # '210015' And ;
				Alltrim(pr_entr.acctcode) # '210016' And Alltrim(pr_entr.acctcode) # '210017' And ;
				Alltrim(pr_entr.acctcode) # '210018' And Alltrim(pr_entr.acctcode) # '210002' And ;
				Alltrim(pr_entr.acctcode) # '801031' And Alltrim(pr_entr.acctcode) # '801032' And ;
				Alltrim(pr_entr.acctcode) # '21001201' And Alltrim(pr_entr.acctcode) # '21001402' And;
				Alltrim(pr_entr.acctcode) # '21001401' And Alltrim(pr_entr.acctcode) # '21001403' And;
				Alltrim(pr_entr.acctcode) # '21001404' And;
				Alltrim(pr_entr.acctcode) # '801039' And Alltrim(pr_entr.acctcode) # '801040' And ;
				Alltrim(pr_entr.acctcode) # '801041'
			*!*	21001201	A/P - MEDICAL SUPPLIES (COS)
			*!*	21001402    A/P - ASO - MEDICAL SUPPLIES
			*!*	21001401    A/P - ASO - COS
			*!*	21001403    A/P - ASO - PF
			*!*	21001404    A/P - ASO - PF DENTAL
			*!*	*801039    DISCOUNT - ASO
			*!*	*801040    DISCOUNT - A/R
			*!*	*801041    DISCOUNT - ADVANCES

			*!*	*210012		A/P - COST OF SERVICE
			*!*	*210013		A/P - PROFESSIONAL FEE (COS
			*!*	*210014		A/P - TPA
			*!*	*210015		A/P - ADVANCES TO O/E
			*!*	*210016		A/P - INCREMENTAL COST
			*!*	*210017   	A/P - A/R-OTHERS
			*!*	*210018   	A/P - A/R-FUTURE COMMISSION
			*!*	*210002   	A/P OTHERS
			*!*	*801031   	DISCOUNT - COS
			*!*	*801032   	DISCOUNT - TA
			If (Alltrim(pr_entr.acctcode) = '114008' And Alltrim(pr_entr.drcrcode) = 'C') Or ;
					(Alltrim(pr_entr.acctcode) = '801013' And Alltrim(pr_entr.drcrcode) = 'C')
				*	114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
				*	801013	MISCELLANEOUS INCOME                        CREDIT
			Else
				Do Case
				Case Isnull(pr_entr.loa)
					??Chr(7)
					Messagebox("Null LOA not accepted for ACCTCODE:["+lcMSG_acctcode+"]",0+16,"Fatal Error")
					Return
				Case Empty(pr_entr.loa)
					??Chr(7)
					Messagebox("Empty LOA not accepted for ACCTCODE:["+lcMSG_acctcode+"]",0+16,"Fatal Error")
					Return
				Case Len(Alltrim(pr_entr.loa)) <= 2	&&5
					??Chr(7)
					Messagebox("Invalid LOA:["+lcMSG_loa+"] for ACCTCODE:["+lcMSG_acctcode+"]",0+16,"Fatal Error")
					Return
				Endcase
			Endif
		Endif
		* prepare for ap validation
		Do Case
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)=='210012'	&&updt-+10/17/2013
			*!*	*210012		A/P - COST OF SERVICE
			lnAP_HMS	= lnAP_HMS	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='21001201'
			*!*	*21001201	A/P - MEDICAL SUPPLIES (COS)
			lnAP_HMS_MEDSP	= lnAP_HMS_MEDSP	+ pr_entr.amount

		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='210013'
			*!*	*210013		A/P - PROFESSIONAL FEE (COS
			lnAP_PF		= lnAP_PF	+ pr_entr.amount

		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)=='210014'	&&updt-+10/17/2013
			*!*	*210014		A/P - TPA
			lnAP_TPA	= lnAP_TPA	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='21001402'
			*!*	*21001402   A/P - ASO - MEDICAL SUPPLIES
			lnAP_TPA_MEDSP	= lnAP_TPA_MEDSP	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='21001401'
			*!*	*21001401   A/P - ASO - COS
			lnAP_TPA_COS	= lnAP_TPA_COS	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='21001403'
			*!*	*21001403   A/P - ASO - PF
			lnAP_TPA_PF	= lnAP_TPA_PF	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='21001404'
			*!*	*21001404   A/P - ASO - PF DENTAL
			lnAP_TPA_PFDN	= lnAP_TPA_PFDN	+ pr_entr.amount

		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='210015'
			*!*	*210015		A/P - ADVANCES TO O/E
			lnAP_TPA_ADV= lnAP_TPA_ADV	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='210016'
			*!*	*210016		A/P - INCREMENTAL COST
			lnAP_TPA_AR	= lnAP_TPA_AR	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='210017'
			*!*	*210017   	A/P - A/R-OTHERS
			lnAP_TPA_OT	= lnAP_TPA_OT	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='210018'
			*!*	*210018    	A/P - A/R-FUTURE COMMISSION
			lnAP_FCOMM	= lnAP_FCOMM	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='210002'
			*!*	*210002   A/P OTHERS
			lnAP_TPA_OTHER	= lnAP_TPA_OTHER	+ pr_entr.amount

		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='801031'
			*!*	*801031   	DISCOUNT - COS
			lnAP_HMS_DSC= lnAP_HMS_DSC	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='801032'
			*!*	*801032   	DISCOUNT - TA
			lcTMPDISCNT	=Alltrim(Str(pr_entr.amount,16,2))
			If Messagebox("Do you wish to apply this discount ["+lcTMPDISCNT+"] to TPA?",4+32,"TPA/AR/ADV-OE DISCOUNT APPLICATION")=6	&&Yes
				lnAP_TPA_DSC= lnAP_TPA_DSC	+ pr_entr.amount
			Else
				If Messagebox("Do you wish to apply this discount ["+lcTMPDISCNT+"] to ADV-OE?",4+32,"TPA/AR/ADV-OE DISCOUNT APPLICATION")=6	&&Yes
					lnAP_ADV_DSC = lnAP_ADV_DSC	+ pr_entr.amount
				Else
					If Messagebox("Do you wish to apply this discount ["+lcTMPDISCNT+"] to AR?",4+32,"TPA/AR/ADV-OE DISCOUNT APPLICATION")=6	&&Yes
						lnAP_AR_DSC = lnAP_AR_DSC	+ pr_entr.amount
					Else
						??Chr(7)
						Messagebox("Invalid Discount Entry (DISCOUNT - TA)",0+16,"Error Found")
						Return
					Endif
				Endif
			Endif
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='801039'
			*!*	*801039    DISCOUNT - ASO
			lnAP_TPA_DSC= lnAP_TPA_DSC	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='801040'
			*!*	*801040    DISCOUNT - A/R
			lnAP_AR_DSC= lnAP_AR_DSC	+ pr_entr.amount
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='801041'
			*!*	*801041    DISCOUNT - ADVANCES
			lnAP_ADV_DSC= lnAP_ADV_DSC	+ pr_entr.amount

		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='114008'
			*!*	*114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
			lcTMPOPSET	=Alltrim(Str(pr_entr.amount,16,2))
			If Messagebox("Do you wish to apply this off set 114008 ["+lcTMPOPSET+"] to AP-COS?",4+32,"AP-COS/TPA OFF SET APPLICATION")=6	&&Yes
				lnAP_OFFSET	= lnAP_OFFSET	+ pr_entr.amount
			Else
				lnAP_OFFSET_TPA = lnAP_OFFSET_TPA	+ pr_entr.amount
			Endif
		Case pr_entr.drcrcode='C' And Alltrim(pr_entr.acctcode)='801013'
			*!*	*801013	MISCELLANEOUS INCOME                        CREDIT
			lcTMPOPSET	=Alltrim(Str(pr_entr.amount,16,2))
			If Messagebox("Do you wish to apply this off set 801013 ["+lcTMPOPSET+"] to AP-COS?",4+32,"AP-COS/TPA OFF SET APPLICATION")=6	&&Yes
				lnAP_OFFSET	= lnAP_OFFSET	+ pr_entr.amount
			Else
				lnAP_OFFSET_TPA = lnAP_OFFSET_TPA	+ pr_entr.amount
			Endif
		Endcase
		* prepare for ap validation
		* check for valid slname
		Select pr_entr
		lcTst_value=Thisform.GetSQLname(Alltrim(pr_entr.Code))
		If Empty(lcTst_value)
			??Chr(7)
			Messagebox("Invalid SLCODE, CODE:["+Alltrim(pr_entr.Code)+"] not found",0+16,"Error Found")
			Return
		Else
			If Alltrim(pr_entr.slname)<>Left(Alltrim(lcTst_value),Len(Alltrim(pr_entr.slname)))
				??Chr(7)
				Messagebox("Encoded SLNAME for CODE:["+Alltrim(pr_entr.Code)+"] different from server records, please update slcode in entries",0+16,"Error Found")
				Return
			Endif
		Endif
		* check for valid slname
		* check for valid acctcode
		Select curGlchart
		Seek Alltrim(pr_entr.acctcode) In curGlchart Order Tag acctcode
		If !Found()
			??Chr(7)
			Messagebox("Invalid Acctcode, ["+Alltrim(pr_entr.acctcode)+"] not found",0+16,"Error Found (sk)")
			Return
		Endif
		If Alltrim(pr_entr.acctcode)==Alltrim(curGlchart.acctcode)
		Else
			??Chr(7)
			Messagebox("Invalid Acctcode, ["+Alltrim(pr_entr.acctcode)+"] not found",0+16,"Error Found (=)")
			Return
		Endif
		* check for valid acctcode
		Select pr_entr
		Skip
	Enddo
	If !(Round(lnDB,2) == Round(lnCR,2))
		??Chr(7)
		nAnswer = Messagebox('Debit = '+Ltrim(Str(lnDB,15,2))+' vs. '+'Credit = '+Ltrim(Str(lnCR,15,2))+' Saving aborted...',0+48+0,'Warning')
		Return
	Endif
	************************************************************************
	**** VALIDATE FOR BALANCED DEBIT/CREDIT
	************************************************************************
	************************************************************************

	************************************************************************
	************************************************************************
	**** VALIDATE MATCHING APPROPRIATE AP ACCTCODE TO ITS SOURCE ACCTCODE
	************************************************************************
	*210017   	A/P - A/R-OTHERS................................lnAP_TPA_OT
	*	-	NONE AS OF THIS DATE
	*210015		A/P - ADVANCES TO O/E...........................lnAP_TPA_ADV
	*	-	114001	ADVANCES TO OFFICERS & EMPLOYEES
	*210016		A/P - INCREMENTAL COST..........................lnAP_TPA_AR
	*	-	114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST

	* YOUR HELL STARTS HERE!!! ########################################################
	*TPA/ASO VERSION 1.0
	*210014		A/P - TPA.......................................lnAP_TPA
	*210002   	A/P OTHERS......................................lnAP_TPA_OTHER
	*	-	210009	TPA FUND ...................................(lnAP_TPA + lnAP_TPA_OTHER)

	*TPA/ASONG ULOL VERSION 2.0 (FUCKING SHIT VERSION)
	*21001402   A/P - ASO - MEDICAL SUPPLIES....................lnAP_TPA_MEDSP
	*	-	21000925	ASO - MEDICAL SUPPLIES
	*21001401   A/P - ASO - COS ................................lnAP_TPA_COS
	*	-	21000924	ASO - COS
	*21001403   A/P - ASO - PF..................................lnAP_TPA_PF		(lnAP_TPA_PF + lnAP_TPA_OTHER)
	*210002    	A/P OTHERS......................................lnAP_TPA_OTHER 	(lnAP_TPA_PF + lnAP_TPA_OTHER)
	*	-	21000923	ASO  - PROFESSIONAL FEE

	*TPA/ASO VERSION 3.0
	*21001402   A/P - ASO - MEDICAL SUPPLIES....................lnAP_TPA_MEDSP
	*21001401   A/P - ASO - COS ................................lnAP_TPA_COS
	*21001403   A/P - ASO - PF..................................lnAP_TPA_PF		(lnAP_TPA_PF + lnAP_TPA_OTHER)
	*210002    	A/P OTHERS......................................lnAP_TPA_OTHER 	(lnAP_TPA_PF + lnAP_TPA_OTHER)
	*	-	210009	TPA FUND ...................................(lnAP_TPA_MEDSP + lnAP_TPA_COS + lnAP_TPA_PF + lnAP_TPA_OTHER)

	*TPA/ASONG ULOL VERSION 4.0 (RETURN OF THE SITH BANG-AW EDITION)
	*21001402   A/P - ASO - MEDICAL SUPPLIES....................lnAP_TPA_MEDSP
	*	-	21000925	ASO - MEDICAL SUPPLIES
	*21001401   A/P - ASO - COS ................................lnAP_TPA_COS
	*	-	210009242	ASO - COS - PF
	*	-	21000924	ASO - COS
	*	-	501010	INSURANCE EXPENSE - ENROLLEES				updt-+10/10/2013
	*21001403   A/P - ASO - PF..................................lnAP_TPA_PF
	*	-	21000923	ASO  - PROFESSIONAL FEE
	*21001404   A/P - ASO - PF DENTAL...........................lnAP_TPA_PFDN
	*	-	21000927	ASO  - DENTAL PROFESSIONAL FEE
	* YOUR HELL ENDS HERE!!! ########################################################

	*210012		A/P - COST OF SERVICE...........................lnAP_HMS
	*	-	50100103	HOSPITAL & MEDICAL SERVICES - PF
	*	-	501001		HOSPITAL & MEDICAL SERVICES
	*	-	501003		LABORATORY EXPENSES
	*	-	501005		ROOM AND BOARD
	*	-	501008		DENTAL EXPENSES
	*	-	501010		INSURANCE EXPENSE - ENROLLEES
	*	-	501013		COS - OTHERS
	*	-	 501006		LABORATORY SUPPLIES
	*	-	 50100101	INSTRUMENT FEE'
	*	-	 50100102	APE/PPE - COS'
	*21001201	A/P - MEDICAL SUPPLIES (COS)....................lnAP_HMS_MEDSP
	*	-	501007	MEDICAL SUPPLIES

	*210013		A/P - PROFESSIONAL FEE (COS)....................lnAP_PF
	*	-	501002	PROFESSIONAL FEES
	*	-	501009	DENTAL - PROFESSIONAL
	*210018    	A/P - A/R-FUTURE COMMISSION.....................lnAP_FCOMM
	*	-	114016  ACCOUNTS RECEIVABLE - FUTURE COMMISSION
	For iteration = 1 To 13
		llGo = .F.
		Do Case
		Case iteration = 1	&&lnAP_TPA_OT
			If !Empty(lnAP_TPA_OT) And !Isnull(lnAP_TPA_OT)
				*	-	NONE AS OF THIS DATE
				llGo = .F.
			Endif
		Case iteration = 2	&&lnAP_TPA_ADV
			If !Empty(lnAP_TPA_ADV) And !Isnull(lnAP_TPA_ADV)
				llGo = .T.
			Endif
		Case iteration = 3	&&lnAP_TPA_AR
			If !Empty(lnAP_TPA_AR) And !Isnull(lnAP_TPA_AR)
				llGo = .T.
			Endif
		Case iteration = 4	&&lnAP_TPA
			If !Empty(lnAP_TPA) And !Isnull(lnAP_TPA)
				llGo = .T.
			Endif
		Case iteration = 5	&&lnAP_HMS
			If !Empty(lnAP_HMS) And !Isnull(lnAP_HMS)
				llGo = .T.
			Endif
		Case iteration = 6	&&lnAP_PF
			If !Empty(lnAP_PF) And !Isnull(lnAP_PF)
				llGo = .T.
			Endif
		Case iteration = 7	&&lnAP_FCOMM
			If !Empty(lnAP_FCOMM) And !Isnull(lnAP_FCOMM)
				llGo = .T.
			Endif


		Case iteration = 8	&&lnAP_HMS_MEDSP
			If !Empty(lnAP_HMS_MEDSP) And !Isnull(lnAP_HMS_MEDSP)
				llGo = .T.
			Endif

		Case iteration = 9 And Ctod(Dtoc(gcDate)) < Ctod('8/1/2013') &&lnAP_TPA_MEDSP
			If !Empty(lnAP_TPA_MEDSP) And !Isnull(lnAP_TPA_MEDSP)
				llGo = .T.
			Endif
			If !Empty(lnAP_TPA_COS) And !Isnull(lnAP_TPA_COS)
				llGo = .T.
			Endif
			If !Empty(lnAP_TPA_PF) And !Isnull(lnAP_TPA_PF)
				llGo = .T.
			Endif

			*!*	 -------------------------------------------------------------------------
			*!*		THE ASO SHIT DISTRIBUTION FIASCO (NOT THE AP ASO DISTRIBUTION
			*!*	 -------------------------------------------------------------------------
		Case iteration = 10	And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013')	&&lnAP_TPA_MEDSP
			If !Empty(lnAP_TPA_MEDSP) And !Isnull(lnAP_TPA_MEDSP)
				llGo = .T.
			Endif
		Case iteration = 11	And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013')	&&lnAP_TPA_COS
			If !Empty(lnAP_TPA_COS) And !Isnull(lnAP_TPA_COS)
				llGo = .T.
			Endif
		Case iteration = 12	And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013')	&&lnAP_TPA_PF
			If !Empty(lnAP_TPA_PF) And !Isnull(lnAP_TPA_PF)
				llGo = .T.
			Endif
		Case iteration = 13	And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013')	&&lnAP_TPA_PFDN
			If !Empty(lnAP_TPA_PFDN) And !Isnull(lnAP_TPA_PFDN)
				llGo = .T.
			Endif
			*!*	 -------------------------------------------------------------------------
			*!*		THE ASO SHIT DISTRIBUTION FIASCO (NOT THE AP ASO DISTRIBUTION
			*!*	 -------------------------------------------------------------------------
		Endcase

		If llGo
			Select pr_entr
			Count To cntRec
			Go Top
			barcnt		= 0
			lnTargetSum	= 0
			Do While !Eof()
				barcnt = barcnt+1
				Wait Window Nowait "Validating AP ["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
				Do Case
				Case iteration = 1	&&lnAP_TPA_OT
					*210017   	A/P - A/R-OTHERS................................lnAP_TPA_OT
					*	-	NONE AS OF THIS DATE
				Case iteration = 2	&&lnAP_TPA_ADV
					*210015		A/P - ADVANCES TO O/E...........................lnAP_TPA_ADV
					If Alltrim(pr_entr.acctcode)='114001' And pr_entr.drcrcode='D' &&114001	ADVANCES TO OFFICERS & EMPLOYEES
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endif
				Case iteration = 3	&&lnAP_TPA_AR
					*210016		A/P - INCREMENTAL COST..........................lnAP_TPA_AR
					If Alltrim(pr_entr.acctcode)='114008' And pr_entr.drcrcode='D'  &&114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endif
				Case iteration = 4	&&lnAP_TPA
					*210014		A/P - TPA.......................................lnAP_TPA
					*210002   	A/P OTHERS......................................lnAP_TPA_OTHER
					If Alltrim(pr_entr.acctcode)='210009' And pr_entr.drcrcode='D'  &&210009	TPA FUND
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endif
				Case iteration = 5	&&lnAP_HMS
					*210012		A/P - COST OF SERVICE...........................lnAP_HMS
					Do Case
					Case Alltrim(pr_entr.acctcode)='50100103' And pr_entr.drcrcode='D'  &&50100103	HOSPITAL & MEDICAL SERVICES - PF
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='501001' And pr_entr.drcrcode='D'  &&501001	HOSPITAL & MEDICAL SERVICES
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='501003' And pr_entr.drcrcode='D'  &&501003	LABORATORY EXPENSES
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='501005' And pr_entr.drcrcode='D'  &&501005	ROOM AND BOARD
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='501008' And pr_entr.drcrcode='D'  &&501008	DENTAL EXPENSES
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='501010' And pr_entr.drcrcode='D'  &&501010	INSURANCE EXPENSE - ENROLLEES
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='501013' And pr_entr.drcrcode='D'  &&501013	COS - OTHERS
						lnTargetSum	= lnTargetSum + pr_entr.amount

					Case Alltrim(pr_entr.acctcode)='501006' And pr_entr.drcrcode='D'  &&501006	LABORATORY SUPPLIES
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='501007' And pr_entr.drcrcode='D'  &&501007	MEDICAL SUPPLIES
						*!*							lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='50100101' And pr_entr.drcrcode='D'  &&50100101	INSTRUMENT FEE
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='50100102' And pr_entr.drcrcode='D'  &&50100102	APE/PPE - COS
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endcase
				Case iteration = 6	&&lnAP_PF
					*210013		A/P - PROFESSIONAL FEE (COS)....................lnAP_PF
					Do Case
					Case Alltrim(pr_entr.acctcode)='501002' And pr_entr.drcrcode='D'  &&501002	PROFESSIONAL FEES
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='501009' And pr_entr.drcrcode='D'  &&501009	DENTAL - PROFESSIONAL
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endcase
				Case iteration = 7	&&lnAP_FCOMM
					*210018    	A/P - A/R-FUTURE COMMISSION.....................lnAP_FCOMM
					If Alltrim(pr_entr.acctcode)='114016' And pr_entr.drcrcode='D'    &&114016  ACCOUNTS RECEIVABLE - FUTURE COMMISSION
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endif

				Case iteration = 8	&&lnAP_HMS_MEDSP
					*501007	MEDICAL SUPPLIES....................................lnAP_HMS_MEDSP
					If Alltrim(pr_entr.acctcode)='501007' And pr_entr.drcrcode='D'  &&501007	MEDICAL SUPPLIES
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endif

				Case iteration = 9 And Ctod(Dtoc(gcDate)) < Ctod('8/1/2013') &&lnAP_TPA_MEDSP + lnAP_TPA_COS + lnAP_TPA_PF
					*210009	TPA FUND
					If Alltrim(pr_entr.acctcode)='210009' And pr_entr.drcrcode='D'  &&210009	TPA FUND
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endif

					*!*	 -------------------------------------------------------------------------
					*!*		THE ASO SHIT DISTRIBUTION FIASCO (NOT THE AP ASO DISTRIBUTION
					*!*	 -------------------------------------------------------------------------
				Case iteration = 10 And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013') &&lnAP_TPA_MEDSP
					*21000925	ASO - MEDICAL SUPPLIES..........................lnAP_TPA_MEDSP
					If Alltrim(pr_entr.acctcode)='21000925' And pr_entr.drcrcode='D'  &&21000925	ASO - MEDICAL SUPPLIES
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endif
				Case iteration = 11 And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013') &&lnAP_TPA_COS
					*210009242	ASO - COS - PF .................................lnAP_TPA_COS
					*21000924	ASO - COS ......................................lnAP_TPA_COS
					*501010		INSURANCE EXPENSE - ENROLLEES...................lnAP_TPA_COS
					Do Case
					Case Alltrim(pr_entr.acctcode)='210009242' And pr_entr.drcrcode='D'  &&210009242	ASO - COS - PF
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='21000924' And pr_entr.drcrcode='D'  &&21000924	ASO - COS
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Case Alltrim(pr_entr.acctcode)='501010' And pr_entr.drcrcode='D'  	&&501010	INSURANCE EXPENSE - ENROLLEES
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endcase
				Case iteration = 12 And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013') &&lnAP_TPA_PF
					*21000923	ASO  - PROFESSIONAL FEE.........................lnAP_TPA_PF
					If Alltrim(pr_entr.acctcode)='21000923' And pr_entr.drcrcode='D'  &&21000923	ASO  - PROFESSIONAL FEE
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endif
				Case iteration = 13 And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013') &&lnAP_TPA_PFDN
					*21000927	ASO  - DENTAL PROFESSIONAL FEE..................lnAP_TPA_PFDN
					If Alltrim(pr_entr.acctcode)='21000927' And pr_entr.drcrcode='D'  &&21000927	ASO  - DENTAL PROFESSIONAL FEE
						lnTargetSum	= lnTargetSum + pr_entr.amount
					Endif
					*!*	 -------------------------------------------------------------------------
					*!*		THE ASO SHIT DISTRIBUTION FIASCO (NOT THE AP ASO DISTRIBUTION
					*!*	 -------------------------------------------------------------------------

				Endcase
				Select pr_entr
				Skip
			Enddo
			Do Case
			Case iteration = 1	&&lnAP_TPA_OT
				*	-	NONE AS OF THIS DATE
			Case iteration = 2	&&lnAP_TPA_ADV
				lnTargetSum =lnTargetSum - lnAP_ADV_DSC &&*!*	*801032   	DISCOUNT - TA
				If !(Round(lnTargetSum,2) == Round(lnAP_TPA_ADV,2))
					??Chr(7)
					Messagebox("Unbalance 210015<>114001",0+16,"Fatal Error")
					Return
				Endif
			Case iteration = 3	&&lnAP_TPA_AR
				lnTargetSum =lnTargetSum - lnAP_AR_DSC 	&&*!*	*801032   	DISCOUNT - TA
				If !(Round(lnTargetSum,2) == Round(lnAP_TPA_AR,2))
					??Chr(7)
					Messagebox("Unbalance 210016<>114008",0+16,"Fatal Error")
					Return
				Endif
			Case iteration = 4	&&lnAP_TPA
				lnTargetSum =lnTargetSum - lnAP_TPA_DSC &&*!*	*801032   	DISCOUNT - TA
				* RECALCULATE FOR OFFSET SCENARIO
				*		114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
				*		801013	MISCELLANEOUS INCOME                        CREDIT
				lnTargetSum =lnTargetSum - lnAP_OFFSET_TPA
				* RECALCULATE FOR OFFSET SCENARIO
				*		114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
				*		801013	MISCELLANEOUS INCOME                        CREDIT
				If !(Round(lnTargetSum,2) == Round(lnAP_TPA + lnAP_TPA_OTHER,2))
					??Chr(7)
					Messagebox("Unbalance (210014 + 210002 - OFFSET)<>210009",0+16,"Fatal Error")
					Return
				Endif
			Case iteration = 5	&&lnAP_HMS
				lnTargetSum =lnTargetSum - lnAP_HMS_DSC &&*!*	*801031   	DISCOUNT - COS
				* RECALCULATE FOR OFFSET SCENARIO
				*		114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
				*		801013	MISCELLANEOUS INCOME                        CREDIT
				lnTargetSum =lnTargetSum - lnAP_OFFSET
				* RECALCULATE FOR OFFSET SCENARIO
				*		114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
				*		801013	MISCELLANEOUS INCOME                        CREDIT
				txtMsg  	="50100103+501001+501005+501006+501007+501008+501010+501013+50100101+50100102"
				If !(Round(lnTargetSum,2) == Round(lnAP_HMS,2))
					??Chr(7)
					Messagebox("Unbalance 210012<>"+txtMsg,0+16,"Fatal Error")
					Return
				Endif
			Case iteration = 6	&&lnAP_PF
				If !(Round(lnTargetSum,2) == Round(lnAP_PF,2))
					??Chr(7)
					Messagebox("Unbalance 210013<>501002+501009",0+16,"Fatal Error")
					Return
				Endif
			Case iteration = 7	&&lnAP_FCOMM
				If !(Round(lnTargetSum,2) == Round(lnAP_FCOMM,2))
					??Chr(7)
					Messagebox("Unbalance 210018<>114016",0+16,"Fatal Error")
					Return
				Endif

			Case iteration = 8	&&lnAP_HMS_MEDSP
				If !(Round(lnTargetSum,2) == Round(lnAP_HMS_MEDSP,2))
					??Chr(7)
					Messagebox("Unbalance 21001201<>501007",0+16,"Fatal Error")
					Return
				Endif

			Case iteration = 9 And Ctod(Dtoc(gcDate)) < Ctod('8/1/2013') &&lnAP_TPA_MEDSP + lnAP_TPA_COS + lnAP_TPA_PF
				lnTargetSum =lnTargetSum - lnAP_TPA_DSC &&*!*	*801039 		DISCOUNT - ASO
				* RECALCULATE FOR OFFSET SCENARIO
				*		114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
				*		801013	MISCELLANEOUS INCOME                        CREDIT
				lnTargetSum =lnTargetSum - lnAP_OFFSET_TPA
				* RECALCULATE FOR OFFSET SCENARIO
				*		114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
				*		801013	MISCELLANEOUS INCOME                        CREDIT
				If !(Round(lnTargetSum,2) == Round(lnAP_TPA_MEDSP + lnAP_TPA_COS + lnAP_TPA_PF + lnAP_TPA_OTHER,2))
					??Chr(7)
					Messagebox("Unbalance 21001401+21001402+21001403+210002<>210009",0+16,"Fatal Error")
					Return
				Endif

				*!*	 -------------------------------------------------------------------------
				*!*		DUE TO THE SHITTY ASO DISTRIBUTION FIASCO (NOT THE AP ASO DISTRIBUTION
				*!*	 -------------------------------------------------------------------------
			Case iteration = 10 And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013')	&&lnAP_TPA_MEDSP
				If !(Round(lnTargetSum,2) == Round(lnAP_TPA_MEDSP,2))
					??Chr(7)
					Messagebox("Unbalance 21001402<>21000925",0+16,"Fatal Error")
					Return
				Endif
			Case iteration = 11	And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013')	&&lnAP_TPA_COS
				lnTargetSum =lnTargetSum - lnAP_TPA_DSC &&*!*	*801039 		DISCOUNT - ASO
				* RECALCULATE FOR OFFSET SCENARIO
				*		114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
				*		801013	MISCELLANEOUS INCOME                        CREDIT
				lnTargetSum =lnTargetSum - lnAP_OFFSET_TPA
				* RECALCULATE FOR OFFSET SCENARIO
				*		114008	ACCOUNTS RECEIVABLE - INCREMENTAL COST		CREDIT
				*		801013	MISCELLANEOUS INCOME                        CREDIT
				If !(Round(lnTargetSum,2) == Round(lnAP_TPA_COS,2))
					??Chr(7)
					Messagebox("Unbalance 21001401<>21000924+210009242",0+16,"Fatal Error")
					Return
				Endif
			Case iteration = 12	And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013')	&&lnAP_TPA_PF
				If !(Round(lnTargetSum,2) == Round(lnAP_TPA_PF,2))
					??Chr(7)
					Messagebox("Unbalance 21001403<>21000923",0+16,"Fatal Error")
					Return
				Endif
			Case iteration = 13	And Ctod(Dtoc(gcDate))=>Ctod('8/1/2013')	&&lnAP_TPA_PFDN
				If !(Round(lnTargetSum,2) == Round(lnAP_TPA_PFDN,2))
					??Chr(7)
					Messagebox("Unbalance 21001404<>21000927",0+16,"Fatal Error")
					Return
				Endif
				*!*	 -------------------------------------------------------------------------
				*!*		DUE TO THE SHITTY ASO DISTRIBUTION FIASCO (NOT THE AP ASO DISTRIBUTION
				*!*	 -------------------------------------------------------------------------

			Endcase
		Endif
	Next
	************************************************************************
	**** VALIDATE MATCHING APPROPRIATE AP ACCTCODE TO ITS SOURCE ACCTCODE
	************************************************************************
	************************************************************************

	************************************************************************
	************************************************************************
	**** VALIDATE PR_NUM/CV (PR_ENTR VS PCI_LOA or PCI_TAG)
	************************************************************************
	If glOldTagSchemeActive
		lnHandle= SQLConnect('pciutil','sa','')
		If lnHandle < _SUCCESS_OK
			Aerror(laErrors)
			Messagebox(laErrors[2],16,"Error in (connect) pci_loa")
			Return
		Endif
	Endif
	If glNewTagSchemeActive
		lnHandleNWschm= SQLConnect(gcNewTagDSN,'sa','')
		If lnHandleNWschm < _SUCCESS_OK
			Aerror(laErrors)
			Messagebox(laErrors[2],16,"Error in (connect) pci_tag")
			Return
		Endif
	Endif
	**** (PR_ENTR VS PCI_LOA) ----------------------------------------------
	If glOldTagSchemeActive
		Select pr_entr
		Count To cntRec
		Go Top
		barcnt		= 0
		Do While !Eof()
			barcnt = barcnt+1
			Wait Window Nowait "Validating [PR_ENTR VS PCI_LOA] LOA/LOA_NO ["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
			If !Empty(pr_entr.loa) And !Isnull(pr_entr.loa)
				lcT_LOA 	=Alltrim(pr_entr.loa)
				lcT_LOANO	=Alltrim(Str(pr_entr.loa_no))
				lcSQLstring	="SELECT * FROM PCIUTIL.DBO.PCI_LOA WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOANO"
				If SQLEXEC(lnHandle,lcSQLstring,'TSTLOA') < _SUCCESS_OK
					Aerror(laErrors)
					Messagebox(laErrors[2],16,"Error in retrieving pci_loa")
					= SQLDISCONNECT(lnHandle)
					If glNewTagSchemeActive
						= SQLDISCONNECT(lnHandleNWschm)
					Endif
					Return
				Endif
				If Reccount("TSTLOA")>=1
					Select TSTLOA
					Go Top
					Do Case
					Case Isnull(TSTLOA.pr_num)

						**** (ADDPRN3LOA VS PCI_LOA) ----------------------------------------------
						Select ADDPRN3LOA
						Seek lcT_LOA+lcT_LOANO
						If !Found()
							Select TSTLOA
							Use
							Select pr_entr
							= SQLDISCONNECT(lnHandle)
							If glNewTagSchemeActive
								= SQLDISCONNECT(lnHandleNWschm)
							Endif
							??Chr(7)
							Messagebox("Null PR_NUM (PR_ENTR<>PCI_LOA) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error")
							Return
						Endif
						**** (ADDPRN3LOA VS PCI_LOA) ----------------------------------------------

					Case Empty(TSTLOA.pr_num)

						**** (ADDPRN3LOA VS PCI_LOA) ----------------------------------------------
						Select ADDPRN3LOA
						Seek lcT_LOA+lcT_LOANO
						If !Found()
							Select TSTLOA
							Use
							Select pr_entr
							= SQLDISCONNECT(lnHandle)
							If glNewTagSchemeActive
								= SQLDISCONNECT(lnHandleNWschm)
							Endif
							??Chr(7)
							Messagebox("Empty PR_NUM (PR_ENTR<>PCI_LOA) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error")
							Return
						Endif
						**** (ADDPRN3LOA VS PCI_LOA) ----------------------------------------------

					Case !(Alltrim(TSTLOA.pr_num) == Alltrim(pr_info.pr_num))
						Select TSTLOA
						Use
						Select pr_entr
						= SQLDISCONNECT(lnHandle)
						If glNewTagSchemeActive
							= SQLDISCONNECT(lnHandleNWschm)
						Endif
						??Chr(7)
						Messagebox("PR_NUM PR_ENTR<>PCI_LOA LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error")
						Return
					Endcase
					Select TSTLOA
					Use
					Select pr_entr
				Else
					Select TSTLOA
					Use
					Select pr_entr
					= SQLDISCONNECT(lnHandle)
					If glNewTagSchemeActive
						= SQLDISCONNECT(lnHandleNWschm)
					Endif
					??Chr(7)
					Messagebox("Missing LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error")
					Return
				Endif
			Endif
			Select pr_entr
			Skip
		Enddo
	Endif
	**** (PR_ENTR VS PCI_LOA) ----------------------------------------------
	**** (PR_ENTR VS PCI_TAG) ----------------------------------------------
	If glNewTagSchemeActive
		Select pr_entr
		Count To cntRec
		Go Top
		barcnt		= 0
		Do While !Eof()
			barcnt = barcnt+1
			Wait Window Nowait "Validating [PR_ENTR VS PCI_TAG] LOA/LOA_NO ["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
			If !Empty(pr_entr.loa) And !Isnull(pr_entr.loa)
				lcT_LOA 	=Alltrim(pr_entr.loa)
				lcT_LOANO	=Alltrim(Str(pr_entr.loa_no))
				lcSQLstring	="SELECT * FROM "+gcNewTagDBF+".DBO."+gcNewTagTABLE+" WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOANO"
				If SQLEXEC(lnHandleNWschm,lcSQLstring,'TSTLOA') < _SUCCESS_OK
					Aerror(laErrors)
					Messagebox(laErrors[2],16,"Error in retrieving pci_tag")
					If glOldTagSchemeActive
						= SQLDISCONNECT(lnHandle)
					Endif
					= SQLDISCONNECT(lnHandleNWschm)
					Return
				Endif
				If Reccount("TSTLOA")>=1
					Select TSTLOA
					Go Top
					Do Case
					Case Isnull(TSTLOA.pr_num)

						**** (ADDPRN3LOA VS PCI_LOA) ----------------------------------------------
						Select ADDPRN3LOA
						Seek lcT_LOA+lcT_LOANO
						If !Found()
							Select TSTLOA
							Use
							Select pr_entr
							If glOldTagSchemeActive
								= SQLDISCONNECT(lnHandle)
							Endif
							= SQLDISCONNECT(lnHandleNWschm)
							??Chr(7)
							Messagebox("Null PR_NUM (PR_ENTR<>PCI_TAG) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error")
							Return
						Endif
						**** (ADDPRN3LOA VS PCI_LOA) ----------------------------------------------

					Case Empty(TSTLOA.pr_num)

						**** (ADDPRN3LOA VS PCI_LOA) ----------------------------------------------
						Select ADDPRN3LOA
						Seek lcT_LOA+lcT_LOANO
						If !Found()
							Select TSTLOA
							Use
							Select pr_entr
							If glOldTagSchemeActive
								= SQLDISCONNECT(lnHandle)
							Endif
							= SQLDISCONNECT(lnHandleNWschm)
							??Chr(7)
							Messagebox("Empty PR_NUM (PR_ENTR<>PCI_TAG) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error")
							Return
						Endif
						**** (ADDPRN3LOA VS PCI_LOA) ----------------------------------------------

					Case !(Alltrim(TSTLOA.pr_num) == Alltrim(pr_info.pr_num))
						Select TSTLOA
						Use
						Select pr_entr
						If glOldTagSchemeActive
							= SQLDISCONNECT(lnHandle)
						Endif
						= SQLDISCONNECT(lnHandleNWschm)
						??Chr(7)
						Messagebox("PR_NUM PR_ENTR<>PCI_TAG LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error")
						Return
					Endcase
					Select TSTLOA
					Use
					Select pr_entr
				Else

					**** (ADDPRN3LOA VS PCI_LOA) ----------------------------------------------
					Select ADDPRN3LOA
					Seek lcT_LOA+lcT_LOANO
					If !Found()
						Select TSTLOA
						Use
						Select pr_entr
						If glOldTagSchemeActive
							= SQLDISCONNECT(lnHandle)
						Endif
						= SQLDISCONNECT(lnHandleNWschm)
						??Chr(7)
						Messagebox("Missing LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error")
						Return
					Endif
					**** (ADDPRN3LOA VS PCI_LOA) ----------------------------------------------

				Endif
			Endif
			Select pr_entr
			Skip
		Enddo
	Endif
	**** (PR_ENTR VS PCI_TAG) ----------------------------------------------

	**** (DELPRN3LOA VS PCI_LOA) ----------------------------------------------
	*	This module was added because the inhouse programmer was tired of correcting all the
	*	damned mistake that this section is generating
	If glOldTagSchemeActive
		If gcRegion#'YY'	&&'16' If Lower(Alltrim(gcUser))=Left('administrator',12)
			Select DELPRN3LOA
			Count To cntRec
			Go Top
			barcnt		= 0
			Do While !Eof()
				barcnt = barcnt+1
				Wait Window Nowait "Validating [DELPRN3LOA VS PCI_LOA] LOA/LOA_NO ["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
				If !Empty(DELPRN3LOA.loa) And !Isnull(DELPRN3LOA.loa)
					lcT_LOA 	=Alltrim(DELPRN3LOA.loa)
					lcT_LOANO	=Alltrim(Str(DELPRN3LOA.loa_no))
					lcSQLstring	="SELECT * FROM PCIUTIL.DBO.PCI_LOA WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOANO"
					If SQLEXEC(lnHandle,lcSQLstring,'TSTLOA') < _SUCCESS_OK
						Aerror(laErrors)
						Messagebox(laErrors[2],16,"Error in retrieving (DELPRN3LOA) pci_loa")
						= SQLDISCONNECT(lnHandle)
						If glNewTagSchemeActive
							= SQLDISCONNECT(lnHandleNWschm)
						Endif
						Return
					Endif
					If Reccount("TSTLOA")>=1
						Select TSTLOA
						Go Top
						Do Case
						Case Isnull(TSTLOA.pr_num)
							Select TSTLOA
							Use
							Select pr_entr
							= SQLDISCONNECT(lnHandle)
							If glNewTagSchemeActive
								= SQLDISCONNECT(lnHandleNWschm)
							Endif
							??Chr(7)
							Messagebox("Null PR_NUM (PR_ENTR<>PCI_LOA) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (DELPRN3LOA)")
							Return
						Case Empty(TSTLOA.pr_num)
							Select TSTLOA
							Use
							Select pr_entr
							= SQLDISCONNECT(lnHandle)
							If glNewTagSchemeActive
								= SQLDISCONNECT(lnHandleNWschm)
							Endif
							??Chr(7)
							Messagebox("Empty PR_NUM (PR_ENTR<>PCI_LOA) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (DELPRN3LOA)")
							Return
						Case !(Alltrim(TSTLOA.pr_num) == Alltrim(pr_info.pr_num))
							Select TSTLOA
							Use
							Select pr_entr
							= SQLDISCONNECT(lnHandle)
							If glNewTagSchemeActive
								= SQLDISCONNECT(lnHandleNWschm)
							Endif
							??Chr(7)
							Messagebox("PR_NUM PR_ENTR<>PCI_LOA LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (DELPRN3LOA)")
							Return
						Endcase
						Select TSTLOA
						Use
						Select pr_entr
					Else
						Select TSTLOA
						Use
						Select pr_entr
						= SQLDISCONNECT(lnHandle)
						If glNewTagSchemeActive
							= SQLDISCONNECT(lnHandleNWschm)
						Endif
						??Chr(7)
						Messagebox("Missing LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (DELPRN3LOA)")
						Return
					Endif
				Endif
				Select DELPRN3LOA
				Skip
			Enddo
		Endif
	Endif
	*	This module was added because the inhouse programmer was tired of correcting all the
	*	damned mistake that this section is generating
	**** (DELPRN3LOA VS PCI_LOA) ----------------------------------------------
	**** (DELPRN3LOA VS PCI_TAG) ----------------------------------------------
	*	This module was added because the inhouse programmer was tired of correcting all the
	*	damned mistake that this section is generating
	If glNewTagSchemeActive
		Select DELPRN3LOA
		Count To cntRec
		Go Top
		barcnt		= 0
		Do While !Eof()
			barcnt = barcnt+1
			Wait Window Nowait "Validating [DELPRN3LOA VS PCI_TAG] LOA/LOA_NO ["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
			If !Empty(DELPRN3LOA.loa) And !Isnull(DELPRN3LOA.loa)
				lcT_LOA 	=Alltrim(DELPRN3LOA.loa)
				lcT_LOANO	=Alltrim(Str(DELPRN3LOA.loa_no))
				lcSQLstring	="SELECT * FROM "+gcNewTagDBF+".DBO."+gcNewTagTABLE+" WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOANO"
				If SQLEXEC(lnHandleNWschm,lcSQLstring,'TSTLOA') < _SUCCESS_OK
					Aerror(laErrors)
					Messagebox(laErrors[2],16,"Error in retrieving (DELPRN3LOA) pci_tag")
					If glOldTagSchemeActive
						= SQLDISCONNECT(lnHandle)
					Endif
					= SQLDISCONNECT(lnHandleNWschm)
					Return
				Endif
				If Reccount("TSTLOA")>=1
					Select TSTLOA
					Go Top
					Do Case
					Case Isnull(TSTLOA.pr_num)
						Select TSTLOA
						Use
						Select pr_entr
						If glOldTagSchemeActive
							= SQLDISCONNECT(lnHandle)
						Endif
						= SQLDISCONNECT(lnHandleNWschm)
						??Chr(7)
						Messagebox("Null PR_NUM (PR_ENTR<>PCI_TAG) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (DELPRN3LOA)")
						Return
					Case Empty(TSTLOA.pr_num)
						Select TSTLOA
						Use
						Select pr_entr
						If glOldTagSchemeActive
							= SQLDISCONNECT(lnHandle)
						Endif
						= SQLDISCONNECT(lnHandleNWschm)
						??Chr(7)
						Messagebox("Empty PR_NUM (PR_ENTR<>PCI_TAG) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (DELPRN3LOA)")
						Return
					Case !(Alltrim(TSTLOA.pr_num) == Alltrim(pr_info.pr_num))
						Select TSTLOA
						Use
						Select pr_entr
						If glOldTagSchemeActive
							= SQLDISCONNECT(lnHandle)
						Endif
						= SQLDISCONNECT(lnHandleNWschm)
						??Chr(7)
						Messagebox("PR_NUM PR_ENTR<>PCI_TAG LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (DELPRN3LOA)")
						Return
					Endcase
					Select TSTLOA
					Use
					Select pr_entr
				Else
					Select TSTLOA
					Use
					Select pr_entr
					If glOldTagSchemeActive
						= SQLDISCONNECT(lnHandle)
					Endif
					= SQLDISCONNECT(lnHandleNWschm)
					??Chr(7)
					Messagebox("Missing LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (DELPRN3LOA)")
					Return
				Endif
			Endif
			Select DELPRN3LOA
			Skip
		Enddo
	Endif
	*	This module was added because the inhouse programmer was tired of correcting all the
	*	damned mistake that this section is generating
	**** (DELPRN3LOA VS PCI_TAG) ----------------------------------------------

	**** (ADDPRN3LOA VS PCI_LOA/PCI_TAG) ----------------------------------------------
	* 	reserved for auto tagging in pci_loa of additional inserted loa in prentr
	**** (ADDPRN3LOA VS PCI_LOA/PCI_TAG) ----------------------------------------------
	If glOldTagSchemeActive
		Select ADDPRN3LOA
		Count To cntRec
		Go Top
		barcnt		= 0
		Do While !Eof()
			barcnt = barcnt+1
			Wait Window Nowait "Validating [ADDPRN3LOA VS PCI_LOA] LOA/LOA_NO ["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
			If !Empty(ADDPRN3LOA .loa) And !Isnull(ADDPRN3LOA .loa)
				lcT_LOA 	=Alltrim(ADDPRN3LOA .loa)
				lcT_LOANO	=Alltrim(Str(ADDPRN3LOA .loa_no))
				lcSQLstring	="SELECT * FROM PCIUTIL.DBO.PCI_LOA WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOANO"
				If SQLEXEC(lnHandle,lcSQLstring,'TSTLOA') < _SUCCESS_OK
					Aerror(laErrors)
					Messagebox(laErrors[2],16,"Error in retrieving (ADDPRN3LOA) pci_loa")
					= SQLDISCONNECT(lnHandle)
					If glNewTagSchemeActive
						= SQLDISCONNECT(lnHandleNWschm)
					Endif
					Return
				Endif
				If Reccount("TSTLOA")>=1
					Select TSTLOA
					Go Top
					Do Case
					Case Isnull(TSTLOA.pr_num)
						*!*							Select TSTLOA
						*!*							Use
						*!*							Select pr_entr
						*!*							= SQLDISCONNECT(lnHandle)
						*!*							If glNewTagSchemeActive
						*!*								= SQLDISCONNECT(lnHandleNWschm)
						*!*							Endif
						*!*							??Chr(7)
						*!*							Messagebox("Null PR_NUM (PR_ENTR<>PCI_LOA) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (ADDPRN3LOA)")
						*!*							Return
					Case Empty(TSTLOA.pr_num)
						*!*							Select TSTLOA
						*!*							Use
						*!*							Select pr_entr
						*!*							= SQLDISCONNECT(lnHandle)
						*!*							If glNewTagSchemeActive
						*!*								= SQLDISCONNECT(lnHandleNWschm)
						*!*							Endif
						*!*							??Chr(7)
						*!*							Messagebox("Empty PR_NUM (PR_ENTR<>PCI_LOA) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (ADDPRN3LOA)")
						*!*							Return
					Case !(Alltrim(TSTLOA.pr_num) == Alltrim(pr_info.pr_num))
						Select TSTLOA
						Use
						Select pr_entr
						= SQLDISCONNECT(lnHandle)
						If glNewTagSchemeActive
							= SQLDISCONNECT(lnHandleNWschm)
						Endif
						??Chr(7)
						Messagebox("PR_NUM PR_ENTR<>PCI_LOA LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (ADDPRN3LOA)")
						Return
					Endcase
					Select TSTLOA
					Use
					Select pr_entr
				Else
					Select TSTLOA
					Use
					Select pr_entr
					= SQLDISCONNECT(lnHandle)
					If glNewTagSchemeActive
						= SQLDISCONNECT(lnHandleNWschm)
					Endif
					??Chr(7)
					Messagebox("Missing LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (ADDPRN3LOA)")
					Return
				Endif
			Endif
			Select ADDPRN3LOA
			Skip
		Enddo
	Endif
	If glNewTagSchemeActive
		Select ADDPRN3LOA
		Count To cntRec
		Go Top
		barcnt		= 0
		Do While !Eof()
			barcnt = barcnt+1
			Wait Window Nowait "Validating [ADDPRN3LOA VS PCI_TAG] LOA/LOA_NO ["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
			If !Empty(ADDPRN3LOA.loa) And !Isnull(ADDPRN3LOA.loa)
				lcT_LOA 	=Alltrim(ADDPRN3LOA.loa)
				lcT_LOANO	=Alltrim(Str(ADDPRN3LOA.loa_no))
				lcSQLstring	="SELECT * FROM "+gcNewTagDBF+".DBO."+gcNewTagTABLE+" WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOANO"
				If SQLEXEC(lnHandleNWschm,lcSQLstring,'TSTLOA') < _SUCCESS_OK
					Aerror(laErrors)
					Messagebox(laErrors[2],16,"Error in retrieving (ADDPRN3LOA) pci_tag")
					If glOldTagSchemeActive
						= SQLDISCONNECT(lnHandle)
					Endif
					= SQLDISCONNECT(lnHandleNWschm)
					Return
				Endif
				If Reccount("TSTLOA")>=1
					Select TSTLOA
					Go Top
					Do Case
					Case Isnull(TSTLOA.pr_num)
						*!*							Select TSTLOA
						*!*							Use
						*!*							Select pr_entr
						*!*							If glOldTagSchemeActive
						*!*								= SQLDISCONNECT(lnHandle)
						*!*							Endif
						*!*							= SQLDISCONNECT(lnHandleNWschm)
						*!*							??Chr(7)
						*!*							Messagebox("Null PR_NUM (PR_ENTR<>PCI_TAG) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (ADDPRN3LOA)")
						*!*							Return
					Case Empty(TSTLOA.pr_num)
						*!*							Select TSTLOA
						*!*							Use
						*!*							Select pr_entr
						*!*							If glOldTagSchemeActive
						*!*								= SQLDISCONNECT(lnHandle)
						*!*							Endif
						*!*							= SQLDISCONNECT(lnHandleNWschm)
						*!*							??Chr(7)
						*!*							Messagebox("Empty PR_NUM (PR_ENTR<>PCI_TAG) LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (ADDPRN3LOA)")
						*!*							Return
					Case !(Alltrim(TSTLOA.pr_num) == Alltrim(pr_info.pr_num))
						Select TSTLOA
						Use
						Select pr_entr
						If glOldTagSchemeActive
							= SQLDISCONNECT(lnHandle)
						Endif
						= SQLDISCONNECT(lnHandleNWschm)
						??Chr(7)
						Messagebox("PR_NUM PR_ENTR<>PCI_TAG LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (ADDPRN3LOA)")
						Return
					Endcase
					Select TSTLOA
					Use
					Select pr_entr
				Else
					*!*						Select TSTLOA
					*!*						Use
					*!*						Select pr_entr
					*!*						If glOldTagSchemeActive
					*!*							= SQLDISCONNECT(lnHandle)
					*!*						Endif
					*!*						= SQLDISCONNECT(lnHandleNWschm)
					*!*						??Chr(7)
					*!*						Messagebox("Missing LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (ADDPRN3LOA)")
					*!*						Return
				Endif
			Endif
			Select ADDPRN3LOA
			Skip
		Enddo
	Endif
	**** (ADDPRN3LOA VS PCI_LOA/PCI_TAG) ----------------------------------------------
	* 	reserved for auto tagging in pci_tag of additional inserted loa in prentr
	**** (ADDPRN3LOA VS PCI_LOA/PCI_TAG) ----------------------------------------------

	If glOldTagSchemeActive
		= SQLDISCONNECT(lnHandle)
	Endif
	If glNewTagSchemeActive
		= SQLDISCONNECT(lnHandleNWschm)
	Endif
	************************************************************************
	**** VALIDATE PR_NUM/CV (PR_ENTR VS PCI_LOA or PCI_TAG)
	************************************************************************
	************************************************************************

	************************************************************************
	************************************************************************
	**** (DELPRN3LOA VS ADDPRN3LOA) ----------------------------------------
	************************************************************************
	Select DELPRN3LOA
	Count To cntRec
	Go Top
	barcnt		= 0
	Do While !Eof()
		barcnt = barcnt+1
		Wait Window Nowait "Validating [DELPRN3LOA VS ADDPRN3LOA] LOA/LOA_NO ["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
		If !Empty(DELPRN3LOA.loa) And !Isnull(DELPRN3LOA.loa)
			lcT_LOA 	=DELPRN3LOA.loa
			lcT_LOANO	=Alltrim(Str(DELPRN3LOA.loa_no))
			Select ADDPRN3LOA
			Seek lcT_LOA+lcT_LOANO
			If Found()
				Select pr_entr
				??Chr(7)
				Messagebox("Addition and Deletion of same LOA not allowed, LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (DELPRN3LOA VS ADDPRN3LOA)")
				Return
			Endif
		Endif
		Select DELPRN3LOA
		Skip
	Enddo
	Select ADDPRN3LOA
	Count To cntRec
	Go Top
	barcnt		= 0
	Do While !Eof()
		barcnt = barcnt+1
		Wait Window Nowait "Validating [ADDPRN3LOA VS DELPRN3LOA] LOA/LOA_NO ["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
		If !Empty(ADDPRN3LOA.loa) And !Isnull(ADDPRN3LOA.loa)
			lcT_LOA 	=ADDPRN3LOA.loa
			lcT_LOANO	=Alltrim(Str(ADDPRN3LOA.loa_no))
			Select DELPRN3LOA
			Seek lcT_LOA+lcT_LOANO
			If Found()
				Select pr_entr
				??Chr(7)
				Messagebox("Deletion and Addition of same LOA not allowed, LOA:["+lcT_LOA+"/"+lcT_LOANO+"]",0+16,"Fatal Error (DELPRN3LOA VS ADDPRN3LOA)")
				Return
			Endif
		Endif
		Select ADDPRN3LOA
		Skip
	Enddo
	************************************************************************
	**** (DELPRN3LOA VS ADDPRN3LOA) ----------------------------------------
	************************************************************************
	************************************************************************

	Select pr_entr
	Wait Window Nowait 'Computing Cr...pls wait..'
	Sum pr_entr.amount To lnAmountc For pr_entr.drcrcode='C' And ;
		(pr_entr.acctcode = '210012' Or pr_entr.acctcode = '210013' Or ;
		pr_entr.acctcode = '210014' Or pr_entr.acctcode = '210015' Or ;
		pr_entr.acctcode = '210016' Or pr_entr.acctcode = '210017' Or ;
		pr_entr.acctcode = '210018' Or ;
		pr_entr.acctcode = '21001201' Or pr_entr.acctcode = '21001402' Or ;
		pr_entr.acctcode = '21001401' Or pr_entr.acctcode = '21001403' Or ;
		pr_entr.acctcode = '21001404' Or ;
		pr_entr.acctcode = '210002' Or ;
		pr_entr.acctcode='1100')
	Wait Clear

	Select pr_info
	Replace pr_info.amount With lnAmountc,pr_info.edited With gcDate,pr_info.edited_by With gcUser
	If Empty(pr_info.duedate)
		Replace pr_info.duedate With .Null.
	Endif
	If Thisform.chkRush.Value=1
		Replace pr_info.RUSH With 'T'
	Else
		Replace pr_info.RUSH With .Null.
	Endif

	lnHandleTRANSACTION=CursorGetProp("ConnectHandle","PR_INFO")
	If SQLSETPROP(lnHandleTRANSACTION,"Transactions",2) < 1 && 1 success -1 fail
		Aerror(laErrors)
		Messagebox(laErrors[2],16,"Error in SQL SET Transaction PR_INFO/PR_ENTR")
		Sele pr_info
		=Tablerevert(.T.)
		Sele pr_entr
		=Tablerevert(.T.)
		Quit
	Endif

	Begin Transaction

	* PR_INFO *
	Sele pr_info
	xx=Tableupdate(.T.)
	If xx=.F.
		Aerror(laErrors)
		Messagebox(laErrors[2],16,"Error in INFO")
		Rollback
		If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
			Aerror(laErrors)
			Messagebox(laErrors[2],16,"Error in rollback PR_INFO")
		Endif
		If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
			Aerror(laErrors)
			Messagebox(laErrors[2],16,"Error in SQL SET Transaction (PR_INFO/AUTO)")
		Endif
		Sele pr_info
		=Tablerevert(.T.)
		Sele pr_entr
		=Tablerevert(.T.)
		??Chr(7)
		Messagebox("Changes in PR Info not saved",0+16+0,"Saving Fail in PR_INFO")
		Return
	Else
		* PR_ENTR *
		Select pr_entr
		xx=Tableupdate(.T.)
		If xx=.F.
			Aerror(laErrors)
			Messagebox(laErrors[2],16,"Error in ENTR")
			Rollback
			If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
				Aerror(laErrors)
				Messagebox(laErrors[2],16,"Error in rollback PR_ENTR")
			Endif
			If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
				Aerror(laErrors)
				Messagebox(laErrors[2],16,"Error in SQL SET Transaction (PR_ENTR/AUTO)")
			Endif
			Sele pr_info
			=Tablerevert(.T.)
			Sele pr_entr
			=Tablerevert(.T.)
			??Chr(7)
			Messagebox("Changes in PR Entry not saved",0+16+0,"Saving Fail in PR_ENTR")
			Return
		Else

			lcT_PR_NUM 	= Alltrim(pr_info.pr_num)
			ldT_PR_DATE = Ctod(Dtoc(pr_info.pr_date))
			******************************************************
			* ---- DELPRN3LOA ------------------------------------
			Select DELPRN3LOA
			Select Distinct * From DELPRN3LOA Into Cursor DELPRN3LOA_TMP
			Select DELPRN3LOA_TMP
			Count To cntFin
			If cntFin >= 1
				* PR_LOA *---------------------------------------------------------
				Select DELPRN3LOA_TMP
				Go Top
				barcnt=0
				Do While !Eof()
					Wait Window Nowait "Deleting from PR_LOA LOA/LOA_NO:["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
					lcT_LOA		= Alltrim(DELPRN3LOA_TMP.loa)
					lcT_LOA_NO	= Alltrim(Str(DELPRN3LOA_TMP.loa_no))
					lcT_LMSG 	= Alltrim(DELPRN3LOA_TMP.loa)+'/'+Alltrim(Str(DELPRN3LOA_TMP.loa_no))
					If !Thisform.LoaStlExistnPRn3(lcT_LOA,lcT_LOA_NO)
						gcQuery		="DELETE FROM PR_LOA WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOA_NO"
						If SQLEXEC(lnHandleTRANSACTION,gcQuery) < _SUCCESS_OK
							Aerror(laErrors)
							Messagebox(laErrors[2],16,"Error in deleting LOA:["+lcT_LMSG+"] in PR_LOA")
							Rollback
							If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in rollback LOA:["+lcT_LMSG+"] PR_LOA")
							Endif
							If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCIPR (PR_LOA/AUTO)")
							Endif
							Sele pr_info
							=Tablerevert(.T.)
							Sele pr_entr
							=Tablerevert(.T.)
							??Chr(7)
							Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in DELPRN3LOA PR_LOA")
							Return
						Endif
					Endif
					Select DELPRN3LOA_TMP
					Skip
				Enddo
				* PR_LOA *---------------------------------------------------------

				* PCI_LOA *--------------------------------------------------------
				*	This module was added because the inhouse programmer was tired of correcting all the
				*	damned mistake that this section is generating
				If glOldTagSchemeActive
					If gcRegion#'YY'	&&'16' Lower(Alltrim(gcUser))=Left('administrator',12)
						*!*	LIMITED TO ADMIN DUE TO THE NEGATIVE REACTION WITH ERWINS GROUP
						*!*	REACTIVATED TOO COMPLICATED TO TOLERATE ERWINS GROUP
						*!*	BACOLOD OFFICE IS THE HOUSE OF GOD IN INTELLICARE, GROUP EXCLUDED
						*!*	ACTIVATED IN BACOLOD OFFICE I HOPE & PRAY I DONT STIR UP ANY SLEEPING DRAGONS WITHIN THAT KINGDOM
						Select DELPRN3LOA_TMP
						Go Top
						Do While !Eof()
							lcT_LOA		= Alltrim(DELPRN3LOA_TMP.loa)
							lcT_LOA_NO	= Alltrim(Str(DELPRN3LOA_TMP.loa_no))
							lcT_LMSG 	= Alltrim(DELPRN3LOA_TMP.loa)+'/'+Alltrim(Str(DELPRN3LOA_TMP.loa_no))
							If !Thisform.LoaStlExistnPRn3(lcT_LOA,lcT_LOA_NO)
								gcQuery1	= "UPDATE PCIUTIL.DBO.PCI_LOA SET PR_NUM='',PR_DATE=NULL,BATCH='' "
								gcQuery2	= "WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOA_NO"
								gcQuery 	= gcQuery1 + gcQuery2
								If SQLEXEC(lnHandleTRANSACTION,gcQuery) < _SUCCESS_OK
									Aerror(laErrors)
									Messagebox(laErrors[2],16,"Error in pr deletion LOA:["+lcT_LMSG+"] PCI_LOA")
									Rollback
									If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
										Aerror(laErrors)
										Messagebox(laErrors[2],16,"Error in rollback pr deletion LOA:["+lcT_LMSG+"] PCI_LOA")
									Endif
									If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
										Aerror(laErrors)
										Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCIUTIL pr deletion (PCI_LOA/AUTO)")
									Endif
									??Chr(7)
									Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in PR_INFO/PR_ENTR/PR_LOA/PCI_LOA")
									Return
								Endif
							Endif
							Select DELPRN3LOA_TMP
							Skip
						Enddo
					Endif
				Endif
				* PCI_LOA *--------------------------------------------------------

				* PCI_TAG *--------------------------------------------------------
				*	This module was added because the inhouse programmer was tired of correcting all the
				*	damned mistake that this section is generating
				If glNewTagSchemeActive
					Select DELPRN3LOA_TMP
					Go Top
					Do While !Eof()
						lcT_LOA		= Alltrim(DELPRN3LOA_TMP.loa)
						lcT_LOA_NO	= Alltrim(Str(DELPRN3LOA_TMP.loa_no))
						lcT_LMSG 	= Alltrim(DELPRN3LOA_TMP.loa)+'/'+Alltrim(Str(DELPRN3LOA_TMP.loa_no))
						If !Thisform.LoaStlExistnPRn3(lcT_LOA,lcT_LOA_NO)
							*gcQuery1	= "UPDATE "+gcNewTagDBF+".DBO."+gcNewTagTABLE+" SET PR_NUM='',PR_DATE=NULL,BATCH='' "
							*gcQuery2	= "WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOA_NO"
							*gcQuery 	= gcQuery1 + gcQuery2
							gcQuery		= "DELETE FROM "+gcNewTagDBF+".DBO."+gcNewTagTABLE+" WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOA_NO"
							If SQLEXEC(lnHandleTRANSACTION,gcQuery) < _SUCCESS_OK
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in pr deletion LOA:["+lcT_LMSG+"] PCI_TAG")
								Rollback
								If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
									Aerror(laErrors)
									Messagebox(laErrors[2],16,"Error in rollback pr deletion LOA:["+lcT_LMSG+"] PCI_TAG")
								Endif
								If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
									Aerror(laErrors)
									Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCITAG pr deletion (PCI_TAG/AUTO)")
								Endif
								??Chr(7)
								Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in PR_INFO/PR_ENTR/PR_LOA/PCI_LOA/PCI_TAG")
								Return
							Endif
						Endif
						Select DELPRN3LOA_TMP
						Skip
					Enddo
				Endif
				* PCI_TAG *--------------------------------------------------------
			Endif	&&cntFin >= 1
			Select DELPRN3LOA_TMP
			Use
			* ---- DELPRN3LOA ------------------------------------
			******************************************************

			******************************************************
			* ---- ADDPRN3LOA ------------------------------------
			Select ADDPRN3LOA
			Select Distinct * From ADDPRN3LOA Into Cursor ADDPRN3LOA_TMP
			Select ADDPRN3LOA_TMP
			Count To cntFin
			If cntFin >= 1
				* PR_LOA *---------------------------------------------------------
				Select ADDPRN3LOA_TMP
				Go Top
				barcnt=0
				Do While !Eof()
					Wait Window Nowait "Inserting from PR_LOA LOA/LOA_NO:["+Alltrim(Str(barcnt))+" of "+Alltrim(Str(cntRec))+"]"
					lcT_LOA		= Alltrim(ADDPRN3LOA_TMP.loa)
					lcT_LOA_NO	= Alltrim(Str(ADDPRN3LOA_TMP.loa_no))
					lcT_LMSG 	= Alltrim(ADDPRN3LOA_TMP.loa)+'/'+Alltrim(Str(ADDPRN3LOA_TMP.loa_no))
					lnErr		= 0
					If Thisform.LoaNotInPRLOA(lcT_LOA,lcT_LOA_NO,lcT_PR_NUM,@lnErr)
						If lnErr#0
							Rollback
							If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in rollback LOA:["+lcT_LMSG+"] PR_LOA")
							Endif
							If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCIPR (PR_LOA/AUTO)")
							Endif
							Sele pr_info
							=Tablerevert(.T.)
							Sele pr_entr
							=Tablerevert(.T.)
							??Chr(7)
							Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in ADDPRN3LOA PR_LOA")
							Return
						Endif
						gcQuery		="INSERT INTO PR_LOA (LOA,LOA_NO,PR_NUM) VALUES (?lcT_LOA,?lcT_LOA_NO,?lcT_PR_NUM)"
						If SQLEXEC(lnHandleTRANSACTION,gcQuery) < _SUCCESS_OK
							Aerror(laErrors)
							Messagebox(laErrors[2],16,"Error in inserting LOA:["+lcT_LMSG+"] in PR_LOA")
							Rollback
							If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in rollback LOA:["+lcT_LMSG+"] PR_LOA")
							Endif
							If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCIPR (PR_LOA/AUTO)")
							Endif
							Sele pr_info
							=Tablerevert(.T.)
							Sele pr_entr
							=Tablerevert(.T.)
							??Chr(7)
							Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in ADDPRN3LOA PR_LOA")
							Return
						Endif
					Endif
					Select ADDPRN3LOA_TMP
					Skip
				Enddo
				* PR_LOA *---------------------------------------------------------

				* PCI_LOA *--------------------------------------------------------
				*	This module was added because the inhouse programmer was tired of correcting all the
				*	damned mistake that this section is generating
				If glOldTagSchemeActive
					If gcRegion#'YY'	&&'16' Lower(Alltrim(gcUser))=Left('administrator',12)
						*!*	LIMITED TO ADMIN DUE TO THE NEGATIVE REACTION WITH ERWINS GROUP
						*!*	REACTIVATED TOO COMPLICATED TO TOLERATE ERWINS GROUP
						*!*	BACOLOD OFFICE IS THE HOUSE OF GOD IN INTELLICARE, GROUP EXCLUDED
						*!*	ACTIVATED IN BACOLOD OFFICE I HOPE & PRAY I DONT STIR UP ANY SLEEPING DRAGONS WITHIN THAT KINGDOM
						Select ADDPRN3LOA_TMP
						Go Top
						Do While !Eof()
							lcT_LOA		= Alltrim(ADDPRN3LOA_TMP.loa)
							lcT_LOA_NO	= Alltrim(Str(ADDPRN3LOA_TMP.loa_no))
							lcT_LMSG 	= Alltrim(ADDPRN3LOA_TMP.loa)+'/'+Alltrim(Str(ADDPRN3LOA_TMP.loa_no))
							lnErr		= 0
							If Thisform.LoaNotTagInPCILOA(lcT_LOA,lcT_LOA_NO,lcT_PR_NUM,@lnErr)
								If lnErr#0
									Rollback
									If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
										Aerror(laErrors)
										Messagebox(laErrors[2],16,"Error in rollback pr updating LOA:["+lcT_LMSG+"] PCI_LOA")
									Endif
									If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
										Aerror(laErrors)
										Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCIUTIL pr updating (PCI_LOA/AUTO)")
									Endif
									??Chr(7)
									Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in PR_INFO/PR_ENTR/PR_LOA/PCI_LOA")
									Return
								Endif
								gcQuery1	= "UPDATE PCIUTIL.DBO.PCI_LOA SET PR_NUM=?lcT_PR_NUM,PR_DATE=?ldT_PR_DATE,BATCH='COMELEC-INS' "
								gcQuery2	= "WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOA_NO"
								gcQuery 	= gcQuery1 + gcQuery2
								If SQLEXEC(lnHandleTRANSACTION,gcQuery) < _SUCCESS_OK
									Aerror(laErrors)
									Messagebox(laErrors[2],16,"Error in pr updating LOA:["+lcT_LMSG+"] PCI_LOA")
									Rollback
									If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
										Aerror(laErrors)
										Messagebox(laErrors[2],16,"Error in rollback pr updating LOA:["+lcT_LMSG+"] PCI_LOA")
									Endif
									If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
										Aerror(laErrors)
										Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCIUTIL pr updating (PCI_LOA/AUTO)")
									Endif
									??Chr(7)
									Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in PR_INFO/PR_ENTR/PR_LOA/PCI_LOA")
									Return
								Endif
							Endif
							Select ADDPRN3LOA_TMP
							Skip
						Enddo
					Endif
				Endif
				* PCI_LOA *--------------------------------------------------------

				* PCI_TAG *--------------------------------------------------------
				*	This module was added because the inhouse programmer was tired of correcting all the
				*	damned mistake that this section is generating
				If glNewTagSchemeActive
					Select ADDPRN3LOA_TMP
					Go Top
					Do While !Eof()
						lcT_LOA		= Alltrim(ADDPRN3LOA_TMP.loa)
						lcT_LOA_NO	= Alltrim(Str(ADDPRN3LOA_TMP.loa_no))
						lcT_LMSG 	= Alltrim(ADDPRN3LOA_TMP.loa)+'/'+Alltrim(Str(ADDPRN3LOA_TMP.loa_no))

						lnHandleNWschm= SQLConnect(gcNewTagDSN,'sa','')
						If lnHandleNWschm < _SUCCESS_OK
							Aerror(laErrors)
							Messagebox(laErrors[2],16,"Error in (connect) pci_tag")
							Rollback
							If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in rollback pr deletion LOA:["+lcT_LMSG+"] PCI_TAG")
							Endif
							If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCITAG pr deletion (PCI_TAG/AUTO)")
							Endif
							??Chr(7)
							Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in PR_INFO/PR_ENTR/PR_LOA/PCI_LOA/PCI_TAG")
							Return
						Endif
						gcQuery	= "SELECT * FROM "+gcNewTagDBF+".DBO."+gcNewTagTABLE+" WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOA_NO"
						If SQLEXEC(lnHandleNWschm,gcQuery,'TEST_SQL') < _SUCCESS_OK
							Aerror(laErrors)
							Messagebox(laErrors[2],16,"Error in pr deletion LOA:["+lcT_LMSG+"] PCI_TAG")
							Rollback
							If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in rollback pr deletion LOA:["+lcT_LMSG+"] PCI_TAG")
							Endif
							If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCITAG pr deletion (PCI_TAG/AUTO)")
							Endif
							??Chr(7)
							Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in PR_INFO/PR_ENTR/PR_LOA/PCI_LOA/PCI_TAG")
							= SQLDISCONNECT(lnHandleNWschm)
							Return
						Endif
						= SQLDISCONNECT(lnHandleNWschm)
						Select TEST_SQL
						If Reccount("TEST_SQL")>=1
							lcWhichSQLcmd ='UPDATE'
						Else
							lcWhichSQLcmd ='INSERT'
						Endif
						Select TEST_SQL
						Use
						Do Case
						Case lcWhichSQLcmd ='UPDATE'
							gcQuery1	= "UPDATE "+gcNewTagDBF+".DBO."+gcNewTagTABLE+" SET PR_NUM=?lcT_PR_NUM,PR_DATE=?ldT_PR_DATE,BATCH='COMELEC-INS' "
							gcQuery2	= "WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOA_NO"
							gcQuery 	= gcQuery1 + gcQuery2
						Case lcWhichSQLcmd ='INSERT'
							lnHandleNWschm= SQLConnect('PCIUTIL','sa','')
							If lnHandleNWschm < _SUCCESS_OK
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in (connect) pci_util")
								Rollback
								If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
									Aerror(laErrors)
									Messagebox(laErrors[2],16,"Error in rollback pr updating LOA:["+lcT_LMSG+"] PCI_TAG")
								Endif
								If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
									Aerror(laErrors)
									Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCITAG pr deletion (PCI_TAG/AUTO)")
								Endif
								Return
							Endif
							gcQuery	= "SELECT LOA,LOA_NO,LOA_DATE FROM PCIUTIL.DBO.PCI_LOA WHERE LOA=?lcT_LOA AND LOA_NO=?lcT_LOA_NO"
							If SQLEXEC(lnHandleNWschm,gcQuery,'GET_SQL') < _SUCCESS_OK
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in pr select LOA:["+lcT_LMSG+"] GET_SQL")
								Rollback
								If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
									Aerror(laErrors)
									Messagebox(laErrors[2],16,"Error in rollback pr select LOA:["+lcT_LMSG+"] GET_SQL")
								Endif
								If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
									Aerror(laErrors)
									Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCITAG pr deletion (GET_SQL/AUTO)")
								Endif
								= SQLDISCONNECT(lnHandleNWschm)
								Return
							Endif
							= SQLDISCONNECT(lnHandleNWschm)
							Select GET_SQL
							If Reccount("GET_SQL")>=1
								Go Top
								ldT_LOA_DATE = Ctod(Dtoc(GET_SQL.LOA_DATE))
							Else
								Rollback
								If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
									Aerror(laErrors)
									Messagebox(laErrors[2],16,"Error in rollback pr deletion LOA:["+lcT_LMSG+"] GET_SQL")
								Endif
								If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
									Aerror(laErrors)
									Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCITAG pr deletion (GET_SQL/AUTO)")
								Endif
								??Chr(7)
								Messagebox("Fatal Error, changes made was not saved, data was lost",0+16+0,"Saving Fail in GET_SQL")
								Return
							Endif
							Select GET_SQL
							Use
							gcQuery1	= "INSERT INTO "+gcNewTagDBF+".DBO."+gcNewTagTABLE+" (LOA,LOA_NO,PR_NUM,PR_DATE,CV,CV_DATE,CHECKNO,BATCH,LOA_DATE,POSTED,POSTED_BY) "
							gcQuery2	= "VALUES (?lcT_LOA,?lcT_LOA_NO,?lcT_PR_NUM,?ldT_PR_DATE,'',NULL,'','COMELEC-INS',?ldT_LOA_DATE,?gcDate,?gcUser)"
							gcQuery 	= gcQuery1 + gcQuery2
						Otherwise
							Rollback
							If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in rollback pr deletion LOA:["+lcT_LMSG+"] PCI_TAG")
							Endif
							If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCITAG pr deletion (PCI_TAG/AUTO)")
							Endif
							??Chr(7)
							Messagebox("Fatal Error, changes made was not saved, data was lost",0+16+0,"Saving Fail in PR_INFO/PR_ENTR/PR_LOA/PCI_LOA/PCI_TAG")
							Quit
						Endcase
						If SQLEXEC(lnHandleTRANSACTION,gcQuery) < _SUCCESS_OK
							Aerror(laErrors)
							Messagebox(laErrors[2],16,"Error in pr deletion LOA:["+lcT_LMSG+"] PCI_TAG")
							Rollback
							If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in rollback pr deletion LOA:["+lcT_LMSG+"] PCI_TAG")
							Endif
							If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
								Aerror(laErrors)
								Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCITAG pr deletion (PCI_TAG/AUTO)")
							Endif
							??Chr(7)
							Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in PR_INFO/PR_ENTR/PR_LOA/PCI_LOA/PCI_TAG")
							Return
						Endif
						Select ADDPRN3LOA_TMP
						Skip
					Enddo
				Endif
				* PCI_TAG *--------------------------------------------------------
			Endif	&&cntFin >= 1
			Select ADDPRN3LOA_TMP
			Use
			* ---- ADDPRN3LOA ------------------------------------
			******************************************************

			******************************************************
			* ---- SAVING TRANSACTION ----------------------------
			If Sqlcommit(lnHandleTRANSACTION) < 1	&& 1 successfull -1 fail
				Aerror(laErrors)
				Messagebox(laErrors[2],16,"Error in commiting changes PR_INFO/PR_ENTR/PR_LOA/PCI_LOA/PCI_TAG")
				Rollback
				If Sqlrollback(lnHandleTRANSACTION) < 1 && 1 Success -1 Fail
					Aerror(laErrors)
					Messagebox(laErrors[2],16,"Error in rollback PR_INFO/PR_ENTR/PR_LOA/PCI_LOA/PCI_TAG")
				Endif
				If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
					Aerror(laErrors)
					Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCIPR (SQLROLLBACK/AUTO)")
				Endif
				??Chr(7)
				Messagebox("Changes made was not saved, data was lost",0+16+0,"Saving Fail in PR_INFO/PR_ENTR/PR_LOA/PCI_LOA/PCI_TAG")
				Return
			Else
				End Transaction
				If SQLSETPROP(lnHandleTRANSACTION,"Transactions",1) < 1 && 1 success -1 fail
					Aerror(laErrors)
					Messagebox(laErrors[2],16,"Error in SQL SET Transaction PCIPR (SQLCOMMIT/AUTO)")
				Endif
				Wait Window Nowait "Refreshing entries, please wait..."
				If Requery('pr_entr') < 1
					Messagebox("Entry view not accurate, please close entry form.",16,"Error in Requery")
				Endif
			Endif
			* ---- SAVING TRANSACTION ----------------------------
			******************************************************
		Endif	&&xx=.F. pr_entr
	Endif	&&xx=.F. pr_info
Endcase

Select ADDPRN3LOA
Delete All

Select DELPRN3LOA
Delete All

Thisform.SetAll("Enabled",.F.,"CommandButton")
Thisform.cmdNew.Visible= .T.			&&Create new pr#
Thisform.cmdAdd.Visible= .F.			&&Add row pr_entr
Thisform.cmdDelete_info.Visible= .T.	&&Cancel
Thisform.cmdDelete_entr.Visible= .F.	&&Delete row pr_entr

Thisform.cmdClose.Caption='\<Close'

Thisform.cmdNew.Enabled= .T.
Thisform.cmdFind.Enabled=.T.
Thisform.cmdClose.Enabled=.T.
Thisform.cmdPrint.Enabled=.T.

Thisform.grid1.Enabled=.T.
Thisform.grid1.ReadOnly=.T.
Thisform.grid1.BackColor=Rgb(192,192,192)
Thisform.grid1.loa.text1.Enabled= .T.
Thisform.grid1.loa_no.text1.Enabled= .T.

Thisform.txtFind.Visible=.F.
Thisform.text1.Visible=.T.

Thisform.SetAll("Readonly",.T.,"Textbox")

If Reccount("pr_info")=1
	Thisform.cmdPrev.Enabled=.T.
	Thisform.cmdNext.Enabled=.T.
	Thisform.cmdEdit.Enabled= .T.
	Thisform.cmdDelete_info.Enabled= .T.
Endif

gcButtonSelection = ""

Thisform.chkRush.Visible= .F.

Thisform.Refresh

This snippet took 0.19 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).