boundclient.vb
来自「wrox出版社的另一套经典的VB2005数据库编程学习书籍,收集了书中源码,郑重」· VB 代码 · 共 81 行
VB
81 行
Option Explicit On
Option Strict On
Imports System.Web.Services.protocols
Public Class BoundClient
'Create the Web service client instances
Private wsOrder As New NWRemoteWS.NWOrdersWS
Private objOrder As New NWRemoteWS.Order
Private Sub btnConnect_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnConnect.Click
Try
'Load the combo box with the last 10 OrderIDs
Me.Cursor = Cursors.WaitCursor
Dim aintOrderID() As Integer
aintOrderID = wsOrder.GetLast10Orders
Dim intCtr As Integer
With cboOrderID
.Enabled = True
.Items.Clear()
For intCtr = 0 To aintOrderID.Length - 1
.Items.Add(aintOrderID(intCtr))
Next
.SelectedIndex = 0
End With
btnGetOrder.Enabled = True
Catch excSoap As SoapException
Me.Cursor = Cursors.Default
MsgBox(excSoap.Message + excSoap.Code.ToString, , "Soap Exception")
Catch excSys As SystemException
Me.Cursor = Cursors.Default
MsgBox(excSys.Message + excSys.StackTrace, , "System Exception")
Finally
Me.Cursor = Cursors.Default
End Try
End Sub
Private Sub btnGetOrder_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnGetOrder.Click
Me.Cursor = Cursors.WaitCursor
Try
'Get the selected order and populate the form controls
With cboOrderID
'Get the Order object
objOrder = wsOrder.GetOrderSP(CInt(.Items(.SelectedIndex)))
End With
If objOrder IsNot Nothing Then
'Bind the Web service instance to the two binding sources
Me.OrderBindingSource.DataSource = objOrder
Me.OrderDetailsBindingSource.DataSource = objOrder
Me.OrderDetailsBindingSource.DataMember = "OrderDetails"
Me.FreightTextBox.Text = Format(CDec(FreightTextBox.Text), "$#,##0.00")
btnUpdateOrder.Enabled = True
End If
Catch excSoap As SoapException
Me.Cursor = Cursors.Default
MsgBox(excSoap.Message + excSoap.Code.ToString, , "Soap Exception")
Catch excSys As SystemException
Me.Cursor = Cursors.Default
MsgBox(excSys.Message + excSys.StackTrace, , "System Exception")
Finally
Me.Cursor = Cursors.Default
End Try
End Sub
Private Sub btnUpdateOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateOrder.Click
Me.Cursor = Cursors.WaitCursor
Try
'Update the back-end data with the client instance
Dim intOrderID As Integer = wsOrder.UpdateOrInsertOrderSP(objOrder)
Catch excSoap As SoapException
Me.Cursor = Cursors.Default
MsgBox(excSoap.Message + excSoap.Code.ToString, , "Soap Exception")
Catch excSys As SystemException
Me.Cursor = Cursors.Default
MsgBox(excSys.Message + excSys.StackTrace, , "System Exception")
Finally
Me.Cursor = Cursors.Default
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?