-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathView.ascx.vb
301 lines (271 loc) · 13.1 KB
/
View.ascx.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
' Copyright (c) 2018 npiweb.com
' All rights reserved.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'
Imports DotNetNuke
Imports DotNetNuke.Common.Globals
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules.Actions
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.UI.Utilities
Imports TAC.DNN.Modules.TAC_NPIDal2.Components
Imports DotNetNuke.Entities.Portals
Imports DotNetNuke.UI.WebControls
''' <summary>
''' The View class displays the content
'''
''' Typically your view control would be used to display content or functionality in your module.
'''
''' View may be the only control you have in your project depending on the complexity of your module
'''
''' Because the control inherits from TAC_NPIinspectorSearchModuleBase you have access to any custom properties
''' defined there, as well as properties from DNN such as PortalId, ModuleId, TabId, UserId and many more.
'''
''' </summary>
Partial Class View
Inherits TAC_NPIinspectorSearchModuleBase
Implements IActionable
''' -----------------------------------------------------------------------------
''' <summary>
''' Page_Load runs when the control is loaded
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' </history>
''' -----------------------------------------------------------------------------
#Region "Controls"
Protected WithEvents cmdSearchZip As CommandButton
Protected WithEvents cmdSearchCCS As CommandButton
Protected WithEvents txtMainSearch As TextBox
Protected WithEvents ddlMiles As DropDownList
Protected WithEvents ddlStateSearch As DropDownList
Protected WithEvents lblResults As Label
Protected WithEvents dgSearchResults As DataGrid
Protected WithEvents lblZipCode As Label
Protected WithEvents lblZipCode2 As Label
Protected WithEvents lblStateText As Label
Protected WithEvents lblStateText2 As Label
#End Region
#Region "Page Load"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
If Not Page.IsPostBack Then
Dim sc As New StatesController
If CType(Settings("DSource"), String) = "GPI" Then
Me.lblZipCode.Text = "Postal Code"
Me.lblZipCode2.Text = "Postal Code"
Me.lblStateText.Text = "Province"
Me.lblStateText2.Text = "Province"
Me.ddlStateSearch.DataSource = sc.GetStatesByCountry("Canada")
Me.ddlStateSearch.DataBind()
Dim newItem As New ListItem
newItem.Value = ""
newItem.Text = "Select A Province"
Me.ddlStateSearch.Items.Insert(0, newItem)
Else
Me.ddlStateSearch.DataSource = sc.GetStatesByCountry("USA")
Me.ddlStateSearch.DataBind()
Dim newItem As New ListItem
newItem.Value = ""
newItem.Text = "Select A State"
Me.ddlStateSearch.Items.Insert(0, newItem)
End If
If Not (Request.Params("searchFor") Is Nothing) And Len(Request.Params("searchFor")) > 0 Then
If CType(Settings("DSource"), String) = "GPI" Then
searchCanadaZips(Request.Params("searchFor"), 30)
Else
searchUSAZips(Request.Params("searchFor"), 30)
Me.txtMainSearch.Text = Request.Params("searchFor")
End If
End If
If Not (Request.Params("searchState") Is Nothing) And Len(Request.Params("searchState")) > 0 Then
If CType(Settings("DSource"), String) = "GPI" Then
searchCanada(Null.NullString, Null.NullString, Request.Params("searchState"))
Else
searchUSA(Null.NullString, Null.NullString, Request.Params("searchState"))
End If
End If
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Public Sub dgSearchResults_itemDataBind(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dgSearchResults.ItemDataBound
'copied from decompiled code using refactor - AJL 6-21-2010
If ((e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem)) Then
Dim enumerator As IEnumerator
Dim link As HyperLink = DirectCast(e.Item.FindControl("hpWebSite"), HyperLink)
Dim portalAliasArrayByPortalID As ArrayList = New PortalAliasController().GetPortalAliasArrayByPortalID(CType(DataBinder.Eval(e.Item.DataItem, "PortalID"), Integer))
Try
enumerator = portalAliasArrayByPortalID.GetEnumerator
Do While enumerator.MoveNext
Dim current As PortalAliasInfo = DirectCast(enumerator.Current, PortalAliasInfo)
link.NavigateUrl = ("http://" & current.HTTPAlias)
Loop
Finally
If TypeOf enumerator Is IDisposable Then
TryCast(enumerator, IDisposable).Dispose()
End If
End Try
End If
End Sub
Sub searchUSAZips(ByVal searchZip As String, ByVal searchMiles As Integer)
Try
Dim cc As New CompanyInfoController
'Check for Single Zip
Dim zlc As New MembersZipCodeLinkController
'Dim objZip As NPI_members_zipcodelinkCollection = DataRepository.NPI_members_zipcodelinkProvider.GetByZip(searchZip)
Dim sc As New StatesController
Dim objZip As NPI_members_zipcodelinkCollection = DataRepository.NPI_members_zipcodelinkProvider.GetByZipActive(searchZip)
If objZip.Count = 1 Then
'Dim objMember As NPI_members = DataRepository.NPI_membersProvider.GetByMemberID(objZip(0).MemberID)
'If Not objMember Is Nothing Then
Dim objCompany As CompanyInfo
'objCompany = DataRepository.NPI_CompanyInfoProvider.GetByCompanyID(objMember.CompanyID)
objCompany = cc.GetCompanyInfoByCompanyId(objZip(0).CompanyID)
'check to make sure portal is not zero
If objCompany.PortalID <> 0 Then
Dim arr As ArrayList
Dim p As New PortalAliasController
Dim pa As PortalAliasInfo
arr = p.GetPortalAliasArrayByPortalID(objCompany.PortalID)
For Each pa In arr
Response.Redirect("http://" & pa.HTTPAlias)
Next
End If
'End If
End If
Dim objResults As DataSet = DataRepository.NPI_membersProvider.FindCloseUSA(searchZip, searchMiles)
If objResults.Tables(0).Rows.Count > 0 Then
Me.dgSearchResults.DataSource = objResults
Me.dgSearchResults.DataBind()
Me.lblResults.Visible = False
Else
Me.lblResults.Visible = True
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Sub searchUSA(ByVal searchCity As String, ByVal searchCounty As String, ByVal searchState As String)
Try
Dim mc As New MembersInfoController
Dim objResults As DataSet = DataRepository.NPI_membersProvider.FindByCityCountyStateUSA(searchCity, searchCounty, searchState)
If objResults.Tables.Count > 0 Then
If objResults.Tables(0).Rows.Count > 0 Then
Me.dgSearchResults.DataSource = objResults
Me.dgSearchResults.DataBind()
Me.lblResults.Visible = False
Else
Me.lblResults.Visible = True
End If
Else
Me.lblResults.Visible = True
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Sub searchCanadaZips(ByVal searchZip As String, ByVal searchMiles As Integer)
Dim cc As New CompanyInfoController
Dim zlc As New MembersZipCodeLinkController
Dim objZip As IEnumerable(Of MembersZipCodeLink) = DataRepository.NPI_members_zipcodelinkProvider.GetByZipActive(searchZip)
If objZip.Count = 0 And searchZip.Length = 6 Then
Dim searchZipWithSpace As String = searchZip.Substring(0, 3) & " " & searchZip.Substring(3, 3)
objZip = DataRepository.NPI_members_zipcodelinkProvider.GetByZipActive(searchZipWithSpace)
End If
If objZip.Count = 1 Then
'Dim objMember As NPI_members = DataRepository.NPI_membersProvider.GetByMemberID(objZip(0).MemberID)
'If Not objMember Is Nothing Then
Dim objCompany As CompanyInfo
'objCompany = DataRepository.NPI_CompanyInfoProvider.GetByCompanyID(objMember.CompanyID)
objCompany = cc.GetCompanyInfoByCompanyId(objZip(0).CompanyID)
'check to make sure portal is not zero
If objCompany.PortalID <> 0 Then
Dim arr As ArrayList
Dim p As New PortalAliasController
Dim pa As PortalAliasInfo
arr = p.GetPortalAliasArrayByPortalID(objCompany.PortalID)
For Each pa In arr
Response.Redirect("http://" & pa.HTTPAlias)
Next
End If
'End If
End If
Dim objResults As DataSet = DataRepository.NPI_membersProvider.FindCloseCanada(searchZip, searchMiles)
If objResults.Tables.Count > 0 Then
If objResults.Tables(0).Rows.Count > 0 Then
Me.dgSearchResults.DataSource = objResults
Me.dgSearchResults.DataBind()
Me.lblResults.Visible = False
Else
Me.lblResults.Visible = True
End If
Else
Me.lblResults.Visible = True
End If
End Sub
Sub searchCanada(ByVal searchCity As String, ByVal searchCounty As String, ByVal searchState As String)
Dim mc As New MembersInfoController
Dim objResults As DataSet = DataRepository.NPI_membersProvider.FindByCityCountyStateCanada(searchCity, searchCounty, searchState)
If objResults.Tables.Count > 0 Then
If objResults.Tables(0).Rows.Count > 0 Then
Me.dgSearchResults.DataSource = objResults
Me.dgSearchResults.DataBind()
Me.lblResults.Visible = False
Else
Me.lblResults.Visible = True
End If
Else
Me.lblResults.Visible = True
End If
End Sub
#End Region
#Region "Button Clicks"
#Region "Search"
Private Sub cmdSearchZip_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdSearchZip.Click
If Page.IsValid Then
If CType(Settings("DSource"), String) = "GPI" Then
searchCanadaZips(Me.txtMainSearch.Text, CType(Me.ddlMiles.SelectedValue, Integer))
Else
searchUSAZips(Me.txtMainSearch.Text, CType(Me.ddlMiles.SelectedValue, Integer))
End If
End If
End Sub
Private Sub cmdSearchCCS_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdSearchCCS.Click
If Page.IsValid Then
If CType(Settings("DSource"), String) = "GPI" Then
searchCanada(Null.NullString, Null.NullString, Me.ddlStateSearch.SelectedValue)
Else
searchUSA(Null.NullString, Null.NullString, Me.ddlStateSearch.SelectedValue)
End If
End If
End Sub
#End Region
#End Region
''' -----------------------------------------------------------------------------
''' <summary>
''' Registers the module actions required for interfacing with the portal framework
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
''' <history>
''' </history>
''' -----------------------------------------------------------------------------
Public ReadOnly Property ModuleActions() As ModuleActionCollection Implements IActionable.ModuleActions
Get
Dim Actions As New ModuleActionCollection
Actions.Add(GetNextActionID, Localization.GetString("EditModule", LocalResourceFile), Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl(), False, DotNetNuke.Security.SecurityAccessLevel.Edit, True, False)
Return Actions
End Get
End Property
End Class