-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathDefault.aspx.cs
More file actions
143 lines (129 loc) · 5.29 KB
/
Default.aspx.cs
File metadata and controls
143 lines (129 loc) · 5.29 KB
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
using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Don't cache so a refresh will go to server
// Stop Caching in IE
Response.Cache.SetCacheability(HttpCacheability.NoCache);
// Stop Caching in Firefox
Response.Cache.SetNoStore();
// Get environment variables and dump them
IDictionary vars = System.Environment.GetEnvironmentVariables();
System.Environment.GetEnvironmentVariables();
foreach (DictionaryEntry entry in vars)
{
// add to querystring all to dump all environment variables
if (Request.QueryString["all"] != null)
Response.Write(entry.Key + " = " + entry.Value + "<br>");
}
lblTime.Text = CurrentEnvironment.CurrentTime;
lblDotNetVersion.Text = CurrentEnvironment.CLRVersion;
lblPort.Text = CurrentEnvironment.Port;
lblInstanceID.Text = CurrentEnvironment.InstanceID;
lblInstanceIndex.Text = CurrentEnvironment.InstanceIndex;
lblInstanceStart.Text = CurrentEnvironment.Uptime;
lblBoundServices.Text = CurrentEnvironment.BoundServices.ToString();
lblDbEngine.Text = CurrentEnvironment.DbEngine.ToString();
// if a database service is bound, show the attendees
if (CurrentEnvironment.hasDbConnection)
{
AttendeeDataSource.ConnectionString = CurrentEnvironment.DbConnectionString;
// Read
AttendeeDataSource.SelectCommand = "select * from attendee";
// Delete
AttendeeDataSource.DeleteCommand = "delete from attendee where id=@id";
AttendeeDataSource.DeleteParameters.Add("id", System.Data.DbType.Int64, "0");
// SQL Server
if (CurrentEnvironment.DbEngine == CurrentEnvironment.DatabaseEngine.SqlServer)
{
// Create
AttendeeDataSource.InsertCommand = @"INSERT INTO [attendee]
([address]
,[city]
,[email_address]
,[first_name]
,[last_name]
,[phone_number]
,[state]
,[zip_code])
VALUES
('123 Main St.'
,'Louisville'
,'user1@example.com'
,'Workshop'
,'Participant'
,'502-123-4567'
,'KY'
,'12345')";
AttendeeDataSource.UpdateCommand = @"update [attendee]
set [address] = @address
,[city] = @city
,[email_address] = @email_address
,[first_name] = @first_name
,[last_name] = @last_name
,[phone_number] = @phone_number
,[state] = @state
,[zip_code] = @zip_code
WHERE id=@id";
}
else if (CurrentEnvironment.DbEngine == CurrentEnvironment.DatabaseEngine.MySql)
{
AttendeeDataSource.ProviderName = "MySql.Data.MySqlClient";
// Create
AttendeeDataSource.InsertCommand = @"INSERT INTO `attendee`
(`address`
,`city`
,`email_address`
,`first_name`
,`last_name`
,`phone_number`
,`state`
,`zip_code`)
VALUES
('123 Main St.'
,'Louisville'
,'user1@example.com'
,'Workshop'
,'Participant'
,'502-123-4567'
,'KY'
,'12345')";
AttendeeDataSource.UpdateCommand = @"UPDATE `attendee`
SET
`address` = @address,
`city` = @city,
`email_address` = @email_address,
`first_name` = @first_name,
`last_name` = @last_name,
`phone_number` = @phone_number,
`state` = @state,
`zip_code` = @zip_code
WHERE `id` = @id;";
}
if (!IsPostBack)
{
// Hidden by default, display
attendeePane.Visible = true;
//gridAttendees.DataSource = AttendeeRepository.getAttendees();
gridAttendees.DataKeyNames = new string[] { "id" };
gridAttendees.DataBind();
}
}
}
protected void btnKill_Click(object sender, EventArgs e)
{
CurrentEnvironment.KillApp();
}
protected void btnAddAttendee_Click(object sender, EventArgs e)
{
AttendeeDataSource.Insert();
Response.Redirect("/");
}
}