*!* 22.12.2016
*!* marius.mutu
*!*	completez_date_xml - corectat eroare sql din versiunea 10/2015

PROCEDURE importbonconsumLE
	LPARAMETERS tnIdSet
	Local loXMLRequest as "Msxml2.xmlhttp"
	Local lcExtract, lcImportXML, lcUserlogIMPPath, lcXML, llCreareGeneratorNumere,lcImportXMLSTR 
	Local lnNrmixuri, loEx, loMixMare,lnI
	PRIVATE pcFisierImport,pnIdGestiune,pnI
	STORE 0 TO pnIdGestiune
	pcFisierImport = gcDirimportxml + [\pour.log]
	lcUserlogIMPPath = gcDirMare + 'USERLOGS\' + m.GCS + '\' + m.gcNumeProgram + [\IMP_PROFITMANAGER]
	lcImportXML =  ADDBS(lcUserlogIMPPath) + [pour_] + ttoc(DATETIME(), 1) + [.xml]
	If !Directory(m.lcUserlogIMPPath)
		Md (m.lcUserlogIMPPath)
	ENDIF
SET STEP ON 
	IF !FILE(m.pcFisierImport)
		aMESSAGEBOX('Nu exista fisierul de import ' + m.pcFisierImport + '!', 0 + 16, _screen.Caption)
		RETURN
	ENDIF
	lcImportXMLSTR = FILETOSTR(m.pcFisierImport)
*!*		lcImportXMLSTR = STRTRAN(STRTRAN(STRTRAN(STRTRAN(STRTRAN(strtran(strtran(strtran(strtran(strtran(lcImportXMLSTR ,CHR(227),[a]),CHR(226),[a]),CHR(238),[i]),CHR(186),[s]),CHR(254),[t]),CHR(195),;
*!*			[A]),CHR(194),[A]),CHR(206),'I'),CHR(170),'S'),CHR(222),'T')
	lcImportXMLSTR = STRTRAN(strtran(strtran(strtran(strtran(strtran(lcImportXMLSTR ,CHR(227),[a]),CHR(226),[a]),CHR(238),[i]),CHR(186),[s]),CHR(254),[t]),CHR(39),[ ])
	lcImportXMLSTR = Strtran(Strtran(Strtran(Strtran(Strtran(lcImportXMLSTR,Chr(195),[A]),Chr(206),[I]),Chr(194),[A]),Chr(170),[S]),Chr(222),[T])							
	TRY
		STRTOFILE(m.lcImportXMLSTR, m.lcImportXML)
