Skip Navigation Links.

Northwind\WebControls\CalendarWCCBase.cs

D:\NorthwindForWeb\Northwind\CS\DotNet\ADO.Net\Northwind\WebControls\CalendarWCCBase.cs
/*
 * This file was generated by ProCG version 2.0
 *
 * File name:	Northwind\WebControls\CalendarWCCBase.cs
 * Language:	C# - ADO.Net 
 * Database:	My Sql
 *
 * Copyright (c) 2002-2019 iGenXSoft.
 * For more information visit http://www.igenxsoft.com
 */

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using Northwind.General;
using Northwind.Data;
using Northwind.WebControls;

namespace Northwind.WebControls
{
	/// <summary>
	/// Summary description for CategoryInputWCC.
	/// </summary>
	[DefaultProperty("Value"), 
	ToolboxData("<{0}:CalendarWCC runat=server></{0}:CategoryInputWCC>")]
	public class CalendarWCCBase : WebCustomControlWCC
	{
		protected System.Web.UI.WebControls.Label m_DateTimeLabel;
		protected System.Web.UI.WebControls.Calendar m_Calendar;
		protected DateTime					m_DateTime;

		public DateTime DateTime
		{
			get
			{
				EnsureChildControls();
				return DateTime.Parse(Value);
			}

			set
			{
				EnsureChildControls();
				Value = value.ToString();
			}
		}



		protected override void CreateChildControls()
		{
			if (this.FieldShowMode == FieldShowModeEnum.SHOW_NORMAL)
			{
				System.Web.UI.UpdatePanel updatePanel = new UpdatePanel();
				updatePanel.ID = "updatePanel";

				System.Web.UI.WebControls.Literal literal;

				m_Calendar = new Calendar();
				m_Calendar.ID = "Calendar";
				m_Calendar.SelectionChanged += new EventHandler(CalendarDateTime_Changed);
				m_Calendar.VisibleMonthChanged += new MonthChangedEventHandler(Calendar_VisibleMonthChanged);
				updatePanel.ContentTemplateContainer.Controls.Add(m_Calendar);
				this.Controls.Add(updatePanel);
			}
			else if (FieldShowMode == FieldShowModeEnum.SHOW_READ_ONLY)
			{
				m_DateTimeLabel = new Label();
				m_DateTimeLabel.ID = "CalendarLabel";
				this.Controls.Add(m_DateTimeLabel);
			}
		}

		void Calendar_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
		{
			UpdateField(e.NewDate.ToString());
		}

		private void CalendarDateTime_Changed(object sender, EventArgs e)
		{
			UpdateField(m_Calendar.SelectedDate.ToString());
		}

		protected override string GetCurrentControlValue()
		{
			string dateTimeString = string.Empty;

			if (this.FieldShowMode == FieldShowModeEnum.SHOW_NORMAL)
			{
				dateTimeString =  CalendarControl.SelectedDate.ToString();
			}
			else if (FieldShowMode == FieldShowModeEnum.SHOW_READ_ONLY)
			{
				dateTimeString = CalendarLabelControl.Text.ToString();
			}
			return dateTimeString;
		}

		protected override void SetCurrentControlValue(string value)
		{
			if (value == "") return;
			if (this.FieldShowMode == FieldShowModeEnum.SHOW_NORMAL)
			{
				CalendarControl.SelectedDate = Convert.ToDateTime(value);
			}
			else if (FieldShowMode == FieldShowModeEnum.SHOW_READ_ONLY)
			{
				CalendarLabelControl.Text = value;
			}
		}

		public Calendar CalendarControl
		{
			get
			{
				return (Calendar)this.FindControl("Calendar");
			}
		}

		public Label CalendarLabelControl
		{
			get
			{
				return (Label)this.FindControl("CalendarLabel");
			}
		}

	}
}


  //      3264 ProCG uses this line - don't edit it