using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using AjaxControlToolkit;
public partial class Calendar_EventCalendar : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!RolesManage.IsUserInRoles(User.Identity.Name, RolesManage.GetRole(EnumRoleType.Calendar)))
{
Response.Redirect("~/");
}
else
{
Intranet2012DataContext intranet2012 = new Intranet2012DataContext();
var roles = from ur in Roles.GetRolesForUser(User.Identity.Name)
join r in intranet2012.RoleTable on ur.ToString() equals r.ID.ToString("00")
where r.TypeID == (int)EnumRoleType.Calendar
select r;
foreach (var role in roles)
{
TabPanel newPanel = new TabPanel();
newPanel.HeaderText = role.RoleName;
switch (role.ID)
{
case 11:
UserControl calendar = (UserControl)Page.LoadControl("~/Calendar/Calendar.ascx");
newPanel.Controls.Add(calendar);
break;
default:
newPanel.Controls.Add(new LiteralControl(role.ID.ToString()));
break;
}
TabContainer1.Tabs.Add(newPanel);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
public partial class UserControls_EventCalendar : System.Web.UI.UserControl
{
private int rightHeight;
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["date"] == null)
{
ViewState["date"] = DateTime.Now;
Calendar((DateTime)ViewState["date"]);
EventDetail((DateTime)ViewState["date"]);
}
RollOverImageButton1.Click += new ImageClickEventHandler(RollOverImageButton1_Click);
RollOverImageButton2.Click += new ImageClickEventHandler(RollOverImageButton2_Click);
}
protected void RollOverImageButton1_Click(object sender, ImageClickEventArgs e)
{
DateTime currentDate = (DateTime)ViewState["date"];
ViewState["date"] = currentDate.AddMonths(-1);
Calendar((DateTime)ViewState["date"]);
EventDetail((DateTime)ViewState["date"]);
}
protected void RollOverImageButton2_Click(object sender, ImageClickEventArgs e)
{
DateTime currentDate = (DateTime)ViewState["date"];
ViewState["date"] = currentDate.AddMonths(1);
Calendar((DateTime)ViewState["date"]);
EventDetail((DateTime)ViewState["date"]);
}
protected void EventDetail(DateTime date)
{
PanelRight.Height = Unit.Parse(string.Format("{0}px", (rightHeight * 74).ToString()));
Label1.Text = string.Format("เดือน{0} {1}", date.ToString("MMMM", new System.Globalization.CultureInfo("th-TH")), date.ToString("yyyy", new System.Globalization.CultureInfo("th-TH")));
foreach (DataRow Dr in GetMonthActivity(date).Rows)
{
TableRow row2 = new TableRow();
TableActivity.Rows.Add(row2);
TableCell cell2 = new TableCell();
cell2.CssClass = "td_activity";
row2.Cells.Add(cell2);
string color;
switch ((int)Dr["TypeID"])
{
default:
color = "red";
break;
case 2:
color = "orange";
break;
case 3:
color = "green";
break;
case 4:
color = "#0066cc";
break;
case 5:
color = "#f06eaa";
break;
}
Table table1 = new Table();
cell2.Controls.Add(table1);
TableRow row11 = new TableRow();
table1.Rows.Add(row11);
TableCell cell11 = new TableCell();
row11.Cells.Add(cell11);
Panel panelType = new Panel();
panelType.Width = Unit.Parse("10px");
panelType.Height = Unit.Parse("10px");
panelType.Style.Add(HtmlTextWriterStyle.BackgroundColor, color);
cell11.Controls.Add(panelType);
TableCell cell12 = new TableCell();
if (Dr["ActivityName"].ToString().Length > 20)
{
cell12.Text = string.Format("{0}...", Dr["ActivityName"].ToString().Substring(0, 20));
cell12.ToolTip = Dr["ActivityName"].ToString();
}
else
{
cell12.Text = Dr["ActivityName"].ToString();
}
row11.Cells.Add(cell12);
TableRow row1 = new TableRow();
TableActivity.Rows.Add(row1);
TableCell cell1 = new TableCell();
cell1.CssClass = "td_activity";
cell1.Style.Add(HtmlTextWriterStyle.TextAlign, "right");
if (Convert.ToDateTime(Dr["StartDate"]).Date.CompareTo(Convert.ToDateTime(Dr["EndDate"]).Date) == 0)
{
if (Convert.ToDateTime(Dr["StartDate"]).ToString("HH:mm") == "08:30" && Convert.ToDateTime(Dr["EndDate"]).ToString("HH:mm") == "16:30")
{
cell1.Text = Convert.ToDateTime(Dr["StartDate"]).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("th-TH"));
}
else
cell1.Text = string.Format("{0} [{1}-{2}]", Convert.ToDateTime(Dr["StartDate"]).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("th-TH")), Convert.ToDateTime(Dr["StartDate"]).ToString("HH:mm", new System.Globalization.CultureInfo("th-TH")), Convert.ToDateTime(Dr["EndDate"]).ToString("HH:mm", new System.Globalization.CultureInfo("th-TH")));
}
else
{
cell1.Text = string.Format("{0} - {1}", Convert.ToDateTime(Dr["StartDate"]).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("th-TH")), Convert.ToDateTime(Dr["EndDate"]).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("th-TH")));
}
row1.Cells.Add(cell1);
}
}
protected void Calendar(DateTime date)
{
LabelMonthName.Text = date.ToString("เดือนMMMM พ.ศ. yyyy", new System.Globalization.CultureInfo("th-TH"));
int daysInMonth = DateTime.DaysInMonth(date.Year, date.Month);
int fristDayOfWeek = (int)DateTime.ParseExact(string.Format("1/{0}/{1}", date.Month.ToString(), date.Year.ToString()), "d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture).DayOfWeek;
int lastDayOfWeek = (int)DateTime.ParseExact(string.Format("{0}/{1}/{2}", daysInMonth.ToString(), date.Month.ToString(), date.Year.ToString()), "d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture).DayOfWeek;
int loopDays = daysInMonth + fristDayOfWeek + (7 - lastDayOfWeek);
rightHeight = (loopDays / 7) + 1;
foreach (TableRow Tbr in Table1.Rows)
{
if (Table1.Rows.GetRowIndex(Tbr) != 0)
Table1.Rows.Remove(Tbr);
}
TableRow Trh = new TableRow();
Table1.Rows.Add(Trh);
foreach (string str in new string[] {"อาทิตย์", "จันทร์", "อังคาร", "พุธ", "พฤหัสบดี", "ศุกร์", "เสาร์"})
{
TableCell Tch = new TableCell();
Trh.Cells.Add(Tch);
Tch.CssClass = "CalendarHead";
Tch.Text = str;
}
for (int i = 0; i < loopDays / 7; i++)
{
TableRow Tr = new TableRow();
Table1.Rows.Add(Tr);
for (int j = 0; j < 7; j++)
{
int printDay = j + (7 * i) - (fristDayOfWeek - 1);
TableCell Tc = new TableCell();
Tr.Cells.Add(Tc);
if (printDay < 1 || printDay > daysInMonth)
{
Tc.CssClass = "CalendarCell";
}
else
{
DateTime aDate = DateTime.ParseExact(string.Format("{0}/{1}/{2}", (j + (7 * i) - (fristDayOfWeek - 1)).ToString(), date.Month.ToString(), date.Year.ToString()), "d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture);
StringBuilder Sb = new StringBuilder();
Sb.AppendLine("<table style=\"width: 100%; height:100%; border-collapse: collapse;\">");
Sb.Append("<tr style=\"height: 20%;\">");
Sb.AppendLine("<td>");
Sb.AppendLine("<div>");
Sb.AppendFormat("<div class={0} style=\"float: left;\">{1}</div>", (DateTime.Now.ToShortDateString() == aDate.ToShortDateString()) ? "CalendarToday" : "CalendarDate", (j + (7 * i) - (fristDayOfWeek - 1)).ToString());
if (HaveHolidays(aDate))
{
Sb.AppendFormat("<div class=\"activitypanel1{0}\" style=\"width: 10px; height: 10px; float: right; margin-top: 5px; background-color: red;\"></div>", aDate.ToString("ddMMyy"));
AddBalloon(1, aDate);
}
Sb.AppendLine("</div>");
Sb.AppendLine("</td>");
Sb.AppendLine("</tr>");
Sb.AppendLine("<tr style=\"height: 40%;\">");
Sb.AppendLine("<td><div style=\"width: 10px; height: 10px;\"></div></td>");
Sb.AppendLine("</tr>");
Sb.AppendLine("<tr style=\"height: 20%;\">");
Sb.AppendLine("<td>");
Sb.AppendLine("<div>");
if (HaveMoENActivity(aDate))
{
Sb.AppendFormat("<div class=\"activitypanel2{0}\" style=\"width: 10px; height: 10px; float: left; margin-left: 6px; background-color: orange\"></div>", aDate.ToString("ddMMyy"));
AddBalloon(2, aDate);
}
if (HaveActivity(aDate))
{
Sb.AppendFormat("<div class=\"activitypanel3{0}\" style=\"width: 10px; height: 10px; float: left; margin-left: 6px; background-color: green\"></div>", aDate.ToString("ddMMyy"));
AddBalloon(3, aDate);
}
if (HaveMeeting(aDate))
{
Sb.AppendFormat("<div class=\"activitypanel4{0}\" style=\"width: 10px; height: 10px; float: left; margin-left: 6px; background-color: #0066cc\"></div>", aDate.ToString("ddMMyy"));
AddBalloon(4, aDate);
}
if (HaveTraining(aDate))
{
Sb.AppendFormat("<div class=\"activitypanel5{0}\" style=\"width: 10px; height: 10px; float: left; margin-left: 6px; background-color: #f06eaa\"></div>", aDate.ToString("ddMMyy"));
AddBalloon(5, aDate);
}
Sb.AppendLine("</div>");
Sb.AppendLine("</td>");
Sb.AppendLine("</tr>");
Sb.AppendLine("</table>");
Panel CalendarDate = new Panel();
CalendarDate.CssClass = "daypanel";
CalendarDate.Controls.Add(new LiteralControl(Sb.ToString()));
Tc.CssClass = (j == 0 || j == 6) ? "CalendarCellHolliday" : "CalendarCellNormal";
Tc.Controls.Add(CalendarDate);
if (HaveHolidays(aDate) || HaveMoENActivity(aDate) || HaveActivity(aDate) || HaveMeeting(aDate) || HaveTraining(aDate))
Tc.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(UpdatePanel3, aDate.ToShortDateString()));
}
}
}
}
ยังมีต่อ
Date :
2013-10-08 08:31:54
By :
ห้ามตอบเกินวันละ 2 กระทู้
No. 12
Guest
ต่อ
EventCalendar.ascx.cs
protected void UpdatePanel3_Load(object sender, EventArgs e)
{
string sEventArguments = this.Request.Params["__EVENTARGUMENT"];
if (!string.IsNullOrEmpty(sEventArguments))
{
if (IsNumeric(sEventArguments.Substring(0, 1)))
{
DateTime aDate;
if (DateTime.TryParse(sEventArguments, out aDate))
{
if (aDate.CompareTo(DateTime.Now.Date) == 0)
{
if (HaveHolidays(aDate))
{
string holidaysList = string.Empty;
foreach (DataRow Dr in GetHolidays(aDate).Rows)
{
holidaysList += string.Format("{0}, ", Dr["ActivityName"].ToString());
}
LabelTitle.Text = string.Format("<span style=\"color: blue;\">วันนี้</span> {0} - <span style=\"color: red;\">[{1}]</span>", aDate.ToString("\tวันddddที่ d MMMM พ.ศ. yyyy\t", new System.Globalization.CultureInfo("th-TH")), holidaysList.Substring(0, holidaysList.Length - 2));
}
else
{
LabelTitle.Text = string.Format("<span style=\"color: blue;\">วันนี้</span> {0}", aDate.ToString("\tวันddddที่ d MMMM พ.ศ. yyyy\t", new System.Globalization.CultureInfo("th-TH")));
}
}
else
{
if (HaveHolidays(aDate))
{
string holidaysList = string.Empty;
foreach (DataRow Dr in GetHolidays(aDate).Rows)
{
holidaysList += string.Format("{0}, ", Dr["ActivityName"].ToString());
}
LabelTitle.Text = string.Format("{0} - <span style=\"color: red;\">[{1}]</span>", aDate.ToString("วันddddที่ d MMMM พ.ศ. yyyy", new System.Globalization.CultureInfo("th-TH")), holidaysList.Substring(0, holidaysList.Length - 2));
}
else
{
LabelTitle.Text = aDate.ToString("วันddddที่ d MMMM พ.ศ. yyyy", new System.Globalization.CultureInfo("th-TH"));
}
}
}
foreach (string timeName in new string[] { "8.00", "9.00", "10.00", "11.00", "12.00", "13.00", "14.00", "15.00", "16.00" })
{
TableRow Tr1 = new TableRow();
TableDetail.Rows.Add(Tr1);
TableCell TcName = new TableCell();
TcName.RowSpan = 2;
TcName.CssClass = "row_head";
Tr1.Cells.Add(TcName);
Table TableName = new Table();
TableName.Width = Unit.Parse("100%");
TableName.Height = Unit.Parse(string.Format("{0}px", (600 / 12 - 1).ToString()));
TableName.Style.Add(HtmlTextWriterStyle.BorderCollapse, "collapse");
TcName.Controls.Add(TableName);
TableRow TrName = new TableRow();
TableName.Rows.Add(TrName);
TableCell Name = new TableCell();
Name.CssClass = "cell_name";
Name.Text = timeName;
TrName.Cells.Add(Name);
TableCell Tc1 = new TableCell();
Tc1.Width = Unit.Parse("90%");
Tc1.CssClass = "row_alt";
Tc1.Height = Unit.Parse(string.Format("{0}px", ((600 / 12 - 1) / 2).ToString()));
Tr1.Cells.Add(Tc1);
TableRow Tr2 = new TableRow();
TableDetail.Rows.Add(Tr2);
TableCell Tc2 = new TableCell();
Tc2.Height = Unit.Parse(string.Format("{0}px", ((600 / 12 - 1) / 2).ToString()));
Tr2.Cells.Add(Tc2);
}
Panel PanelActivity = new Panel();
PanelActivity.CssClass = "panel_activity";
PanelEventDetail.Controls.Add(PanelActivity);
int i = 0;
string[] color = new string[] { "red", "orange", "green", "#0066cc", "#f06eaa" };
foreach (DataRow Dr in GetAllActivity(aDate).Rows)
{
int top = GetTop((DateTime)Dr["StartDate"], aDate);
int height = GetHeight((DateTime)Dr["EndDate"], aDate, top);
Panel aPanel = new Panel();
aPanel.CssClass = "panel_detail";
aPanel.Height = Unit.Parse(string.Format("{0}px", height.ToString()));
aPanel.Style.Add(HtmlTextWriterStyle.Top, string.Format("{0}px", top.ToString()));
aPanel.Style.Add(HtmlTextWriterStyle.Left, string.Format("{0}px", (i * 150 + (i + 1) * 2 + i + i).ToString()));
aPanel.Style.Add(HtmlTextWriterStyle.BackgroundColor, color[(int)Dr["TypeID"] - 1]);
aPanel.Controls.Add(new LiteralControl(string.Format("<span style=\"color: white; font-weight: bold;\" title=\"{0} [{1}]\">{0}</span><br /><span style=\"color: white;\">[{1}]</span>", Dr["ActivityName"].ToString(), GetTime(top, height).ToString())));
PanelActivity.Controls.Add(aPanel);
i++;
}
ModalPopupExtender3.Show();
}
}
}
protected bool HaveHolidays(DateTime aDate)
{
Intranet2012DataContext intranet2012 = new Intranet2012DataContext();
return (from a in intranet2012.Activity
where a.TypeID == 1 && (a.StartDate.Date.CompareTo(aDate) <= 0 && a.EndDate.Date.CompareTo(aDate) >= 0)
select a).Count() > 0 ? true : false;
}
protected bool HaveMoENActivity(DateTime aDate)
{
Intranet2012DataContext intranet2012 = new Intranet2012DataContext();
return (from a in intranet2012.Activity
where a.TypeID == 2 && (a.StartDate.Date.CompareTo(aDate) <= 0 && a.EndDate.Date.CompareTo(aDate) >= 0)
select a).Count() > 0 ? true : false;
}
protected bool HaveActivity(DateTime aDate)
{
Intranet2012DataContext intranet2012 = new Intranet2012DataContext();
return (from a in intranet2012.Activity
where a.TypeID == 3 && (a.StartDate.Date.CompareTo(aDate) <= 0 && a.EndDate.Date.CompareTo(aDate) >= 0)
select a).Count() > 0 ? true : false;
}
protected bool HaveMeeting(DateTime aDate)
{
Intranet2012DataContext intranet2012 = new Intranet2012DataContext();
return (from a in intranet2012.Activity
where a.TypeID == 4 && (a.StartDate.Date.CompareTo(aDate) <= 0 && a.EndDate.Date.CompareTo(aDate) >= 0)
select a).Count() > 0 ? true : false;
}
protected bool HaveTraining(DateTime aDate)
{
Intranet2012DataContext intranet2012 = new Intranet2012DataContext();
return (from a in intranet2012.Activity
where a.TypeID == 5 && (a.StartDate.Date.CompareTo(aDate) <= 0 && a.EndDate.Date.CompareTo(aDate) >= 0)
select a).Count() > 0 ? true : false;
}
protected DataTable GetHolidays(DateTime aDate)
{
Intranet2012DataContext intranet2012 = new Intranet2012DataContext();
var holidays = from a in intranet2012.Activity
where a.TypeID == 1 && (a.StartDate.Date.CompareTo(aDate) <= 0 && a.EndDate.Date.CompareTo(aDate) >= 0)
select a;
return Intranet2012Datebase.LINQToDataTable(holidays);
}
protected DataTable GetAllActivity(DateTime aDate)
{
Intranet2012DataContext intranet2012 = new Intranet2012DataContext();
var activity = from a in intranet2012.Activity
where a.TypeID != 1 && (a.StartDate.Date.CompareTo(aDate) <= 0 && a.EndDate.Date.CompareTo(aDate) >= 0)
orderby a.StartDate ascending
select a;
return Intranet2012Datebase.LINQToDataTable(activity);
}
protected DataTable GetMonthActivity(DateTime aDate)
{
Intranet2012DataContext intranet2012 = new Intranet2012DataContext();
var activity = (from a in intranet2012.Activity
where (a.StartDate.Year == aDate.Year && a.StartDate.Month == aDate.Month) || (a.EndDate.Year == aDate.Year && a.EndDate.Month == aDate.Month)
orderby a.StartDate ascending
select a).ToList();
return Intranet2012Datebase.LINQToDataTable(activity);
}
protected void AddBalloon(int ActivityType, DateTime date)
{
ClientScriptManager clientScript = Page.ClientScript;
string scriptName = string.Format("activitypanel{0}{1}", ActivityType.ToString(), date.ToString("ddMMyy"));
if (!clientScript.IsStartupScriptRegistered(this.GetType(), scriptName))
{
Intranet2012DataContext intranet2012 = new Intranet2012DataContext();
var activity = from a in intranet2012.Activity
where a.TypeID == ActivityType && (a.StartDate.Date.CompareTo(date) <= 0 && a.EndDate.Date.CompareTo(date) >= 0)
orderby a.StartDate, a.EndDate ascending
select a;
string activityType = (from t in intranet2012.ActivityType
where t.ID == ActivityType
select t.TypeName).First();
string[] color = new string[] { "red", "orange", "green", "#0066cc", "#f06eaa" };
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("$(function() {");
stringBuilder.AppendFormat("$(\".activitypanel{0}{1}\").each(function()", ActivityType.ToString(), date.ToString("ddMMyy"));
stringBuilder.Append("{ $(this).balloon({ contents: \"");
stringBuilder.AppendFormat("<span style='margin: 10px 0px 0px 10px; font-weight: bold; color: {0}'>{1}</span><br />", color[ActivityType - 1], activityType);
stringBuilder.Append("<ul class='activitylist'>");
foreach (TableActivity a in activity)
{
string duration;
if (a.StartDate.Date.CompareTo(a.EndDate.Date) == 0 && a.StartDate.TimeOfDay == new TimeSpan(8, 30, 0) && a.EndDate.TimeOfDay == new TimeSpan(16, 30, 0))
{
duration = "[เต็มวัน]";
}
else if (a.StartDate.Date.CompareTo(a.EndDate.Date) != 0)
{
duration = string.Format("[{0} - {1}]", a.StartDate.ToString("dd MMM yyyy", new System.Globalization.CultureInfo("th-TH")), a.EndDate.ToString("dd MMM yyyy", new System.Globalization.CultureInfo("th-TH")));
}
else
{
duration = string.Format("[{0}น. - {1}น.]", a.StartDate.ToString("HH:mm"), a.EndDate.ToString("HH:mm"));
}
stringBuilder.AppendFormat("<li>{0} {1}</li>", a.ActivityName, duration);
}
stringBuilder.Append("</ul>\", position: \"bottom\" }); });");
stringBuilder.AppendLine("});");
ScriptManager.RegisterStartupScript(Page, this.GetType(), scriptName, stringBuilder.ToString(), true);
}
}
ยังมีต่อ
Date :
2013-10-08 08:33:17
By :
ห้ามตอบเกินวันละ 2 กระทู้
No. 13
Guest
ต่อ
EventCalendar.ascx.cs
protected int GetHeight(DateTime EndDate, DateTime CurrentDate, int top)
{
int height = 416;
if (CurrentDate.CompareTo(EndDate.Date) > 0)
{
height = 416;
}
else if (CurrentDate.CompareTo(EndDate.Date) == 0)
{
switch (EndDate.ToString("HH:mm"))
{
case "09:00":
height = 26;
break;
case "09:30":
height = 52;
break;
case "10:00":
height = 78;
break;
case "10:30":
height = 104;
break;
case "11:00":
height = 130;
break;
case "11:30":
height = 156;
break;
case "12:00":
height = 182;
break;
case "12:30":
height = 208;
break;
case "13:00":
height = 234;
break;
case "13:30":
height = 260;
break;
case "14:00":
height = 286;
break;
case "14:30":
height = 312;
break;
case "15:00":
height = 338;
break;
case "15:30":
height = 364;
break;
case "16:00":
height = 390;
break;
case "16:30":
height = 416;
break;
}
}
return (height - top - 20 < 0) ? 416 - top - 20 : height - top - 20;
}
protected int GetTop(DateTime StartDate, DateTime CurrentDate)
{
int top = 0;
if (CurrentDate.CompareTo(StartDate.Date) < 0)
{
top = 0;
}
else if (CurrentDate.CompareTo(StartDate.Date) == 0)
{
switch (StartDate.ToString("HH:mm"))
{
case "08:30":
top = 0;
break;
case "09:00":
top = 26;
break;
case "09:30":
top = 52;
break;
case "10:00":
top = 78;
break;
case "10:30":
top = 104;
break;
case "11:00":
top = 130;
break;
case "11:30":
top = 156;
break;
case "12:00":
top = 182;
break;
case "12:30":
top = 208;
break;
case "13:00":
top = 234;
break;
case "13:30":
top = 260;
break;
case "14:00":
top = 286;
break;
case "14:30":
top = 312;
break;
case "15:00":
top = 338;
break;
case "15:30":
top = 364;
break;
case "16:00":
top = 390;
break;
}
}
return top;
}
protected string GetTime(int Top, int Height)
{
string start = string.Empty;
string end = string.Empty;
switch (Top)
{
case 0:
start = "08:30";
break;
case 26:
start = "09:00";
break;
case 52:
start = "09:30";
break;
case 78:
start = "10:00";
break;
case 104:
start = "10:30";
break;
case 130:
start = "11:00";
break;
case 156:
start = "11:30";
break;
case 182:
start = "12:00";
break;
case 208:
start = "12:20";
break;
case 234:
start = "13:00";
break;
case 260:
start = "13:30";
break;
case 286:
start = "14:00";
break;
case 312:
start = "14:30";
break;
case 338:
start = "15:00";
break;
case 364:
start = "15:30";
break;
case 390:
start = "16:00";
break;
}
switch (Height + Top + 20)
{
case 26:
end = "09:00";
break;
case 52:
end = "09:30";
break;
case 78:
end = "10:00";
break;
case 104:
end = "10:30";
break;
case 130:
end = "11:00";
break;
case 156:
end = "11:30";
break;
case 182:
end = "12:00";
break;
case 208:
end = "12:20";
break;
case 234:
end = "13:00";
break;
case 260:
end = "13:30";
break;
case 286:
end = "14:00";
break;
case 312:
end = "14:30";
break;
case 338:
end = "15:00";
break;
case 364:
end = "15:30";
break;
case 390:
end = "16:00";
break;
case 416:
end = "16:30";
break;
}
return string.Format("{0}น. - {1}น.", start, end);
}
public bool IsNumeric(string stringToTest)
{
int result;
if (int.TryParse(stringToTest, out result))
{
return true;
}
else
{
return false;
}
}
}
นี่คือที่ผมทำได้ สามารถดึงค่าจาก DB มาเช็คได้แล้ว
นี่คือ code ที่ดึงค่ามาครับ
Code (VB.NET)
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
Dim adoDATA As New DataTable
adoDATA = clsDB.GetDT("SELECT * FROM MST_Activity ")
For i As Integer = 0 To adoDATA.Rows.Count - 1
If e.Day.Date = Format(adoDATA.Rows(i).Item("ActDate"), "dd/MM/yyyy") Then
e.Cell.BackColor = System.Drawing.Color.Red
e.Cell.BorderColor = System.Drawing.Color.Gray
e.Cell.BorderWidth = 1
End If
Next
'If e.Day.Date = "11/10/2556" Or e.Day.Date = "10/10/2556" Then
' e.Cell.BackColor = System.Drawing.Color.Red
'End If
End Sub
ณ ตอนนี้ DB เก็บ ค่า ActDate แค่วันเดียว
ทีนี้ผมมีข้อสงสัยว่า
1. ถ้าเกิด DB เก็บค่าวันที่ของ Activity เป็นวันเริ่มต้นกับวันสิ้นสุด จะมีการเช็คค่าอย่างไรครับ?
2. อยากให้ตัวเลขตรงวันที่ไม่มีขีดเส้นใต้ทำยังไง? (ผมกำหนด underline เป็น false แล้วแต่ยังไม่หาย)
3. ปุ่ม Next & Prev สามารถกำหนดเป็นรูปได้มั้ยครับ?