-
Notifications
You must be signed in to change notification settings - Fork 0
/
VenueCalendar.aspx.cs
223 lines (190 loc) · 8.72 KB
/
VenueCalendar.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
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Telerik.Web.UI;
public partial class VenueCalendar : Telerik.Web.UI.RadAjaxPage
{
private void Page_Load(object sender, EventArgs e)
{
HtmlLink lk = new HtmlLink();
HtmlHead head = (HtmlHead)Page.Header;
lk.Attributes.Add("rel", "canonical");
lk.Href = "http://hippohappenings.com/locale-calendar";
head.Controls.AddAt(0, lk);
HttpCookie cookie = Request.Cookies["BrowserDate"];
if (cookie == null)
{
cookie = new HttpCookie("BrowserDate");
cookie.Value = DateTime.Now.ToString();
cookie.Expires = DateTime.Now.AddDays(22);
Response.Cookies.Add(cookie);
}
DateTime dateNow = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));
if (!IsPostBack)
{
try
{
if (Session["User"] != null)
{
IntroLabel.Text = "Click on an event for information, send the information to friends or add the event to your calendar. ";
}
else
{
IntroLabel.Text = "Click on an event for information. And, <b><a style=\"text-decoration: none; color: #145769; font-size: 14px; font-family: Arial; text-decoration: underline;\" href=\"login\">Log in</a></b> or <b><a style=\"text-decoration: none; color: #145769; font-size: 14px; font-family: Arial; text-decoration: underline;\" href=\"Register.aspx\">Register</a></b> to be able to do much more!";
}
RadScheduler1.SelectedDate = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));
}
catch (Exception ex)
{
Response.Redirect("home");
}
}
string id = Request.QueryString["ID"].ToString();
RadScheduler1.DataSource = GetVenueEvents();
Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
DataSet ds = dat.GetData("SELECT Name FROM Venues WHERE ID=" + id);
CalendarHeading.Text = "<a class=\"NavyLink\" href=\"" + dat.MakeNiceName(ds.Tables[0].Rows[0]["Name"].ToString()) + "_" + id + "_Venue\">" + ds.Tables[0].Rows[0]["Name"].ToString() + "</a> Events Calendar ";
}
protected DataView GetVenueEvents()
{
HttpCookie cookie = Request.Cookies["BrowserDate"];
if (cookie == null)
{
cookie = new HttpCookie("BrowserDate");
cookie.Value = DateTime.Now.ToString();
cookie.Expires = DateTime.Now.AddDays(22);
Response.Cookies.Add(cookie);
}
Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
string id = Request.QueryString["ID"].ToString();
DataView dvNormal = dat.GetDataDV("SELECT EO.DateTimeStart AS Start, EO.DateTimeEnd AS " +
"[End], E.Header, CONVERT(NVARCHAR,E.ID)+';E;'+CONVERT(NVARCHAR,EO.ID) AS ID, V.Name "+
"FROM Event_Occurance EO, Events E, Venues " +
"V WHERE EO.EventID=E.ID AND E.Venue=V.ID AND V.ID=" + id);
return dvNormal;
}
protected DataView MergeDV(DataView firstDV, DataView secondDV)
{
DataTable dt = firstDV.ToTable();
DataRow oneRow;
foreach (DataRowView row in secondDV)
{
oneRow = dt.NewRow();
oneRow["Start"] = row["Start"];
oneRow["End"] = row["End"];
oneRow["Header"] = row["Header"];
oneRow["ID"] = row["ID"];
oneRow["Name"] = row["Name"];
dt.Rows.Add(oneRow);
}
return new DataView(dt, "", "", DataViewRowState.CurrentRows);
}
protected void Page_Init(object sender, EventArgs e)
{
HttpCookie cookie = Request.Cookies["BrowserDate"];
if (cookie == null)
{
cookie = new HttpCookie("BrowserDate");
cookie.Value = DateTime.Now.ToString();
cookie.Expires = DateTime.Now.AddDays(22);
Response.Cookies.Add(cookie);
}
Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
Session["Type"] = "Calendar";
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
}
protected void RadAjaxManager1_AjaxSettingCreating(object sender, Telerik.Web.UI.AjaxSettingCreatingEventArgs e)
{
e.UpdatePanel.UpdateMode = UpdatePanelUpdateMode.Always;
}
protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
{
HttpCookie cookie = Request.Cookies["BrowserDate"];
string venueID = Request.QueryString["ID"].ToString();
char[] delim = { ';' };
string[] tokens = e.Appointment.ID.ToString().Split(delim);
string aptmntID = tokens[0];
string reOcurrID = tokens[2];
string switchOn = tokens[1];
Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
DateTime dateNow = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));
DataSet ds = dat.GetData("SELECT DATEADD(minute,450,EO.DateTimeStart) AS Start, DATEADD(minute,450,EO.DateTimeEnd) AS [End], E.Header, " +
"E.ID, E.Address, V.Name FROM Venues V, Events E, Event_Occurance EO WHERE E.Venue=V.ID AND " +
"EO.EventID=E.ID AND V.ID=" + venueID);
DataView dv = new DataView(ds.Tables[0], "ID=" + aptmntID, "", DataViewRowState.CurrentRows);
e.Appointment.ToolTip = "";
RadToolTip newToolTip = new RadToolTip();
string address = "";
DateTime date = e.Appointment.Start;
newToolTip.Text = "<div width=\"250px\" id=\"divE" + aptmntID + "\"><a href=\"" +
dat.MakeNiceName(e.Appointment.Subject) + "_" +
aptmntID + "_Event\" class=\"NavyLink12\">" +
dat.BreakUpString(e.Appointment.Subject, 20) + "</a>" +
"<br/>" + date.ToShortTimeString();
if (Session["User"] != null)
{
DataView dvUser = dat.GetDataDV("SELECT * FROM User_Calendar WHERE UserID=" +
Session["User"].ToString() + " AND EventID=" + aptmntID);
newToolTip.Text += "<br/><a href=\"javascript:OpenRad2('divE" + aptmntID + "','" +
aptmntID + "', 'E', " + reOcurrID + ");\"><img title=\"Send info to friends\" alt=\"Send info to " +
"friends\" style=\"border: none;\" " +
"src=\"image/Envelope.png\" /></a>";
string addText = "";
if (dvUser.Count > 0)
{
e.Appointment.BackColor = System.Drawing.Color.Yellow;
newToolTip.Text = "<span style=\"color: orange;\">Event is in your calendar</span>" +
newToolTip.Text + "</div>";
}
else
{
newToolTip.Text += "<a style=\"text-decoration: none;\" " +
"href=\"javascript:AddToCalendar('divE" + aptmntID + "','" +
aptmntID + "', 'E');\"><img style=\"padding-bottom: 4px; border: 0;\" " +
"title=\"Add to Calendar\" alt=\"Add to Calendar\" " +
"src=\"image/CalendarIcon.png\" /></a></div>";
}
}
else
newToolTip.Text += "</div>";
newToolTip.TargetControlID = e.Appointment.ClientID;
newToolTip.IsClientID = true;
newToolTip.ManualClose = true;
newToolTip.HideEvent = ToolTipHideEvent.ManualClose;
newToolTip.Animation = ToolTipAnimation.None;
newToolTip.AutoCloseDelay = 100000000;
newToolTip.HideDelay = 1000000;
newToolTip.ShowEvent = ToolTipShowEvent.OnClick;
newToolTip.Position = ToolTipPosition.MiddleRight;
newToolTip.Width = 250;
newToolTip.Skin = "Sunset";
ToolTipPanel.Controls.Add(newToolTip);
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
}
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
}
protected void RadCalendar1_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
{
}
protected void ShowAll_Click(object sender, EventArgs e)
{
}
protected void gotoAd(object sender, EventArgs e)
{
Response.Redirect("Ad.aspx?ID=1");
}
}