*!*			Copy File (pcFisierImport) To (lcImportXML)
	CATCH TO loEx
		aMESSAGEBOX(loEx.Message, 0 + 16, _screen.Caption)
		RETURN
	ENDTRY

	If Type('poGeneratorNumere') = 'U'
		Private poGeneratorNumere
		poGeneratorNumere = Createobject('oGeneratorNumere')
		llCreareGeneratorNumere = .T.
	ENDIF
	
	XMLTOCURSOR(lcImportXML, 'crsXMLmare', 512)

	SELECT crsXmlMare
	LOCATE FOR LEFT(ALLTRIM(TRANSFORM(date)),6)<> ALLTRIM(STR(gnAn))+PADL(ALLTRIM(STR(gnLuna)),2,'0')
	IF FOUND()
		aMESSAGEBOX('Fisierul de importat are documente cu data actului din alta luna decat cea in care se lucreaza!', 0 + 16, _screen.Caption)
		USE IN crsXmlMare
		RETURN

	ENDIF
	SELECT crsXmlMare
	loXMLRequest = CreateObject("Msxml2.xmlhttp")
	loXMLRequest.open("GET", lcImportXML, .F.)
	loXMLRequest.send(.null.)
	lcXML = loXMLRequest.responseText
	lnNrmixuri = OCCURS([<MIX>], lcXML)
	CREATE CURSOR crsExecutii (instr m, nrord c(50))
	CREATE CURSOR crsAtentionari (mesaj c(100), afara l, codmat c(50),rezolvat l, nrord c(50),pret n(16,4),id_lucrare n(10),time n(20))
	CREATE CURSOR crsBontot (id_articol n(20), denumire c(100), cant n(14, 3), pret n(16, 4), valoare n(16, 4), proc_tvav n(5, 2), id_lucrare n(10), codmat c(50),time n(20))
	CREATE CURSOR crsIesiritot (id_lucrare n(10), serie c(100), cant n(14, 3), nract n(14), id_fdoc n(5), dataact d, dataireg d, id_gestout n(5), id_responsabil n(10), id_venchelt n(5), id_sectie n(5), id_articol n(20),suma_imp n(16,4),suma n(16,4), nrord c(50),time n(20))

	loTherm = Newobject("_thermometer","_therm","","Import bon de consum pe lucrare in curs de executie ...")
	lcTask = "Import ..."
	_Screen.MousePointer= 11
	With loTherm
		.AlwaysOnTop=.T.
		.Show()

		lnPercent = 5
		.Update(lnPercent, lcTask)

		pnI = 1
		FOR lnI = 1 TO lnNrmixuri
			pnI = lnI
			lcExtract = [<mix>] + STREXTRACT(lcXML, '</version>', '<panels>', lnI) + [</mix>]
			XMLTOCURSOR(lcExtract, 'crsingrediente')

			lnPercent = 50 / (lnNrmixuri - lnI)
			.Update(lnPercent, lcTask)

			SELECT crsXmlMare
			GOTO lnI
			SCATTER NAME loMixMare
			IF !completez_date_xml(loMixMare, tnIdSet)
				USE IN crsingrediente
				aMESSAGEBOX('Bonul de consum NU a fost importat!', 0 + 48, _screen.Caption)
				EXIT
			ENDIF
			USE IN crsingrediente

		ENDFOR
		.AlwaysOnTop=.F.
		IF !afiseaza_mesaje()
			lnPercent = 70
			.Update(lnPercent, lcTask)
			DO executa_instr WITH tnIdSet
		ENDIF

		lnPercent = 100
		.Update(lnPercent, lcTask)

		USE IN crsExecutii
		USE IN crsAtentionari
		USE IN crsBontot
		USE IN crsIesiritot
		USE IN crsXmlMare
		.Complete()
		.AlwaysOnTop=.F.
	Endwith
	Release loTherm
	_Screen.MousePointer= 0
ENDPROC
*---------------------------------


PROCEDURE completez_date_xml
	LPARAMETERS toMixMare, tnIdSet
	PRIVATE poActActan, pcXMLDetaliiBon, pcXMLDetaliiIesiri, pnIdVanzare, pcMesaj
	LOCAL lnRaspunReset
	STORE 0 TO lnRaspunReset 

 Dimension taValori[1,3]
 taValori[1,1]="poAct.nract"
 taValori[1,2]= [1]
 taValori[1,3]= .T.
