-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEditObserverOfScience.ascx.cs
223 lines (191 loc) · 5.83 KB
/
EditObserverOfScience.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
using System;
using System.Web.UI.WebControls;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using DotNetNuke.UI.UserControls;
namespace ObserverOfScience
{
public partial class EditObserverOfScience : PortalModuleBase
{
// ALT: private int itemId = Null.NullInteger;
private int? itemId = null;
#region Handlers
/// <summary>
/// Handles Page_Load event for a control
/// </summary>
/// <param name='sender'>
/// Sender.
/// </param>
/// <param name='e'>
/// Event args.
/// </param>
protected void Page_Load (object sender, EventArgs e)
{
try
{
// parse querystring parameters
int tmpItemId;
if (int.TryParse (Request.QueryString ["InventionID"], out tmpItemId))
itemId = tmpItemId;
if (!IsPostBack)
{
// load the data into the control the first time we hit this page
cmdDelete.Attributes.Add ("onClick", "javascript:return confirm('" + Localization.GetString ("DeleteItem") + "');");
// check we have an item to lookup
// ALT: if (!Null.IsNull (itemId)
if (itemId.HasValue)
{
// load the item
var ctrl = new ObserverOfScienceController ();
var item = ctrl.Get<InventionInfo> (itemId.Value, this.ModuleId);
if (item != null)
{
//TODO: Fill controls with data
txtTitle.Text=item.Name;
// txtListOfDevelopment.Text=item.ListOfDevelopment;
//txtDevelopment.Text=item.Development;
txtDescription.Text = item.Description;
// txtYearOfDevelopment.Text = item.YearOfDevelopment.ToString();
//setup audit control;
//ctlAudit.CreatedByUser = item.CreatedByUserName;
// ctlAudit.CreatedDate = item.CreatedOnDate.ToLongDateString ();
}
else
Response.Redirect (Globals.NavigateURL (), true);
}
else
{
cmdDelete.Visible = false;
ctlAudit.Visible = false;
}
}
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException (this, ex);
}
}
/// <summary>
/// Handles Click event for cmdUpdate button
/// </summary>
/// <param name='sender'>
/// Sender.
/// </param>
/// <param name='e'>
/// Event args.
/// </param>
protected void cmdUpdate_Click (object sender, EventArgs e)
{
try
{
var ctrl = new ObserverOfScienceController ();
ObserverOfScienceInfo item;
InventionInfo inv;
// determine if we are adding or updating
// ALT: if (Null.IsNull (itemId))
if (!itemId.HasValue)
{
// TODO: populate new object properties with data from controls
// to add new record
//Описание разработки
inv = new InventionInfo();
inv.Description = txtDescription.Text;
inv.Status = txtStatus.Text;
inv.YearOfCreation = DateTime.Today;// временно
inv.Advantages = txtAdvantages.Text;
inv.InventionEssence = txtInventionEssence.Text;
inv.Name = txtTitle.Text;
ctrl.Add<InventionInfo>(inv);
item = new ObserverOfScienceInfo ();
item.ModuleID = ModuleId;
item.CreatedByUser = this.UserId;
item.InventionId = inv.InventionID;
ctrl.Add<ObserverOfScienceInfo> (item);
//inv.Name = txtTitle.Text;
//ctrl.Add<InventionInfo>(inv);
//Суть разработки
//inv.Name = txtTitle.Text;
//ctrAdd<InventionInfo>(inv);
}
else
{
inv = ctrl.Get<InventionInfo> (itemId.Value);
inv.Description = txtDescription.Text;
inv.Advantages = txtAdvantages.Text;
inv.InventionEssence = txtInventionEssence.Text;
inv.Name = txtTitle.Text;
ctrl.Update<InventionInfo>(inv);
/*
inv = ctrl.Get<InventionInfo> (itemId.Value);
inv.Advantages = txtTitle.Text;
ctrl.Update<InventionInfo>(inv);
inv = ctrl.Get<InventionInfo> (itemId.Value);
inv.Name = txtTitle.Text;
ctrl.Update<InventionInfo>(inv);
*/
//по аналогии с выше написанным + править поля в таблицах инвеншанинфо и удалить поля из оbserver of sience кроме invenrionid и modulId
// TODO: update properties of existing object with data from controls
// to update existing record
//item = ctrl.Get<ObserverOfScienceInfo> (itemId.Value, this.ModuleId);
//item.Content = txtDescription.Text;
//ctrl.Update<ObserverOfScienceInfo> (item);
}
Response.Redirect (Globals.NavigateURL (), true);
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException (this, ex);
}
}
/// <summary>
/// Handles Click event for cmdCancel button
/// </summary>
/// <param name='sender'>
/// Sender.
/// </param>
/// <param name='e'>
/// Event args.
/// </param>
protected void cmdCancel_Click (object sender, EventArgs e)
{
try
{
Response.Redirect (Globals.NavigateURL (), true);
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException (this, ex);
}
}
/// <summary>
/// Handles Click event for cmdDelete button
/// </summary>
/// <param name='sender'>
/// Sender.
/// </param>
/// <param name='e'>
/// Event args.
/// </param>
protected void cmdDelete_Click (object sender, EventArgs e)
{
try
{
// ALT: if (!Null.IsNull (itemId))
if (itemId.HasValue)
{
var ctrl = new ObserverOfScienceController ();
ctrl.Delete<ObserverOfScienceInfo> (itemId.Value);
Response.Redirect (Globals.NavigateURL (), true);
}
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException (this, ex);
}
}
#endregion
}
}