//"proczo.sc","Procedury zamówienia obcego","\Procedury\",0,1.0.0,SYSTEM

#include "MobileWarehouse - include"

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

int Sub OnBeforeInsert(long lId)
	OnBeforeInsert = 0
EndSub

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

int Sub OnKhChanged(long lId)
	OnKhChanged = 0
EndSub

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

int Sub OnBeforeBuforEdit(long lId)
	OnBeforeBuforEdit = 0
EndSub

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

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

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

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

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

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

int Sub OnBeforeAnuluj(long lId)
	Unlock(lId, 5)
	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, 5)
	OnAfterCancel = 0
EndSub