*!*	 lans(id_set_operatie,.F.,.T.,@taValori)
 
	Local lcActactanSave, lcCursor, lcSql, lnBut, lnCante, lnPret, lnSucces, lnnr, loLucrari, loart,lnValImport
	Local loing
	lnValImport = 0
	lcActactanSave = gcTempPath + 'oscrie_in_fisiere_actactan' + ALLTRIM(TRANSFORM(toMixMare.date)) + '.xml'
	IF pnI = 1
		lnRaspunReset = aMESSAGEBOX('Resetati datele documentului deja introduse?',4+32,_screen.Caption)
	ENDIF 
	IF !FILE(lcActactanSave) OR lnRaspunReset  = 6

		IF  lans(tnIdSet,.F.,.T.,@taValori) = 2
			RETURN .f.
		ENDIF
		*----salvez xml-ul cu datele introduse
		SELECT ACTACTAN
		CURSORTOXML('actactan', lcActactanSave, 1, 2 + 512, 0, "1")
	ELSE
		XMLTOCURSOR(lcActactanSave, 'actactan', 512)
		SELECT ACTACTAN
	ENDIF
	SET STEP ON

	*-----------------------
	*!*	generez numarul de bon urmator
	LOCAL lCursorSerii, lcNumeCursor, lcSerieCursor
	llCreareGeneratorNumere = .T.
	lCursorSerii = poGeneratorNumere.creeaza_cursor_serii(22)
	lcNumeCursor = poGeneratorNumere.getNumeCursor(22)
	lcSerieCursor = poGeneratorNumere.getSerieCursor(22)
	*!*		If poGeneratorNumere.verifica_serie(2)
	lnnr = poGeneratorNumere.aloca_numar(22, Null)
	*!*		ENDIF
	SELECT ACTACTAN
	REPLACE ALL nract WITH lnnr, nnir WITH lnnr
	*-----------------------
	*--------------------
	*!*	caut id_lucrare in nom_lucrari unde nrord = jobnumber - daca nu exista lucrarea = atentionare = afara din bon
	lcSql = [select id_lucrare,nrord from nom_lucrari where nrord = '] + ALLTRIM(toMixMare.jobnumber) + [' and sters = 0]
	lcCursor = [v_lucrari]

	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	goExecutor.oReset()
	IF lnSucces < 0
		aMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
		RETURN .f.
	ENDIF

	SELECT v_Lucrari
	SCATTER NAME loLucrari
	IF EMPTY(NVL(id_lucrare, 0))
		INSERT INTO crsAtentionari (mesaj, afara,nrord) VALUES ('Nu exista lucrarea ' + ALLTRIM(toMixMare.jobnumber) + [!], .t.,ALLTRIM(toMixMare.jobnumber))
	ELSE
		SELECT ACTACTAN
		REPLACE ALL id_lucrare WITH loLucrari.id_lucrare, nrord WITH loLucrari.nrord
	ENDIF
	USE IN v_Lucrari
		*--------------------
	*!*	caut daca lucrarea a fost validata, daca este validat  => atentionare => il scoate din bon
	lcSql = [select validat from dev_ordl d left join nom_lucrari l on d.id_lucrare = l.id_lucrare where d.sters = 0 and l.sters = 0 and l.nrord = '] + ALLTRIM(toMixMare.jobnumber) + [']
	lcCursor = [v_validat]

	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	goExecutor.oReset()
	IF lnSucces < 0
		aMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
		RETURN .f.
	ENDIF

	SELECT v_validat
	IF validat = 1
		INSERT INTO crsAtentionari (mesaj, afara,nrord) VALUES ('Lucrarea ' + ALLTRIM(toMixMare.jobnumber) + [ a  fost validata si nu se mai pot face modificari asupra ei!!], .t.,ALLTRIM(toMixMare.jobnumber))
	ENDIF
	USE IN v_validat
*-------------------------------
	SELECT ACTACTAN
	LOCATE FOR nr_nota = 1
	SCATTER NAME poActActan
	pnIdGestiune = poActActan.id_gestout
	USE IN ACTACTAN

	SELECT crsingrediente
	SCAN
		SCATTER NAME loing
		lnCante = ROUND((VAL(STRTRAN(ALLTRIM(TRANSFORM(loing.amount)), ',', '.')) / VAL(STRTRAN(ALLTRIM(TRANSFORM(loing.density)), ',', '.'))) / 1000, gnpcant) && transform in litri din grame
