using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; namespace Education.Forms.Common { public partial class 起訖日顯示 : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } [Bindable(true)] public Object 起日 { get; set; } [Bindable(true)] public Object 迄日 { get; set; } [Bindable(true)] [DefaultValue("yyyy-MM-dd")] public string Format { get; set; } public override void DataBind() { base.DataBind(); if (DesignMode) return; DateTime dt起日 = WebLib.DAC.GetDateTime(起日); DateTime dt迄日 = WebLib.DAC.GetDateTime(迄日); if (dt起日.Ticks > 0) { lb起日.Text = dt起日.ToString(Format); } else { lb起日.Text = ""; } if (dt迄日.Ticks > 0 && dt起日.CompareTo(dt迄日) != 0) { lb至.Text = "至"; lb迄日.Text = dt迄日.ToString(Format); } else { lb至.Text = ""; lb迄日.Text = ""; } } } }