//"procsp.sc","Procedury dokumentu sprzedaży","\Procedury\",0,1.0.0,SYSTEM

#include "MobileWarehouse - include"

int Sub OnAddNewDokument(long lId)
	int block = IsLocked(lId, 3)
	if(block == 0) then
		Lock(lId, 3)
	endif
	OnAddNewDokument = 0
EndSub

 int Sub OnBeforeInsert(long lId)
	Lock(lId, 3)
	OnBeforeInsert = 0
 EndSub

 int Sub OnAfterInsert(long lId)
	Unlock(lId, 3)	
 	OnAfterInsert = 0
 EndSub

int Sub OnKhChanged(long lId)
	OnKhChanged = 0
EndSub

int Sub OnBeforeEdit(long lId)
	int block = IsLocked(lId, 3)
	if(block == 0) then
		Lock(lId, 3)
		OnBeforeEdit = 0
	else
		OnBeforeEdit = DocumentInEditMode()
	endif
	//OnBeforeEdit = 0
EndSub

int Sub OnBeforeBuforEdit(long lId)
	OnBeforeBuforEdit = 0
EndSub

int Sub OnAfterUpdate(long lId)
	Unlock(lId, 3)
	OnAfterUpdate = 0
EndSub

int Sub OnAfterBuforUpdate(long lId)
	Unlock(lId, 3)
	OnAfterBuforUpdate = 0
EndSub

int Sub OnBeforeDelete(long lId)
	Unlock(lId, 3)
	OnBeforeDelete = 0
EndSub

int Sub OnBeforeBuforDelete(long lId)
	Unlock(lId, 3)
	OnBeforeBuforDelete = 0
EndSub

int Sub OnAfterDelete(long lId)
	Unlock(lId, 3)
	OnAfterDelete = 0
EndSub

int Sub OnAfterBuforDelete(long lId)
	Unlock(lId, 3)
	OnAfterBuforDelete = 0
EndSub

int Sub OnBeforeAnuluj(long lId)
	Unlock(lId, 3)
	OnBeforeAnuluj = 0
EndSub

int Sub OnTwChanged(long lId)
	OnTwChanged = 0
EndSub

int Sub OnBeforeCancel(long lId)
	OnBeforeCancel = 0
EndSub

int Sub OnAfterCancel(long lId)
	Unlock(lId, 3)
	OnAfterCancel = 0
EndSub