*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="oconfigcont.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS imob_conturi AS _frmbase OF "..\comun\clase\_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.cAcont.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cAcont.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cCont.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cCont.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cSCD.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cSCD.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cASCD.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cASCD.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cSCC.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cSCC.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cASCC.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cASCC.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cId.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cId.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cSectie.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cSectie.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid1.cSectie._combobox1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Gridextra1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />

	*<PropValue>
		BorderStyle = 3
		DoCreate = .T.
		Height = 440
		Name = "imob_conturi"
		Width = 710
		WindowState = 2
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 714
		_shape2.Anchor = 8
		_shape2.Left = 719
		_shape2.Name = "_shape2"
		_shape2.Top = -1
		_shape2.Visible = .F.
		Lb_titlu_alb_b121.Caption = "Configurare note inchidere amortizare"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 7
		BUT_TERMIN1.Anchor = 8
		BUT_TERMIN1.Left = 677
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 2
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.Visible = .T.
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Anchor = 8, ;
		Left = 557, ;
		Name = "But_excel1", ;
		TabIndex = 6, ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_nou1' AS but_nou WITH ;
		Anchor = 8, ;
		Left = 586, ;
		Name = "But_nou1", ;
		TabIndex = 5, ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'But_sterge1' AS but_sterge WITH ;
		Anchor = 8, ;
		Left = 616, ;
		Name = "But_sterge1", ;
		TabIndex = 4, ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'grid1' AS _grdbase WITH ;
		Anchor = 15, ;
		ColumnCount = 8, ;
		DeleteMark = .F., ;
		FontName = "Arial", ;
		Height = 398, ;
		Left = 8, ;
		Name = "grid1", ;
		Panel = 1, ;
		RecordSource = "imob_conturi", ;
		RowHeight = 18, ;
		TabIndex = 1, ;
		Top = 38, ;
		Width = 700, ;
		Column1.ColumnOrder = 2, ;
		Column1.ControlSource = "acont", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 9, ;
		Column1.Format = "K", ;
		Column1.Name = "cAcont", ;
		Column1.Width = 55, ;
		Column2.ColumnOrder = 1, ;
		Column2.ControlSource = "cont", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 9, ;
		Column2.Format = "K", ;
		Column2.Name = "cCont", ;
		Column2.Width = 69, ;
		Column3.ColumnOrder = 4, ;
		Column3.ControlSource = "scd", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 9, ;
		Column3.Format = "K", ;
		Column3.Name = "cSCD", ;
		Column3.Width = 73, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "ascd", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 9, ;
		Column4.Format = "K", ;
		Column4.Name = "cASCD", ;
		Column4.Width = 75, ;
		Column5.ColumnOrder = 6, ;
		Column5.ControlSource = "scc", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 9, ;
		Column5.Format = "K", ;
		Column5.Name = "cSCC", ;
		Column5.Width = 68, ;
		Column6.ColumnOrder = 7, ;
		Column6.ControlSource = "ascc", ;
		Column6.FontName = "Arial", ;
		Column6.FontSize = 9, ;
		Column6.Format = "K", ;
		Column6.Name = "cASCC", ;
		Column6.Width = 81, ;
		Column7.ColumnOrder = 8, ;
		Column7.ControlSource = "id", ;
		Column7.FontName = "Arial", ;
		Column7.FontSize = 9, ;
		Column7.Name = "cId", ;
		Column7.ReadOnly = .T., ;
		Column7.Width = 55, ;
		Column8.Bound = .F., ;
		Column8.ColumnOrder = 3, ;
		Column8.ControlSource = "Iif(Seek(imob_conturi.id_sectie,'vnom_sectii','id_sectie'),vnom_sectii.sectie,'')", ;
		Column8.CurrentControl = "_combobox1", ;
		Column8.FontName = "Arial", ;
		Column8.Name = "cSectie", ;
		Column8.Sparse = .F., ;
		Column8.Width = 182
		*< END OBJECT: ClassLib="..\comun\clase\_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid1.cAcont.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Analitic", ;
		FontName = "Arial", ;
		FontSize = 9, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid1.cASCC.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Analitic amort.", ;
		FontName = "Arial", ;
		FontSize = 9, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid1.cASCD.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Analitic chelt.", ;
		FontName = "Arial", ;
		FontSize = 9, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid1.cCont.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cont", ;
		FontName = "Arial", ;
		FontSize = 9, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid1.cId.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Id", ;
		FontName = "Arial", ;
		FontSize = 9, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid1.cSCC.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cont amort.", ;
		FontName = "Arial", ;
		FontSize = 9, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid1.cSCD.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cont chelt.", ;
		FontName = "Arial", ;
		FontSize = 9, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid1.cSectie._combobox1' AS _combobox WITH ;
		BorderStyle = 0, ;
		BoundColumn = 2, ;
		BoundTo = .T., ;
		ControlSource = "imob_conturi.id_sectie", ;
		Left = 119, ;
		Name = "_combobox1", ;
		RowSource = "select vnom_sectii.sectie, id_sectie from vnom_sectii into cursor crsSectii order by sectie", ;
		RowSourceType = 3, ;
		Top = 81
		*< END OBJECT: ClassLib="..\comun\clase\_baza.vcx" BaseClass="combobox" />

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

	ADD OBJECT 'grid1.cSectie.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Gridextra1' AS gridextra WITH ;
		gridexpression = Thisform.grid1, ;
		Left = 624, ;
		Name = "Gridextra1", ;
		Top = 120
		*< END OBJECT: ClassLib="..\comun\utile\gridextras\gridextras.vcx" BaseClass="custom" />
	
	PROCEDURE do_adauga
		LOCAL loRec
		Sele imob_conturi
		IF !EMPTY(NVL(cont,''))
			SCATTER NAME loRec FIELDS EXCEPT id 
		ENDIF 	
		
		APPEND BLANK 
		IF TYPE('loRec') = 'O'
			GATHER NAME loRec
		ENDIF 	
		
		thisform.grid1.cCont.text1.SetFocus()
		Thisform.grid1.Refresh()
		  
	ENDPROC

	PROCEDURE do_excel
		DO export_excel_grid WITH thisform.grid1 
	ENDPROC

	PROCEDURE do_sterge
		Select imob_conturi
		lcCont = Alltrim(Cont) + Iif(!Empty(Nvl(acont, '')), '.' + Alltrim(acont),"")
		
		If AMESSAGEBOX('Se sterge configurarea pentru contul ' + m.lcCont,4+32,_Screen.Caption) <> 6
			Return
		Endif
		Sele imob_conturi
		Delete
		Try
			Skip -1
		Catch
			GO TOP 
		Endtry
		
		Thisform.grid1.SetFocus()
		
		
		
	ENDPROC

	PROCEDURE inainte_de_do_termin
		Local llSucces, llSucces2, lcText
		Local lcDeleted, lcExec
		PRIVATE poRec
		llSucces = .T.
		lcText = ''
		Wait Window 'Se actualizeaza inregistrarile...' Nowait
		
		SELECT id_sectie, sectie, cont, acont, COUNT(*) as nr FROM imob_conturi GROUP BY id_sectie, sectie, cont, acont HAVING COUNT(*) > 1 INTO CURSOR cVerificareTemp
		IF _tally > 0
			llSucces = .F.
			SELECT cVerificareTemp
			SCAN 
				lcText = lcText + ALLTRIM(sectie) + ' ' + ALLTRIM(cont) + IIF(!EMPTY(NVL(acont,'')), '.' + ALLTRIM(acont), '') + CHR(13) + CHR(10)
			ENDSCAN 
			USE IN (SELECT('cVerificareTemp'))
			lcText = 'Conturile urmatoare apar de mai multe ori in lista. Pastrati o singura pozitie!' + CHR(13) + CHR(10) + m.lcText
			AMESSAGEBOX(m.lcText,0+48,_screen.Caption)
		ENDIF 
		IF !m.llSucces
			RETURN m.llSucces
		endi
		
		llSucces = This.do_deschide_tranzactie()
		If m.llSucces
			lcDeleted = Set("Deleted")
			Set Deleted Off
		
			Select imob_conturi
			Scan
				Scatter Name poRec
				WAIT WINDOW TRANSFORM(RECNO()) + '/' + TRANSFORM(RECCOUNT()) NOWAIT 
				lcExec = ''
				poRec.id_sectie = IIF(EMPTY(NVL(poRec.id_sectie,0)), NULL, poRec.id_sectie)
		
				If !Empty(Nvl(poRec.Id, 0))
					If Deleted()
						lcExec = 'DELETE FROM imob_inchidere WHERE id = ?poRec.id'
					Else
						lcExec = 'UPDATE imob_inchidere set id_sectie = ?poRec.id_sectie, cont = TRIM(?poRec.cont), acont = TRIM(?poRec.acont), scd = TRIM(?poRec.scd), ascd = TRIM(?poRec.ascd), scc = TRIM(?poRec.scc), ascc = TRIM(?poRec.ascc) WHERE id = ?poRec.id'
					Endif
				Else
					If !Deleted()
						lcExec = 'INSERT INTO imob_inchidere (id_sectie, cont, acont, scd, ascd, scc, ascc) values (?poRec.id_sectie, TRIM(?poRec.cont), TRIM(?poRec.acont), TRIM(?poRec.scd), TRIM(?poRec.ascd), TRIM(?poRec.scc), TRIM(?poRec.ascc))'
					Endif
				Endif
				If !Empty(m.lcExec)
					lnSucces = goExecutor.oExecute(m.lcExec)
					llSucces = (m.lnSucces > 0)
					If !m.llSucces
						AMESSAGEBOX('Sectie: ' + ALLTRIM(NVL(sectie,'')) + ' Cont: ' + ALLTRIM(NVL(poRec.cont,'')) + ;
						IIF(!EMPTY(NVL(poRec.acont,'')), '.' + ALLTRIM(poRec.acont), '') + CHR(13) + CHR(10) + ;
						goExecutor.oPrelucrareEroare(),0+48,_screen.Caption)
						Exit
					Endif
				Endif
			Endscan
			If m.llSucces
				llSucces = This.do_inchide_tranzactie(1) && COMMIT
			Else
				llSucces2 = This.do_inchide_tranzactie(2) && ROLLBACK
			Endif
			Set Deleted &lcDeleted
		Endif
		
		Return m.llSucces
		
	ENDPROC

	PROCEDURE Init
		DODEFAULT()
		
		this.WindowState = 2 
		this.grid1.AutoFit()
		lnHeight = this.Height 
		*!*	this.WindowState = 0 
		this.Width = 500
		this.Height = m.lnHeight
		
		
		this.gridextra1.setup()
		
	ENDPROC

	PROCEDURE grid1.cAcont.Text1.LostFocus
		PARAMETERS PlClick
		lcCont = ALLTRIM(NVL(cont,''))
		lcAcont = ALLTRIM(NVL(acont,''))
		llReturn = verific_analitic(m.plClick, m.lcCont, m.lcAcont,'acont','imob_conturi') && in oOperatii_comune.prg
	ENDPROC

	PROCEDURE grid1.cASCC.Text1.LostFocus
		PARAMETERS PlClick
		lcCont = ALLTRIM(NVL(scc,''))
		lcAcont = ALLTRIM(NVL(ascc,''))
		llReturn = verific_analitic(m.plClick, m.lcCont, m.lcAcont,'ascc','imob_conturi') && in oOperatii_comune.prg
	ENDPROC

	PROCEDURE grid1.cASCD.AddObject
		LPARAMETERS cName, cClass
	ENDPROC

	PROCEDURE grid1.cASCD.Text1.LostFocus
		PARAMETERS PlClick
		lcCont = ALLTRIM(NVL(scd,''))
		lcAcont = ALLTRIM(NVL(ascd,''))
		llReturn = verific_analitic(m.plClick, m.lcCont, m.lcAcont,'ascd','imob_conturi') && in oOperatii_comune.prg
	ENDPROC

	PROCEDURE grid1.cSectie._combobox1.Valid
		REPLACE sectie WITH crsSectii.sectie IN imob_conturi 
	ENDPROC

	PROCEDURE grid1.Init
		* NU STERGE
	ENDPROC

ENDDEFINE
