You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Web.UI.WebControls; using System.ComponentModel; using System.Data.SqlClient; using System.Text; using System.Drawing;
#region histroy
///程式代號:UCCalendar
///程式名稱:系統共用多日期選擇控件
///程式說明:
///xx.YYYY/MM/DD VER AUTHOR COMMENTS(說明修改的內容)
///01.2012/08/03 1.0 Ethan CREATE
#endregion
namespace OT.Controls { public class Calendar : System.Web.UI.WebControls.Calendar { public List<DateTime> SelectDate { set { ViewState["SelectDate"] = value; } get { if (ViewState["SelectDate"] == null) ViewState["SelectDate"] = new List<DateTime>(); return (List<DateTime>)ViewState["SelectDate"]; } }
public Dictionary<string, string> NameAndColors { set; get; //set
//{
// ViewState["NameAndColors"] = value;
//}
//get
//{
// if (ViewState["NameAndColors"] == null)
// ViewState["NameAndColors"] = new Dictionary<string, string>();
// return (Dictionary<string, string>)ViewState["NameAndColors"];
//}
}
public int ColumsCount { set { ViewState["ColumsCount"] = value; } get { if (ViewState["ColumsCount"] == null) ViewState["ColumsCount"] = 3; return Convert.ToInt32(ViewState["ColumsCount"]); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); }
protected override void OnDayRender(TableCell cell, CalendarDay day) { cell.VerticalAlign = VerticalAlign.Top; cell.HorizontalAlign = HorizontalAlign.Left; List<DateTime> lstSelectData = SelectDate; CheckBox chkSelect = new CheckBox(); ; chkSelect.ID = day.Date.ToString("yyyy/MM/dd"); chkSelect.Attributes.Add("Date", day.Date.ToString("yyyy/MM/dd")); chkSelect.Attributes.Add("onclick", "fnSelectDate(this);"); chkSelect.Text = day.Date.Day.ToString().PadLeft(2, '0'); if (lstSelectData.Contains(day.Date)) { chkSelect.Checked = true; } if (day.IsWeekend) { chkSelect.ForeColor = System.Drawing.Color.Red; } cell.Controls.Clear(); if (!day.IsOtherMonth) { cell.Controls.Add(chkSelect); if (NameAndColors != null) { int intCount = 3; foreach (KeyValuePair<string, string> item in NameAndColors) { if (item.Value.IndexOf(day.Date.ToString("yyyy/MM/dd")) > -1) { Label lblGoodDayName = new Label(); lblGoodDayName.Text = "■"; lblGoodDayName.ToolTip = item.Key; //lblGoodDayName.BackColor = ColorTranslator.FromHtml(item.Value.Split(';')[0]);
lblGoodDayName.ForeColor = ColorTranslator.FromHtml(item.Value.Split(';')[0]); lblGoodDayName.Font.Bold = true; if (intCount % ColumsCount == 0) { Literal ltrBr = new Literal(); ltrBr.Text = "<br />"; cell.Controls.Add(ltrBr); } cell.Controls.Add(lblGoodDayName); intCount++; } } } }
//base.OnDayRender(cell, day);
}
} }
|