*!*			lnPret = VAL(STRTRAN(ALLTRIM(TRANSFORM(loing.price)), ',', '.'))

		lcSql = [select a.id_articol,a.denumire,a.codmat] + ;
			[,SUM(a.cants+a.cant-a.cante) as stoc,a.pret  from vstoc a where a.an = ?gnAn and a.luna = ?gnluna and a.codmat = '] + ALLTRIM(loing.code) + [' and id_gestiune = ]+ ALLTRIM(STR(poActActan.id_gestout));
			+[ group by a.id_articol,a.denumire,a.codmat,a.pret]
		lcCursor = [v_articole]
		

		lnSucces = goExecutor.oExecute(lcSql, lcCursor)
		goExecutor.oReset()
		IF lnSucces < 0
			aMESSAGEBOX(ALLTRIM(toMixMare.jobnumber)+ [ ] + goExecutor.cEroare, 0 + 16, "Eroare")
			RETURN .f.
		ENDIF

		SELECT v_articole
		DELETE for stoc <  lnCante
		GO TOP
		
		SCATTER NAME loart
		lnPret = loart.pret
		*---------------------------
		*!*			daca nu exista articolul respectiv  in nom_articole/in stoc => atentionare => il scoate din bon
		IF EMPTY(NVL(loart.id_articol, 0))
			INSERT INTO crsAtentionari (mesaj, afara, codmat,nrord) VALUES ('Nu exista articolul ' + ALLTRIM(loing.code) + [ in stocul gestiunii ]+ALLTRIM(poActActan.gestout)+[!], .t., ALLTRIM(loing.code),ALLTRIM(toMixMare.jobnumber))
		ENDIF
		*----------------------------

		*---------------------------
		*!*	daca exista mai multe articole cu acelasi codmat, sa il pun sa aleaga (dar ii arat si stocul pe fiecare posibilitate de alegere)
		SELECT v_articole
		IF RECCOUNT() > 1
			INSERT INTO crsAtentionari (mesaj, afara, codmat,nrord,pret,id_lucrare,time) VALUES ('Exista mai multe articole cu codul material = ' + ALLTRIM(loart.codmat) + [!], .f., ALLTRIM(loart.codmat),ALLTRIM(toMixMare.jobnumber),loart.pret,loLucrari.id_lucrare,VAL(TRANSFORM(toMixMare.time)))
		ENDIF
		*----------------------------

		INSERT INTO crsBontot (id_articol, denumire, cant, pret, valoare, proc_tvav, id_lucrare, codmat,time);
			VALUES (loart.id_articol, ALLTRIM(loart.denumire), lnCante, lnPret, lnCante * lnPret, gnProcTvaImp, loLucrari.id_lucrare, ALLTRIM(loing.code),VAL(TRANSFORM(toMixMare.time)))
		lnValImport = lnValImport + round(lnCante * lnPret,2)
		SELECT crsingrediente
	ENDSCAN


	INSERT INTO crsIesiritot (id_lucrare, serie, cant, nract, id_fdoc, dataact, dataireg, id_gestout, id_responsabil, id_venchelt, id_sectie, id_articol,suma_imp,nrord,suma,time);
		VALUES (loLucrari.id_lucrare, ALLTRIM(NVL(TRANSFORM(toMixMare.colorcode),[])) + [ - ] + ALLTRIM(toMixMare.colorname), VAL(strtran(ALLTRIM(TRANSFORM(toMixMare.mixsize)), [,], [.])), ;
		poActActan.nract, poActActan.id_fdoc, poActActan.dataact, poActActan.dataireg, poActActan.id_gestout, poActActan.id_responsabil, poActActan.id_venchelt, poActActan.id_sectie, -100009,lnValImport,ALLTRIM(toMixMare.jobnumber),0,VAL(TRANSFORM(toMixMare.time)))


	poGeneratorNumere.resetAll()





	RETURN .t.
	*!*	----------------afiseaza mesaje----------------
PROCEDURE afiseaza_mesaje
	LOCAL llErori
	Local loAfisMesaje as 'frm_atenterori'
	Private pcselect, pcschema, pcfiltru, pcorder, postoc, llAfiseaza
	Store '' To postoc
	pcschema = ['stoc n(16,4),id_articol n(10),codmat c(50),denumire c(100),nume_gestiune c(50),cgest c(20),pret n(16,4), ales n(1)']
	pcselect = ['select a.cants+a.cant-a.cante as stoc,a.id_articol,a.codmat,a.denumire,a.nume_gestiune,a.cgest,a.pret, 0 as ales  from vstoc a '+] + ;
		['where 1=2']
	pcfiltru =  [ 1 = 2]
	pcorder = [a.denumire]
	llAfiseaza = .F.
	gencursor('poStoc', 'v_stoc', pcselect, pcfiltru, pcschema, pcorder, llAfiseaza)
	postoc.ca_baza1.afisare()
	*!*	SELECT v_stoc
	*!*	BROWSE

	SELECT crsAtentionari
	LOCATE FOR afara = .t.
	IF FOUND()
		llErori = .t.
	ENDIF

	SELECT crsAtentionari
	IF RECCOUNT() > 0
		GO TOP
		loAfisMesaje = CREATEOBJECT('frm_atenterori')
		loAfisMesaje._grdrow2.ReadOnly = .f.
		loAfisMesaje.nidgestiune = pnIdGestiune
		loAfisMesaje.but_termin1.visible = !llErori
		loAfisMesaje.show(1)
	ENDIF

	IF gnButon = 2
		llErori = .t.
	ENDIF
	SELECT crsIesiritot 
	SCAN 
		SCATTER NAME loiesiri 
		SELECT round(SUM(cant * pret),2) as suma FROM crsBontot INTO CURSOR crsBonsume WHERE id_lucrare = loiesiri.id_lucrare AND time = loiesiri.time
		SELECT crsIesiritot 
		REPLACE suma_imp WITH crsBonsume.suma 
		USE IN crsBonsume 
		SELECT crsIesiritot 
	ENDSCAN 
	RELEASE loiesiri
	
	SELECT crsBontot
	RETURN llErori
	*!*	----------------afiseaza mesaje----------------

	*!*	----------------executa_instr----------------

