*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="ointroduceri_depozit.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS frm_articole_noi AS formtermin 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="grdArticole" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdArticole.cCodBare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdArticole.cCodBare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdArticole.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdArticole.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdArticole.cCantitate.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdArticole.cCantitate.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdArticole.cIdArticol.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdArticole.cIdArticol.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="BUT_RENUNT1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_modifica2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_LBBASE1" UniqueID="" Timestamp="" />

	*<PropValue>
		BorderStyle = 1
		DoCreate = .T.
		Height = 360
		Name = "frm_articole_noi"
		Width = 491
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 600
		_shape2.Left = 441
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		Lb_titlu_alb_b121.Caption = "Articole noi"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		BUT_TERMIN1.Left = 461
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_LBBASE1' AS _lbbase WITH ;
		Caption = "Articole pentru care nu s-a gasit codul de bare in baza de date", ;
		Left = 13, ;
		Name = "_LBBASE1", ;
		Top = 37
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />

	ADD OBJECT 'But_modifica2' AS but_modifica WITH ;
		caction = do_modifica, ;
		Left = 399, ;
		Name = "But_modifica2", ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'grdArticole' AS _grdbase WITH ;
		ColumnCount = 4, ;
		DeleteMark = .F., ;
		Height = 288, ;
		Left = 8, ;
		Name = "grdArticole", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordSource = "crsArticoleNoiTemp", ;
		Top = 60, ;
		Width = 472, ;
		Column1.ColumnOrder = 3, ;
		Column1.ControlSource = "codbare", ;
		Column1.Name = "cCodBare", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 135, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "denumire", ;
		Column2.Name = "cDenumire", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 157, ;
		Column3.ColumnOrder = 4, ;
		Column3.ControlSource = "cantitate", ;
		Column3.Name = "cCantitate", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 74, ;
		Column4.ColumnOrder = 1, ;
		Column4.ControlSource = "id_articol", ;
		Column4.Name = "cIdArticol", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 66
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

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

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

	ADD OBJECT 'grdArticole.cCodBare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod bare", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

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

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

	ADD OBJECT 'grdArticole.cIdArticol.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Id articol", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdArticole.cIdArticol.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE do_modifica
		Private pcCodBare, pnId
		PRIVATE poArticol
		pcCodBare = Alltrim(crsArticoleNoiTemp.codbare)
		pnId = crsArticoleNoiTemp.id
		
		
		
		loArticol = caut_articol() && ocautare.prg
		poArticol = loArticol
		
		If !Empty(Nvl(poArticol.id_articol,0))
		
			If Alltrim(Upper(NVL(poArticol.codbare,''))) <> Alltrim(Upper(NVL(crsArticoleNoiTemp.codbare,'')))
				lcSql = [update nom_articole set codbare = ?pcCodBare where id_articol = ?poArticol.id_articol]
				lnSucces = goExecutor.oExecute(lcSql)
				If lnSucces < 0
					AMESSAGEBOX(goExecutor.cEroare, 0+16, 'Eroare')
				Endif
			ENDIF
		
			lcSql = [update dep_nir_detalii set id_articol = ?poArticol.id_articol, denumire = ?ALLTRIM(poArticol.denumire) where id = ?pnId]
			lnSucces = goExecutor.oExecute(lcSql)
			If lnSucces < 0
				AMESSAGEBOX(goExecutor.cEroare, 0+16, 'Eroare')
			Endif
			
			Replace id_articol With poArticol.id_articol,  denumire With poArticol.denumire In crsArticoleNoiTemp
		
		Endif
		
		
	ENDPROC

	PROCEDURE inainte_de_do_termin
		SELECT crsArticoleNoiTemp
		LOCATE FOR EMPTY(NVL(id_articol,0))
		IF FOUND()
			AMESSAGEBOX('Nu ati identificat toate articolele!',0+48,'Articole')
			THIS.grdArticole.SetFocus()
			RETURN .F.
		ENDIF 
		
		RETURN .T.
	ENDPROC

	PROCEDURE Init
		DODEFAULT()
		this.grdArticole.SetAll("DynamicBackColor","IIF(NVL(ID_ARTICOL,0) = 0, RGB(160,180,240), RGB(255,255,255))", "Column")
	ENDPROC

	PROCEDURE grdArticole.AfterRowColChange
		LPARAMETERS nColIndex
		
		*!* VERIFIC DACA ARTICOLUL ARE ID_ARTICOL
		IF !INLIST(THIS.RowColChange,1,3) 
			RETURN
		ENDIF 
		
		
		IF NVL(crsArticoleNoiTemp.id_articol,0) = 0
			THISFORM.DO_MODIFICA()
		ENDIF 
	ENDPROC

ENDDEFINE
