This repository has been archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathEditParameter.ascx.cs
200 lines (150 loc) · 4.77 KB
/
EditParameter.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
196
197
198
199
using System;
using DotNetNuke.Common;
using DotNetNuke.Entities.Modules;
namespace DNNStuff.SQLViewPro
{
public partial class EditParameter : PortalModuleBase
{
private const string STR_ReferringUrl = "EditParameter_ReferringUrl";
#region Web Form Designer Generated Code
//This call is required by the Web Form Designer.
[System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
{
}
private void Page_Init(Object sender, EventArgs e)
{
//CODEGEN: This method call is required by the Web Form Designer
//Do not modify it using the code editor.
InitializeComponent();
// initialize
ParameterId = int.Parse(DNNUtilities.QueryStringDefault(Request, "ParameterId", "-1"));
ReportSetId = int.Parse(DNNUtilities.QueryStringDefault(Request, "ReportSetId", "-1"));
InitParameter();
}
#endregion
#region Page
public int ReportSetId {get; set;}
public int ParameterId {get; set;}
public ParameterInfo Parameter {get; set;}
public string ParameterConfig {get; set;}
private void SaveReferringPage()
{
// save referring page
if (Request.UrlReferrer == null)
{
Session[STR_ReferringUrl] = Globals.NavigateURL();
}
else
{
Session[STR_ReferringUrl] = Request.UrlReferrer.AbsoluteUri;
}
}
private void Page_Load(Object sender, EventArgs e)
{
DNNUtilities.InjectCSS(Page, ResolveUrl("Resources/Support/edit.css"));
Page.ClientScript.RegisterClientScriptInclude(GetType(), "yeti", ResolveUrl("resources/support/yetii-min.js"));
if (Page.IsPostBack)
{
RenderParameterSettings();
}
else
{
SaveReferringPage();
// drop down parameter type
BindParameterType();
BindParameter();
// do parameter type
RenderParameterSettings();
RetrieveParameterSettings();
}
}
#endregion
#region Data
private void InitParameter()
{
var objParameterController = new ParameterController();
var objParameter = objParameterController.GetParameter(ParameterId);
// load from database
if (objParameter == null)
{
Parameter = new ParameterInfo();
}
else
{
Parameter = objParameter;
}
}
private void BindParameter()
{
txtName.Text = Parameter.ParameterName;
txtCaption.Text = Parameter.ParameterCaption;
ddParameterType.SelectedValue = Parameter.ParameterTypeId;
}
private void SaveParameter()
{
RetrieveParameterSettings();
var objParameterController = new ParameterController();
ParameterId = objParameterController.UpdateParameter(ReportSetId, ParameterId, txtName.Text, txtCaption.Text, ddParameterType.SelectedValue, ParameterConfig, -1);
}
private void BindParameterType()
{
var objParameterTypeController = new ParameterTypeController();
ddParameterType.DataTextField = "ParameterTypeName";
ddParameterType.DataValueField = "ParameterTypeId";
ddParameterType.DataSource = objParameterTypeController.ListParameterType();
ddParameterType.DataBind();
}
#endregion
#region Navigation
protected void cmdUpdate_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
SaveParameter();
// Redirect back to the Parameter set
NavigateBack();
}
}
protected void cmdCancel_Click(object sender, EventArgs e)
{
NavigateBack();
}
private void NavigateBack()
{
if (Session[STR_ReferringUrl] != null)
{
Response.Redirect(Session[STR_ReferringUrl].ToString());
}
}
#endregion
private void RetrieveParameterSettings()
{
var objParameterSettings = (Controls.ParameterSettingsControlBase) (phParameterSettings.FindControl("ParameterSettings"));
ParameterConfig = (string) objParameterSettings.UpdateSettings();
}
private void RenderParameterSettings()
{
var parameterTypeId = ddParameterType.SelectedValue;
var objParameterTypeController = new ParameterTypeController();
var objParameterType = objParameterTypeController.GetParameterType(parameterTypeId);
var objParameterSettingsBase = default(Controls.ParameterSettingsControlBase);
objParameterSettingsBase = (Controls.ParameterSettingsControlBase) (LoadControl(ResolveUrl(objParameterType.ParameterTypeSettingsControlSrc)));
objParameterSettingsBase.ID = "ParameterSettings";
if (Parameter != null)
{
objParameterSettingsBase.LoadSettings(Parameter.ParameterConfig);
}
else
{
objParameterSettingsBase.LoadSettings(null);
}
phParameterSettings.Controls.Add(objParameterSettingsBase);
// update settings requirements
txtCaption_Required.Enabled = Convert.ToBoolean(objParameterSettingsBase.CaptionRequired);
}
protected void ddParameterType_SelectedIndexChanged(object sender, EventArgs e)
{
RetrieveParameterSettings();
}
}
}