|
Sub getRecentProduct(CustomerID As String) Dim sXML As String Dim xml As DOMDocument Dim N As IXMLDOMNode Dim productName As String sXML = getCommandXML("RecentPurchaseByCustomerID") Set xml = New DOMDocument xml.loadXML sXML Set N = xml.selectSingleNode("command/param[name='CustomerID']/value") N.Text = CustomerID Set xml = executeSPWithReturn(xml.xml) productName = xml.selectSingleNode("values/ProductName").Text ' 显示text域 txtResult.Text = "" Me.txtResult.Visible = True dgResult.Visible = False ' 显示product名 txtResult.Text = "最近的产品是: " & productName End Sub
Sub getCustomerList() Dim sXML As String Dim i As Integer Dim s As String sXML = getCommandXML("getCustomerList") Set RCustomers = getRecordset(sXML) Set dgCustomers.DataSource = RCustomers End Sub
Sub getCustomerDetail(CustomerID As String) ' 找出列表中相关联的ID号 Dim sXML As String Dim R As Recordset Dim F As Field Dim s As String Dim N As IXMLDOMNode Dim xml As DOMDocument sXML = getCommandXML("CustOrderHist") Set xml = New DOMDocument xml.loadXML sXML Set N = xml.selectSingleNode("command/param[name='CustomerID']/value") N.Text = CustomerID Set R = getRecordset(xml.xml) ' 隐藏 text , 因为它是一个记录集 txtResult.Visible = False
dgResult.Visible = True Set dgResult.DataSource = R End Sub
Function getRecordset(sXML As String) As Recordset Dim R As Recordset Dim xml As DOMDocument Set xml = getData(sXML) Debug.Print TypeName(xml) On Error Resume Next Set R = New Recordset R.Open xml If Err.Number <> 0 Then MsgBox Err.Description Exit Function Else Set getRecordset = R End If End Function
Function executeSPWithReturn(sXML As String) As DOMDocument Dim d As New Dictionary Dim xml As DOMDocument Dim nodes As IXMLDOMNodeList Dim N As IXMLDOMNode Set xml = getData(sXML) If xml.documentElement.nodeName = "values" Then Set executeSPWithReturn = xml Else '发生错误
|