-
Notifications
You must be signed in to change notification settings - Fork 0
/
Configuration.ascx.cs
195 lines (165 loc) · 5.38 KB
/
Configuration.ascx.cs
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Localization;
using DotNetNuke.Services.Exceptions;
namespace forDNN.Modules.UniversalAutosave
{
public partial class Configuration : PortalModuleBase, IActionable
{
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
#region Private Properties
private int CurrentPage
{
get
{
return (Request.QueryString["currentpage"] == null) ? 1 : Convert.ToInt32(Request.QueryString["currentpage"]);
}
}
private int PageSize
{
get
{
return (Request.QueryString["pagesize"] == null) ? Convert.ToInt32(ddlConfigurationPageSize.SelectedValue) : Convert.ToInt32(Request.QueryString["pagesize"]);
}
}
#endregion
#region Event Handlers
private bool LoadSettings()
{
lnkAddConfiguration.NavigateUrl = EditUrl("ConfigurationEdit");
Session["ConfigurationSort"] = "Title";
return true;
}
protected void Page_Load(object sender, System.EventArgs e)
{
try
{
if (!LoadSettings())
{
return;
}
if (!IsPostBack)
{
DrawConfigurationList();
}
}
catch (Exception exc)
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
#endregion
#region Optional Interfaces
public DotNetNuke.Entities.Modules.Actions.ModuleActionCollection ModuleActions
{
get
{
DotNetNuke.Entities.Modules.Actions.ModuleActionCollection Actions = new DotNetNuke.Entities.Modules.Actions.ModuleActionCollection();
Actions.Add(GetNextActionID(),
Localization.GetString("AddConfiguration", this.LocalResourceFile),
DotNetNuke.Entities.Modules.Actions.ModuleActionType.AddContent,
"", "", EditUrl("ConfigurationEdit"), false, DotNetNuke.Security.SecurityAccessLevel.Edit, true, false);
return Actions;
}
}
#endregion
#region List
private void DrawConfigurationList()
{
List<ConfigurationInfo> lstConfigurations = ConfigurationController.Configuration_GetAllItems((string)Session["ConfigurationSort"]);
if (Request.QueryString["PageSize"] != null)
{
ddlConfigurationPageSize.SelectedValue = PageSize.ToString();
}
ctlPagingControl.TotalRecords = lstConfigurations.Count;
ctlPagingControl.PageSize = PageSize;
ctlPagingControl.CurrentPage = CurrentPage;
ctlPagingControl.TabID = this.TabId;
ctlPagingControl.QuerystringParams = string.Format("PageSize={0}", PageSize);
Localization.LocalizeDataGrid(ref grdConfig, this.LocalResourceFile);
grdConfig.PageSize = ctlPagingControl.PageSize;
grdConfig.CurrentPageIndex = ctlPagingControl.CurrentPage - 1;
grdConfig.DataSource = lstConfigurations;
grdConfig.DataBind();
}
private void DeleteConfiguration(int ConfigurationID)
{
ConfigurationController.Configuration_Delete(ConfigurationID);
DrawConfigurationList();
}
protected void ddlConfigurationPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
string URL =
DotNetNuke.Common.Globals.NavigateURL(
this.TabId, "",
new string[]
{
string.Format("currentpage={0}", 1),
string.Format("pagesize={0}", Convert.ToInt32(ddlConfigurationPageSize.SelectedValue))
});
Response.Redirect(URL, true);
}
protected void grdConfig_ItemDataBound(object sender, DataGridItemEventArgs e)
{
var item = e.Item;
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.SelectedItem)
{
ConfigurationInfo objConfig = (ConfigurationInfo)item.DataItem;
string EditItemURL = EditUrl("ConfigurationID", objConfig.ConfigurationID.ToString(), "ConfigurationEdit");
//Edit link
var imgColumnControl = item.Controls[0].Controls[0];
if (imgColumnControl is HyperLink)
{
var editLink = (HyperLink)imgColumnControl;
editLink.NavigateUrl = EditItemURL;
}
//Delete link
imgColumnControl = item.Controls[1].Controls[0];
if (imgColumnControl is ImageButton)
{
var delImage = (ImageButton)imgColumnControl;
delImage.CommandName = "delete";
delImage.CommandArgument = objConfig.ConfigurationID.ToString();
CommonController.AddConfirmation(delImage);
}
Literal litTitle = (Literal)item.FindControl("litTitle");
litTitle.Text = string.Format("<a href=\"{0}\">{1}</a>", EditItemURL, objConfig.Title);
}
}
protected void grdConfig_DeleteCommand(object source, DataGridCommandEventArgs e)
{
DeleteConfiguration(Convert.ToInt32(e.CommandArgument));
}
protected void grdConfig_SortCommand(object source, DataGridSortCommandEventArgs e)
{
Session["ConfigurationSort"] = e.SortExpression;
DrawConfigurationList();
}
#endregion
}
}