-
Notifications
You must be signed in to change notification settings - Fork 0
/
ESAFSiteObservations.aspx.cs
646 lines (599 loc) · 35.6 KB
/
ESAFSiteObservations.aspx.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace NBADWDataEntryApplication
{
/// <summary>
/// Summary description for ESAFSiteObservations_WaterCrossing.
/// </summary>
public partial class ESAFSiteObservations : System.Web.UI.Page
{
#region Controls
protected System.Data.OleDb.OleDbConnection oleDbConnection1;
protected NBADWDataEntryApplication.dscdEnvironmentalObservations objdscdEnvironmentalObservations;
protected System.Data.OleDb.OleDbDataAdapter oleDbdatblEnvironmentalObservations;
protected NBADWDataEntryApplication.dstblEnvironmentalObservations objdstblEnvironmentalObservations;
protected System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
protected System.Data.OleDb.OleDbDataAdapter oleDbdacdEnvironmentalObservations;
protected System.Data.OleDb.OleDbCommand oleDbSelectCommand3;
protected System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
protected System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;
protected System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;
protected System.Data.OleDb.OleDbDataAdapter oleDbdacdEnvironmentalObservations_Groups;
protected System.Data.DataView dvcdEnvironmentalObservations;
protected NBADWDataEntryApplication.dscdEnvironmentalObservations_Groups objdscdEnvironmentalObservations_Groups;
protected System.Data.OleDb.OleDbCommand oleDbSelectCommand2;
protected System.Data.OleDb.OleDbCommand oleDbInsertCommand2;
protected System.Data.OleDb.OleDbCommand oleDbUpdateCommand2;
protected System.Data.OleDb.OleDbCommand oleDbDeleteCommand2;
protected System.Data.DataView dvtblEnvironmentalObservations;
#endregion
protected void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack)
{
LoadDataSets();
dlstObservationGroup.DataBind();
dlstObservationGroup.SelectedIndex = 0;
SetdlstObservation();
dvtblEnvironmentalObservations.RowFilter = "AquaticActivityID = '"+Session["CurrentActivityID"].ToString()+"'";
dgCurrentRecords.DataBind();
try
{
if((bool)Session["Modify"])
{
dvtblEnvironmentalObservations.RowFilter = "AquaticActivityID = '"+Session["CurrentActivityID"].ToString()+"'";
dgCurrentRecords.DataBind();
btnNext.Visible = false;
btnReturn.Visible = true;
//Set Labels
lblh2.Text = "EDIT Assessment";
lblStep.Visible = false;
}
}
catch
{
//do nothing
}
}
else//retrieve datasets
{
System.IO.StringReader sr1 = new System.IO.StringReader((string)(ViewState["dSet1"]));
System.IO.StringReader sr2 = new System.IO.StringReader((string)(ViewState["dSet2"]));
//System.IO.StringReader sr3 = new System.IO.StringReader((string)(ViewState["dSet3"]));
objdscdEnvironmentalObservations_Groups.ReadXml(sr1);
objdscdEnvironmentalObservations.ReadXml(sr2);
//objdstblEnvironmentalObservations.ReadXml(sr3);
}
}
#region SetValues
public void SetdlstObservation()
{
Debug.WriteLine("Setting observations");
dvcdEnvironmentalObservations.RowFilter= "ObservationGroup= '"+dlstObservationGroup.SelectedItem+ "'";
dlstObservation.DataBind();
dlstObservation.SelectedIndex = 0;
SetSupplimentaryFields();
}
public void SetSupplimentaryFields()
{
ClearSupplimentaryValues();
switch (dlstObservation.SelectedValue)
{
//Other
case "4":
case "15":
case "18":
case "22":
case "33":
case "37":
case "38":
case "43":
case "48":
case "57":
lblSpecify.Visible = true;
txtSpecify.Visible = true;
break;
//Pipe Size
case "8":
lblPipeSize.Visible = true;
txtPipeSize.Visible = true;
txtPipeSizeValidator.Enabled = true;
break;
//Obstruction of fish passage
case "23":
case "24":
case "28":
case "29":
case "49":
case "50":
case "51":
case "52":
lblObstruction.Visible = true;
chkObstruction.Visible = true;
break;
//Name/Species
case "34":
case "35":
case "36":
lblSpecies.Visible = true;
txtSpecies.Visible = true;
break;
//Specify Name
case "46":
lblName.Visible = true;
txtName.Visible = true;
break;
}
}
public void ClearSupplimentaryValues()
{
lblSpecify.Visible = false;
txtSpecify.Visible = false;
lblPipeSize.Visible = false;
txtPipeSize.Visible = false;
txtPipeSizeValidator.Enabled = false;
lblObstruction.Visible = false;
chkObstruction.Visible = false;
lblSpecies.Visible = false;
txtSpecies.Visible = false;
lblName.Visible = false;
txtName.Visible = false;
}
#endregion
#region Fill & Load
public void FillDataSets(NBADWDataEntryApplication.dscdEnvironmentalObservations_Groups dataSet1, NBADWDataEntryApplication.dscdEnvironmentalObservations dataSet2, NBADWDataEntryApplication.dstblEnvironmentalObservations dataSet3)
{
// Turn off constraint checking before the dataset is filled.
// This allows the adapters to fill the dataset without concern
// for dependencies between the tables.
dataSet1.EnforceConstraints = false;
dataSet2.EnforceConstraints = false;
dataSet3.EnforceConstraints = false;
try
{
// Open the connection.
this.oleDbConnection1.Open();
// Attempt to fill the dataset through the OleDbDataAdapter1.
this.oleDbdacdEnvironmentalObservations_Groups.Fill(dataSet1);
this.oleDbdacdEnvironmentalObservations.Fill(dataSet2);
this.oleDbdatblEnvironmentalObservations.Fill(dataSet3);
}
catch (System.Exception fillException)
{
// Add your error handling code here.
throw fillException;
}
finally
{
// Turn constraint checking back on.
dataSet1.EnforceConstraints = true;
dataSet2.EnforceConstraints = true;
dataSet3.EnforceConstraints = true;
// Close the connection whether or not the exception was thrown.
this.oleDbConnection1.Close();
System.IO.StringWriter sw1 = new System.IO.StringWriter();
System.IO.StringWriter sw2 = new System.IO.StringWriter();
//System.IO.StringWriter sw3 = new System.IO.StringWriter();
// Write the DataSet to the ViewState property.
dataSet1.WriteXml(sw1);
dataSet2.WriteXml(sw2);
//dataSet3.WriteXml(sw3);
ViewState["dSet1"] = sw1.ToString();
ViewState["dSet2"] = sw2.ToString();
//ViewState["dSet3"] = sw3.ToString();
//tEO = objdstblEnvironmentalObservations.Tables["tblEnvironmentalObservations"];
}
}
public void LoadDataSets()
{
// Create a new dataset to hold the records returned from the call to FillDataSet.
// A temporary dataset is used because filling the existing dataset would
// require the databindings to be rebound.
NBADWDataEntryApplication.dscdEnvironmentalObservations_Groups objDataSetTemp1;
NBADWDataEntryApplication.dscdEnvironmentalObservations objDataSetTemp2;
NBADWDataEntryApplication.dstblEnvironmentalObservations objDataSetTemp3;
objDataSetTemp1 = new NBADWDataEntryApplication.dscdEnvironmentalObservations_Groups();
objDataSetTemp2 = new NBADWDataEntryApplication.dscdEnvironmentalObservations();
objDataSetTemp3 = new NBADWDataEntryApplication.dstblEnvironmentalObservations();
try
{
// Attempt to fill the temporary dataset.
this.FillDataSets(objDataSetTemp1, objDataSetTemp2, objDataSetTemp3);
}
catch (System.Exception eFillDataSet)
{
// Add your error handling code here.
throw eFillDataSet;
}
try
{
// Empty the old records from the dataset.
objdscdEnvironmentalObservations_Groups.Clear();
objdscdEnvironmentalObservations.Clear();
objdstblEnvironmentalObservations.Clear();
// Merge the records into the main dataset.
objdscdEnvironmentalObservations_Groups.Merge(objDataSetTemp1);
objdscdEnvironmentalObservations.Merge(objDataSetTemp2);
objdstblEnvironmentalObservations.Merge(objDataSetTemp3);
}
catch (System.Exception eLoadMerge)
{
// Add your error handling code here.
throw eLoadMerge;
}
}
public void FillTable(NBADWDataEntryApplication.dstblEnvironmentalObservations dataSet3)
{
// Turn off constraint checking before the dataset is filled.
// This allows the adapters to fill the dataset without concern
// for dependencies between the tables.
dataSet3.EnforceConstraints = false;
try
{
// Open the connection.
this.oleDbConnection1.Open();
// Attempt to fill the dataset through the OleDbDataAdapter1.
this.oleDbdatblEnvironmentalObservations.Fill(dataSet3);
}
catch (System.Exception fillException)
{
// Add your error handling code here.
throw fillException;
}
finally
{
// Turn constraint checking back on.
dataSet3.EnforceConstraints = true;
// Close the connection whether or not the exception was thrown.
this.oleDbConnection1.Close();
//System.IO.StringWriter sw3 = new System.IO.StringWriter();
// Write the DataSet to the ViewState property.
//dataSet3.WriteXml(sw3);
//ViewState["dSet3"] = sw3.ToString();
}
}
public void LoadTable()
{
// Create a new dataset to hold the records returned from the call to FillDataSet.
// A temporary dataset is used because filling the existing dataset would
// require the databindings to be rebound.
NBADWDataEntryApplication.dstblEnvironmentalObservations objDataSetTemp3;
objDataSetTemp3 = new NBADWDataEntryApplication.dstblEnvironmentalObservations();
try
{
// Attempt to fill the temporary dataset.
this.FillTable(objDataSetTemp3);
}
catch (System.Exception eFillDataSet)
{
// Add your error handling code here.
throw eFillDataSet;
}
try
{
// Empty the old records from the dataset.
objdstblEnvironmentalObservations.Clear();
// Merge the records into the main dataset.
objdstblEnvironmentalObservations.Merge(objDataSetTemp3);
}
catch (System.Exception eLoadMerge)
{
// Add your error handling code here.
throw eLoadMerge;
}
}
#endregion
#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()
{
this.oleDbdacdEnvironmentalObservations_Groups = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.objdscdEnvironmentalObservations = new NBADWDataEntryApplication.dscdEnvironmentalObservations();
this.oleDbdatblEnvironmentalObservations = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbDeleteCommand2 = new System.Data.OleDb.OleDbCommand();
this.oleDbInsertCommand2 = new System.Data.OleDb.OleDbCommand();
this.oleDbSelectCommand2 = new System.Data.OleDb.OleDbCommand();
this.oleDbUpdateCommand2 = new System.Data.OleDb.OleDbCommand();
this.objdstblEnvironmentalObservations = new NBADWDataEntryApplication.dstblEnvironmentalObservations();
this.dvcdEnvironmentalObservations = new System.Data.DataView();
this.oleDbdacdEnvironmentalObservations = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbSelectCommand3 = new System.Data.OleDb.OleDbCommand();
this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
this.objdscdEnvironmentalObservations_Groups = new NBADWDataEntryApplication.dscdEnvironmentalObservations_Groups();
this.dvtblEnvironmentalObservations = new System.Data.DataView();
((System.ComponentModel.ISupportInitialize)(this.objdscdEnvironmentalObservations)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.objdstblEnvironmentalObservations)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dvcdEnvironmentalObservations)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.objdscdEnvironmentalObservations_Groups)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dvtblEnvironmentalObservations)).BeginInit();
this.dgCurrentRecords.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgCurrentRecords_DeleteCommand);
//
// oleDbdacdEnvironmentalObservations_Groups
//
this.oleDbdacdEnvironmentalObservations_Groups.SelectCommand = this.oleDbSelectCommand1;
this.oleDbdacdEnvironmentalObservations_Groups.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "cdEnvironmentalObservations", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("ObservationGroup", "ObservationGroup")})});
//
// oleDbSelectCommand1
//
this.oleDbSelectCommand1.CommandText = "SELECT MIN(ObservationID) AS ObservationID, ObservationGroup FROM cdEnvironmental" +
"Observations GROUP BY ObservationGroup ORDER BY MIN(ObservationID)";
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
//
// oleDbConnection1
//
try
{
//this.oleDbConnection1.ConnectionString = @"Jet OLEDB:Registry Path=;Data Source=""C:\Data_Warehouse\Tabular_Data\NBAquaticDataWarehouse_DW.mdb"";Jet OLEDB:System database=;Jet OLEDB:Global Bulk Transactions=1;User ID=Admin;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:SFP=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Engine Type=5;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:Global Partial Bulk Ops=2;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Create System Database=False;Jet OLEDB:Database Locking Mode=1";
this.oleDbConnection1.ConnectionString = Session["ConnectionString"].ToString();
}
catch(System.NullReferenceException)
{
Server.Transfer("Login.aspx");
}
// objdscdEnvironmentalObservations
//
this.objdscdEnvironmentalObservations.DataSetName = "dscdEnvironmentalObservations";
this.objdscdEnvironmentalObservations.Locale = new System.Globalization.CultureInfo("en-US");
//
// oleDbdatblEnvironmentalObservations
//
this.oleDbdatblEnvironmentalObservations.DeleteCommand = this.oleDbDeleteCommand2;
this.oleDbdatblEnvironmentalObservations.InsertCommand = this.oleDbInsertCommand2;
this.oleDbdatblEnvironmentalObservations.SelectCommand = this.oleDbSelectCommand2;
this.oleDbdatblEnvironmentalObservations.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "tblEnvironmentalObservations", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("AquaticActivityID", "AquaticActivityID"),
new System.Data.Common.DataColumnMapping("EnvObservationID", "EnvObservationID"),
new System.Data.Common.DataColumnMapping("FishPassageObstructionInd", "FishPassageObstructionInd"),
new System.Data.Common.DataColumnMapping("Observation", "Observation"),
new System.Data.Common.DataColumnMapping("ObservationGroup", "ObservationGroup"),
new System.Data.Common.DataColumnMapping("ObservationSupp", "ObservationSupp"),
new System.Data.Common.DataColumnMapping("PipeSize_cm", "PipeSize_cm")})});
this.oleDbdatblEnvironmentalObservations.UpdateCommand = this.oleDbUpdateCommand2;
//
// oleDbDeleteCommand2
//
this.oleDbDeleteCommand2.CommandText = "DELETE FROM tblEnvironmentalObservations WHERE (EnvObservationID = ?)";
this.oleDbDeleteCommand2.Connection = this.oleDbConnection1;
this.oleDbDeleteCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("EnvObservationID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "EnvObservationID", System.Data.DataRowVersion.Original, null));
//
// oleDbInsertCommand2
//
this.oleDbInsertCommand2.CommandText = "INSERT INTO tblEnvironmentalObservations(AquaticActivityID, FishPassageObstructio" +
"nInd, Observation, ObservationGroup, ObservationSupp, PipeSize_cm) VALUES (?, ?," +
" ?, ?, ?, ?)";
this.oleDbInsertCommand2.Connection = this.oleDbConnection1;
this.oleDbInsertCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("AquaticActivityID", System.Data.OleDb.OleDbType.Integer, 0, "AquaticActivityID"));
this.oleDbInsertCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("FishPassageObstructionInd", System.Data.OleDb.OleDbType.Boolean, 2, "FishPassageObstructionInd"));
this.oleDbInsertCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Observation", System.Data.OleDb.OleDbType.VarWChar, 50, "Observation"));
this.oleDbInsertCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("ObservationGroup", System.Data.OleDb.OleDbType.VarWChar, 50, "ObservationGroup"));
this.oleDbInsertCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("ObservationSupp", System.Data.OleDb.OleDbType.VarWChar, 50, "ObservationSupp"));
this.oleDbInsertCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("PipeSize_cm", System.Data.OleDb.OleDbType.Integer, 0, "PipeSize_cm"));
//
// oleDbSelectCommand2
//
this.oleDbSelectCommand2.CommandText = "SELECT AquaticActivityID, EnvObservationID, FishPassageObstructionInd, Observatio" +
"n, ObservationGroup, ObservationSupp, PipeSize_cm FROM tblEnvironmentalObservati" +
"ons";
this.oleDbSelectCommand2.Connection = this.oleDbConnection1;
//
// oleDbUpdateCommand2
//
this.oleDbUpdateCommand2.CommandText = @"UPDATE tblEnvironmentalObservations SET AquaticActivityID = ?, FishPassageObstructionInd = ?, Observation = ?, ObservationGroup = ?, ObservationSupp = ?, PipeSize_cm = ? WHERE (EnvObservationID = ?) AND (AquaticActivityID = ? OR ? IS NULL AND AquaticActivityID IS NULL) AND (FishPassageObstructionInd = ?) AND (Observation = ? OR ? IS NULL AND Observation IS NULL) AND (ObservationGroup = ? OR ? IS NULL AND ObservationGroup IS NULL) AND (ObservationSupp = ? OR ? IS NULL AND ObservationSupp IS NULL) AND (PipeSize_cm = ? OR ? IS NULL AND PipeSize_cm IS NULL)";
this.oleDbUpdateCommand2.Connection = this.oleDbConnection1;
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("AquaticActivityID", System.Data.OleDb.OleDbType.Integer, 0, "AquaticActivityID"));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("FishPassageObstructionInd", System.Data.OleDb.OleDbType.Boolean, 2, "FishPassageObstructionInd"));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Observation", System.Data.OleDb.OleDbType.VarWChar, 50, "Observation"));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("ObservationGroup", System.Data.OleDb.OleDbType.VarWChar, 50, "ObservationGroup"));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("ObservationSupp", System.Data.OleDb.OleDbType.VarWChar, 50, "ObservationSupp"));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("PipeSize_cm", System.Data.OleDb.OleDbType.Integer, 0, "PipeSize_cm"));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_EnvObservationID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "EnvObservationID", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_AquaticActivityID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "AquaticActivityID", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_AquaticActivityID1", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "AquaticActivityID", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_FishPassageObstructionInd", System.Data.OleDb.OleDbType.Boolean, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "FishPassageObstructionInd", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Observation", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Observation", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Observation1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Observation", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationGroup", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationGroup", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationGroup1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationGroup", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationSupp", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationSupp", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationSupp1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationSupp", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_PipeSize_cm", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "PipeSize_cm", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_PipeSize_cm1", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "PipeSize_cm", System.Data.DataRowVersion.Original, null));
//
// objdstblEnvironmentalObservations
//
this.objdstblEnvironmentalObservations.DataSetName = "dstblEnvironmentalObservations";
this.objdstblEnvironmentalObservations.Locale = new System.Globalization.CultureInfo("en-US");
//
// dvcdEnvironmentalObservations
//
this.dvcdEnvironmentalObservations.Table = this.objdscdEnvironmentalObservations.cdEnvironmentalObservations;
//
// oleDbdacdEnvironmentalObservations
//
this.oleDbdacdEnvironmentalObservations.DeleteCommand = this.oleDbDeleteCommand1;
this.oleDbdacdEnvironmentalObservations.InsertCommand = this.oleDbInsertCommand1;
this.oleDbdacdEnvironmentalObservations.SelectCommand = this.oleDbSelectCommand3;
this.oleDbdacdEnvironmentalObservations.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "cdEnvironmentalObservations", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("Observation", "Observation"),
new System.Data.Common.DataColumnMapping("ObservationCategory", "ObservationCategory"),
new System.Data.Common.DataColumnMapping("ObservationGroup", "ObservationGroup"),
new System.Data.Common.DataColumnMapping("ObservationID", "ObservationID")})});
this.oleDbdacdEnvironmentalObservations.UpdateCommand = this.oleDbUpdateCommand1;
//
// oleDbDeleteCommand1
//
this.oleDbDeleteCommand1.CommandText = @"DELETE FROM cdEnvironmentalObservations WHERE (ObservationID = ?) AND (Observation = ? OR ? IS NULL AND Observation IS NULL) AND (ObservationCategory = ? OR ? IS NULL AND ObservationCategory IS NULL) AND (ObservationGroup = ? OR ? IS NULL AND ObservationGroup IS NULL)";
this.oleDbDeleteCommand1.Connection = this.oleDbConnection1;
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationID", System.Data.DataRowVersion.Original, null));
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Observation", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Observation", System.Data.DataRowVersion.Original, null));
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Observation1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Observation", System.Data.DataRowVersion.Original, null));
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationCategory", System.Data.OleDb.OleDbType.VarWChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationCategory", System.Data.DataRowVersion.Original, null));
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationCategory1", System.Data.OleDb.OleDbType.VarWChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationCategory", System.Data.DataRowVersion.Original, null));
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationGroup", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationGroup", System.Data.DataRowVersion.Original, null));
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationGroup1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationGroup", System.Data.DataRowVersion.Original, null));
//
// oleDbInsertCommand1
//
this.oleDbInsertCommand1.CommandText = "INSERT INTO cdEnvironmentalObservations(Observation, ObservationCategory, Observa" +
"tionGroup) VALUES (?, ?, ?)";
this.oleDbInsertCommand1.Connection = this.oleDbConnection1;
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Observation", System.Data.OleDb.OleDbType.VarWChar, 50, "Observation"));
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ObservationCategory", System.Data.OleDb.OleDbType.VarWChar, 40, "ObservationCategory"));
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ObservationGroup", System.Data.OleDb.OleDbType.VarWChar, 50, "ObservationGroup"));
//
// oleDbSelectCommand3
//
this.oleDbSelectCommand3.CommandText = "SELECT Observation, ObservationCategory, ObservationGroup, ObservationID FROM cdE" +
"nvironmentalObservations";
this.oleDbSelectCommand3.Connection = this.oleDbConnection1;
//
// oleDbUpdateCommand1
//
this.oleDbUpdateCommand1.CommandText = @"UPDATE cdEnvironmentalObservations SET Observation = ?, ObservationCategory = ?, ObservationGroup = ? WHERE (ObservationID = ?) AND (Observation = ? OR ? IS NULL AND Observation IS NULL) AND (ObservationCategory = ? OR ? IS NULL AND ObservationCategory IS NULL) AND (ObservationGroup = ? OR ? IS NULL AND ObservationGroup IS NULL)";
this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Observation", System.Data.OleDb.OleDbType.VarWChar, 50, "Observation"));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ObservationCategory", System.Data.OleDb.OleDbType.VarWChar, 40, "ObservationCategory"));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ObservationGroup", System.Data.OleDb.OleDbType.VarWChar, 50, "ObservationGroup"));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationID", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Observation", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Observation", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Observation1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Observation", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationCategory", System.Data.OleDb.OleDbType.VarWChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationCategory", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationCategory1", System.Data.OleDb.OleDbType.VarWChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationCategory", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationGroup", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationGroup", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ObservationGroup1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ObservationGroup", System.Data.DataRowVersion.Original, null));
//
// objdscdEnvironmentalObservations_Groups
//
this.objdscdEnvironmentalObservations_Groups.DataSetName = "dscdEnvironmentalObservations_Groups";
this.objdscdEnvironmentalObservations_Groups.Locale = new System.Globalization.CultureInfo("en-US");
//
// dvtblEnvironmentalObservations
//
this.dvtblEnvironmentalObservations.Table = this.objdstblEnvironmentalObservations.tblEnvironmentalObservations;
((System.ComponentModel.ISupportInitialize)(this.objdscdEnvironmentalObservations)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.objdstblEnvironmentalObservations)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dvcdEnvironmentalObservations)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.objdscdEnvironmentalObservations_Groups)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dvtblEnvironmentalObservations)).EndInit();
}
#endregion
#region Index Changed
protected void dlstObservationGroup_SelectedIndexChanged(object sender, System.EventArgs e)
{
Debug.WriteLine("index has changed");
SetdlstObservation();
}
protected void dlstObservation_SelectedIndexChanged(object sender, System.EventArgs e)
{
SetSupplimentaryFields();
}
#endregion
#region Buttons
protected void btnAdd_Click(object sender, System.EventArgs e)
{
DataTable tEO = objdstblEnvironmentalObservations.tblEnvironmentalObservations;
DataRow rEO = tEO.NewRow();
rEO["AquaticActivityID"] = Session["CurrentActivityID"];
rEO["ObservationGroup"] = dlstObservationGroup.SelectedItem;
rEO["Observation"] = dlstObservation.SelectedItem;
if (txtSpecify.Visible)
{
rEO["ObservationSupp"] = txtSpecify.Text;
}
if (txtPipeSize.Visible)
{
try
{
rEO["PipeSize_cm"] = int.Parse(txtPipeSize.Text);
}
catch (Exception)
{
}
}
if (chkObstruction.Visible)
{
rEO["FishPassageObstructionInd"] = chkObstruction.Checked;
}
if (txtSpecies.Visible)
{
rEO["ObservationSupp"] = txtSpecies.Text;
}
if (txtName.Visible)
{
rEO["ObservationSupp"] = txtName.Text;
}
tEO.Rows.Add(rEO);
try
{
oleDbdatblEnvironmentalObservations.Update(objdstblEnvironmentalObservations);
LoadTable();
dvtblEnvironmentalObservations.RowFilter = "AquaticActivityID = '"+Session["CurrentActivityID"].ToString()+"'";
dgCurrentRecords.DataBind();
if(!(bool)Session["Modify"])
{
btnNext.Visible = true;
}
}
catch (Exception ex)
{
Debug.WriteLine("Error during update of tblEnvironmental: "+ ex.ToString());
}
}
protected void btnNext_Click(object sender, System.EventArgs e)
{
Server.Transfer("ESAFSiteCharacteristics.aspx");
}
protected void btnReturn_Click(object sender, System.EventArgs e)
{
Server.Transfer("ESAFView.aspx");
}
#endregion
private void dgCurrentRecords_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
LoadTable();
int i = (int)dgCurrentRecords.DataKeys[(int) e.Item.ItemIndex];
DataRow dr = objdstblEnvironmentalObservations.tblEnvironmentalObservations.Rows.Find(i);
dr.Delete();
try
{
oleDbdatblEnvironmentalObservations.Update(objdstblEnvironmentalObservations);
LoadTable();
dvtblEnvironmentalObservations.RowFilter = "AquaticActivityID = '"+Session["CurrentActivityID"].ToString()+"'";
dgCurrentRecords.DataBind();
}
catch (Exception ex)
{
Debug.WriteLine("Error during delete of tblEnvironmental: "+ ex.ToString());
}
}
}
}