*** OPROCEDURI_ACTUALIZARI

*** SE ALEGE O CONVERSIE EXISTENTA SAU UNA NOUA
FUNCTION GETCONVERSIE
	LOCAL lcselect,lcfiltru,lcschema,lcorder,lccoloana,lcTitlu,lcTitluColoana,lcNume_Proc,llAllInList,lcFiltruOriginal,lcPrimaColoana, lnPornire, lnTipReturn, lcIdColumn, llDesktop
	LOCAL loCauta, lcConversie
	lcConversie = ""

	lcselect = "select distinct conversie from conversie_conturi"
	lcfiltru = ""
	lcschema = ""
	lcorder = "conversie"
	lccoloana = "conversie"
	lcTitlu = "Alegeti conversia"
	lcTitluColoana = "Conversie"
	lcNumeProc = ""
	llAllInList = .F.
	lcFiltruOriginal = ""
	lcPrimaColoana = "conversie"
	lnPornire = 1
	lnTipReturn = 0
	lcIdColumn = ""
	llDesktop = .F.

	IF AMESSAGEBOX('Conversie existenta (DA) / Noua (NU)?',4+32,'Conversie') = 6
		loCauta = cauta_alfa(lcselect,lcfiltru,lcschema,lcorder,lccoloana,lcTitlu,lcTitluColoana,lcNume_Proc,llAllInList,lcFiltruOriginal,lcPrimaColoana, lnPornire, lnTipReturn, lcIdColumn, llDesktop) && 11.07.2007
		lcConversie = UPPER(ALLTRIM(loCauta.conversie))
	ELSE
		lcConversie = UPPER(ALLTRIM(INPUTBOX("Conversie","Conversie","Ordin ...")))
	ENDIF
	RETURN UPPER(ALLTRIM(lcConversie))

ENDFUNC && GETCONVERSIE

*** SE EDITEAZA INREGISTRARILE DIN CONVERSIA ALEASA
*** SE APLICA CONVERSIA PLAN/BALANTA/JURNAL
PROCEDURE CONVERSIE_CONTURI
	LPARAMETERS tcSubiect, tnAn, tnLuna

	&& tcSubiect : PLAN;BALANTA

	IF m.glLunaInchisa
		AMESSAGEBOX('Luna este inchisa! Operatia nu este permisa.',0+64,_screen.Caption)
		RETURN
	ENDIF 

	LOCAL lcnume, lcalias, lcselect, lcfiltru, lcschema, lcorder, llAfisare, lcgroup, llModParam, lcFiltruOriginal
	LOCAL lcSql, lnSucces, lcMesaj

	PRIVATE pnAn, poConversie, pcConversie
	poConversie = NULL

	IF EMPTY(tcSubiect) OR TYPE('tcSubiect') # 'C'
		RETURN
	ENDIF
	IF PCOUNT() < 2 OR TYPE('tnAn') # 'N'
		pnAn = gnAn
	ELSE
		pnAn = tnAn
	ENDIF

	IF PCOUNT() < 3 OR TYPE('tnLuna') # 'N'
		pnLuna = gnLuna
	ELSE
		pnLuna = tnLuna
	ENDIF

	pcConversie = GETCONVERSIE()
	IF EMPTY(ALLTRIM(pcConversie))
		RETURN
	ENDIF

	lcnume = [poConversie]
	lcalias = [crsConversieConturi]
	lcselect = [SELECT ACONT_NOU, ACONT_VECHI, CONT_NOU, CONT_VECHI, EXPLICATIE, ID, SE_APLICA, TIP_SOLD, CONVERSIE FROM CONVERSIE_CONTURI]
	lcschema = [ACONT_NOU C(4), ACONT_VECHI C(4), CONT_NOU C(4), CONT_VECHI C(4), EXPLICATIE C(100), ID N(10), SE_APLICA N(1), TIP_SOLD C(1), CONVERSIE C(100)]
	lcfiltru = []
	lcorder = [cont_vechi, acont_vechi, cont_nou, acont_nou]
	llAfisare = .F.
	lcgroup = []
	llModParam = .T.
	lcFiltruOriginal = [UPPER(TRIM(conversie)) = '] + UPPER(ALLTRIM(pcConversie)) + [']
	gencursor(lcnume, lcalias, lcselect, lcfiltru, lcschema, lcorder, llAfisare, lcgroup, llModParam, lcFiltruOriginal)
	poConversie.ca_baza1.afisare()

	*!*		SELECT crsConversieConturi
	*!*		INDEX on cont_nou + acont_nou + cont_vechi + acont_vechi TAG ordonare

	loFrmConversie = CREATEOBJECT("frm_conversie_conturi")
	loFrmConversie.cSubiectConversie = UPPER(ALLTRIM(tcSubiect))
	loFrmConversie.lb_titlu_alb_b121.CAPTION = "Configurare conturi " + ALLTRIM(pcConversie)
	loFrmConversie.cConversie = pcConversie
	loFrmConversie.SHOW(1)

	lcMesaj = ""
	lcSql = ""
	IF INLIST(UPPER(ALLTRIM(tcSubiect)), "PLAN", "BALANTA", "JURNAL")
		DO CASE
			CASE UPPER(ALLTRIM(tcSubiect)) = 'PLAN'
				lcMesaj = 'Doriti sa actualizati planul de conturi?'
				lcSql = [begin pack_conversie.conversie_plan_cont(?pcConversie, ?pnAn); end;]
			CASE  UPPER(ALLTRIM(tcSubiect)) = 'BALANTA'
				lcMesaj = 'Doriti sa actualizati balanta de verificare?'
				lcSql = [begin pack_conversie.conversie_balanta(?pcConversie, ?pnAn,?pnLuna); end;]
			CASE  UPPER(ALLTRIM(tcSubiect)) = 'JURNAL'
				lcMesaj = 'Doriti sa actualizati registrul jurnal?'
				lcSql = [begin pack_conversie.conversie_jurnal(?pcConversie, ?pnAn,?pnLuna); end;]
		ENDCASE

		IF gnButon = 1 AND AMESSAGEBOX(lcMesaj, 4+32, 'Actualizare') = 6
			lnSucces = goExecutor.oExecute(lcSql)
			IF lnSucces < 0
				AMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
			ELSE
				AMESSAGEBOX('Actualizarea s-a terminat cu succes',0+64)
			ENDIF
		ENDIF
	ENDIF

ENDPROC && CONVERSIE_CONTURI



