-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAdminProductDoc.ascx.vb
216 lines (159 loc) · 9.53 KB
/
AdminProductDoc.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
' --- Copyright (c) notice NevoWeb ---
' Copyright (c) 2008 SARL NevoWeb. www.nevoweb.com. BSD License.
' Author: D.C.Lee
' ------------------------------------------------------------------------
' 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.
' ------------------------------------------------------------------------
' This copyright notice may NOT be removed, obscured or modified without written consent from the author.
' --- End copyright notice ---
Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports NEvoWeb.Modules.NB_Store.SharedFunctions
Imports DotNetNuke.Services.FileSystem
Namespace NEvoWeb.Modules.NB_Store
Partial Public Class AdminProductDoc
Inherits Framework.UserControlBase
#Region "Private Members"
Private ResourceFile As String
#End Region
Public Event AddButton(ByVal sender As Object, ByVal e As System.EventArgs)
Public Event DeleteDoc(ByVal DocID As Integer)
Public Event SelectDoc(ByVal FileName As String, ByVal DocDesc As String, ByVal DocPath As String, ByVal FileExt As String)
Public Event SearchDocs(ByVal FilterText As String)
#Region "Events"
Private Sub cmdAddDoc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAddDoc.Click
RaiseEvent AddButton(sender, e)
End Sub
Private Sub dgDocs_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgDocs.DeleteCommand
Try
Dim item As DataGridItem = e.Item
Dim ItemId As Integer = Int32.Parse(e.CommandArgument.ToString)
Dim objCtrl As New ProductController
objCtrl.DeleteProductDoc(ItemId)
RaiseEvent DeleteDoc(ItemId)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub dgDocs_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgDocs.ItemDataBound
Dim item As DataGridItem = e.Item
If item.ItemType = ListItemType.Item Or _
item.ItemType = ListItemType.AlternatingItem Or _
item.ItemType = ListItemType.SelectedItem Then
Dim imgColumnControl As Control = item.Controls(1).Controls(0)
If TypeOf imgColumnControl Is ImageButton Then
Dim remImage As ImageButton = CType(imgColumnControl, ImageButton)
remImage.Attributes.Add("onClick", "javascript:return confirm('" & Localization.GetString("cmdDeleteDoc", ResourceFile) & "');")
End If
End If
End Sub
Private Sub dgDocs_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgDocs.PreRender
Dim dg As DataGrid = sender
ResourceFile = Services.Localization.Localization.GetResourceFile(Me, Me.GetType().BaseType.Name + ".ascx")
If dg.Controls.Count > 0 Then
DirectCast(dg.Controls(0).Controls(0).Controls(0).FindControl("ShowSelectLang"), ShowSelectLang).Refresh()
DirectCast(dg.Controls(0).Controls(0).Controls(0).FindControl("nlName"), Label).Text = Localization.GetString("nlName", ResourceFile)
DirectCast(dg.Controls(0).Controls(0).Controls(0).FindControl("ShowSelectLang2"), ShowSelectLang).Refresh()
DirectCast(dg.Controls(0).Controls(0).Controls(0).FindControl("nlDescription"), Label).Text = Localization.GetString("nlDescription", ResourceFile)
End If
End Sub
Private Sub dgSelectDoc_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgSelectDoc.EditCommand
Try
RaiseEvent SelectDoc(e.Item.Cells(1).Text, e.Item.Cells(2).Text, e.Item.Cells(3).Text, e.Item.Cells(4).Text)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub dgSelectDoc_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgSelectDoc.PageIndexChanged
dgSelectDoc.CurrentPageIndex = e.NewPageIndex
RaiseEvent SearchDocs(txtSearch.Text)
End Sub
Private Sub cmdSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
dgSelectDoc.CurrentPageIndex = 0
RaiseEvent SearchDocs(txtSearch.Text)
End Sub
#End Region
#Region "Methods"
Public Sub HideSelectList()
dgSelectDoc.Visible = False
End Sub
Public Sub populateSelectDocs(ByVal Lang As String, ByVal FilterText As String)
Dim objCtrl As New ProductController
ResourceFile = Services.Localization.Localization.GetResourceFile(Me, Me.GetType().BaseType.Name + ".ascx")
DotNetNuke.Services.Localization.Localization.LocalizeDataGrid(dgSelectDoc, ResourceFile)
' get content
Dim aryList As ArrayList
aryList = objCtrl.GetProductSelectDocList(Lang, FilterText, PortalSettings.PortalId)
dgSelectDoc.DataSource = aryList
dgSelectDoc.DataBind()
dgSelectDoc.Visible = True
End Sub
Public Sub populateDocs(ByVal ProductID As Integer, ByVal Lang As String)
Dim objCtrl As New ProductController
ResourceFile = Services.Localization.Localization.GetResourceFile(Me, Me.GetType().BaseType.Name + ".ascx")
DotNetNuke.Services.Localization.Localization.LocalizeDataGrid(dgDocs, ResourceFile)
' get content
Dim aryList As ArrayList
aryList = objCtrl.GetProductDocList(ProductID, Lang)
dgDocs.DataSource = aryList
dgDocs.DataBind()
End Sub
Public Function DocsCount() As Integer
Return dgDocs.Items.Count
End Function
Public Sub updateDocs(ByVal Lang As String)
Dim objCtrl As New ProductController
Dim objInfo As NB_Store_ProductDocInfo
Dim i As DataGridItem
Dim DocID As Integer
For Each i In dgDocs.Items
DocID = CInt(i.Cells(0).Text)
objInfo = objCtrl.GetProductDoc(DocID, Lang)
If Not objInfo Is Nothing Then
objInfo.DocDesc = CType(i.FindControl("txtDocDesc"), TextBox).Text
objInfo.ListOrder = CType(i.FindControl("txtListOrder"), TextBox).Text
objInfo.Hidden = CType(i.FindControl("chkHide"), CheckBox).Checked
objInfo.FileName = CType(i.FindControl("txtDocName"), TextBox).Text
objInfo.Lang = Lang
objCtrl.UpdateObjProductDoc(objInfo)
End If
Next
End Sub
Public Sub UploadDoc(ByVal ProdID As Integer, ByVal Lang As String)
Dim strMsg As String = ""
Dim fs As New FileSystemUtils
Dim objCtrl As New ProductController
Dim HideFlag As Boolean = False
Dim strGUID As String
If cmdBrowse.FileName <> "" Then
CreateDir(PortalSettings, PRODUCTDOCSFOLDER)
Dim NewFileName As String = ""
strGUID = Guid.NewGuid.ToString
Dim objDInfo As New NB_Store_ProductDocInfo
objDInfo.DocID = -1
objDInfo.DocDesc = ""
objDInfo.DocPath = PortalSettings.HomeDirectoryMapPath & PRODUCTDOCSFOLDER & "\" & strGUID & System.IO.Path.GetExtension(cmdBrowse.FileName)
objDInfo.FileExt = System.IO.Path.GetExtension(cmdBrowse.FileName)
objDInfo.FileName = System.IO.Path.GetFileNameWithoutExtension(cmdBrowse.FileName)
objDInfo.Hidden = False
objDInfo.Lang = Lang
objDInfo.ListOrder = 1
objDInfo.ProductID = ProdID
Dim strFolderpath As String = GetSubFolderPath(objDInfo.DocPath, PortalSettings.PortalId)
FileSystemUtils.UploadFile(PortalSettings.HomeDirectoryMapPath & PRODUCTDOCSFOLDER & "\", cmdBrowse.PostedFile, strGUID & System.IO.Path.GetExtension(cmdBrowse.FileName))
Dim folderInfo As DotNetNuke.Services.FileSystem.FolderInfo = FileSystemUtils.GetFolder(PortalSettings.PortalId, PRODUCTDOCSFOLDER)
If folderInfo.StorageLocation = FolderController.StorageLocationTypes.SecureFileSystem Then
objDInfo.DocPath = PortalSettings.HomeDirectoryMapPath & PRODUCTDOCSFOLDER & "\" & strGUID & System.IO.Path.GetExtension(cmdBrowse.FileName) & glbProtectedExtension
End If
objCtrl.UpdateObjProductDoc(objDInfo)
End If
End Sub
#End Region
End Class
End Namespace