************************************************************************************
Procedure CAUT_ALF
Parameters NUMEBAZA,NUMECIMP,CAPTEXT,VARMEM
Local MC0,MC1,MC2
Set Safety Off
MC0='SELE '+NUMEBAZA
MC1='VARMEM=M.'+NUMECIMP
MC2='SET order TO TAG '+NUMECIMP

&MC0
Go Top
If Eof()
	Appe Blank
Endif
&MC2
OCA=Createobject("CAUTALF")
OCA.Caption=CAPTEXT
OCA.GRID1.RecordSource=NUMEBAZA
OCA.GRID1.COLUMN1.ControlSource=NUMECIMP
OCA.Show(1)

Scatter Memvar
&MC1

Return
************************************************************************************
Procedure CAUT_ALFa
Parameters NUMEBAZA,NUMECIMP,CAPTEXT,VARMEM
Local MC0,MC1,MC2
Set Safety Off
MC0='SELE '+NUMEBAZA
MC1='VARMEM=M.'+NUMECIMP
MC2='SET order TO TAG '+NUMECIMP

&MC0

Go Top
If Eof()
	Appe Blank
Endif

&MC2
OCA=Createobject("CAUTALFa")
OCA.Caption=CAPTEXT
OCA.GRID1.RecordSource=NUMEBAZA
OCA.GRID1.COLUMN1.ControlSource=NUMECIMP
OCA.cmdrenunt1.Visible=.T.
OCA.Show(1)

Scatter Memvar
&MC1

Return
************************************************************************************
Procedure CODARE
Sele COD
If Flock()
	Goto Bottom
*SCATTER MEMVAR
	m.COD=COD+1
	Append Blank
*m.COD=RECNO()
	Gather Memvar
Endif
Unlock
Return
************************************************************************************
Procedure mesaj
Parameters m1,m2
ot=Create('text')
ot.label2.Caption=m1
ot.label3.Caption=m2
ot.Show(1)
Return
************************************************************************************
Procedure mesajval
Parameters m1,m2
ot=Create('textval')
ot.label2.Caption=m1
ot.valoare=m2
ot.Show(1)
Return
************************************************************************************
*!*	Procedure IESIRE
*!*	*close tables
*!*	*close database
*!*	*set defa to &dirgen
*!*	*erase actactan.*
*!*	*erase ?temp.*
*!*	Quit
*!*	Return
*!*	************************************************************************************
*!*	Function e_ultima_luna
*!*	Sele calendar
*!*	Loca For m.NL=NL And m.an=an
*!*	Skip
*!*	If Eof()
*!*		ultima_luna=.T.
*!*		Return .T.
*!*	Else
*!*		ultima_luna=.F.
*!*		Return .F.
*!*	Endif
*!*	************************************************************************************
*!*	Procedure danu
*!*	Parameters m1
*!*	od=Create('danu')
*!*	od.label1.Caption=m1
*!*	od.Show(1)
*!*	Return
*!*	************************************************************************************
*!*	Procedure danuquit
*!*	Parameters m1
*!*	od=Create('danu')
*!*	od.label1.Caption=m1
*!*	od.Show(1)
*!*	If buton=2
*!*		Quit
*!*	Endif
*!*	Return
************************************************************************************
Procedure nrord
Parameters ALI
Sele &ALI
A=Reccount()
If A=0
	Return
Endif
If A>65000
	Return 0
Endif
Declare NROR(A)
K=0
Scan
	K=K+1
	NROR(K)=Recno()
Endscan
Return
************************************************************************************
Function NRCRT
NR=Ascan(NROR,Recno())
Return NR
************************************************************************************
Procedure inchidprog

Endproc
*!*	Procedure inchidprog
*!*	Local CC,M.NUMESTATIE,UU
*!*	Return
*!*	UU=utilizator

*!*	*IF !FILE('&loc\&nfscurt\tempo\OPTIUNI.DBF')
*!*	*RETURN
*!*	*ENDIF
*!*	If !Used('OPTIUNI')
*!*		Return
*!*	Endif
*!*	*SELE 0
*!*	*USE &loc\&nfscurt\tempo\OPTIUNI SHAR ALIAS OPTIUNI
*!*	Sele OPTIUNI
*!*	Loca For OPTIUNE='RETEA'
*!*	If !Found() Or (Found() And !DA)
*!*		Sele OPTIUNI
*!*		Use
*!*		Return
*!*	Endif
*!*	Sele OPTIUNI
*!*	Use

