若你想從這一份文件的的某一欄位當Key 而從視界中尋找與 該Key相關的文件,
可以從下面範例來修改,而從視界取得與該Key相關文件相關內容。
'-------------------------------------------------------------------------------
Sub Click(Source As Button)
'We are accessing a document in the same database the script lies.
'Therfore, get the session, the the current database.
Dim s As notessession
Set s=New notessession
Dim db As notesdatabase
Set db=s.currentdatabase
'get the front end document
Dim w As notesuiworkspace
Set w=New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=w.currentdocument
'宣告ODBC connect
Dim conP As New ODBCConnection
Dim conC As New ODBCConnection
Dim qryP As New ODBCQuery
Dim qryC As New ODBCQuery
Dim resultP As New ODBCResultSet
Dim resultC As New ODBCResultSet
'
'Add code here
'
'get backend document of the current document
Dim doc As notesdocument
Set doc=uidoc.document
'將主文件資料存至Oracle
Set qryP.Connection = conP
Set qryC.Connection=conC
Set resultP.Query = qryP
Set resultC.Query=qryC
Call conP.ConnectTo("cerp","ymh","hedl26")
Call conC.ConnectTo("cerp","ymh","hedl26")
qryP.SQL = "SELECT * FROM scheduleoutline"
qryC.SQL="SELECT * FROM scheduleevent"
'----新增進度大綱資訊到Oracle scheduleoutlineTable-------------------------
resultP.Execute
resultP.addrow
Call resultP.setvalue("sitecode",Trim(uidoc.FieldGetText("sitecode")))
Call resultP.setvalue("sitelabel",Trim(uidoc.FieldGetText("sitelabel")))
Call resultP.setvalue("socode",Trim(uidoc.FieldGetText("socode")))
Call resultP.setvalue("rescode",Trim(uidoc.FieldGetText("rescode")))
Call resultP.setvalue("soname",Trim(uidoc.FieldGetText("soname")))
Call resultP.setvalue("soworkday",Trim(uidoc.FieldGetText("soworkday")))
Call resultP.setvalue("sostartdate",Trim(uidoc.FieldGetText("sostartdate")))
Call resultP.setvalue("sofinishdate",Trim(uidoc.FieldGetText("sofinishdate")))
Call resultP.setvalue("sorate",Trim(uidoc.FieldGetText("sorate")))
Call resultP.setvalue("somoney",Trim(uidoc.FieldGetText("somoney")))
Call resultP.setvalue("ndunid",Trim(uidoc.FieldGetText("unid")))
resultP.updaterow
'--------------------------------------------------------------------------
'---------取得進度項目資訊套表的進度項目文件轉入Oracle purchaseitem Table-------
Dim viewkey As String
Dim subnview As NotesView
Dim subndoc As NotesDocument
Set subnview=db.GetView("(ColScheduleoutlineR)")
Set subndoc=subnview.GetFirstDocument
viewkey=Trim(doc.socode(0)) 'Key請購單號
Do Until subndoc Is Nothing
If (subndoc.socode(0)=viewkey) Then
resultC.Execute
resultC.addrow
Call resultc.setvalue("sitecode",Trim(subndoc.sitecode(0)))
Call resultc.setvalue("socode",Trim(subndoc.socode(0)))
Call resultc.setvalue("rescode",Trim(subndoc.rescode(0)))
Call resultc.setvalue("resname",Trim(subndoc.resname(0)))
Call resultc.setvalue("seworkday",Trim(subndoc.seworkday(0)))
Call resultc.setvalue("sestartdate",Trim(subndoc.sestartdate(0)))
Call resultc.setvalue("sefinishdate",Trim(subndoc.sefinishdate(0)))
Call resultc.setvalue("serate",Trim(subndoc.serate(0)))
Call resultc.setvalue("semoney",Trim(subndoc.semoney(0)))
Call resultc.setvalue("ndpunid",Trim(subndoc.UnidParent(0)))
Call resultc.setvalue("ndcunid",Trim(subndoc.Unid(0)))
resultC.updaterow
End If
Set subndoc = subnview.GetNextDocument(subndoc)
Loop
'---------------------------------------------------------
resultP.close(DB_CLOSE)
conP.disconnect
resultC.close(DB_CLOSE)
conC.disconnect
End Sub
'-------------------------------------------------------------------------------
沒有留言:
張貼留言