net操作webservices 例子(2)

Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlServerCe
Imports System.IO
Imports System.Xml
Imports System.Net

Public Class Form2
    Public row As Integer
    Public ok1 As String
    Public ok2 As String
    Public ok3 As String
    Public ok4 As String
    Dim data As DataTable
    Public Sub SetData(ByVal temp As DataTable, ByVal mm As Integer)
        data = temp
        row = mm
    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.DataGrid1.DataSource = data
        Me.DataGrid1.Select(row)
    End Sub

    '修改本地数据,并保存
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        '获取当前选择行
        row = Me.DataGrid1.CurrentRowIndex()
        'Dim i As Integer
        Dim g As Integer
        'Dim con As SqlCeConnection
        'con = New SqlCeConnection("DataSource=\mysdf.sdf")
        'Dim com As SqlCeCommand
        'For i = 0 To data.Rows.Count - 1
        For g = 0 To data.Columns.Count - 1
            If g = 0 Then
                ok1 = data.Rows(row)(g).ToString
            End If
            If g = 1 Then
                ok2 = data.Rows(row)(g).ToString
            End If
            If g = 2 Then
                ok3 = data.Rows(row)(g).ToString
            End If
            If g = 3 Then
                ok4 = data.Rows(row)(g).ToString
            End If
            'MessageBox.Show(ok1)
            '修改数据
        Next
        Form3.ref(ok1, ok2, ok3, ok4, row)
        Form3.ShowDialog()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim i As Integer
            Dim g As Integer
            g = data.Rows.Count
            Dim j As Integer
            Dim URL4 As String = "http://123.my-portal.cn:8080/sap/bc/soap/rfc?sap-client=123"
            Dim cred As NetworkCredential
            cred = New NetworkCredential("123456", "123456")
            Dim z03 As New ZWRORDER0003.ZWRORDER0003Service
            Dim pcc() As ZWRORDER0003.Z1CRM_WERK_PC
            ReDim pcc(g)
            z03.Url = URL4
            z03.Credentials = cred

            For i = 0 To data.Rows.Count - 1
                pcc(i) = New ZWRORDER0003.Z1CRM_WERK_PC

                For j = 0 To data.Columns.Count - 1
                    If j = 0 Then
                        pcc(i).PCNO = data.Rows(i)(j)
                    ElseIf j = 1 Then
                        ' pcc(i).XH = data.Rows(i)(j)
                    ElseIf j = 2 Then
                        pcc(i).WERKS = data.Rows(i)(j)
                    ElseIf j = 3 Then
                        pcc(i).PC_DATE = data.Rows(i)(j).ToString.Substring(0, 4) + data.Rows(i)(j).ToString.Substring(5, 2) + data.Rows(i)(j).ToString.Substring(8, 2)
                    End If
                Next
            Next

            '需要更新的数据通过参数传递过去,更新的语句在SAP端进行书写
            '更改的数据进行保存
            '如果全部保存的话, 还只能用Update语句进行。
            '两种方式都已经进行了测试,可以正常运行。

            Dim result As String
            result = z03.ZWRORDER0003(pcc)
            MessageBox.Show(result)
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub
End Class

posted @ 2007-06-15 08:39  寒天飞雪  阅读(390)  评论(0编辑  收藏  举报