*!*	If !File('C:\CONTAFIN\TEMP\RETEA.DBF')
*!*		Return
*!*	Endif
*!*	Sele 0
*!*	Use C:\CONTAFIN\TEMP\RETEA Shar Alias RETEA
*!*	m.NUMESTATIE=Allt(NUMESTATIE)
*!*	CC=DIRGEN
*!*	Use

*!*	If File('&DIRGEN\Dateretea\istoric.DBF')
*!*		Sele 0
*!*		Use &DIRGEN\Dateretea\istoric Share Alias istoric
*!*	Else
*!*		Sele 0
*!*		Use &CC\START2000\Data\istoric Share Alias istoric
*!*	Endif

*!*	Sele istoric
*!*	Set Order To DATAORAINT
*!*	Loca For Empty(dataoraies) And Allt(statie)=m.NUMESTATIE And Allt(utilizator)=Allt(UU)
*!*	If Found()
*!*		If Flock()
*!*			Repl dataoraies With Datetime()
*!*			Unlock
*!*		Endif
*!*	Endif
*!*	Sele istoric
*!*	Use


*!*	If File('&DIRGEN\Dateretea\activ.DBF')
*!*		Sele 0
*!*		Use &DIRGEN\Dateretea\Activ Share Alias Activ
*!*	Else
*!*		Sele 0
*!*		Use &CC\START2000\Data\Activ Share Alias Activ
*!*	Endif

*!*	Sele Activ
*!*	Loca For Allt(statie)=m.NUMESTATIE
*!*	If !Found()
*!*		Wait Wind 'Aceasta statie nu este inregistrata in server!'
*!*	Else
*!*		Sele Activ
*!*		If Flock()
*!*			Repl DEVIZE With .F.
*!*		Endif
*!*		Unlock
*!*	Endif
*!*	Sele Activ
*!*	Use


*!*	Return
************************************************************************************
Procedure caut_alfa_cursor
Parameters NUMEBAZA,NUMECIMP,CAPTEXT,VARMEM
Local MC0,MC1,MC2, llVizibil
Set Safety Off
llVizibil = .T.

MC0='SELE '+NUMEBAZA
MC1='VARMEM=M.'+NUMECIMP
*MC2='SET order TO TAG '+NUMECIMP
MC2 = [INDEX ON ] +NUMECIMP+ [ TAG nume OF &loc\&nfscurt\tempo\xindex.idx COMPACT ASCENDING ]


*!*	&MC0
*!*	&MC2
*!*	GO TOP

Local lcNumeCol2
Store '' To lcNumeCol2

LcCol = Alltrim(NUMEBAZA) + '.cod_fiscal'
If Type(LcCol) # 'U'
	lcNumeCol2 = 'cod_fiscal'
Endif

LcCol = Alltrim(NUMEBAZA) + '.gest'
If Type(LcCol) # 'U'
	lcNumeCol2 = 'gest'
Endif

LcCol = Alltrim(NUMEBAZA) + '.id_sectie'
If Type(LcCol) # 'U'
	lcNumeCol2 = 'id_sectie'
Endif

If Empty(lcNumeCol2)
	lcNumeCol2 = 'space(4)'
	llVizibil = .F.
Endif

LcCol = Alltrim(NUMEBAZA) + '.id'
If Type(LcCol) # 'U'
	lcNumeCol3 = 'id'
Else
	lcNumeCol3 = 'space(4)'
Endif

Select Distinct &NUMECIMP, &lcNumeCol2, &lcNumeCol3 From (NUMEBAZA) Into Cursor tnomenclator Readwrite Order By &NUMECIMP

OCA=Createobject("CAUTALFa")
OCA.Caption=CAPTEXT
OCA.GRID1.RecordSource='tnomenclator'
OCA.GRID1.COLUMN1.ControlSource = NUMECIMP
OCA.GRID1.COLUMN2.ControlSource = lcNumeCol2
OCA.GRID1.COLUMN2.Visible = llVizibil
OCA.cmdrenunt1.Visible=.T.
OCA.command1.Visible=.F.
OCA.command2.Visible=.F.
OCA.command3.Visible=.F.
OCA.Show(1)

If buton=2
	Use In tnomenclator
	Return
Endif

lcFile = Addbs(gcTempPath) + 'xindex.idx'
If File(lcFile)
	Set Index To
	Delete File &lcFile
Endif

Select tnomenclator
Scatter Memvar
&MC1

Use In tnomenclator
Return