Function SP_OpenPNR(pdoc As NotesDocument) As Integer
'//調閱PNR單
On Error Goto errorhandler
Call jmcf_blnSetNewUIVars()
'
Dim SourceDB As NotesDatabase, SourceDoc As NotesDocument, sysdoc As NotesDocument
Dim itemPNRDB As NotesItem, itemPNRPath As NotesItem
Dim PNRdb As NotesDatabase, PNRdoc As NotesDocument, PNRvi As NotesView
Dim varSel As Variant, A As Variant, Item As Integer, i As Integer, varTmp As Variant
'
Set SourceDB = jmcdb
Set SourceDoc = jmcdoc_Source
Set sysdoc = GetSystemDocument("Form-SystemSetup")
If sysdoc Is Nothing Then Error 997, "not found sysdoc!!"
'
Set itemPNRDB = sysdoc.GetFirstItem("DBServer_" + pdoc.ProdType(0))
Set itemPNRPath = sysdoc.GetFirstItem("DBFilePath_" + + pdoc.ProdType(0))
Set pnrdb = New NotesDatabase(itemPNRDB.Values(0), itemPNRPath.Values(0))
If pnrdb Is Nothing Then Error 997, "not found PNR DB!!"
varSel = ""
Redim A(0 To Ubound(pdoc.GetItemValue("PNR")))
i = 0
Forall aa In pdoc.GetItemValue("PNR")
A(i) = Cstr(i +1) + ". " + aa
i = i + 1
End Forall
If A(0) = "" Then Exit Function
Set PNRvi = PNRdb.GetView("View-pwcUniqueID")
If PNRvi Is Nothing Then
Print "Search SerialNumber..."
Set PNRvi = PNRdb.GetView("View-SerialNumber")
varSel = jmcws.Prompt (PROMPT_OKCANCELLIST,Sourcedb.title,"Select item","", A)
If varSel = "" Then Exit Function
varTmp = Split(varSel, ".")
Item = Cint(varTmp(0)) - 1
Set PNRdoc = PNRvi.GetDocumentByKey(pdoc.PNR(Item), True)
Else
Print "Search PNRUniqueID..."
varSel = jmcws.Prompt (PROMPT_OKCANCELLIST,Sourcedb.title,"Select item","", A)
If varSel = "" Then Exit Function
varTmp = Split(varSel, ".")
Item = Cint(varTmp(0)) - 1
Set PNRdoc = PNRvi.GetDocumentByKey(pdoc.PNRUniqueID(Item), True)
End If
If PNRdoc Is Nothing Then Error 997, "not found PNRdoc!!" : Exit Function
Call jmcws.EditDocument (False,PNRdoc)
TheEnd:
Exit Function
ErrorHandler:
SP_OpenPNR = False
Print "lib: SP.ReferenceAction4UI: SP_OpenPNR() error line = " + Cstr(Erl) + ", error = " + Error$
Call SP_ErrorBox("lib: SP.ReferenceAction4UI: SP_OpenPNR() error")
Resume TheEnd
End Function
沒有留言:
張貼留言