*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="onom_curs.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS actualizare_curs_bnr AS _custom OF "_baza.vcx" 
 	*< CLASSDATA: Baseclass="custom" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<DefinedPropArrayMethod>
		*m: citeste_curs
		*m: citeste_curs_altesurse
		*m: citeste_curs_bnr
		*m: initializeaza
		*m: scrie_curs_bnr
		*p: ccursor
		*p: clink
		*p: ctempfile
		*p: ddata
		*p: ncurs
		*p: nmultiplicator
		*p: ntip		&& 1 - Se cauta cursul la adresa din This.cLink; 2 - Se cauta cursul folosind obiectul "curs".
		*p: _memberdata		&& XML Metadata for customizable properties
	*</DefinedPropArrayMethod>

	*<PropValue>
		ccursor = ccrsbnr
		clink = https://www.bnr.ro/nbrfxrates.xml
		ctempfile = C:\temp\temp.xml
		ddata = {}
		Height = 17
		Name = "actualizare_curs_bnr"
		ncurs = 0.0000
		nmultiplicator = 1
		ntip = 1
		Width = 37
		_memberdata = <VFPData>
			<memberdata name="ctempfile" display="cTempFile"/>
			<memberdata name="clink" display="cLink"/>
			<memberdata name="ccursor" display="cCursor"/>
			<memberdata name="ddata" display="dData"/>
			<memberdata name="ntip" display="nTip"/>
		</VFPData>
	*</PropValue>
	
	PROCEDURE citeste_curs
		Lparameters tdZiua,tcIsoValuta
		This.nmultiplicator = 1
		This.ncurs = 0.0000
		If !Used(This.cCursor) Or tdZiua <> This.dData
			This.initializeaza(tdZiua)
		Endif
		If !Empty(tcIsoValuta)
			Select (This.cCursor)
			Locate For Alltrim(Currency) = Alltrim(tcIsoValuta)
			If Found()
				This.nmultiplicator = Iif(Empty(Nvl(multiplier,0)),1,multiplier)
				This.ncurs = Curs
			Endif
		Endif
		
	ENDPROC

	PROCEDURE citeste_curs_altesurse
		Local loCurs,lnCurs,lcSql,lnSucces,loActualizareCurs,lnCurs,lcValuta,lnMultiplicator
		If Empty(This.cCursor)
			This.cCursor = [ccrsbnr]
		Endif
		If Used(This.cCursor)
			Use In (This.cCursor)
		Endif
		lcSql = [{call pack_curs.citeste_valute()}]
		lnSucces = goExecutor.oExecute(lcSql,This.cCursor)
		If lnSucces < 0
			amessagebox(goExecutor.cEroare,16,"Eroare")
		Else
			Wait "Se actualizeaza cursurile..." Window Nowait
			loActualizareCurs = Createobject("curs",This.dData)
			Select (This.cCursor)
			Scan
				lcValuta = Alltrim(Currency)
				Wait Alltrim(Str(Recno())) + "/" + Alltrim(Str(Reccount())) + " - " + lcValuta + " ..." Window Nowait
				lnCurs = loActualizareCurs.calccurs(This.dData,lcValuta)
				lnMultiplicator = 1
				If lnCurs <> 0
					Do While lnCurs <> Round(lnCurs,4)
						*!* daca cursurile au mai mult de 4 zecimale : inmultesc cu 100 pana raman doar cu 4 zecimale
						lnMultiplicator = lnMultiplicator * 100
						lnCurs = lnCurs * lnMultiplicator
					Enddo
				Endif
				Replace multiplier With lnMultiplicator,Curs With lnCurs
			Endscan
			Delete For Curs = 0
			Wait "Cursurile au fost actualizate!" Window Nowait
		Endif
		Release loCurs,lnCurs,lcSql,lnSucces,loActualizareCurs,lnCurs,lcValuta,lnMultiplicator
	ENDPROC

	PROCEDURE citeste_curs_bnr
		Local loHTTP As 'winHTTP.winHTTPrequest.5.1'
		Local lcData, lcFisier, lcServer
		
		If Empty(This.cCursor)
			This.cCursor = [ccrsbnr]
		Endif
		creeaza_backup_cursoare(This.cCursor)		&&	modificare	03.06.2013
		If Used(This.cCursor)
			Use In (This.cCursor)
		Endif
		
		lcServer = This.cLink
		loHTTP = Createobject('winHTTP.winHTTPrequest.5.1')
		loHTTP.Open('GET', lcServer, .F.)
		loHTTP.setRequestHeader("Content-Type", "application/xml;")
		poLog.Log(m.lcServer)
		loHTTP.Send()
		
		If loHTTP.Status = 200
			lcFisier = loHTTP.Responsebody
		
			lcFisier = Strextract(lcFisier,[</OrigCurrency>],[</Body>])
			lcData = Strextract(lcFisier,[date="],["])
			lcFisier= Strtran(lcFisier,[date="]+lcData+["],[])
			lcFisier= Strtran(Strtran(lcFisier,[">],[" curs="]),[</Rate>],[" />])
			Xmltocursor(lcFisier,This.cCursor)
			This.dData = Ttod(Ctot(lcData+[T000000]))+1
			*!*	modificare	03.06.2013
			sterge_backup_cursoare(This.cCursor)
		Else
			repune_backup_cursoare(This.cCursor)
		Endif
		*!*	modificare	03.06.2013	^
		Release loUpdate,loIp,loUrl,lcData,lnSize,lcFisier,lcData
		 
	ENDPROC

	PROCEDURE Destroy
		If Used(This.cCursor)
			Use In (This.cCursor)
		Endif
	ENDPROC

	PROCEDURE Init
		Lparameters tnTip
		This.nTip = Iif(Empty(tnTip),1,tnTip)
		If !Directory(Justpath(This.cTempFile))
			This.cTempFile = gcAppPath + Justfname(This.cTempFile)
		Endif
	ENDPROC

	PROCEDURE initializeaza
		Lparameters tdZiua
		Private pdData
		This.dData = tdZiua
		pdData = This.dData
		
		lcSql = [{call pack_curs.citeste_cotatii_curs(?pdData)}]
		lnSucces = goExecutor.oExecute(lcSql,This.cCursor)
		If lnSucces < 0
			amessagebox(goExecutor.cEroare,16,"Eroare")
		Else
			If Reccount(This.cCursor)=0
				ltDataOra = get_Ora()
				Do Case
					Case This.nTip = 1
						Do Case
							Case (This.dData = Ttod(ltDataOra) And Hour(ltDataOra) <13) Or (This.dData = Ttod(ltDataOra) + 1 And Hour(ltDataOra) >= 13)
								This.citeste_curs_bnr()
							Case This.dData < Ttod(ltDataOra) Or This.dData = Ttod(ltDataOra) And Hour(ltDataOra) >= 13
								If amessagebox("Nu poate fi preluat automat cursul BNR. Doriti sa accesati pagina BNR?",4+32,"Confirmare") = 6
									goUrl("http://www.bnr.ro")		&&	din wwutils.prg
								Endif
							Otherwise
								amessagebox("Nu exista cursul BNR pentru data specificata!",48,"Atentie")
						Endcase
					Case This.nTip = 2
						If This.dData <= Ttod(ltDataOra)
							This.citeste_curs_altesurse()
						Else
							amessagebox("Nu exista cursul BNR pentru data specificata!",48,"Atentie")
						Endif
					Case This.nTip = 3
						Do Case
							Case (This.dData = Ttod(ltDataOra) And Hour(ltDataOra) <13) Or (This.dData = Ttod(ltDataOra) + 1 And Hour(ltDataOra) >= 13)
								This.citeste_curs_bnr()
							Case This.dData < Ttod(ltDataOra) Or This.dData = Ttod(ltDataOra) And Hour(ltDataOra) >= 13
								This.citeste_curs_altesurse()
							Otherwise
								amessagebox("Nu exista cursul BNR pentru data specificata!",48,"Atentie")
						Endcase
					Otherwise
						If amessagebox("Doriti sa accesati pagina BNR?",4+32,"Confirmare") = 6
							goUrl("http://www.bnr.ro")		&&	din wwutils.prg
						Endif
				Endcase
				If Reccount(This.cCursor)>0
					This.scrie_curs_bnr()
				Endif
			Endif
		Endif
	ENDPROC

	PROCEDURE scrie_curs_bnr
		Private pdData,pcSirCursuri
		pdData = This.dData
		pcSirCursuri = []
		Select (This.cCursor)
		Scan
			pcSirCursuri = 	pcSirCursuri + Alltrim(Currency) + [;] + Alltrim(Str(Iif(Empty(Nvl(multiplier,0)),1,multiplier))) + [;] + ;
				ALLTRIM(Str(Curs,14,gnPCurs)) + [|]
		Endscan
		If Dow(pdData,2) = 6
			lcSql = [begin pack_curs.scrie_cotatii_curs(?pdData,?pcSirCursuri,?gnIdUtil); ] + ;
				[pack_curs.scrie_cotatii_curs(?pdData+1,?pcSirCursuri,?gnIdUtil);] + ;
				[pack_curs.scrie_cotatii_curs(?pdData+2,?pcSirCursuri,?gnIdUtil); end;]
		Else
			lcSql = [begin pack_curs.scrie_cotatii_curs(?pdData,?pcSirCursuri,?gnIdUtil); end;]
		Endif
		lnSucces = goExecutor.oExecute(lcSql)
		If lnSucces < 0
			amessagebox(goExecutor.cEroare,16,"Eroare")
		Endif
		Release pdData,pcSirCursuri
	ENDPROC

ENDDEFINE

DEFINE CLASS curs AS custom 
 	*< CLASSDATA: Baseclass="custom" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<DefinedPropArrayMethod>
		*m: calccurs		&& lnCurs = loCurs.calccurs(DATE(),'EUR')
		*m: readurl
		*m: retudata
		*p: cbanca		&& BNR/BCE
		*p: csite		&& site-ul pentru cursul valutar (ex:INFOVALUTAR)
		*p: cvaluta		&& Valuta
		*p: ddata		&& Data cursului valutar
	*</DefinedPropArrayMethod>

	*<PropValue>
		cbanca = BNR
		csite = INFOVALUTAR
		cvaluta = EUR
		ddata = {}
		Height = 17
		Name = "curs"
		Width = 17
	*</PropValue>
	
	PROCEDURE calccurs		&& lnCurs = loCurs.calccurs(DATE(),'EUR')
		Lparameters tdData, tcValuta as , tcBanca, tcSite
		
		If Pcount() >= 1
			This.dData = m.tdData
		Endif
		If Pcount() >= 2
			This.cValuta = Upper(Alltrim(m.tcValuta))
		Endif
		If Pcount() >= 3
			This.cBanca = Upper(Alltrim(m.tcBanca))
		ENDIF
		If Pcount() >= 4
			This.cSite = Upper(Alltrim(m.tcSite))
		Endif
		
		
		Local lcUrl, lcBanca, ldData, lcSite, lnCurs, oldPoint, oldDecimals
		lnCurs = 0
		
		lcSite = Upper(This.cSite)
		If Empty(m.lcSite)
			lcSite = 'INFOVALUTAR'
		Endif
		
		ldData = Iif(Empty(Nvl(This.dData, {})) Or Type('this.dData') <> 'D', Date(), This.dData)
		lcBanca = Iif(!Inlist(Upper(This.cBanca), 'BNR', 'BCE'), 'BNR', Upper(This.cBanca))
		lcValuta = ALLTRIM(UPPER(this.cValuta))
		If lcSite = 'INFOVALUTAR'
			lcUrl="http://www.infovalutar.ro/" + This.retudata(m.ldData) + [/] + m.lcValuta + [.] + m.lcBanca
		
			lcWebContent = This.ReadURL(m.lcUrl)
		
			oldPoint = Set("Point")
			oldDecimals = SET("Decimals")
			Set Point To [.]
			SET DECIMALS TO 4
			lnCurs=Val(lcWebContent)
			Set Point To &oldPoint
			SET DECIMALS TO &oldDecimals
		
			If Vartype(lnCurs) <> [N]
				lnCurs = 0
			Endif
		ENDIF
		
		Return lnCurs
		
	ENDPROC

	PROCEDURE Init
		Lparameters tdData, tcValuta, tcBanca, tcSite
		
		If Pcount() >= 1
			This.dData = m.tdData
		Endif
		If Pcount() >= 2
			This.cValuta = Upper(Alltrim(m.tcValuta))
		Endif
		If Pcount() >= 3
			This.cBanca = Upper(Alltrim(m.tcBanca))
		Endif
		
		If Pcount() >= 4
			This.cSite = Upper(Alltrim(m.tcSite))
		Endif
		
		
	ENDPROC

	PROCEDURE readurl
		* readurl.prg 06-Mar-98
		
		* 06-Mar-98 pulled from  Q174524 on March 98 Technet CD
		* 06-Mar-98 bug fixed about the length of the sReadBuffer
		
		*Any Internet or intranet URL can be passed as a parameter. Microsoft.com
		*was chosen for this example.
		
		*Note that Microsoft Internet Explorer must be installed on the computer.
		
		* passed: URLName, in the form "http://www.microsoft.com"
		*
		* returns: the content of the URL
		*
		* usage:
		*
		* uWebContent = ReadURL( "http://www.microsoft.com" )
		* uWebContent = ReadURL( "http://www.SomeSite.com/SomeJPG.jpg" )
		* This next one provides feedback on the download every 4092 bytes:
		* uWebContent = ReadURL( "http://www.SomeSite.com/SomeBigFile.exe",
		* "GiveFeedback(lcBytesRead,llOK)", 4092 )
		*
		* notes:
		* 1 - IE does not need to be running to use this, but must be installed
		
		LPARAMETERS pcUrlName, pcOptFeedback, pnOptBuffSize, pcOptOutputFile
		* These parameters are No good, pcOptOutputBuffer, pcOptOutputWhole
		* because once they're passed as parameters, the original names get hidden, so the
		* feedback function can't reference them that way, anyway.
		*May 27, 03: Loader v1.01: Added parameter "pcOptOutputFile" to be able to download
		* files bigger than 16MB
		
		DECLARE INTEGER InternetOpen IN wininet.DLL STRING sAgent, ;
		   INTEGER lAccessType, STRING sProxyName, ;
		   STRING sProxyBypass, INTEGER lFlags
		
		DECLARE INTEGER InternetOpenUrl IN wininet.DLL ;
		   INTEGER hInternetSession, STRING sUrl, STRING sHeaders, ;
		   INTEGER lHeadersLength, INTEGER lFlags, INTEGER lContext
		
		DECLARE INTEGER InternetReadFile IN wininet.DLL INTEGER hfile, ;
		   STRING @sBuffer, INTEGER lNumberofBytesToRead, INTEGER @lBytesRead
		
		DECLARE short InternetCloseHandle IN wininet.DLL INTEGER hInst
		
		#DEFINE INTERNET_OPEN_TYPE_PRECONFIG 0
		#DEFINE INTERNET_OPEN_TYPE_DIRECT 1
		#DEFINE INTERNET_OPEN_TYPE_PROXY 3
		#DEFINE SYNCHRONOUS 0
		#DEFINE INTERNET_FLAG_RELOAD 2147483648
		
		LOCAL lcAgent, lhInternetSession, lhUrlFile, llOk, lnOk, lcRetVal, lcReadBuffer, lnBytesRead, laDr[1], llCancel
		
		if vartype(pcOptFeedback)='C'
		  * if we're given a feedback function, make sure it has both parentheses (looks like a function)
		  if not ( at('(',pcOptFeedback)>0 and (at('(',pcOptFeedback) < at(')',pcOptFeedback) ) )
		    pcOptFeedback = .f.
		  endif
		endif
		
		* what application is using Internet services?
		lcAgent = "VFP"
		
		lhInternetSession = InternetOpen( lcAgent, INTERNET_OPEN_TYPE_PRECONFIG, '', '', SYNCHRONOUS )
		
		IF lhInternetSession = 0
		   WAIT WINDOW "Internet session cannot be established" TIME 2
		   RETURN .null.
		ENDIF
		
		lhUrlFile = InternetOpenUrl( lhInternetSession, pcUrlName, '', 0, INTERNET_FLAG_RELOAD, 0 )
		
		IF lhUrlFile = 0
		   * URL cannot be opened
		   RETURN .null.
		ENDIF
		
		lcRetVal = ""
		llOk = .t.
		llCancel = .F.
		lnTotalBytesRead = 0
		lnBytesRead = 0
		lcReadBuffer = ''
		if VarType(pcOptFeedback)='C' && Call the feedback at the zero mark
		  =&pcOptFeedback
		endif
		
		* Clear output file, if it exists.
		if type('pcOptOutputFile')='C' and ADIR(laDr,pcOptOutputFile)>0
		  DELETE FILE (pcOptOutputFile)
		endif
		
		DO WHILE llOK and NOT llCancel
		   * set aside a big buffer
		   lcReadBuffer = SPACE(iif(VarType(pnOptBuffSize)='N',pnOptBuffSize,32767))
		   lnBytesRead = 0
		   lnOK = InternetReadFile( lhUrlFile, @lcReadBuffer, LEN(lcReadBuffer), @lnBytesRead)
		
		   lnTotalBytesRead = lnTotalBytesRead + lnBytesRead
		   
		   if ( lnBytesRead > 0 )
		      if type('pcOptOutputFile')='C'
		        StrToFile(left(lcReadBuffer,lnBytesRead),pcOptOutputFile,.T.) && Add to file.
		      else
		        lcRetVal = lcRetVal + left( lcReadBuffer, lnBytesRead )
		      endif
		   endif
		   
		*!* if vartype(pcOptOutputBuffer)='C'
		*!* pcOptOutputBuffer = left( lcReadBuffer, lnBytesRead )
		*!* endif
		*!* if vartype(pcOptOutputWhole)='C'
		*!* pcOptOutputWhole = lcRetVal
		*!* endif
		
		   * error trap - either a read failure or read past eof()
		   llOk = ( lnOK = 1 ) and ( lnBytesRead > 0 )
		   
		   if vartype(pcOptFeedback)='C'
		     if not &pcOptFeedback
		       llCancel = .T.
		     endif
		   endif
		ENDDO
		
		* close all the handles we opened
		InternetCloseHandle( lhUrlFile )
		InternetCloseHandle( lhInternetSession )
		
		* IF saving to file, return Success status.
		if type('pcOptOutputFile')='C'
		  RETURN NOT llCancel
		endif
		* return the URL contents
		RETURN lcRetVal
		
	ENDPROC

	PROCEDURE retudata
		Parameters dData
		
		oldCentury=Set("Century")
		oldDataFormat=Set("Date")
		oldDateMark=Set("Mark")
		Set Century On
		Set Date YMD
		Set Mark To [/]
		lcDate=Dtoc(dData)
		Set Century &oldCentury
		Set Date &oldDataFormat
		Set Mark To &oldDateMark
		Return lcDate
		
	ENDPROC

ENDDEFINE

DEFINE CLASS cus_odata_curs AS _cusodatabase OF "_cus_odata_base.vcx" 
 	*< CLASSDATA: Baseclass="custom" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<PropValue>
		Name = "cus_odata_curs"
	*</PropValue>
	
	PROCEDURE make_sql
		Lparameters toRec,tnId
		
		lcActiune = Alltrim(This.cActiune)
		
		If Inlist(lcActiune, "UPDATE",'INSERT') And Type('toRec') != "O"
			Return .F.
		Endif
		
		If Inlist(lcActiune, "UPDATE",'DELETE') And Type('tnId') != "N"
			Return .F.
		Endif
		
		If Inlist(lcActiune, "UPDATE",'DELETE')
			lcId = Alltrim(Str(tnId))
		*!*		lcnom = gcS + ".dev_masiniclienti"
		*!*		lcamp = "id_masiniclient"
		*!*		lclook = gcS + ".dev_vordl"
		*!*		lclookid = "id_masiniclient"
		Endif
		
		If Inlist(lcActiune, "UPDATE",'INSERT')
			lcData = Dtos(toRec.Data)
			lcData2 = Dtos(toRec.data2)
			lcIdValuta = Nvl(Alltrim(Str(toRec.id_valuta)),"")
			lcCurs = Alltrim(Str(toRec.Curs,14,gnPCurs))
			lcMultiplicator = ALLTRIM(STR(toRec.multiplicator,10,0))
		Endif
		
		
		Do Case
		Case lcActiune = "INSERT"
			lcSql = [begin pack_curs.adauga_curs(to_date('] + lcData + [','YYYYMMDD'),] + ;
				[to_date('] + lcData2 +[','YYYYMMDD'),] + lcIdValuta + [,] + ;
				lcMultiplicator + [,] + lcCurs + [,] + Alltrim(Str(gnIdUtil)) + [); end;]
		
		Case lcActiune = "UPDATE"
			lcSql = [begin pack_curs.modifica_curs(] + lcId + [,to_date('] + lcData + [','YYYYMMDD'),] + ;
				[to_date('] + lcData2 +[','YYYYMMDD'),] + lcIdValuta + [,] + lcMultiplicator + [,] + ;
				lcCurs + [,] + Alltrim(Str(gnIdUtil)) + [); end;]
		
		Case lcActiune = "DELETE"
			lcSql = [begin pack_curs.sterge_curs(] + lcId + [,] + Alltrim(Str(gnIdUtil)) + [); end;]
		Endcase
		This.csql = lcSql
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_curs AS _frmbase OF "_frm_base.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cData.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cData.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cData2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cData2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cNume_val.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cNume_val.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cCurs.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cCurs.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cMultiplicator.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cMultiplicator.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cIso_valuta.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cIso_valuta.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_modifica1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="ck_data" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_nume_val" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="ck_data2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="ck_zi_curs" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_cauta1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="tx_zi_curs" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_reset1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Gridextra1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*p: ddatacurs
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 3
		cgridsortlist = grd_curs
		ddatacurs = {}
		DoCreate = .T.
		Height = 590
		Name = "frm_curs"
		Width = 544
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 557
		_shape1.ZOrderSet = 2
		_shape2.Anchor = 8
		_shape2.Height = 29
		_shape2.Left = 420
		_shape2.Name = "_shape2"
		_shape2.Top = -1
		_shape2.Width = 129
		_shape2.ZOrderSet = 3
		Lb_titlu_alb_b121.Caption = "CURS VALUTAR"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 10
		Lb_titlu_alb_b121.ZOrderSet = 4
		BUT_TERMIN1.Anchor = 8
		BUT_TERMIN1.Left = 514
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 8
		BUT_TERMIN1.Top = 0
		BUT_TERMIN1.ZOrderSet = 8
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT 'But_modifica1' AS but_modifica WITH ;
		Anchor = 8, ;
		Left = 453, ;
		Name = "But_modifica1", ;
		TabIndex = 13, ;
		Top = 0
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_nou1' AS but_nou WITH ;
		Anchor = 8, ;
		Left = 422, ;
		Name = "But_nou1", ;
		TabIndex = 11, ;
		Top = 0
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_sterge1' AS but_sterge WITH ;
		Anchor = 8, ;
		Left = 484, ;
		Name = "But_sterge1", ;
		TabIndex = 12, ;
		Top = 0
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'ck_data' AS ck_filtru_numar WITH ;
		Alignment = 0, ;
		camp_nume = data, ;
		Caption = "Data inceput", ;
		Left = 23, ;
		Name = "ck_data", ;
		TabIndex = 1, ;
		tip = D, ;
		Top = 38
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'ck_data2' AS ck_filtru_numar WITH ;
		Alignment = 0, ;
		camp_nume = data2, ;
		Caption = "Data sfarsit", ;
		Left = 23, ;
		Name = "ck_data2", ;
		TabIndex = 2, ;
		tip = D, ;
		Top = 54
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Ck_nume_val' AS ck_filtru_text WITH ;
		Alignment = 0, ;
		camp_nume = nume_val, ;
		Caption = "Valuta", ;
		Left = 23, ;
		Name = "Ck_nume_val", ;
		TabIndex = 3, ;
		Top = 70, ;
		Width = 56, ;
		ZOrderSet = 11
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'ck_zi_curs' AS _checkbox WITH ;
		Alignment = 0, ;
		Caption = "Zi curs", ;
		Left = 130, ;
		Name = "ck_zi_curs", ;
		TabIndex = 4, ;
		Top = 39
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Cmd_cauta1' AS cmd_cauta WITH ;
		Anchor = 8, ;
		Left = 369, ;
		Name = "Cmd_cauta1", ;
		TabIndex = 6, ;
		Top = 45, ;
		ZOrderSet = 14
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Cmd_reset1' AS cmd_reset WITH ;
		Anchor = 8, ;
		Left = 456, ;
		Name = "Cmd_reset1", ;
		TabIndex = 9, ;
		Top = 45, ;
		ZOrderSet = 15
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'grd_curs' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 6, ;
		DeleteMark = .F., ;
		Height = 480, ;
		Left = 15, ;
		Name = "grd_curs", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordSource = "crscurs", ;
		RowHeight = 19, ;
		TabIndex = 7, ;
		Top = 96, ;
		Width = 525, ;
		ZOrderSet = 7, ;
		Column1.ControlSource = "data", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cData", ;
		Column1.ReadOnly = .T., ;
		Column1.Visible = .T., ;
		Column1.Width = 77, ;
		Column2.ControlSource = "data2", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "cData2", ;
		Column2.ReadOnly = .T., ;
		Column2.Visible = .T., ;
		Column2.Width = 77, ;
		Column3.ColumnOrder = 3, ;
		Column3.ControlSource = "nume_val", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.Name = "cNume_val", ;
		Column3.ReadOnly = .T., ;
		Column3.Visible = .T., ;
		Column3.Width = 90, ;
		Column4.ColumnOrder = 6, ;
		Column4.ControlSource = "curs", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.InputMask = (get_mask(14,gnPCurs)), ;
		Column4.Name = "cCurs", ;
		Column4.ReadOnly = .T., ;
		Column4.Visible = .T., ;
		Column4.Width = 99, ;
		Column5.ColumnOrder = 4, ;
		Column5.ControlSource = "multiplicator", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.InputMask = (get_mask(10,0)), ;
		Column5.Name = "cMultiplicator", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 73, ;
		Column6.ColumnOrder = 5, ;
		Column6.ControlSource = "iso_valuta", ;
		Column6.FontName = "Arial", ;
		Column6.FontSize = 10, ;
		Column6.Name = "cIso_valuta", ;
		Column6.ReadOnly = .T., ;
		Column6.Width = 59
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grd_curs.cCurs.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Curs", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cCurs.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255, ;
		Visible = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_curs.cData.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data inceput", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cData.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255, ;
		Visible = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_curs.cData2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data sfarsit", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cData2.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255, ;
		Visible = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_curs.cIso_valuta.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Simbol", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cIso_valuta.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_curs.cMultiplicator.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Multiplicator", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cMultiplicator.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_curs.cNume_val.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valuta", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cNume_val.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255, ;
		Visible = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Gridextra1' AS gridextra WITH ;
		gridexpression = Thisform.grd_curs, ;
		Left = 262, ;
		Name = "Gridextra1", ;
		Top = 60
		*< END OBJECT: ClassLib="..\utile\gridextras\gridextras.vcx" BaseClass="custom" />

	ADD OBJECT 'tx_zi_curs' AS _textbox WITH ;
		Alignment = 3, ;
		Height = 23, ;
		Left = 130, ;
		Name = "tx_zi_curs", ;
		ReadOnly = .T., ;
		TabIndex = 5, ;
		Top = 57, ;
		Value = {}, ;
		Width = 84
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />
	
	PROCEDURE actualizeaza_grid1
		Lparameters tcFiltru
		Local lcFiltru
		lcFiltru = tcFiltru
		If Empty(lcFiltru)
			lcFiltru = pocurs.ca_baza1.cfiltru
		Endif
		save_grid_comment(This.grd_curs)
		pocurs.ca_baza1.cfiltru = lcFiltru
		pocurs.ca_baza1.afisare()
		restore_grid_comment(This.grd_curs)
	ENDPROC

	PROCEDURE do_adauga
		Local lcRaport
		x= xmenu('\<O valuta;\<Toate valutele din nomenclator')
		
		If x > 0
			Private pniesire
			pniesire=0
			*!*	modificare ROAFACTURARE	v 2.0.46
			*!*		ldData = Ttod(get_ora())
			If Empty(Thisform.ddatacurs)
				ldData = Ttod(get_ora())
			Else
				ldData = Thisform.ddatacurs
			Endif
			*!*	modificare ROAFACTURARE	v 2.0.46	^
			If x = 1
				Select crscurs
				Scatter Name loRec Blank
				loRec.Data = ldData
				loRec.data2 = ldData
				Do Adauga_Modifica_Inregistrare With "curs",loRec,,"INSERT"
			Else
				lcCursor = [crsCursNou]
				If Used(lcCursor)
					Use In (lcCursor)
				Endif
				lcSql = [select id_valuta,nume_val,0.0000 as curs,0.0000 as curs_bnr,1 as multiplicator,nume_val2 as iso_valuta ] + ;
					[ from ] + gcS + [.vnom_valute where moneda_nationala = 0 and inactiv = 0 order by nume_val]
				lnSucces = goExecutor.oExecute(lcSql,lcCursor)
				If lnSucces < 0
					amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
				Else
					Private ofrmcursnou
					ofrmcursnou = Createobject('frm_curs_nou_multiplu',ldData)
					ofrmcursnou.Show(1)
					Release ofrmcursnou
				Endif
				If Used(lcCursor)
					Use In (lcCursor)
				Endif
			Endif
			If pniesire=1
				This.actualizeaza_grid1()
			Endif
		Endif
		Thisform.grd_curs.SetFocus()
	ENDPROC

	PROCEDURE do_cauta
		Local lcFiltru
		Store [] To lcFiltru
		
		If Thisform.ck_data.Value = 1
			lcFiltru = lcFiltru + Thisform.ck_data.filtru
		Endif
		
		If Thisform.ck_data2.Value = 1
			lcFiltru = lcFiltru + Thisform.ck_data2.filtru
		Endif
		
		If Thisform.ck_nume_val.Value = 1
			lcFiltru = lcFiltru + Thisform.ck_nume_val.filtru
		Endif
		
		If Thisform.ck_zi_curs.Value = 1
			lcData = Dtoc(Thisform.tx_zi_curs.Value,1)
			lcFiltru = lcFiltru + [ and data <= to_date('] + lcData + [','YYYYMMDD') ] + ;
				[and data2 >= to_date('] + lcData + [','YYYYMMDD') ]
		Endif
		
		If !Empty(lcFiltru)
			lcFiltru=Substr(lcFiltru,6)
		Else
			lcFiltru=[2=2]
		Endif
		
		Thisform.actualizeaza_grid1(lcFiltru)
		
		If Reccount('crscurs')=0
			amessagebox("Cautarea nu a intors rezultate!",64,"Info cautare")
			Thisform.ck_data.SetFocus()
		Else
			Thisform.grd_curs.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_modifica
		If Reccount('crscurs')>0
			Private pniesire
			pniesire=0
		
			Select crscurs
			Scatter Name loRec
			Do Adauga_Modifica_Inregistrare With "curs",loRec,loRec.id_curs,"UPDATE"
			If pniesire=1
				This.actualizeaza_grid1()
			Endif
			Thisform.grd_curs.SetFocus()
		Else
			amessagebox("Nu puteti face modificari,deoarece in aceasta selectie nu exista inregistrari!",0+48,"Atentie")
			Thisform.ck_data.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_reset
		Thisform.ck_data.Value = 0
		Thisform.ck_data2.Value = 0
		Thisform.ck_nume_val.Value = 0
		Thisform.ck_zi_curs.Value = 0
		Thisform.ck_data.SetFocus()
		Thisform.Refresh
		
	ENDPROC

	PROCEDURE do_sterge
		If Reccount('crscurs')>0
			Select crscurs
			Scatter Name loRec
			Do STERGE_INREGISTRARE With "curs",loRec.id_curs
			This.actualizeaza_grid1()
		Else
			amessagebox("Nu puteti sterge,deoarece in aceasta selectie nu exista inregistrari!",0+48,"Atentie")
		Endif
	ENDPROC

	PROCEDURE Init
		*!*	modificare ROAFACTURARE	v 2.0.46
		Lparameters tdDataCurs
		DoDefault()
		If !Empty(tdDataCurs)
			Thisform.ddatacurs = tdDataCurs
			Thisform.ck_zi_curs.Value = 1
			Thisform.tx_zi_curs.Value = tdDataCurs
		Endif
		*!*	modificare ROAFACTURARE	v 2.0.46	^
		
		this.gridextra1.setup()
	ENDPROC

	PROCEDURE ck_zi_curs.InteractiveChange
		If This.Value = 1
			Thisform.tx_zi_curs.ReadOnly = .F.
			Thisform.tx_zi_curs.SetFocus()
		Else
			Thisform.tx_zi_curs.ReadOnly = .T.
			Thisform.tx_zi_curs.Value = {}
		Endif
		
	ENDPROC

	PROCEDURE ck_zi_curs.ProgrammaticChange
		This.InteractiveChange()
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_curs_nou AS _frmbase OF "_frm_base.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="clb_data" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_data2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cus_odata_curs1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_curs" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_nume_val" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_multiplicator" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_curs_bnr" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="BUT_MODIPARAM1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: actualizeaza_curs_bnr
		*m: do_cauta_marca
		*m: do_cauta_valuta
		*p: nid
		*p: oactualizare
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 240
		Name = "frm_curs_nou"
		oactualizare = 
		Width = 374
		_shape1.Name = "_shape1"
		_shape2.Height = 29
		_shape2.Left = 312
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 64
		Lb_titlu_alb_b121.Caption = "CURS VALUTAR"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 9
		BUT_TERMIN1.Left = 344
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 7
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Name = "GRIDSORT1"
	*</PropValue>

	ADD OBJECT 'BUT_MODIPARAM1' AS but_modiparam WITH ;
		caction = do_modifica, ;
		Left = 328, ;
		Name = "BUT_MODIPARAM1", ;
		TabIndex = 10, ;
		Top = 191
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Left = 314, ;
		Name = "But_renunt1", ;
		TabIndex = 8, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'clb_data' AS clb_tx_simplu WITH ;
		Left = 20, ;
		Name = "clb_data", ;
		TabIndex = 1, ;
		Top = 48, ;
		Text_simplu1.ControlSource = "porec.data", ;
		Text_simplu1.MaxLength = 10, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Data inceput", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_data2' AS clb_tx_simplu WITH ;
		Left = 20, ;
		Name = "clb_data2", ;
		TabIndex = 2, ;
		Top = 76, ;
		Text_simplu1.ControlSource = "porec.data2", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Data sfarsit", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_curs' AS clb_tx_simplu WITH ;
		Left = 20, ;
		Name = "Clb_tx_curs", ;
		TabIndex = 6, ;
		Top = 188, ;
		Text_simplu1.ControlSource = "porec.curs", ;
		Text_simplu1.InputMask = (get_mask(14,gnPCurs)), ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Curs", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_curs_bnr' AS clb_tx_simplu WITH ;
		Left = 20, ;
		Name = "Clb_tx_curs_bnr", ;
		TabIndex = 5, ;
		Top = 160, ;
		Text_simplu1.ControlSource = "porec.curs_bnr", ;
		Text_simplu1.InputMask = (get_mask(14,gnPCurs)), ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Lb_simplu1.Caption = "Curs BNR", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_multiplicator' AS clb_tx_simplu WITH ;
		Left = 20, ;
		Name = "Clb_tx_multiplicator", ;
		TabIndex = 4, ;
		Top = 132, ;
		Text_simplu1.ControlSource = "porec.multiplicator", ;
		Text_simplu1.InputMask = (get_mask(10,0)), ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Lb_simplu1.Caption = "Multiplicator", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_nume_val' AS ct_clb_cautare WITH ;
		cconditie = EMPTY(porec.id_valuta), ;
		cprocedura = thisform.do_cauta_valuta, ;
		cvar_afisata = porec.nume_val, ;
		Left = 19, ;
		Name = "Ct_clb_nume_val", ;
		TabIndex = 3, ;
		Top = 103, ;
		img_cautare.Name = "img_cautare", ;
		clb_tx_cautare.Lb_simplu1.Caption = "Valuta", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Cus_odata_curs1' AS cus_odata_curs WITH ;
		Left = 324, ;
		Name = "Cus_odata_curs1", ;
		Top = 48
		*< END OBJECT: ClassLib="onom_curs.vcx" BaseClass="custom" />
	
	PROCEDURE actualizeaza_curs_bnr
		Thisform.LockScreen = .T.
		This.oactualizare.citeste_curs(poRec.Data,poRec.iso_valuta)
		Thisform.LockScreen = .F.
		poRec.multiplicator = This.oactualizare.nmultiplicator
		poRec.curs_bnr = This.oactualizare.ncurs
		If poRec.curs_bnr = 0
			This.clb_tx_multiplicator.text_simplu1.ReadOnly = .F.
		Else
			This.clb_tx_multiplicator.text_simplu1.ReadOnly = .T.
			IF EMPTY(NVL(poRec.curs,0))
				poRec.curs = poRec.curs_bnr
			ENDIF 	
		Endif
		Thisform.clb_tx_multiplicator.Refresh()
		Thisform.clb_tx_curs_bnr.Refresh()
		
	ENDPROC

	PROCEDURE Destroy
		Unbindevents(poRec,"data",Thisform,"actualizeaza_curs_bnr")
		Unbindevents(poRec,"iso_valuta",Thisform,"actualizeaza_curs_bnr")
	ENDPROC

	PROCEDURE do_cauta_marca
	ENDPROC

	PROCEDURE do_cauta_valuta
		locauta=caut_valuta(,,.T.)
		If !Isnull(locauta)
			porec.id_valuta = locauta.id_valuta
			porec.iso_valuta = locauta.nume_val2
			porec.nume_val = locauta.nume_val
		
			Thisform.ct_clb_nume_val.Refresh()
			Thisform.clb_tx_curs.SetFocus()
		Endif
	ENDPROC

	PROCEDURE do_modifica
		Local lnOptiune
		lnOptiune = xmenu("\<Copiaza cursul BNR;Aplica un \<procent cursului BNR")
		Do Case
			Case lnOptiune = 1
				poRec.Curs = poRec.curs_bnr
			Case lnOptiune = 2
				lcProcent = Inputbox("Introduceti procentul care se aplica cursului BNR","Procent","0")
				poRec.Curs = Round(poRec.curs_bnr * (Val(Nvl(lcProcent,"0"))/100+1),gnPCurs)
		Endcase
		Thisform.clb_tx_curs.Refresh()
		
	ENDPROC

	PROCEDURE inainte_de_do_termin
		Local PLRETURN
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If Inlist(lccontrol,"TEXTBOX","EDITBOX","COMBOBOX")
			lcval=This.ActiveControl.ControlSource
			&lcval=Thisform.ActiveControl.Value
		Endif
		Do Case
		Case Empty(porec.Data) Or Isnull(porec.Data)
			amessagebox('Nu ati completat data de inceput!',0+48,"Atentie")
			This.clb_data.SetFocus()
			PLRETURN=.F.
		
		Case Empty(porec.data2) Or Isnull(porec.data2)
			amessagebox('Nu ati completat data de sfarsit!',0+48,"Atentie")
			This.clb_data2.SetFocus()
			PLRETURN=.F.
		
		Case Empty(porec.id_valuta)
			amessagebox('Nu ati completat valuta!',0+48,"Atentie")
			This.ct_clb_nume_val.SetFocus()
			PLRETURN=.F.
		
		Case Empty(porec.Curs)
			amessagebox('Nu ati completat cursul!',0+48,"Atentie")
			This.clb_tx_curs.SetFocus()
			PLRETURN=.F.
		*!*	modificare	31.08.2011
		CASE EMPTY(porec.multiplicator)
			amessagebox('Multiplicatorul nu poate fi 0!',0+48,"Atentie")
			This.clb_tx_multiplicator.text_simplu1.SetFocus()
			plReturn = .F.
		*!*	modificare	31.08.2011	^
		Otherwise
			PLRETURN=This.cus_odata_curs1.salvare(This.OREC,This.NID)
			If !PLRETURN
				Thisform.clb_data.SetFocus()
			Endif
		Endcase
		Return PLRETURN
		
	ENDPROC

	PROCEDURE Init
		Lparameters toRec, tnId, tcActiune
		
		DoDefault()
		
		This.orec= toRec
		This.nid = tnId
		This.cus_odata_curs1.cactiune = tcActiune
		If tcActiune='UPDATE'
			Thisform.ct_clb_nume_val.do_dezactiveaza()
		*!*		update_modele_masini(porec.id_marca_masina)
		*!*		Thisform.cb_model._CBBASE1.RowSource=[crsmodelemasini.model_masina,id_model_masina]
		*!*		Thisform.cb_model._CBBASE1.RowSourceType= 6
		*!*		Select crsmodelemasini
		*!*		Locate For model_masina=porec.model_masina
		*!*		Thisform.cb_model._CBBASE1.Requery
		*!*		Thisform.cb_model._CBBASE1.Refresh()
		ENDIF
		Bindevent(poRec,"data",Thisform,"actualizeaza_curs_bnr",1)
		Bindevent(poRec,"iso_valuta",Thisform,"actualizeaza_curs_bnr",1)
		Thisform.oactualizare = Createobject("actualizare_curs_bnr",gnTipActualizareCurs)
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_curs_nou_multiplu AS _frmbase OF "_frm_base.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="clb_data" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_data2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cNume_val.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cNume_val.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cCurs.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cCurs.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cMultiplicator.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cMultiplicator.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cCurs_BNR.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cCurs_BNR.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cIso_valuta.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_curs.cIso_valuta.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="BUT_MODIPARAM1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: actualizeaza_curs_bnr
		*p: ddata
		*p: nid
		*p: oactualizare
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		ddata = {}
		DoCreate = .T.
		Height = 400
		Name = "frm_curs_nou_multiplu"
		oactualizare = .NULL.
		Width = 441
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 442
		_shape2.Height = 29
		_shape2.Left = 383
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 64
		Lb_titlu_alb_b121.Caption = "CURS VALUTAR"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 6
		BUT_TERMIN1.Left = 411
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Name = "GRIDSORT1"
	*</PropValue>

	ADD OBJECT 'BUT_MODIPARAM1' AS but_modiparam WITH ;
		caction = do_modifica, ;
		Left = 401, ;
		Name = "BUT_MODIPARAM1", ;
		Top = 70
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Left = 381, ;
		Name = "But_renunt1", ;
		TabIndex = 5, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'clb_data' AS clb_tx_simplu WITH ;
		Left = 12, ;
		Name = "clb_data", ;
		TabIndex = 1, ;
		Top = 41, ;
		Text_simplu1.ControlSource = "Thisform.ddata", ;
		Text_simplu1.MaxLength = 10, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Data inceput", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_data2' AS clb_tx_simplu WITH ;
		Left = 12, ;
		Name = "clb_data2", ;
		TabIndex = 2, ;
		Top = 69, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Data sfarsit", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'grd_curs' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		Height = 276, ;
		Left = 10, ;
		Name = "grd_curs", ;
		Panel = 1, ;
		ReadOnly = .F., ;
		RecordSource = "crscursnou", ;
		RowHeight = 19, ;
		TabIndex = 3, ;
		Top = 108, ;
		Width = 424, ;
		ZOrderSet = 7, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "nume_val", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cNume_val", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 72, ;
		Column2.BackColor = 170,213,255, ;
		Column2.ColumnOrder = 5, ;
		Column2.ControlSource = "curs", ;
		Column2.DynamicBackColor = "RGB(170,213,255)", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.InputMask = (get_mask(14,gnPCurs)), ;
		Column2.Name = "cCurs", ;
		Column2.ReadOnly = .F., ;
		Column2.Width = 94, ;
		Column3.ColumnOrder = 2, ;
		Column3.ControlSource = "multiplicator", ;
		Column3.DynamicBackColor = "IIF(curs_bnr=0,RGB(255,255,180),RGB(255,255,255))", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.InputMask = (get_mask(10,0)), ;
		Column3.Name = "cMultiplicator", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 77, ;
		Column4.ColumnOrder = 4, ;
		Column4.ControlSource = "curs_bnr", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.InputMask = (get_mask(14,gnPCurs)), ;
		Column4.Name = "cCurs_BNR", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 78, ;
		Column5.ColumnOrder = 3, ;
		Column5.ControlSource = "iso_valuta", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cIso_valuta", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 56
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grd_curs.cCurs.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Curs", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cCurs.Text1' AS textbox WITH ;
		BackColor = 170,213,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .F., ;
		SelectedBackColor = 100,185,255, ;
		Visible = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_curs.cCurs_BNR.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Curs BNR", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cCurs_BNR.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_curs.cIso_valuta.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Simbol", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cIso_valuta.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_curs.cMultiplicator.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Multiplicator", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cMultiplicator.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_curs.cNume_val.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valuta", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_curs.cNume_val.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255, ;
		Visible = .T.
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE actualizeaza_curs_bnr
		Thisform.LockScreen = .T.
		Thisform.oactualizare.citeste_curs(Thisform.ddata)
		Thisform.LockScreen = .F.
		Thisform.grd_curs.salveaza_grid()
		copiaza_structura_cursor([crscursnou],[crscursnout])
		Insert Into crscursnout Select * From crscursnou
		Use In crscursnou
		Select a.id_valuta,a.nume_val,a.Curs,Cast(Nvl(b.Curs,0.0000) As N(14,4)) As curs_bnr,;
			CAST(Iif(Empty(Nvl(b.multiplier,0)),Nvl(a.multiplicator,1),b.multiplier) As N(10)) As multiplicator,a.iso_valuta ;
			FROM crscursnout a Left Join (This.oactualizare.cCursor) b On Alltrim(a.iso_valuta) = Alltrim(b.Currency) ;
			INTO Cursor crscursnou Readwrite Order By nume_val
		Select crscursnou
		Go Top
		Thisform.grd_curs.incarca_grid()
		
	ENDPROC

	PROCEDURE Destroy
		Unbindevents(Thisform.clb_data.text_simplu1,"InteractiveChange",Thisform,"actualizeaza_curs_bnr")
	ENDPROC

	PROCEDURE do_modifica
		Local lnOptiune,lnRecno
		lnOptiune = xmenu("\<Copiaza cursul BNR pentru valutele care nu au cursul completat;" + ;
			"C\<opiaza cursul BNR pentru toate valutele;\-;Se aplica un \<procent cursului BNR pentru valutele care nu au cursul completat;" + ;
			"Se aplica un p\<rocent cursului BNR pentru toate valutele;\-;\<Reseteaza toate cursurile")
		Select crsCursNou
		lnRecno = Recno()
		Do Case
			Case lnOptiune = 1
				Replace Curs With curs_bnr For Curs = 0
			Case lnOptiune = 2
				Replace All Curs With curs_bnr
			Case lnOptiune = 4
				lcProcent = Inputbox("Introduceti procentul care se aplica cursului BNR","Procent","0")
				Replace Curs With Round(curs_bnr * (Val(Nvl(lcProcent,"0"))/100+1),gnPCurs) For Curs = 0
			Case lnOptiune = 5
				lcProcent = Inputbox("Introduceti procentul care se aplica cursului BNR","Procent","0")
				Replace All Curs With Round(curs_bnr * (Val(Nvl(lcProcent,"0"))/100+1),gnPCurs)
			Case lnOptiune = 7
				Replace All Curs With 0
		Endcase
		Go lnRecno
	ENDPROC

	PROCEDURE inainte_de_do_termin
		Local PLRETURN
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If Inlist(lccontrol,"TEXTBOX","EDITBOX","COMBOBOX")
			lcval=This.ActiveControl.ControlSource
			&lcval=Thisform.ActiveControl.Value
		Endif
		ldData = Thisform.ddata
		ldData2 = Thisform.clb_data2.text_simplu1.Value
		*!*	modificare	31.08.2011
		Select crscursnou
		Locate For multiplicator = 0
		If Found()
			amessagebox("Multiplicatorul nu poate fi 0!",48,"Atentie")
			Thisform.grd_curs.SetFocus()
			PLRETURN=.F.
		Else
			Go Top
		*!*	modificare	31.08.2011	^
			Do Case
				Case Empty(ldData) Or Isnull(ldData)
					amessagebox('Nu ati completat data de inceput!',0+48,"Atentie")
					This.clb_data.SetFocus()
					PLRETURN=.F.
		
				Case Empty(ldData2) Or Isnull(ldData2)
					amessagebox('Nu ati completat data de sfarsit!',0+48,"Atentie")
					This.clb_data2.SetFocus()
					PLRETURN=.F.
		
				Otherwise
					lcData = Dtos(ldData)
					lcData2 = Dtos(ldData2)
					lcSql = []		&&		modificare ROAFACTURARE v 2.0.71
					Select crscursnou
					Scan For Curs <> 0
						lcSql = lcSql + [pack_curs.adauga_curs(to_date('] + lcData + [','YYYYMMDD'),] + ;
							[to_date('] + lcData2 +[','YYYYMMDD'),] + Alltrim(Str(id_valuta)) + [,] + ;
							ALLTRIM(Str(multiplicator)) + [,] + Alltrim(Str(Curs,14,4)) + [,?gnIdUtil);]
					Endscan
					*!*	modificare ROAFACTURARE v 2.0.71
					If Empty(lcSql)
						amessagebox("Nu ati completat cursul pentru nicio valuta!",48,"Atentie")
						PLRETURN = .F.
					Else
						*!*	modificare ROAFACTURARE v 2.0.71	^
						lcSql = [begin ] + lcSql + [ end;]
						lnSucces = goExecutor.oExecute(lcSql)
						If lnSucces < 0
							amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
							Thisform.clb_data.SetFocus()
							PLRETURN = .F.
						Else
							PLRETURN = .T.
						Endif
						*!*	modificare ROAFACTURARE v 2.0.71
					Endif
					*!*	modificare ROAFACTURARE v 2.0.71	^
			Endcase
		*!*	modificare	31.08.2011
		Endif
		*!*	modificare	31.08.2011	^
		Return PLRETURN
		
	ENDPROC

	PROCEDURE Init
		Lparameters tdData
		Thisform.ddata = tdData
		Thisform.clb_data2.text_simplu1.Value = tdData
		DoDefault()
		Thisform.oactualizare = Createobject("actualizare_curs_bnr",gnTipActualizareCurs)
		Thisform.actualizeaza_curs_bnr()
		Bindevent(Thisform,"ddata",Thisform,"actualizeaza_curs_bnr",1)
	ENDPROC

	PROCEDURE grd_curs.cMultiplicator.Text1.GotFocus
		If curs_bnr = 0
			This.ReadOnly = .F.
			This.Parent.ReadOnly = .F.
		Else
			This.ReadOnly = .T.
			This.Parent.ReadOnly = .T.
		Endif
	ENDPROC

	PROCEDURE grd_curs.Init
		*
	ENDPROC

ENDDEFINE
