*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="cauta_alfa_forms.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS cauta_alfa_form 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="_GRID1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmd_select" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_cauta1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cb_tx_cautare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_verifica1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_copiaza1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_activeaza_selectare
		*m: do_alege
		*m: do_schimba_explicatia
		*p: cales
		*p: cfiltru_original
		*p: cidcolumn
		*p: cnume_proc
		*p: cpornire
		*p: cproceduracopiaza
		*p: cproceduraverifica
		*p: crs_cursor
		*p: crs_cursort
		*p: lales
		*p: ll_allinlist
		*p: primacoloana
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 3
		cales = 
		cfiltru_original = 2=2
		cgridsortlist = _grid1
		cidcolumn = 
		cnume_proc = 
		cpornire = 0
		cproceduracopiaza = 
		cproceduraverifica = 
		crs_cursor = 
		crs_cursort = 
		Desktop = .F.
		DoCreate = .T.
		Height = 331
		lales = .F.
		Name = "cauta_alfa_form"
		primacoloana = 
		Width = 507
		WindowType = 1
		_memberdata = <VFPData>
			<memberdata name="cproceduracopiaza" display="cProceduraCopiaza"/>
			<memberdata name="cproceduraverifica" display="cProceduraVerifica"/>
		</VFPData>
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 508
		_shape2.Height = 29
		_shape2.Left = 371
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 63
		Lb_titlu_alb_b121.FontName = "Arial Narrow"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 7
		BUT_TERMIN1.Anchor = 8
		BUT_TERMIN1.Left = 476
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_GRID1' AS _grid WITH ;
		Anchor = 15, ;
		ColumnCount = 4, ;
		DeleteMark = .F., ;
		FontName = "Segoe UI", ;
		FontSize = 10, ;
		Height = 217, ;
		Left = 5, ;
		Name = "_GRID1", ;
		Panel = 1, ;
		ReadOnly = .F., ;
		RecordMark = .T., ;
		RecordSource = "cursor_curent", ;
		RowHeight = 20, ;
		TabIndex = 3, ;
		Top = 76, ;
		Width = 499, ;
		Column1.BackColor = 255,255,255, ;
		Column1.ControlSource = "", ;
		Column1.FontName = "Segoe UI", ;
		Column1.FontSize = 10, ;
		Column1.Name = "Column1", ;
		Column1.ReadOnly = .F., ;
		Column1.Width = 300, ;
		Column2.BackColor = 255,255,255, ;
		Column2.FontName = "Segoe UI", ;
		Column2.FontSize = 10, ;
		Column2.Name = "Column2", ;
		Column2.ReadOnly = .F., ;
		Column2.Width = 100, ;
		Column3.BackColor = 255,255,255, ;
		Column3.FontName = "Segoe UI", ;
		Column3.FontSize = 10, ;
		Column3.Name = "Column3", ;
		Column3.ReadOnly = .F., ;
		Column4.BackColor = 255,255,255, ;
		Column4.FontName = "Segoe UI", ;
		Column4.FontSize = 10, ;
		Column4.Name = "Column4", ;
		Column4.ReadOnly = .F.
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="grid" />

	ADD OBJECT '_GRID1.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Header1", ;
		FontName = "Segoe UI", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_GRID1.Column1.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Segoe UI", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .F.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_GRID1.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Header1", ;
		FontName = "Segoe UI", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_GRID1.Column2.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Segoe UI", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .F.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_GRID1.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Header1", ;
		FontName = "Segoe UI", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_GRID1.Column3.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Segoe UI", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .F.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_GRID1.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Header1", ;
		FontName = "Segoe UI", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_GRID1.Column4.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Segoe UI", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .F.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'But_copiaza1' AS but_copiaza WITH ;
		Anchor = 8, ;
		Left = 385, ;
		Name = "But_copiaza1", ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

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

	ADD OBJECT 'But_verifica1' AS but_verifica WITH ;
		Anchor = 8, ;
		Left = 415, ;
		Name = "But_verifica1", ;
		TabIndex = 14, ;
		ToolTipText = "Validare cod", ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Cb_tx_cautare1' AS cb_tx_cautare WITH ;
		Anchor = 10, ;
		Height = 27, ;
		Left = 25, ;
		Name = "Cb_tx_cautare1", ;
		TabIndex = 1, ;
		Top = 45, ;
		Width = 383, ;
		Text.Format = "!", ;
		Text.Height = 25, ;
		Text.Left = 103, ;
		Text.Name = "Text", ;
		Text.TabIndex = 2, ;
		Text.Top = 1, ;
		Text.Width = 275, ;
		Criteriu.Name = "Criteriu", ;
		Criteriu.TabIndex = 1
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

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

	ADD OBJECT 'cmd_select' AS _commandbutton WITH ;
		Anchor = 6, ;
		Caption = "\<Selecteazã tot", ;
		FontBold = .T., ;
		Height = 27, ;
		Left = 8, ;
		Name = "cmd_select", ;
		TabIndex = 6, ;
		Top = 300, ;
		Visible = .F., ;
		Width = 133
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="commandbutton" />
	
	PROCEDURE actualizeaza_grid1
		LPARAMETERS pcFiltru
		LOCAL lcToolTip
		LOCAL lcFiltru, lcCamp
		LOCAL lcCursor, lcCursort
		lcCursor = this.crs_cursor 
		lcCursort = this.crs_cursort 
		goLog.Log('1',program())
		lcCamp = ' '
		lcFiltru=pcFiltru
		IF EMPTY(lcFiltru)
			lcFiltru=deca_baza1.ca_baza1.cfiltru
		ENDIF
		
		lcListaId = ""
		IF this.lAles
			lcIdColumn = this.cIdcolumn 
			SELECT &lcIdColumn FROM (lcCursor) WITH (BUFFERING = .T.) WHERE SUBSTR(this.cAles,RECNO(),1) = 'X' INTO CURSOR crsListaId 
			lcListaId = cursor2lista("crsListaId",lcIdColumn,",")
			USE IN crsListaId
			
			IF !EMPTY(lcListaId)
				lcFiltru = "((" + lcFiltru + ") OR (" + lcIdColumn + " IN (" + lcListaId + ")))"
			ENDIF 	
		ENDIF 
		lcToolTip = this._grid1.ToolTipText 
		goLog.Log('2',program())
		save_grid(This._grid1)
		goLog.Log('3',program())
		deca_baza1.ca_baza1.cfiltru=lcfiltru
		goLog.Log('4',program())
		deca_baza1.ca_baza1.afisare()
		goLog.Log('5',program())
		
		IF this.lAles
			IF !EMPTY(lcListaId)
				this.cAles = ""
				SELECT (lcCursor)
				SCAN
					lcValue = TRANSFORM(&lcIdColumn)
					IF lcValue$lcListaId
						this.cAles = this.cAles + "X"
					ELSE 
						this.cAles = this.cAles + " "	
					ENDIF 	
				ENDSCAN 
				GO TOP 
			ELSE 
				this.cAles = REPLICATE(" ",Reccount(lcCursor))		
			ENDIF 
		ENDIF 	
		
		IF (this.ll_allinlist)
			*SELECT * from cursor_temp INTO CURSOR cursor_curent WHERE .F. readwrite 
			SELECT * FROM &lccursort INTO CURSOR &lccursor WHERE .F. READWRITE 
			*SELECT cursor_curent
			SELECT (lccursor)
			IF OCCURS([,],tccoloana) > 0
				lcField = LEFT(tccoloana,AT([,],tccoloana)-1)
				lcCamp = lccursort + '.' + lcfield
				*IF TYPE('cursor_temp.&lcField')# 'C'
				IF TYPE(lcCamp) # 'C'
					lcfield = FIELD(1)
				ENDIF 
			ELSE 
				lcField = tccoloana
				lcCamp = lccursort + '.' + lcfield
			ENDIF 
			*IF TYPE('cursor_temp.&lcField')= 'C'
			IF TYPE(lcCamp) = 'C'
				INSERT INTO (lcCursor) (&lcfield) values("<TOATE INREGISTRARILE>")
			ENDIF 
			*SELECT cursor_curent
			SELECT (lccursor)
			*APPEND FROM DBF("cursor_temp")
			APPEND FROM DBF(lccursort)
			*USE IN cursor_temp 
			USE IN (lccursort)
		ENDIF 
		goLog.Log('6',program())
		restore_grid(This._grid1)
		this._grid1.ToolTipText = lcToolTip
		*!*	modificare	16.08.2010 - M.A.
		If Thisform.lAles
			Thisform.do_schimba_explicatia()
		Endif
		*!*	modificare	16.08.2010 - M.A.	^
		goLog.Log('7',program())
	ENDPROC

	PROCEDURE Destroy
		*!*	modificare	16.08.2010 - M.A.
		Unbindevents(Thisform,"lAles",Thisform,"do_activeaza_selectare")
		If Thisform.lAles
			Unbindevents(Thisform,"cales",Thisform,"do_schimba_explicatia")
		Endif
		*!*	modificare	16.08.2010 - M.A.	^
	ENDPROC

	PROCEDURE do_activeaza_selectare
		*!*	modificare	16.08.2010 - M.A.
		If Thisform.lAles
			Thisform.cmd_select.Visible = .T.
			Bindevent(Thisform,"cales",Thisform,"do_schimba_explicatia",1)
		Endif
		*!*	modificare	16.08.2010 - M.A.	^
	ENDPROC

	PROCEDURE do_adauga
		If Thisform.but_nou1.Visible
			Select (This._GRID1.RecordSource)
			Scatter Name poRec Blank
			lcname = Thisform.cnume_proc
		*	Do &lcname In onomenclatoare.prg
			IF !EMPTY(lcName)
				lcRun = [do ] + lcName + [ in onomenclatoare.prg]
				&lcRun
			ENDIF 	
			Thisform.do_cauta
		Endif
		
	ENDPROC

	PROCEDURE do_alege
		If Thisform.lAles
			lcCursor = Thisform._GRID1.RecordSource
			lnRecno = Recno(lcCursor)
			If Substr(Thisform.cAles, lnRecno,1) = ' '
				lcReplacement = 'X'
			Else
				lcReplacement = ' '
			Endif
			Thisform.cAles = Left(Thisform.cAles,lnRecno - 1) + lcReplacement + Substr(Thisform.cAles, lnRecno + 1)
			pcAles = Thisform.cAles
			Thisform._GRID1.Refresh()
		Endif
	ENDPROC

	PROCEDURE do_cauta
		*!* 19.11.2011
		*!* marius.mutu
		*!* lcvar = field(1) in loc de thisform.primacoloana
		goLog.Log('1',Program())
		Private lcfiltru,lcval1
		lcfiltru=''
		Local lcCursor, lcCursort
		lcCursor = This.crs_cursor
		lcCursort = This.crs_cursort
		
		&& pot sa fac cautarea dupa mai multe coloane (ex: nr contract, denumire client)
		lnCount = GETWORDCOUNT(Alltrim(This.primacoloana), [,])
		FOR lnColoana = 1 TO m.lnCount 
			lcColoana = GETWORDNUM(Alltrim(This.primacoloana), m.lnColoana, [,])
			With Thisform.cb_tx_cautare1
				lcval1=Strtran(Alltrim(Upper(.Text.Value)),['],[''])
				Do Case
					Case .criteriu.Value = "1" And !Empty(.Text.Value)
						lcfiltru = m.lcFiltru  + [ OR ] + Alltrim(Upper(lcColoana)) + [ LIKE '] + lcval1 + [%']
					Case .criteriu.Value = "2" And !Empty(.Text.Value)
						lcfiltru = m.lcFiltru  + [ OR ] + Alltrim(Upper(lcColoana)) + [ ='] + lcval1 + [']
					Case .criteriu.Value = "3" And !Empty(.Text.Value)
						lcfiltru = m.lcFiltru  + [ OR ] + Alltrim(Upper(lcColoana)) + [ !='] + lcval1 + [']
					Case .criteriu.Value = "4" And !Empty(.Text.Value)
						lcfiltru = m.lcFiltru  + [ OR ] + Alltrim(Upper(lcColoana)) + [ LIKE '%] + lcval1 + [%']
					Case .criteriu.Value = "5" And !Empty(.Text.Value)
						lcfiltru = m.lcFiltru  + [ OR ] + Alltrim(Upper(lcColoana)) + [ NOT LIKE '%] + lcval1 + [%']
					Case .criteriu.Value = "6"
						lcfiltru = [2=2]
				Endcase
			Endwith
		ENDFOR
		lcFiltru = ALLTRIM(m.lcfiltru)
		IF LEFT(m.lcfiltru, 3) = [OR ]
			lcFiltru = SUBSTR(m.lcfiltru, 4)
		ENDIF 
		
		If Alltrim(lcval1) = [%]
			lcfiltru = [2=2]
		Endif
		
		If Empty(lcfiltru)
			aMessagebox("Alegeti un criteriu!",0+48,"Atentie")
			Thisform.cb_tx_cautare1.criteriu.SetFocus()
			Return
		Endif
		
		
		lcfiltru = This.cfiltru_original + [ and ] + [(] + m.lcFiltru + [)]
		goLog.Log('2',Program())
		Thisform.actualizeaza_grid1(lcfiltru)
		goLog.Log('3',Program())
		Select (lcCursor)
		*Select cursor_curent
		Go Top
		*If (Reccount('cursor_curent')=0)
		If (Reccount(lcCursor)=0)
			aMessagebox("Nu exista rezultate!",0+48,"Atentie")
			Thisform.cb_tx_cautare1.criteriu.SetFocus()
		Else
			Go Top
			*!* 19.12.2011
			*!*		lcvar = ALLTRIM(IIF(AT('.',lcColoana)=0,lcColoana, SUBSTR(lcColoana,AT('.',lcColoana)+1)))
			lcVar = Field(1)
			*!* 19.12.2011 ^
			lcFirstInList = &lcVar
			If Type([lcFirstInList]) = 'C' And (Reccount(lcCursor)>1 And Alltrim(lcFirstInList)=='<TOATE INREGISTRARILE>')
				*IF (Reccount('cursor_curent')>1 AND ALLTRIM(lcFirstInList)=='<TOATE INREGISTRARILE>')
				Goto 2
			ENDIF
			* 06.06.2022
			thisform._griD1.AutoFit()
			FOR lnColumn = 1 TO this._GRID1.ColumnCount
				lcColumn = 'this._gRID1.column' + ALLTRIM(STR(m.lnColumn))
				loColumn = EVALUATE(m.lcColumn)
				lnColumnw = loColumn.Width
				lnMinW = IIF(m.lnColumn = 1, 300, IIF(m.lnColumn = 2, 100, 75))
				loColumn.Width = MAX(m.lnColumnw, m.lnMinW)
			ENDFOR 
			* 06.06.2022 ^
			Thisform._GRID1.SetFocus()
		Endif
		goLog.Log('4',Program())
		
	ENDPROC

	PROCEDURE do_copiaza
		Local lcName, lcRun, loRec
		If Thisform.but_copiaza1.Visible
			Select (This._GRID1.RecordSource)
			Scatter Name loRec
			lcName = Thisform.cProceduraCopiaza
			If !Empty(m.lcName)
				lcRun = [do ] + lcName + [ with m.loRec in onomenclatoare.prg]
				&lcRun
			Endif
		Endif
		  
	ENDPROC

	PROCEDURE do_schimba_explicatia
		*!*	modificare	16.08.2010 - M.A.
		Local lcCursor
		lcCursor = Thisform._GRID1.RecordSource
		If Used(lcCursor)
			If Between(Occurs('X',Thisform.cAles),0,Reccount(lcCursor)-1) OR RECCOUNT(lcCursor) = 0
				Thisform.cmd_select.Caption = "\<Selecteazã tot"
			Else
				Thisform.cmd_select.Caption = "De\<selecteazã tot"
			Endif
		Endif
		Release lcCursor
		*!*	modificare	16.08.2010 - M.A.	^
		
	ENDPROC

	PROCEDURE do_selectall
		*!*	modificare	16.08.2010 - M.A.
		Local lcCursor,lcCaracter
		lcCursor = Thisform._GRID1.RecordSource
		If Occurs('X',Thisform.cAles) < Reccount(lcCursor)
			lcCaracter = 'X'
		Else
			lcCaracter = ' '
		Endif
		Thisform.cAles = Replicate(lcCaracter,Reccount(lcCursor))
		pcAles = Thisform.cAles
		Thisform._GRID1.Refresh()
		RELEASE lcCursor,lcCaracter
		*!*	modificare	16.08.2010 - M.A.	^
	ENDPROC

	PROCEDURE do_verifica
		Local lcName, lcRun, loRec
		If Thisform.but_verifica1.Visible
			Select (This._GRID1.RecordSource)
			Scatter Name loRec
			lcName = Thisform.cProceduraVerifica
			If !Empty(m.lcName)
				lcRun = [do ] + lcName + [ with m.loRec in onomenclatoare.prg]
				&lcRun
			Endif
		Endif
		  
	ENDPROC

	PROCEDURE inainte_de_do_termin
		If Type('This.oVerifAlegere') = 'O' And !Isnull(This.oVerifAlegere)
			Return This.oVerifAlegere.VerificaAlegere(Thisform)
		Endif
		Return DODEFAULT()
	ENDPROC

	PROCEDURE Init
		Lparameters tcCursor, tcNume_Proc, tcTitluColoana, tccoloana, tl_AllInList, ;
			tcPrimaColoana, tnPornire, tcGridDynamicBackColor, tcGridToolTip, ;
			tcProceduraVerifica, tcProceduraCopiaza
			
		*!*	modificare	16.08.2010 - M.A.
		BINDEVENT(Thisform,"lAles",Thisform,"do_activeaza_selectare",1)
		*!*	modificare	16.08.2010 - M.A.	^
		This._GRID1.RecordSource = tcCursor
		This.cnume_proc = tcNume_Proc
		This.ll_allinlist = tl_AllInList
		If Empty(tcNume_Proc)
			Thisform.But_nou1.Enabled=.F.
			Thisform.But_nou1.Visible=.F.
		Endif
		If Empty(tcProceduraCopiaza)
			Thisform.but_copiaza1.Enabled=.F.
			Thisform.but_copiaza1.Visible=.F.
			this.but_nou1.Left = this.but_copiaza1.Left 
		ENDIF
		If Empty(tcProceduraVerifica)
			Thisform.but_verifica1.Enabled=.F.
			Thisform.but_verifica1.Visible=.F.
			this.but_nou1.Left = this.but_verifica1.Left
		ENDIF
		
		**miscarefereastra:
		DoDefault()
		lnNrCols = Occurs(",",tcTitluColoana) + 1
		
		**ajustare width coloana grid:
		This.cnume_proc = tcNume_Proc
		this.cProceduraCopiaza = m.tcProceduraCopiaza
		this.cProceduraVerifica = m.tcProceduraVerifica
		
		This._GRID1.ColumnCount = lnNrCols
		* ajustez latimea coloanelor in do_cauta
		*!*	If lnNrCols > 1
		*!*		This._GRID1.coLUMN1.Width = This._GRID1.coLUMN1.Width - (This._GRID1.coLUMN1.Width/2)
		*!*	Endif
		
		tcTitluColoana = "," + tcTitluColoana + ","
		For i=1 To lnNrCols
			lcheader = [this._GRID1.coLUMN] + Alltrim(Str(i))+ [.hEADER1.Caption = PROPER(LEFT( SUBSTR(tcTitluColoana,AT(",",tcTitluColoana,i)+1),AT(",",tcTitluColoana,i+1)-AT(",",tcTitluColoana,i)-1))]
			&lcheader
		Endfor
		
		tccoloana = "," + tccoloana + ","
		For i=1 To lnNrCols
			lcControlSource = [this._GRID1.coLUMN] + Alltrim(Str(i))+ [.ControlSource = PROPER(LEFT( SUBSTR(tcColoana,AT(",",tcColoana,i)+1),AT(",",tcColoana,i+1)-AT(",",tcColoana,i)-1))]
			&lcControlSource
		Endfor
		
		&& dupa care se face filtru:
		If Empty(tcPrimaColoana)
			This.primacoloana = Proper(Left( Substr(tccoloana,At(",",tccoloana,1)+1),At(",",tccoloana,1+1)-At(",",tccoloana,1)-1))
		Else
			This.primacoloana = tcPrimaColoana
		Endif
		
		If !Empty(tnPornire)
			This.cPornire = Alltrim(Str(tnPornire))
		Else
			This.cPornire = "1"
		Endif
		*!*	modificare 06.12.2006
		Thisform.cb_tx_cautare1.do_initializeaza_ct(Thisform.cPornire)
		*!*	modificare 06.12.2006	^
		
		&& setez DynamicBackColor
		If Type('tcGridDynamicBackColor') = 'C' And !Empty(tcGridDynamicBackColor)
			This._GRID1.SetAll("DynamicBackColor", tcGridDynamicBackColor, "Column")
		Endif
		
		If Type('tcGridToolTip') = 'C' And !Empty(tcGridToolTip)
			This._GRID1.ToolTipText = tcGridToolTip
		Endif
		
		*!*	adaugat 08.05.2009
		*!*	alex.lepadatu
		
		Local loGrid, loColumnTexti
		loGrid = Thisform._GRID1
		For i = 1 To loGrid.ColumnCount
			loColumnTexti= loGrid.Columns(i).text1
			If !Thisform.lales
				Bindevent(loColumnTexti,"dblClick",This,"do_termin")
			Endif
		Endfor
		*!*	08.05.2009
		
	ENDPROC

	PROCEDURE KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl
		lcControl = UPPER(ALLTRIM(THIS.ACTIVECONTROL.NAME))
		LOCAL lcCursor, lcCursort
		lcCursor = THIS.crs_cursor
		lcCursort = THIS.crs_cursort
		
		**verificare:
		**MESSAGEBOX("control:"+lcControl+" "+STR(nKeyCode))
		DO CASE
			CASE nKeyCode = 32 AND lcControl = '_GRID1' && space
				thisform.do_alege()
			CASE nKeyCode = 13 AND lcControl = '_GRID1' && enter
				NODEFAULT
				THIS.buT_TERMIN1.SETFOCUS
				*!* DACA APAS SAGEATA JOS SAU SUS SA SE DESCHIDA LISTA
		*!*		CASE INLIST(nKeyCode,5, 24) AND lcControl = 'CRITERIU'&& UPARROW, DNARROW
		*!*			KEYBOARD '{ALT+DNARROW}'
			CASE nKeyCode = 13 AND lcControl = 'TEXT' && enter
				NODEFAULT
				*If Reccount('cursor_curent')==0 Or This.cb_tx_cautare1.Text.ReadOnly=.F. Or !Empty(This.cb_tx_cautare1.Text.Value)
				*!*	If Reccount(lcCursor)==0 Or This.cb_tx_cautare1.Text.ReadOnly=.F. Or !Empty(This.cb_tx_cautare1.Text.Value)
				IF RECCOUNT(lcCursor)<> 0 OR THIS.cb_tx_cautare1.TEXT.READONLY OR !EMPTY(THIS.cb_tx_cautare1.TEXT.VALUE)
					&& daca exista inregistrari sau vreau toate inregistrarile sau este completat textul de cautare
					THIS.do_cauta()
					THIS._GRID1.SETFOCUS
				ELSE
					&& sare pe terminat daca dau enter in textbox si nu am scris nimic
					NODEFAULT
					THIS.buT_TERMIN1.SETFOCUS
				ENDIF
		
			CASE nKeyCode = 9 AND lcControl = 'TEXT' && tab
				NODEFAULT
				THIS._GRID1.SETFOCUS
		
			CASE (nKeyCode >=33 AND nKeyCode <=122) AND (lcControl <> 'TEXT')
				NODEFAULT
				THIS.cb_tx_cautare1.TEXT.VALUE = ALLTRIM(THIS.cb_tx_cautare1.TEXT.VALUE) + CHR(nKeyCode)
				THIS.cb_tx_cautare1.SETFOCUS
				KEYBOARD '{END}'
		
			CASE (nKeyCode = 127) AND (lcControl <> 'TEXT') && backspace
				NODEFAULT
				THIS.cb_tx_cautare1.TEXT.VALUE = LEFT(ALLTRIM(THIS.cb_tx_cautare1.TEXT.VALUE),LEN(ALLTRIM(THIS.cb_tx_cautare1.TEXT.VALUE))-1)
				THIS.cb_tx_cautare1.SETFOCUS
				KEYBOARD '{END}'
		
			CASE nKeyCode = -3 && F4
				NODEFAULT
				IF TYPE('THIS.oVerifAlegere') = 'O' AND !ISNULL(THIS.oVerifAlegere)
					THIS.oVerifAlegere.Detalii()
				ENDIF
		
			OTHERWISE
				DODEFAULT(nKeyCode, nShiftAltCtrl)
		ENDCASE
		
	ENDPROC

	PROCEDURE Unload
		RETURN this.cAles 
	ENDPROC

	PROCEDURE Cb_tx_cautare1.Criteriu.Init
		
		
		
	ENDPROC

	PROCEDURE cmd_select.Click
		Thisform.do_selectall()
	ENDPROC

	PROCEDURE _GRID1.Column1.Text1.Click
		Thisform.do_alege()
	ENDPROC

	PROCEDURE _GRID1.Init
		DoDefault()
		This.SetAll("dynamicbackcolor","iif(SUBSTR(thisform.cAles,RECNO(),1)='X',RGB(106,181,255), RGB(255,255,255))","Column")
	ENDPROC

ENDDEFINE

DEFINE CLASS cauta_alfa_form_desktop AS cauta_alfa_form OF "cauta_alfa_forms.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<PropValue>
		Desktop = .T.
		DoCreate = .T.
		Name = "cauta_alfa_form_desktop"
		_shape1.Name = "_shape1"
		_shape2.Name = "_shape2"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		Gridsort1.Name = "Gridsort1"
		_GRID1.COLUMN1.Header1.Name = "Header1"
		_GRID1.COLUMN1.Name = "COLUMN1"
		_GRID1.COLUMN1.Text1.Name = "Text1"
		_GRID1.COLUMN2.Header1.Name = "Header1"
		_GRID1.COLUMN2.Name = "COLUMN2"
		_GRID1.COLUMN2.Text1.Name = "Text1"
		_GRID1.COLUMN3.Header1.Name = "Header1"
		_GRID1.COLUMN3.Name = "COLUMN3"
		_GRID1.COLUMN3.Text1.Name = "Text1"
		_GRID1.COLUMN4.Header1.Name = "Header1"
		_GRID1.COLUMN4.Name = "COLUMN4"
		_GRID1.COLUMN4.Text1.Name = "Text1"
		_GRID1.Name = "_GRID1"
		But_renunt1.Name = "But_renunt1"
		_commandbutton2.Name = "_commandbutton2"
		Cmd_cauta1.Name = "Cmd_cauta1"
		Cb_tx_cautare1.Criteriu.Name = "Criteriu"
		Cb_tx_cautare1.Name = "Cb_tx_cautare1"
		Cb_tx_cautare1.Text.Name = "Text"
		But_nou1.Name = "But_nou1"
	*</PropValue>

ENDDEFINE

DEFINE CLASS cauta_alfa_form_gs 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="Ct_grid_search1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_commandbutton2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*p: cales
		*p: cfiltru_original
		*p: cidcolumn
		*p: cnume_proc
		*p: cpornire
		*p: crs_cursor
		*p: crs_cursort
		*p: lales
		*p: ll_allinlist
		*p: primacoloana
	*</DefinedPropArrayMethod>

	*<PropValue>
		cales = 
		cfiltru_original = 2=2
		cgridsortlist = ct_grid_search1._grid1
		cidcolumn = 
		cnume_proc = 
		cpornire = 0
		crs_cursor = 
		crs_cursort = 
		Desktop = .F.
		DoCreate = .T.
		Height = 493
		lales = .F.
		Name = "cauta_alfa_form_gs"
		primacoloana = 
		Width = 348
		WindowType = 1
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 348
		_shape1.ZOrderSet = 1
		_shape2.Height = 29
		_shape2.Left = 285
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 63
		_shape2.ZOrderSet = 2
		Lb_titlu_alb_b121.FontName = "Arial Narrow"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 7
		Lb_titlu_alb_b121.ZOrderSet = 3
		BUT_TERMIN1.Left = 318
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 4
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_commandbutton2' AS _commandbutton WITH ;
		Caption = "\<Nou", ;
		Comment = "*:OnResize=LT", ;
		Left = 132, ;
		Name = "_commandbutton2", ;
		TabIndex = 6, ;
		Top = 456, ;
		Visible = .F., ;
		ZOrderSet = 7
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_nou1' AS but_nou WITH ;
		Left = 300, ;
		Name = "But_nou1", ;
		Top = 456, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'Ct_grid_search1' AS ct_grid_search WITH ;
		Left = 11, ;
		Name = "Ct_grid_search1", ;
		Top = 36, ;
		ZOrderSet = 0, ;
		_GRID1.Name = "_GRID1", ;
		Titlu.Name = "Titlu", ;
		Cb_tx_cautare1.Criteriu.Name = "Criteriu", ;
		Cb_tx_cautare1.Name = "Cb_tx_cautare1", ;
		Cb_tx_cautare1.Text.Name = "Text"
		*< END OBJECT: ClassLib="ferestre_cere_date.vcx" BaseClass="container" />
	
	PROCEDURE do_adauga
		If Thisform.but_nou1.Visible
			Select (Thisform.ct_grid_search1.cnumecursor)
			Scatter Name poRec Blank
			lcname = Thisform.cnume_proc
			Do &lcname In onomenclatoare.prg
			Thisform.do_cauta
		Endif
		
	ENDPROC

	PROCEDURE Init
		Lparameters tcCursor, tcNume_Proc, tcTitlu , tcTitluColoane, tcNumeColoane, tcSelect, tcSchema, tcFiltru, tcFiltruOriginal, tcOrder, tl_AllInList, tnPornire, toValoarePropusa
		Thisform.lb_titlu_alb_b121.Caption=tcTitlu
		Thisform.cnume_proc = tcNume_Proc
		Thisform.ll_allinlist = tl_AllInList
		If Empty(tcNume_Proc)
			Thisform.But_nou1.Enabled=.F.
			Thisform.But_nou1.Visible=.F.
		Endif
		**miscarefereastra:
		DoDefault()
		lnNrCols = Occurs(",",tcTitluColoana) + 1
		
		This.cnume_proc = tcNume_Proc
		If !Empty(tnPornire)
			This.cPornire = Alltrim(Str(tnPornire))
		Else
			This.cPornire = "1"
		Endif
		
		With Thisform.ct_grid_search1
			.cnumecursor = tcCursor
			.cSelect = tcSelect
			.cSchema = tcSchema
			.cFiltru = tcFiltru
			.cFiltruOriginal = tcFiltruOriginal
			.cTitlu = tcTitlu
			.corder = tcOrder
			.cnume_coloane = tcNumeColoane
			.ctitlu_coloane = tcTitluColoane
		Endwith
		
		Thisform.ct_grid_search1.initializare(.T.)
		
		Thisform.ct_grid_search1.Cb_tx_cautare1.criteriu.Init
		
		If !Empty(toValoarePropusa)
			Thisform.ct_grid_search1.cb_tx_cautare1.Text.Value = toValoarePropusa
		Endif
	ENDPROC

	PROCEDURE KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		lcControl = Upper(Alltrim(This.ActiveControl.Name))
		lcCursor = This.ct_grid_search1._GRID1.RecordSource
		
		Do Case
		Case nKeyCode = 13 And lcControl = '_GRID1' && enter
			Nodefault
			This.buT_TERMIN1.SetFocus()
		
		Case nKeyCode = 13 And lcControl = 'TEXT' && enter
			Nodefault
			With This.ct_grid_search1
				If Reccount(lcCursor)==0 Or .cb_tx_cautare1.Text.ReadOnly=.F. Or !Empty(.cb_tx_cautare1.Text.Value)
					.do_cauta()
				Endif
				._GRID1.SetFocus()
			Endwith
		
		Case nKeyCode = 9 And lcControl = 'TEXT' && tab
			Nodefault
			This.ct_grid_search1._GRID1.SetFocus()
		
		Case (nKeyCode >=33 And nKeyCode <=122) And (lcControl <> 'TEXT')
			Nodefault
			With This.ct_grid_search1.cb_tx_cautare1
				.Text.Value = Alltrim(.Text.Value) + Chr(nKeyCode)
				.SetFocus()
			Endwith
			Keyboard '{END}'
		
		Case (nKeyCode = 127) And (lcControl <> 'TEXT') && backspace
			Nodefault
			With This.ct_grid_search1.cb_tx_cautare1
				.Text.Value = Left(Alltrim(.Text.Value),Len(Alltrim(.Text.Value))-1)
				.SetFocus()
			Endwith
			Keyboard '{END}'
		Otherwise
			DoDefault(nKeyCode, nShiftAltCtrl)
		Endcase
	ENDPROC

	PROCEDURE Unload
		RETURN this.cAles 
	ENDPROC

	PROCEDURE _commandbutton2.Click
		
		lcname = thisform.cnume_proc 
		DO &lcname IN onomenclatoare.prg 
		
		thisform.do_cauta 
		
		
	ENDPROC

ENDDEFINE

DEFINE CLASS cauta_alfa_form_plus 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="_GRID1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_start_criterii1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbSelecteaza" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_verifica1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_copiaza1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_alege
		*p: cales
		*p: cfiltru_original
		*p: cidcolumn
		*p: cnume_proc
		*p: cpornire
		*p: cproceduracopiaza
		*p: cproceduraverifica
		*p: crs_cursor
		*p: crs_cursort
		*p: cstringcriterii		&& string criterii pentru butonul de cautare
		*p: lales
		*p: ll_allinlist
		*p: primacoloana
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 3
		cales = 
		cfiltru_original = 2=2
		cgridsortlist = _grid1
		cidcolumn = 
		cnume_proc = 
		cpornire = 0
		cproceduracopiaza = 
		cproceduraverifica = 
		crs_cursor = 
		crs_cursort = 
		cstringcriterii = 
		Desktop = .F.
		DoCreate = .T.
		Height = 331
		lales = .F.
		Name = "cauta_alfa_form_plus"
		primacoloana = 
		Width = 707
		WindowType = 1
		_memberdata = <VFPData>
			<memberdata name="cstringcriterii" type="property" display="cStringCriterii"/>
			<memberdata name="cproceduracopiaza" display="cProceduraCopiaza"/>
			<memberdata name="cproceduraverifica" display="cProceduraVerifica"/>
		</VFPData>
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 708
		_shape2.Height = 29
		_shape2.Left = 660
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 63
		Lb_titlu_alb_b121.FontName = "Arial Narrow"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 7
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 676
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 0
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_GRID1' AS _grid WITH ;
		Anchor = 15, ;
		ColumnCount = -1, ;
		DeleteMark = .F., ;
		Height = 273, ;
		Left = 5, ;
		Name = "_GRID1", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordMark = .T., ;
		RecordSource = "cursor_curent", ;
		TabIndex = 3, ;
		Top = 51, ;
		Width = 691
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="grid" />

	ADD OBJECT 'But_copiaza1' AS but_copiaza WITH ;
		Anchor = 8, ;
		Left = 552, ;
		Name = "But_copiaza1", ;
		Top = 0
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

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

	ADD OBJECT 'But_start_criterii1' AS but_start_criterii WITH ;
		Anchor = 9, ;
		Comment = "*:OnResize=RT", ;
		Left = 614, ;
		Name = "But_start_criterii1", ;
		Top = 0
		*< END OBJECT: ClassLib="ocriterii.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_verifica1' AS but_verifica WITH ;
		Anchor = 8, ;
		Left = 582, ;
		Name = "But_verifica1", ;
		TabIndex = 14, ;
		ToolTipText = "Validare cod", ;
		Top = 0
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'lbSelecteaza' AS _lbbase WITH ;
		AutoSize = .T., ;
		Caption = "Selecteaza tot", ;
		FontBold = .T., ;
		FontUnderline = .T., ;
		ForeColor = 0,64,128, ;
		Left = 7, ;
		Name = "lbSelecteaza", ;
		Top = 33
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />
	
	PROCEDURE actualizeaza_grid1
		LPARAMETERS pcFiltru
		LOCAL lcToolTip
		LOCAL lcFiltru, lcCamp
		LOCAL lcCursor, lcCursort
		lcCursor = this.crs_cursor 
		lcCursort = this.crs_cursort 
		
		lcCamp = ' '
		lcFiltru=pcFiltru
		IF EMPTY(lcFiltru)
			lcFiltru=deca_baza1.ca_baza1.cfiltru
		ENDIF
		
		lcListaId = ""
		IF this.lAles
			lcIdColumn = this.cIdcolumn 
			SELECT &lcIdColumn FROM (lcCursor) WITH (BUFFERING = .T.) WHERE SUBSTR(this.cAles,RECNO(),1) = 'X' INTO CURSOR crsListaId 
			lcListaId = cursor2lista("crsListaId",lcIdColumn,",")
			USE IN crsListaId
			
			IF !EMPTY(lcListaId)
				lcFiltru = "((" + lcFiltru + ") OR (" + lcIdColumn + " IN (" + lcListaId + ")))"
			ENDIF 	
		ENDIF 
		
		
		lcToolTip = this._grid1.ToolTipText 
		save_grid(This._grid1)
		deca_baza1.ca_baza1.cfiltru=lcfiltru
		deca_baza1.ca_baza1.afisare()
		
		IF this.lAles
			IF !EMPTY(lcListaId)
				this.cAles = ""
				SELECT (lcCursor)
				SCAN
					lcValue = TRANSFORM(&lcIdColumn)
					IF lcValue$lcListaId
						this.cAles = this.cAles + "X"
					ELSE 
						this.cAles = this.cAles + " "	
					ENDIF 	
				ENDSCAN 
				GO TOP 
			ELSE 
				this.cAles = REPLICATE(" ",Reccount(lcCursor))		
			ENDIF 
		ENDIF 	
		
		IF (this.ll_allinlist)
			*SELECT * from cursor_temp INTO CURSOR cursor_curent WHERE .F. readwrite 
			SELECT * FROM &lccursort INTO CURSOR &lccursor WHERE .F. READWRITE 
			*SELECT cursor_curent
			SELECT (lccursor)
			IF OCCURS([,],tccoloana) > 0
				lcField = LEFT(tccoloana,AT([,],tccoloana)-1)
				lcCamp = lccursort + '.' + lcfield
				*IF TYPE('cursor_temp.&lcField')# 'C'
				IF TYPE(lcCamp) # 'C'
					lcfield = FIELD(1)
				ENDIF 
			ELSE 
				lcField = tccoloana
				lcCamp = lccursort + '.' + lcfield
			ENDIF 
			*IF TYPE('cursor_temp.&lcField')= 'C'
			IF TYPE(lcCamp) = 'C'
				INSERT INTO (lcCursor) (&lcfield) values("<TOATE INREGISTRARILE>")
			ENDIF 
			*SELECT cursor_curent
			SELECT (lccursor)
			*APPEND FROM DBF("cursor_temp")
			APPEND FROM DBF(lccursort)
			*USE IN cursor_temp 
			USE IN (lccursort)
		ENDIF 
		restore_grid(This._grid1)
		this._grid1.ToolTipText = lcToolTip
	ENDPROC

	PROCEDURE do_adauga
		If Thisform.but_nou1.Visible
			Select (This._GRID1.RecordSource)
			Scatter Name poRec Blank
			lcname = Thisform.cnume_proc
		*	Do &lcname In onomenclatoare.prg
			IF !EMPTY(lcName)
				lcRun = [do ] + lcName + [ in onomenclatoare.prg]
				&lcRun
			ENDIF 	
			Thisform.do_cauta
		Endif
		
	ENDPROC

	PROCEDURE do_alege
		Lparameters tnSelecteazaToate && 0/.F. DEFAULT O INREGISTRARE, 1 = SELECTEAZA TOT, 2 = DESELECTEAZA TOT
		
		Local lnSelecteazaToate
		If Pcount() = 0 Or Type('tnSelecteazaToate') <> 'N'
			lnSelecteazaToate = 0
		Else
			lnSelecteazaToate = tnSelecteazaToate
		Endif
		If Thisform.lAles
			lcCursor = Thisform._GRID1.RecordSource
			lnRecno = Recno(lcCursor)
			Do Case
				Case lnSelecteazaToate = 0 && selectez/deselectez inregistrarea curenta
					If Substr(Thisform.cAles, lnRecno,1) = ' '
						lcReplacement = 'X'
					Else
						lcReplacement = ' '
					Endif
					Thisform.cAles = Left(Thisform.cAles,lnRecno - 1) + lcReplacement + Substr(Thisform.cAles, lnRecno + 1)
				Case lnSelecteazaToate = 1 && selecteaza tot
					Thisform.cAles = REPLICATE('X', LEN(thisform.cAles))
				Otherwise 	&& deselecteaza tot
					Thisform.cAles = REPLICATE(' ', LEN(thisform.cAles))
			Endcase
		
			pcAles = Thisform.cAles
			Thisform._GRID1.Refresh()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta
		*!* 19.12.2011
		*!* marius.mutu
		*!* lcvar = field(1) in loc de thisform.primacoloana
		
		Private lcfiltru,lcval1
		lcfiltru = ''
		LOCAL lcCursor, lcCursort
		lcCursor = this.crs_cursor
		lcCursort = this.crs_cursort
		
		lcColoana = ALLTRIM(this.primacoloana)
		*!*	With Thisform.cb_tx_cautare1
		*!*		lcval1=Strtran(Alltrim(Upper(.Text.Value)),['],[''])
		*!*		Do Case
		*!*		Case .criteriu.Value = "1" And !Empty(.Text.Value)
		*!*			lcfiltru = Alltrim(Upper(lcColoana)) + [ LIKE '] + lcval1 + [%']
		*!*		Case .criteriu.Value = "2" And !Empty(.Text.Value)
		*!*			lcfiltru = Alltrim(Upper(lcColoana)) + [ ='] + lcval1 + [']
		*!*		Case .criteriu.Value = "3" And !Empty(.Text.Value)
		*!*			lcfiltru = Alltrim(Upper(lcColoana)) + [ !='] + lcval1 + [']
		*!*		Case .criteriu.Value = "4" And !Empty(.Text.Value)
		*!*			lcfiltru = Alltrim(Upper(lcColoana)) + [ LIKE '%] + lcval1 + [%']
		*!*		Case .criteriu.Value = "5" And !Empty(.Text.Value)
		*!*			lcfiltru = Alltrim(Upper(lcColoana)) + [ NOT LIKE '%] + lcval1 + [%']
		*!*		Case .criteriu.Value = "6"
		*!*			lcfiltru = [2=2]
		*!*		Endcase
		*!*	Endwith
		
		*!*	IF ALLTRIM(lcval1) = [%]
		*!*		lcfiltru = [2=2]
		*!*	ENDIF
		
		*!*	If Empty(lcfiltru)
		*!*		aMessagebox("Alegeti un criteriu!",0+48,"Atentie")
		*!*		Thisform.cb_tx_cautare1.criteriu.SetFocus()
		*!*		Return
		*!*	Endif
		lcfiltru = This.cfiltru_original
		
		&& filtru pretty
		If Len(Thisform.filtru_pretty)>0
			filtrutext = Thisform.filtru_pretty
			lcfiltru = lcfiltru+" and ("+Alltrim(filtrutext)+")"
		Endif
		
		If This.filtru_pretty#"none"
			Thisform.actualizeaza_grid1(lcfiltru)
		
			Select (lccursor)
			*Select cursor_curent
			Go Top
			*If (Reccount('cursor_curent')=0)
			If (Reccount(lccursor)=0)
				aMessagebox("Nu exista rezultate!",0+48,"Atentie")
				Thisform.cb_tx_cautare1.critERIU.SetFocus()
			Else
				Go Top
				*!* 19.12.2011
		*!*		lcvar = ALLTRIM(IIF(AT('.',lcColoana)=0,lcColoana, SUBSTR(lcColoana,AT('.',lcColoana)+1)))	
				lcVar = FIELD(1)
				*!* 19.12.2011 ^
				lcFirstInList = &lcvar
				If Type([lcFirstInList]) = 'C' And (Reccount(lccursor)>1 And Alltrim(lcFirstInList)=='<TOATE INREGISTRARILE>')
					*IF (Reccount('cursor_curent')>1 AND ALLTRIM(lcFirstInList)=='<TOATE INREGISTRARILE>')
					Goto 2
				ENDIF
				this._grID1.AutoFit()
				Thisform._GRID1.SetFocus()
			Endif
		Endif
		
	ENDPROC

	PROCEDURE do_copiaza
		Local lcName, lcRun, loRec
		If Thisform.but_copiaza1.Visible
			Select (This._GRID1.RecordSource)
			Scatter Name loRec
			lcName = Thisform.cProceduraCopiaza
			If !Empty(m.lcName)
				lcRun = [do ] + lcName + [ with m.loRec in onomenclatoare.prg]
				&lcRun
			Endif
		Endif
		  
	ENDPROC

	PROCEDURE do_verifica
		Local lcName, lcRun, loRec
		If Thisform.but_verifica1.Visible
			Select (This._GRID1.RecordSource)
			Scatter Name loRec
			lcName = Thisform.cProceduraVerifica
			If !Empty(m.lcName)
				lcRun = [do ] + lcName + [ with m.loRec in onomenclatoare.prg]
				&lcRun
			Endif
		Endif
		  
	ENDPROC

	PROCEDURE Init
		Lparameters tcCursor, tcNume_Proc, tcTitluColoana, tccoloana, tl_AllInList, tcPrimaColoana, tnPornire, ;
			tcGridDynamicBackColor, tcGridToolTip, tcStringCriterii, ;
			tcProceduraVerifica, tcProceduraCopiaza
			
		DoDefault()
		
		This._GRID1.RecordSource = tcCursor
		This.cnume_proc = tcNume_Proc
		This.ll_allinlist = tl_AllInList
		this.cStringCriterii = IIF(TYPE('tcStringCriterii') = 'C', tcStringCriterii, "")
		
		If Empty(tcNume_Proc)
			Thisform.But_nou1.Enabled=.F.
			Thisform.But_nou1.Visible=.F.
		Endif
		If Empty(tcProceduraVerifica)
			Thisform.but_verifica1.Enabled=.F.
			Thisform.but_verifica1.Visible=.F.
		ENDIF
		If Empty(tcProceduraCopiaza)
			Thisform.but_copiaza1.Enabled=.F.
			Thisform.but_copiaza1.Visible=.F.
		ENDIF
		
		lnNrCols = Occurs(",",tcTitluColoana) + 1
		
		**ajustare width coloana grid:
		This.cnume_proc = tcNume_Proc
		this.cProceduraCopiaza = m.tcProceduraCopiaza
		this.cProceduraVerifica = m.tcProceduraVerifica
		
		This._GRID1.ColumnCount = lnNrCols
		If lnNrCols > 1
			This._GRID1.coLUMN1.Width = This._GRID1.coLUMN1.Width - (This._GRID1.coLUMN1.Width/2)
		Endif
		
		tcTitluColoana = "," + tcTitluColoana + ","
		For i=1 To lnNrCols
			lcheader = [this._GRID1.coLUMN] + Alltrim(Str(i))+ [.hEADER1.Caption = PROPER(LEFT( SUBSTR(tcTitluColoana,AT(",",tcTitluColoana,i)+1),AT(",",tcTitluColoana,i+1)-AT(",",tcTitluColoana,i)-1))]
			&lcheader
		Endfor
		
		tccoloana = "," + tccoloana + ","
		For i=1 To lnNrCols
			lcControlSource = [this._GRID1.coLUMN] + Alltrim(Str(i))+ [.ControlSource = PROPER(LEFT( SUBSTR(tcColoana,AT(",",tcColoana,i)+1),AT(",",tcColoana,i+1)-AT(",",tcColoana,i)-1))]
			&lcControlSource
		Endfor
		
		&& dupa care se face filtru:
		If Empty(tcPrimaColoana)
			This.primacoloana = Proper(Left( Substr(tccoloana,At(",",tccoloana,1)+1),At(",",tccoloana,1+1)-At(",",tccoloana,1)-1))
		Else
			This.primacoloana = tcPrimaColoana
		Endif
		
		*!*	If !Empty(tnPornire)
		*!*		This.cPornire = Alltrim(Str(tnPornire))
		*!*	Else
		*!*		This.cPornire = "1"
		*!*	Endif
		*!*	modificare 06.12.2006
		*!*	Thisform.cb_tx_cautare1.do_initializeaza_ct(Thisform.cPornire)
		*!*	modificare 06.12.2006	^
		
		&& setez DynamicBackColor
		This._GRID1.SetAll("dynamicbackcolor","iif(SUBSTR(thisform.cAles,RECNO(),1)='X',RGB(106,181,255), RGB(255,255,255))","Column")
		If Type('tcGridDynamicBackColor') = 'C' And !Empty(tcGridDynamicBackColor)
			This._GRID1.SetAll("DynamicBackColor", tcGridDynamicBackColor, "Column")
		Endif
		
		If Type('tcGridToolTip') = 'C' And !Empty(tcGridToolTip)
			This._GRID1.ToolTipText = tcGridToolTip
		Endif
		
		
	ENDPROC

	PROCEDURE KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl
		lcControl = UPPER(ALLTRIM(THIS.ACTIVECONTROL.NAME))
		LOCAL lcCursor, lcCursort
		lcCursor = THIS.crs_cursor
		lcCursort = THIS.crs_cursort
		
		**verificare:
		*!*	MESSAGEBOX("control:"+lcControl+" "+STR(nKeyCode))
		DO CASE
			CASE nKeyCode = 32 AND lcControl = '_GRID1' && space
				thisform.do_alege()
			CASE nKeyCode = 13 AND lcControl = '_GRID1' && enter
				NODEFAULT
				THIS.buT_TERMIN1.SETFOCUS
				*!* DACA APAS SAGEATA JOS SAU SUS SA SE DESCHIDA LISTA
		*!*		CASE INLIST(nKeyCode,5, 24) AND lcControl = 'CRITERIU'&& UPARROW, DNARROW
		*!*			KEYBOARD '{ALT+DNARROW}'
			CASE nKeyCode = 13 AND lcControl = 'TEXT' && enter
				NODEFAULT
				*If Reccount('cursor_curent')==0 Or This.cb_tx_cautare1.Text.ReadOnly=.F. Or !Empty(This.cb_tx_cautare1.Text.Value)
				*!*	If Reccount(lcCursor)==0 Or This.cb_tx_cautare1.Text.ReadOnly=.F. Or !Empty(This.cb_tx_cautare1.Text.Value)
		*!*			IF RECCOUNT(lcCursor)<> 0 OR THIS.cb_tx_cautare1.TEXT.READONLY OR !EMPTY(THIS.cb_tx_cautare1.TEXT.VALUE)
		*!*				&& daca exista inregistrari sau vreau toate inregistrarile sau este completat textul de cautare
		*!*				THIS.do_cauta()
		*!*				THIS._GRID1.SETFOCUS
		*!*			ELSE
					&& sare pe terminat daca dau enter in textbox si nu am scris nimic
					NODEFAULT
					THIS.buT_TERMIN1.SETFOCUS
		*!*			ENDIF
		
			CASE nKeyCode = 9 AND lcControl = 'TEXT' && tab
				NODEFAULT
				THIS._GRID1.SETFOCUS
		
		*!*		CASE (nKeyCode >=33 AND nKeyCode <=122) AND (lcControl <> 'TEXT')
		*!*			NODEFAULT
		*!*			THIS.cb_tx_cautare1.TEXT.VALUE = ALLTRIM(THIS.cb_tx_cautare1.TEXT.VALUE) + CHR(nKeyCode)
		*!*			THIS.cb_tx_cautare1.SETFOCUS
		*!*			KEYBOARD '{END}'
		
		*!*		CASE (nKeyCode = 127) AND (lcControl <> 'TEXT') && backspace
		*!*			NODEFAULT
		*!*			THIS.cb_tx_cautare1.TEXT.VALUE = LEFT(ALLTRIM(THIS.cb_tx_cautare1.TEXT.VALUE),LEN(ALLTRIM(THIS.cb_tx_cautare1.TEXT.VALUE))-1)
		*!*			THIS.cb_tx_cautare1.SETFOCUS
		*!*			KEYBOARD '{END}'
		
			OTHERWISE
				DODEFAULT(nKeyCode, nShiftAltCtrl)
		ENDCASE
		
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		DODEFAULT(nStyle)
		
		*!*	24.07.2009
		Local loGrid, loColumnTexti
		loGrid = Thisform._GRID1
		For i = 1 To loGrid.ColumnCount
			loColumnTexti= loGrid.Columns(i).text1
			If !Thisform.lales
				Bindevent(loColumnTexti,"dblClick",This,"do_termin")
			ELSE 
				Bindevent(loColumnTexti,"Click",This,"do_alege")
			Endif
		Endfor
		*!*	24.07.2009
		
	ENDPROC

	PROCEDURE Unload
		RETURN this.cAles 
	ENDPROC

	PROCEDURE But_start_criterii1.loadcriterii
		PARAMETERS tacriterii
		EXTERNAL ARRAY tacriterii
		#DEFINE crlf CHR(13)+CHR(10)
		PRIVATE lcStringCriterii
		lcStringCriterii = thisform.cStringCriterii
		*!*	lcStringCriterii="Cod material\codmat\T\none\" + crlf + ;
		*!*		"Denumire articol\denumire\T\id_articol\nom_articol"+ crlf + ;
		*!*		"Subgrupa articol\none\I\id_subgrupa\nom_subgrupa_articol"+ crlf
		
		DODEFAULT()
		
	ENDPROC

	PROCEDURE lbSelecteaza.Click
		Local lnSelecteazaToate
		
		lnSelecteazaToate = Iif(This.Caption = 'Selecteaza tot', 1, 2)
		thisform.do_alege(lnSelecteazaToate)
		
		If This.Caption = 'Selecteaza tot'
			This.Caption = 'Deselecteaza tot'
		Else
			This.Caption = 'Selecteaza tot'
		Endif
		
		This.Refresh()
	ENDPROC

ENDDEFINE

DEFINE CLASS cauta_alfa_form_vfp 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="_GRID1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_GRID1.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_cauta1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cb_tx_cautare1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*p: cfiltru_original
		*p: cnume_proc
		*p: cpornire
		*p: ll_allinlist
		*p: primacoloana
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cfiltru_original = 2=2
		cnume_proc = 
		cpornire = 
		DoCreate = .T.
		Height = 331
		Name = "cauta_alfa_form_vfp"
		primacoloana = 
		Width = 435
		WindowType = 1
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 432
		_shape2.Height = 29
		_shape2.Left = 371
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 63
		Lb_titlu_alb_b121.FontName = "Arial Narrow"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 7
		BUT_TERMIN1.Left = 405
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_GRID1' AS _grid WITH ;
		ColumnCount = 4, ;
		DeleteMark = .F., ;
		Height = 217, ;
		Left = 5, ;
		Name = "_GRID1", ;
		Panel = 1, ;
		RecordMark = .F., ;
		RecordSource = "cursor_curent", ;
		TabIndex = 3, ;
		Top = 76, ;
		Width = 427, ;
		Column1.ControlSource = "", ;
		Column1.Name = "Column1", ;
		Column1.Width = 403, ;
		Column2.Name = "Column2", ;
		Column3.Name = "Column3", ;
		Column4.Name = "Column4"
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="grid" />

	ADD OBJECT '_GRID1.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Header1", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_GRID1.Column1.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_GRID1.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Header1", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_GRID1.Column2.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_GRID1.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Header1", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_GRID1.Column3.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_GRID1.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Header1", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_GRID1.Column4.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

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

	ADD OBJECT 'Cb_tx_cautare1' AS cb_tx_cautare WITH ;
		Left = 25, ;
		Name = "Cb_tx_cautare1", ;
		TabIndex = 1, ;
		Top = 45, ;
		Text.Format = "!", ;
		Text.Name = "Text", ;
		Text.TabIndex = 2, ;
		Criteriu.Name = "Criteriu", ;
		Criteriu.TabIndex = 1
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Cmd_cauta1' AS cmd_cauta WITH ;
		Left = 332, ;
		Name = "Cmd_cauta1", ;
		TabIndex = 2, ;
		Top = 45
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />
	
	PROCEDURE actualizeaza_grid1
		Lparameters pcFiltru
		Local lcFiltru
		lcFiltru=pcFiltru
		Select cursor_curent
		Set Filter To &lcFiltru
	ENDPROC

	PROCEDURE do_cauta
		Private lcfiltru,lcval1,lctip
		lcfiltru=''
		lcColoana = Alltrim(This.primacoloana)
		lctip = Type(This._gRID1.RecordSource+[.]+This.primacoloana)	&&	modificare	14.10.2011
		With Thisform.cb_tx_cautare1
			*!*	modificare	14.10.2011
			If Inlist(lctip,[D],[T],[N])
				Do Case
					Case lctip = [N]
						lcval1 = Alltrim(Str(.Text.Value))
					Case lctip = [T]
						lcval1 = [CTOT(']+Ttoc(.Text.Value) + [')]
					Otherwise
						lcval1 = [CTOD(']+Dtoc(.Text.Value) + [')]
				Endcase
				Do Case
					Case .criteriu.Value = "1"		&&	egala
						lcfiltru = Alltrim(Upper(lcColoana)) + [ =] + lcval1 + []
					Case .criteriu.Value = "2"		&&	diferita
						lcfiltru = Alltrim(Upper(lcColoana)) + [ !=] + lcval1 + []
					Case .criteriu.Value = "3"		&&	mai mare
						lcfiltru = Alltrim(Upper(lcColoana)) + [ >] + lcval1 + []
					Case .criteriu.Value = "4"		&&	mai mica
						lcfiltru = Alltrim(Upper(lcColoana)) + [ <] + lcval1 + []
					Case .criteriu.Value = "5"		&&	mai mare sau egala
						lcfiltru = Alltrim(Upper(lcColoana)) + [ >=] + lcval1 + []
					Case .criteriu.Value = "6"		&&	mai mica sau egala
						lcfiltru = Alltrim(Upper(lcColoana)) + [ <=] + lcval1 + []
				Endcase
			Else
				*!*	modificare	14.10.2011	^
				lcval1=Strtran(Alltrim(Upper(.Text.Value)),['],[''])
				Do Case
					Case .criteriu.Value = "1" And !Empty(.Text.Value)
						lcfiltru = [ LIKE('] + lcval1 + [*',]+Alltrim(Upper(lcColoana))+[)]
					Case .criteriu.Value = "2" And !Empty(.Text.Value)
						lcfiltru = Alltrim(Upper(lcColoana)) + [ ='] + lcval1 + [']
					Case .criteriu.Value = "3" And !Empty(.Text.Value)
						lcfiltru = Alltrim(Upper(lcColoana)) + [ !='] + lcval1 + [']
					Case .criteriu.Value = "4" And !Empty(.Text.Value)
						lcfiltru = [ LIKE('*] + lcval1 + [*',]+Alltrim(Upper(lcColoana))+[)]
					Case .criteriu.Value = "5" And !Empty(.Text.Value)
						lcfiltru = [ !LIKE('*] + lcval1 + [*',]+Alltrim(Upper(lcColoana))+[)]
					Case .criteriu.Value = "6"
						lcfiltru = [2=2]
				Endcase
				If Alltrim(lcval1) = [%]
					lcfiltru = [2=2]
				Endif
				*!*	modificare	14.10.2011
			Endif
			*!*	modificare	14.10.2011	^
		Endwith
		
		If Empty(lcfiltru)
			aMessagebox("Alegeti un criteriu!",0+48,"Atentie")
			Thisform.cb_tx_cautare1.criteriu.SetFocus()
			Return
		Endif
		
		lcfiltru = This.cfiltru_original + [ and ] + lcfiltru
		
		Thisform.actualizeaza_grid1(lcfiltru)
		Select cursor_curent
		Go Top
		If (Reccount('cursor_curent')=0)
			aMessagebox("Nu exista rezultate!",0+48,"Atentie")
			Thisform.cb_tx_cautare1.criteriu.SetFocus()
		Else
			Go Top
			If Type(lcColoana)='C'
				lcFirstInList = &lcColoana
				If (Reccount('cursor_curent')>1 And Alltrim(lcFirstInList)=='<TOATE INREGISTRARILE>')
					Goto 2
				Endif
			Endif
			Thisform._gRID1.SetFocus()
		Endif
	ENDPROC

	PROCEDURE Init
		Lparameters tcNume_Proc,tcTitluColoana,tccoloana,tl_AllInList,tnPornire,tcFiltruAfisat
		This.cnume_proc = tcNume_Proc
		This.ll_allinlist = tl_AllInList
		**miscarefereastra:
		DoDefault()
		lnNrCols = Occurs(",",tcTitluColoana) + 1
		
		**ajustare width coloana grid:
		This.cnume_proc = tcNume_Proc
		This._GRID1.ColumnCount = lnNrCols
		If lnNrCols > 1
			This._GRID1.coLUMN1.Width = This._GRID1.coLUMN1.Width - (This._GRID1.coLUMN1.Width/2)
		Endif
		
		*!*	modificare 22.01.2007
		If !Empty(tnPornire)
			This.cPornire = Alltrim(Str(tnPornire))
		Else
			This.cPornire = "1"
		Endif
		*!*	modificare	14.10.2011	:	am mutat-o mai jos
		*!*	thisform.cb_tx_cautare1.do_initializeaza_ct(Thisform.cPornire)
		*!*	modificare	14.10.2011	^
		*!*	modificare 22.01.2007	^
		
		tcTitluColoana = "," + tcTitluColoana + ","
		For i=1 To lnNrCols
			lcheader = [this._GRID1.coLUMN] + Alltrim(Str(i))+ [.hEADER1.Caption = PROPER(LEFT( SUBSTR(tcTitluColoana,AT(",",tcTitluColoana,i)+1),AT(",",tcTitluColoana,i+1)-AT(",",tcTitluColoana,i)-1))]
			&lcheader
		Endfor
		
		tcColoana = "," + tcColoana + ","
		For i=1 To lnNrCols
			lcControlSource = [this._GRID1.coLUMN] + Alltrim(Str(i))+ [.ControlSource = PROPER(LEFT( SUBSTR(tcColoana,AT(",",tcColoana,i)+1),AT(",",tcColoana,i+1)-AT(",",tcColoana,i)-1))]
			&lcControlSource
		Endfor
		
		&& dupa care se face filtru:
		this.primacoloana = PROPER(LEFT( SUBSTR(tcColoana,AT(",",tcColoana,1)+1),AT(",",tcColoana,1+1)-AT(",",tcColoana,1)-1))
		*!*	modificare	14.10.2011
		thisform.cb_tx_cautare1.do_initializeaza_ct(Thisform.cPornire,TYPE([cursor_curent.]+this.primacoloana))
		*!*	modificare	14.10.2011	^
		*!*	modificare	04.08.2011
		If !Empty(tcFiltruAfisat)
			Thisform.cb_tx_cautare1.text.Value = tcFiltruAfisat
			Thisform.cmd_CAUTA1.Click()
		Endif
		*!*	modificare	04.08.2011	^
	ENDPROC

	PROCEDURE KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		lcControl = Upper(Alltrim(This.ActiveControl.Name))
		
		
		**verificare:
		**MESSAGEBOX("control:"+lcControl+" "+STR(nKeyCode))
		DO case
		case nKeyCode = 13 And lcControl = '_GRID1' && enter
			Nodefault
			This.buT_TERMIN1.SetFocus
		
		case nKeyCode = 13 And lcControl = 'TEXT' && enter
			Nodefault
			If Reccount('cursor_curent')==0 Or This.cb_tx_cautare1.Text.ReadOnly=.F. Or !Empty(This.cb_tx_cautare1.Text.Value)
				This.do_cauta
			Endif
			This._GRID1.SetFocus
		
		case nKeyCode = 9 And lcControl = 'TEXT' && tab
			Nodefault
			This._GRID1.SetFocus
		
		case (nKeyCode >=33 And nKeyCode <=122) And (lcControl <> 'TEXT')
			Nodefault
			This.cb_tx_cautare1.Text.Value = Alltrim(This.cb_tx_cautare1.Text.Value) + Chr(nKeyCode)
			This.cb_tx_cautare1.SetFocus
			Keyboard '{END}'
		
		case (nKeyCode = 127) And (lcControl <> 'TEXT') && backspace
			Nodefault
			This.cb_tx_cautare1.Text.Value = Left(Alltrim(This.cb_tx_cautare1.Text.Value),Len(Alltrim(This.cb_tx_cautare1.Text.Value))-1)
			This.cb_tx_cautare1.SetFocus
			Keyboard '{END}'
		
		otherwise
			DoDefault(nKeyCode, nShiftAltCtrl)
		Endcase
		
	ENDPROC

ENDDEFINE