PROCEDURE executa_instr
	LPARAMETERS tnIdSet
	PRIVATE pcXMLDetaliiIesiri, pcXMLDetaliiBon, pnIdVanzare
	LOCAL lcCursorVerificare
	Local lcCursorFinal, lcSql, llReturn, lnReturn, lnSucces, loexec, loiesiri,lnSume0
	STORE 0 TO lnSume0
	
	PRIVATE pcSirDifAcont, pcSirDifPart
	lcCursorVerificare = [crsactverif]
	lcCursorFinal = [actactan]
	pcSirDifAcont = []
	pcSirDifPart = []
	SELECT crsIesiritot
	GO TOP 
	oModificSumaLuc = CREATEOBJECT('frm_lucrari_sume')
	oModificSumaLuc._grdBase1.column3.readonly = .f.
	oModificSumaLuc.show(1)
	SELECT crsIesiritot
	COUNT FOR suma_imp=0 TO lnSume0
	IF lnSume0 > 0
		aMESSAGEBOX('Atentie! Bonurile cu sume = 0 nu vor fi importate!',0+64,_screen.Caption)
		SELECT crsIesiritot
		DELETE ALL FOR suma_imp = 0 &&AND suma = 0
	ENDIF 
	IF gnButon = 2
		poGeneratorNumere.dezaloca_numar(22)
		Release poDate, poGeneratorNumere
		RETURN .f.
	ENDIF 
		SELECT crsIesiritot
		SCAN
			SCATTER NAME loiesiri
			SELECT id_lucrare, serie, cant, id_articol,suma FROM crsIesiritot INTO CURSOR crsIesiri WHERE id_lucrare = loiesiri.id_lucrare AND time = loiesiri.time
			Cursortoxml("crsIesiri", "pcXMLDetaliiIesiri", 1, 1, 0, "")
			SELECT crsIesiri 
			USE IN crsIesiri
			SELECT * FROM crsBontot INTO CURSOR crsBon WHERE id_lucrare = loiesiri.id_lucrare AND time = loiesiri.time
			Cursortoxml("crsBon", "pcXMLDetaliiBon", 1, 1, 0, "")
			USE IN crsBon

			SELECT crsExecutii
			SCATTER NAME loexec MEMO BLANK
			loexec.instr = [{call pack_gest_import.import_BON(] + ALLTRIM(STR(loiesiri.nract)) + [,]
			loexec.instr = loexec.instr + ALLTRIM(STR(loiesiri.id_fdoc)) + [,]
			loexec.instr = loexec.instr + [ TO_DATE('] + NVL(DTOS(loiesiri.dataact), "") + [','YYYYMMDD'),]
			loexec.instr = loexec.instr + [ TO_DATE('] + NVL(DTOS(loiesiri.dataireg), "") + [','YYYYMMDD'),]
			loexec.instr = loexec.instr + ALLTRIM(STR(loiesiri.id_gestout)) + [,]
			loexec.instr = loexec.instr + ALLTRIM(STR(loiesiri.id_responsabil)) + [,]
			loexec.instr = loexec.instr + ALLTRIM(STR(loiesiri.id_venchelt)) + [,]
			loexec.instr = loexec.instr + ALLTRIM(STR(loiesiri.id_sectie)) + [,]
			loexec.instr = loexec.instr + [?gnIdutil,]
			loexec.instr = loexec.instr + [?gnIdSucursala,]
			loexec.instr = loexec.instr + ALLTRIM(STR(tnIdSet)) + [,']
			loexec.instr = loexec.instr + ALLTRIM(pcXMLDetaliiBon) + [',']
			loexec.instr = loexec.instr + ALLTRIM(pcXMLDetaliiIesiri) + [')}]
			
			loexec.nrord = ALLTRIM(loIesiri.nrord)

			INSERT INTO crsExecutii (instr,nrord) VALUES (loexec.instr,loexec.nrord)

			SELECT crsIesiritot
		ENDSCAN

		SELECT crsExecutii
		lnSucces = SQLSetprop(gnHandle, "Transactions", 2)
		If lnSucces < 0
			aMESSAGEBOX('Programul nu a reusit trecerea pe tranzactie manuala', 0 + 16, 'Eroare')
		ELSE

			SELECT crsExecutii
			SCAN
				SCATTER NAME loexec memo

				lnSucces = goExecutor.oExecute(loexec.instr, lcCursorVerificare)

				If lnSucces < 0
					aMESSAGEBOX(ALLTRIM(loexec.nrord)+[ ]+goExecutor.oPrelucrareEroare(), 0 + 16, "Eroare")
					llReturn = .F.
					EXIT 
				else
					If Reccount(lcCursorVerificare) > 0
						gnButon = 1
						Select a.*, a.suma As totftva, a.suma As tottva, Ttod(a.dataactt) As dataact, ;
							Ttod(a.datairegt) As dataireg, Ttod(a.datascadt) As datascad, ;
							0 As pozitie_1, 0 As pozitie_2 From (lcCursorVerificare) a Into Cursor (lcCursorFinal) Readwrite
						Use In (lcCursorVerificare)
						Select (lcCursorFinal)
						Do Form verificare With .T., .T.
						If gnButon = 1
							Select (lcCursorFinal)
							Scan For Nvl(ascd, '') <> Nvl(ascd1, '') Or Nvl(ascc, '') <> Nvl(ascc1, '') Or ;
									NVL(id_partd, 0) <> Nvl(id_partd1, 0) Or Nvl(id_partc, 0) <> Nvl(id_partc1, 0)
								If Nvl(ascd, '') <> Nvl(ascd1, '') Or Nvl(ascc, '') <> Nvl(ascc1, '')
									pcSirDifAcont = pcSirDifAcont + Alltrim(Str(id_act)) + [|] + Alltrim(Nvl(ascd, '')) + [|] + Alltrim(Nvl(ascc, '')) + [;]
								Endif
								If Nvl(id_partd, 0) <> Nvl(id_partd1, 0) Or Nvl(id_partc, 0) <> Nvl(id_partc1, 0)
									If (Like([41*], scd) And Nvl(id_partd, 0) <> Nvl(id_partd1, 0)) ;
											Or (Like([41*], scc) And Nvl(id_partc, 0) <> Nvl(id_partc1, 0))
										aMESSAGEBOX("Nu puteti modifica clientul!", 48, "Atentie")
										llReturn = .F.
									Else
										pcSirDifPart = pcSirDifPart + Alltrim(Str(id_act)) + [|] + Alltrim(Str(Nvl(id_partd, 0))) + [|] + Alltrim(Str(Nvl(id_partc, 0))) + [;]
									Endif
								Endif
							Endscan


							lcSql = [begin pack_gest_import.finalizeaza_scriere_verificare(?gnAn,?gnLuna,] + ;
								['] + Alltrim(Nvl(pcSirDifAcont, [])) + [','] + ;
								ALLTRIM(Nvl(pcSirDifPart, [])) + ['); end;]
							lnSucces = goExecutor.oExecute(lcSql)
						Endif
						If lnSucces < 0
							aMESSAGEBOX(goExecutor.oPrelucrareEroare(), 16, "Eroare")
						Endif
						Use In (lcCursorFinal)
					Endif
				Endif
				Use In (Select(lcCursorVerificare))


			ENDSCAN

		ENDIF
	IF lnSucces < 0 OR gnButon = 2
		poGeneratorNumere.dezaloca_numar(22)
		Release poDate, poGeneratorNumere
		lnSucces = goExecutor.oExecute('ROLLBACK')
		aMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		aMESSAGEBOX('Bonul de consum NU a fost importat!', 0 + 48, _screen.Caption)
		llReturn = .F.

	ELSE
		lnSucces = goExecutor.oExecute('COMMIT')
		aMESSAGEBOX('Importul bonului de consum a luat sfarsit!', 0 + 64, _screen.Caption)
		DELETE File (pcFisierImport)
		llReturn = .T.
		SELECT crsIesiritot
		SCAN
			SCATTER NAME loiesiri
			lnTip = gnTipGest
			DO listare_descarcare_productie WITH loiesiri.nract, lnTip
			SELECT crsIesiritot
		ENDSCAN

	ENDIF

	lnSucces = SQLSetprop(gnHandle, "Transactions", 1)
	If lnSucces < 0
		aMESSAGEBOX('Programul nu a reusit trecerea pe tranzactie automata', 0 + 16, 'Eroare')
	ENDIF

	RETURN llReturn
ENDPROC
*!*	----------------executa_instr----------------


