01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.Linq;
04.
using
System.Web;
05.
using
System.Web.UI;
06.
using
System.Web.UI.WebControls;
07.
using
System.Web.Security;
08.
using
System.Data;
09.
using
System.Data.SqlClient;
10.
using
System.IO;
11.
using
System.Drawing;
12.
13.
namespace
Project
14.
{
15.
public
partial
class
testCalendar : System.Web.UI.Page
16.
{
17.
clsDatabase clsDB =
new
clsDatabase();
18.
SqlConnection mycn;
19.
SqlDataAdapter myda;
20.
DataSet ds =
new
DataSet();
21.
DataSet dsSelDate;
22.
String strConn;
23.
private
void
Page_Load(
object
sender, System.EventArgs e)
24.
{
25.
26.
strConn =
"Data Source=localhost;uid=sa;pwd=1234;Initial Catalog=northwind"
;
27.
mycn =
new
SqlConnection(strConn);
28.
myda =
new
SqlDataAdapter(
"Select * FROM Calendar_Event"
, mycn);
29.
30.
31.
GridView1.Visible =
false
;
32.
Calendar1.TodayDayStyle.BackColor = Color.Gray;
33.
Calendar1.TodayDayStyle.ForeColor = Color.White;
34.
}
35.
protected
void
CalendarDRender(
object
sender, System.Web.UI.WebControls.DayRenderEventArgs e)
36.
{
37.
38.
if
(!e.Day.IsOtherMonth)
39.
{
40.
foreach
(DataRow dr
in
ds.Tables[0].Rows)
41.
{
42.
if
((dr[
"DueDate"
].ToString() != DBNull.Value.ToString()))
43.
{
44.
DateTime dtEvent = (DateTime)dr[
"DueDate"
];
45.
if
(dtEvent.Equals(e.Day.Date))
46.
{
47.
e.Cell.BackColor = Color.PaleVioletRed;
48.
}
49.
}
50.
}
51.
}
52.
53.
else
54.
{
55.
e.Cell.Text =
""
;
56.
}
57.
}
58.
59.
protected
void
Calendar1_SelectionChanged1(
object
sender, EventArgs e)
60.
{
61.
62.
System.Globalization.CultureInfo en =
new
System.Globalization.CultureInfo(
"en-US"
);
63.
String Date_clik = Calendar1.SelectedDate.ToString(
"MM/dd/yyyy"
, en);
64.
this
.Literal1.Text = Date_clik;
65.
Literal1.Visible =
true
;
66.
67.
68.
myda =
new
SqlDataAdapter(
"Select * from Calendar_Event where DueDate='"
+ Calendar1.SelectedDate.ToString(
"MM/dd/yyyy"
, en) +
"'"
, mycn);
69.
dsSelDate =
new
DataSet();
70.
71.
72.
73.
74.
75.
76.
77.
78.
{
79.
80.
81.
GridView1.Visible =
true
;
82.
GridView1.DataSource = dsSelDate;
83.
GridView1.DataBind();
84.
85.
86.
}
87.
}
88.
89.
90.
91.
}
92.
}