par Lionel » 07 Fév 2003 à 11:20
A ulisiser tel quel dans le masque :Sub Queryopen (Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant) Dim ws As New notesuiworkspace Dim s As New notessession Dim Uidoc As Notesuidocument Dim doc As NotesDocument Dim boxType As Long Dim answer As Integer Set uidoc = source Set doc = source.Document Continue = True If Mode = 1 And Not source.IsNewDoc Then If uidoc.document.LockedBy (0) = "" Then uidoc.document.lockedby = s.COMMONUSERNAME If Not uidoc.Document.Save (False, False, True) Then ' If problem mit save => wird konflikt geben -> kein Edit Status Messagebox("Le document est déjà en cours de traitement" ) Call uidoc.Close End If uidoc.document.save True, False Else If uidoc.document.lockedby(0) = s.COMMONUSERNAME Then boxType = MB_YESNO + MB_ICONQUESTION Answer = Messagebox ("Les dernières modifications ne se sont pas enregistrées correctement, voulez vous continuer??", MB_YESNO, "Unlock?") If answer = 7 Then Continue = False Else uidoc.document.lockedby = s.COMMONUSERNAME uidoc.document.save True, False End If Else continue = False Messagebox("Le document est déjà en cours de traitement par" + uidoc.document.lockedby(0)) End If End If End If End SubSub Querymodechange(Source As Notesuidocument, Continue As Variant) Dim s As New notessession Dim doc As NotesDocument Dim boxType As Long Dim answer As Integer Set doc = source.Document Continue = True If source.EditMode = False Then ' READ -> EDIT If doc.LockedBy (0) = s.COMMONUSERNAME Then boxType = MB_YESNO + MB_ICONQUESTION Answer = Messagebox ("Les dernières modifications ne se sont pas enregistrées correctement, voulez vous continuer?", MB_YESNO, "Unlock?") If answer = 7 Then Continue = False End If Elseif doc.LockedBy (0) <> "" Then Messagebox ("Le document est déjà en cours de traitement par " + doc.lockedby(0)) continue = False End IfSub Postmodechange(Source As Notesuidocument) Dim s As New notessession Dim doc As NotesDocument If source.EditMode = True Then ' READ -> EDIT Call Source.reload () Set doc = source.Document If doc.LockedBy (0) = "" Then doc.lockedby = s.COMMONUSERNAME If (False = doc.Save (False, False, True) ) Then Messagebox ("Le document est déjà en cours de traitement" ) doc.SaveOptions = "0" Call Source.close () Exit Sub End If doc.save True, False End If End IfSub Queryclose(Source As Notesuidocument, Continue As Variant) Dim uiw As New notesuiworkspace Dim doc As notesDocument Set doc = Source.Document If ( Source.EditMode ) And Not (Source.Isnewdoc)Then doc.LockedBy = "" doc.SaveOptions = "1" If (False = doc.Save (False, False, True)) Then Print "" End If' Source.refreshhideformulas End If Call uiw.ViewRefresh End Sub