forked from ventrian/News-Articles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathucEditPageSortOrder.ascx.vb
executable file
·175 lines (104 loc) · 5.3 KB
/
ucEditPageSortOrder.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
'
' News Articles for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by Ventrian ( [email protected] ) ( http://www.ventrian.com )
'
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Imports Ventrian.NewsArticles.Base
Namespace Ventrian.NewsArticles
Partial Public Class ucEditPageSortOrder
Inherits NewsArticleModuleBase
#Region " Private Members "
Private _articleID As Integer
#End Region
#Region " Private Methods "
Private Sub ReadQueryString()
If (IsNumeric(Request("ArticleID"))) Then
_articleID = Convert.ToInt32(Request("ArticleID"))
End If
End Sub
Private Sub CheckSecurity()
If (HasEditRights(_articleID, Me.ModuleId, Me.TabId) = False) Then
Response.Redirect(Common.GetModuleLink(Me.TabId, Me.ModuleId, "NotAuthorized", ArticleSettings), True)
End If
End Sub
Private Sub BindOrder()
Dim objPageController As PageController = New PageController
lstSortOrder.DataSource = objPageController.GetPageList(_articleID)
lstSortOrder.DataBind()
If (lstSortOrder.Items.Count = 0) Then
Response.Redirect(Common.GetModuleLink(Me.TabId, Me.ModuleId, "EditPages", ArticleSettings, "ArticleID=" & _articleID.ToString()), True)
End If
End Sub
#End Region
#Region " Event Handlers "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
ReadQueryString()
If (IsPostBack = False) Then
CheckSecurity()
BindOrder()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
Try
Dim objPageController As PageController = New PageController
For i As Integer = 0 To lstSortOrder.Items.Count - 1
Dim objPage As PageInfo = objPageController.GetPage(Convert.ToInt32(lstSortOrder.Items(i).Value))
objPage.SortOrder = i
objPageController.UpdatePage(objPage)
Next
Response.Redirect(Common.GetModuleLink(Me.TabId, Me.ModuleId, "EditPages", ArticleSettings, "ArticleID=" & _articleID.ToString()), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
Try
Response.Redirect(Common.GetModuleLink(Me.TabId, Me.ModuleId, "EditPages", ArticleSettings, "ArticleID=" & _articleID.ToString()), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub upBtn_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles upBtn.Click
Try
If (lstSortOrder.SelectedIndex <> -1) Then
If (lstSortOrder.SelectedIndex <> 0) Then
Dim tempIndex As Integer = lstSortOrder.SelectedIndex
Dim newListItem As ListItem = New ListItem
newListItem.Text = lstSortOrder.SelectedItem.Text
newListItem.Value = lstSortOrder.SelectedItem.Value
lstSortOrder.Items.RemoveAt(tempIndex)
lstSortOrder.Items.Insert(tempIndex - 1, newListItem)
lstSortOrder.SelectedIndex = tempIndex - 1
End If
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub downBtn_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles downBtn.Click
Try
If (lstSortOrder.SelectedIndex <> -1) Then
If (lstSortOrder.SelectedIndex <> lstSortOrder.Items.Count - 1) Then
Dim tempIndex As Integer = lstSortOrder.SelectedIndex
Dim newListItem As ListItem = New ListItem
newListItem.Text = lstSortOrder.SelectedItem.Text
newListItem.Value = lstSortOrder.SelectedItem.Value
lstSortOrder.Items.RemoveAt(tempIndex)
lstSortOrder.Items.Insert(tempIndex + 1, newListItem)
lstSortOrder.SelectedIndex = tempIndex + 1
End If
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace