Partial Class MyPage
Inherits System.Web.UI.Page
Public Property MerchantID() As Integer
Get
Return CNull(ViewState("MerchantID"), -1)
End Get
Private Set(ByVal value As Integer)
ViewState("MerchantID") = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Call DisplayInfo(1) ' dummy value
End If
End Sub
Private Sub DisplayInfo(ByVal nInfoID As Integer)
Dim ws As New MyWebService
Dim sXML As String = ws.GetInfo(nInfoID)
Dim reader As New System.IO.StringReader(sXML)
Dim ds As New DataSet
ds.ReadXml(reader)
' Need to figure out if linked to merchant
If ds.Tables(0).Rows.Count > 0 Then
' Determine Merchant
MerchantID = ds.Tables(0).Rows(0).Item("MerchantID")
' Determine Opt In
Call DisplayOptInOut(ds.Tables(0).Rows(0).Item("OptInInd"))
End If
End Sub
Private Sub DisplayOptInOut(ByVal bIsOptIn As Boolean)
If bIsOptIn Then
' Show Opt Out
Me.imgLinkMerchant.Src = "~/images/merchantRemove.jpg"
Me.litLinkMerchant.Text = "Opt Out"
Else
' Show Opt In
Me.imgLinkMerchant.Src = "~/images/merchantAdd.jpg"
Me.litLinkMerchant.Text = "Opt In"
End If
End Sub
Public Sub btnLinkMerchant_Click(ByVal sender As Object, ByVal e As EventArgs)
Call LinkUnlinkMerchant()
End Sub
Private Sub LinkUnlinkMerchant()
' Add / Remove Favorite
Dim bLink As Boolean = (Me.litLinkMerchant.Text = "Opt In") ' desired action
Dim ws As New MyWebService
If bLink Then
ws.LinkToMerchant(MerchantID)
Else
ws.UnlinkFromMerchant(MerchantID)
End If
Call DisplayInfo(1)
End Sub
End Class |