Skip Navigation Links.

Northwind\WebControls\ControlBase.cs

D:\NorthwindForWeb\Northwind\CS\DotNet\ADO.Net\Northwind\WebControls\ControlBase.cs
/*
 * This file was generated by ProCG version 2.0
 *
 * File name:	Northwind\WebControls\ControlBase.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.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using Northwind.General;
using Northwind.Data;
using System.Collections;
using System.ComponentModel;

namespace Northwind.WebControls
{
	public class NorthwindControlBase : WebControl, Northwind.WebControls.NorthwindControlInterface
	{
		protected DataManager m_DataManager;
		protected ComboBoxManager m_ComboBoxManager;
		protected NorthwindWebEnv m_WebEnv;
		protected string m_CollectionDataSourceControlId;
		protected CollectionDataSourceWCC m_CollectionDataSourceControl;
		protected IStructDataCollection m_DataCollection;
		protected CStructData m_Data;
		protected int m_Index = 0;
		protected Control m_Control;
		protected StateBag m_ViewState;
		protected string m_CollectionDataInstanceName;
		protected string m_DataInstanceName;
		protected IDictionary m_DataObjectsContainer;

		public  NorthwindControlBase(Control control, StateBag viewState)
		{
			m_Control = control;
			m_ViewState = viewState;
		}

		public string CollectionDataSourceControlId
		{
			get
			{
				if (m_CollectionDataSourceControlId == null || m_CollectionDataSourceControlId.Equals(string.Empty))
				{
					if (m_ViewState["CollectionDataSourceControlId"] == null)
						m_CollectionDataSourceControlId = string.Empty;
					else
						m_CollectionDataSourceControlId = (string)m_ViewState["DataCollectionSourceId"];
				}
				return m_CollectionDataSourceControlId;
			}
			set 
			{
				m_CollectionDataSourceControlId = value;
				m_ViewState["CollectionDataSourceControlId"] = value; 
			}
		}

		public CollectionDataSourceWCC CollectionDataSourceControl
		{
			get
			{
				if (m_CollectionDataSourceControl == null)
				{
					if (String.IsNullOrEmpty(CollectionDataSourceControlId))
						return null;
					Control dataCollectionSource = NorthwindWebEnv.FindControlRecursive(m_Control.Page, CollectionDataSourceControlId);
					if (dataCollectionSource == null)
						throw new Exception("DataCollectionSource with this Id " + CollectionDataSourceControlId + " was not found in the page");
					if (!(dataCollectionSource is CollectionDataSourceWCC))
						throw new Exception("DataCollectionSource control is not type of  CollectionDataSourceWCC");
					m_CollectionDataSourceControl = (CollectionDataSourceWCC)dataCollectionSource;
				}
				return m_CollectionDataSourceControl;
			}
		}

		public int Index
		{
			get
			{
				if (m_ViewState["Index"] == null)
					m_Index = 0;
				else
					m_Index = (int)m_ViewState["Index"];
				return m_Index;
			}
			set { m_ViewState["Index"] = value; }
		}

		public virtual NorthwindWebEnv WebEnv
		{
			get
			{
				return (m_WebEnv);
			}
			set
			{
				m_WebEnv = value;
			}
		}

		public DataManager DataManager
		{
			get
			{
				if (m_DataManager != null)
					return m_DataManager;
				if (m_Control.Page == null)
					return null;
				if (m_Control.Page is NorthwindPage)
				{
					NorthwindPage page = (NorthwindPage)(m_Control.Page);
					m_DataManager = (page.DataManager);
				}
				else
				{
					throw new Exception("Running in an invalid context - This can only in NorthwindPage page type");
				}
				return ((NorthwindPage)(m_Control.Page)).DataManager;
			}
			set
			{
				if (!m_DataManager.Equals(value))
				{
					m_DataManager = value;
				}
			}
		}

		public ComboBoxManager ComboBoxManager
		{
			get
			{
				if (m_ComboBoxManager != null)
					return m_ComboBoxManager;
				if (m_Control.Page == null)
					return null;

				if (m_Control.Page is NorthwindPage)
				{
					NorthwindPage page = (NorthwindPage)(m_Control.Page);
					m_ComboBoxManager = (page.ComboBoxManager);
					m_ComboBoxManager.EmptyOptionText = "";

				}
				else
				{
					throw new Exception("Running in an invalid context - This can only in NorthwindPage page type");
				}
				return m_ComboBoxManager;
			}
			set
			{
				m_ComboBoxManager = value;
				m_ComboBoxManager.EmptyOptionText = "";
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual CStructData Data
		{
			get
			{
				//if (m_Data != null)
				//{
				//    return m_Data;
				//}
				if (DataCollection != null)
				{
					int dataIndex = DataIndex;

					if (dataIndex >= DataCollection.Count)
						m_Data = null;
					else
						m_Data = DataCollection.GetAtReturnsStructData(dataIndex);
				}
				else
				{
					m_Data = GetStructDataFromDataInstanceName();
				}
				return m_Data;
			}
			set
			{
				if (value != null)
				{
					if (DataCollection != null)
					{
						SetDataToCollection(value);
						m_Data = value;
						return;
					}
					if (DataInstanceName == "")
						throw new Exception("DataInstanceName must be specified");
				}
				m_Data = value;
				if (DataObjectsContainer != null)
				{
					DataObjectsContainer[DataInstanceName] = m_Data;
				}
				else
				{
					if (KeepDataInSession)
						this.Page.Session[DataInstanceName] = m_Data;
					else
						this.m_ViewState[DataInstanceName] = m_Data;
				}

			}
		}

		public void SetDataToCollection(CStructData value)
		{
			IStructDataCollection structDataCollection = DataCollection;
			if (DataIndex >= 0 && structDataCollection != null)
			{
				if (value is CRecordData && (value as CRecordData).IsDeleted())
				{
					structDataCollection.RemoveAt(DataIndex);
				}
				else
				{
					if (DataIndex < structDataCollection.Count)
						structDataCollection[Index] = value;
				}
			}

			SetCollection(structDataCollection);
		}

		protected void SetCollection(IStructDataCollection structDataCollection)
		{

			if (CollectionDataSourceControl != null)
			{
				CollectionDataSourceWCC collectionDataSourde = CollectionDataSourceControl;
				collectionDataSourde.DataCollection = structDataCollection;
			}
			else if (String.IsNullOrEmpty(this.CollectionDataInstanceName))
			{
				if (DataObjectsContainer != null)
				{
					DataObjectsContainer[CollectionDataInstanceName] = structDataCollection;
				}
				else
				{
					if (KeepDataInSession)
						this.Page.Session[CollectionDataInstanceName] = structDataCollection;
					else
						this.m_ViewState[CollectionDataInstanceName] = structDataCollection;
				}
			}
		}

		public IStructDataCollection DataCollection
		{
			get
			{
				if (CollectionDataSourceControl != null)
				{
					CollectionDataSourceWCC collectionDataSourde = CollectionDataSourceControl;
					m_DataCollection = collectionDataSourde.DataCollection;
				}
				else if (!String.IsNullOrEmpty(this.CollectionDataInstanceName))
					m_DataCollection = DataCollectionFromCollectionDataInstanceName();
				return m_DataCollection;
			}
		}

		private IStructDataCollection DataCollectionFromCollectionDataInstanceName()
		{
			IStructDataCollection structDataCollection;

			if (DataObjectsContainer != null)
			{
				structDataCollection = (IStructDataCollection)DataObjectsContainer[CollectionDataInstanceName];
			}
			else
			{
				if (KeepDataInSession)
					structDataCollection = (IStructDataCollection)this.Page.Session[CollectionDataInstanceName];
				else
					structDataCollection = (IStructDataCollection)this.m_ViewState[CollectionDataInstanceName];
			}
			return structDataCollection;
		}
		
		private CStructData GetStructDataFromDataInstanceName()
		{

			if (DataInstanceName == "")
				throw new Exception("DataInstanceName must be specified");

			if (DataObjectsContainer != null)
			{

				if (DataObjectsContainer[DataInstanceName] != null)
				{
					m_Data = (CStructData)DataObjectsContainer[DataInstanceName];
				}
			}
			else
			{
				if (KeepDataInSession)
				{
					if (this.Page != null && this.Page.Session[DataInstanceName] != null)
						m_Data = (CStructData)this.Page.Session[DataInstanceName];
				}
				else
				{
					if (this.m_ViewState[DataInstanceName] != null)
						m_Data = (CStructData)this.m_ViewState[DataInstanceName];
				}
			}
			return m_Data;
		}

		
		public int DataIndex
		{
			get
			{
				int dataIndex = 0;

				if (CollectionDataSourceControl != null)
				{
					dataIndex = CollectionDataSourceControl.StartingIndex + this.Index;
				}
				else if (String.IsNullOrEmpty(this.CollectionDataInstanceName))
					dataIndex = Index;
				else
					dataIndex = Index;
				return dataIndex;
			}
		}
		
		public void DataChangedByClient()
		{
			CollectionDataSourceWCC collectionDataSourde = CollectionDataSourceControl;
			collectionDataSourde.DataCollection = m_DataCollection;
		}
		
		/*
		protected int FieldsListType
		{
			set
			{
				m_FieldsListType = value;
				m_ViewState["FieldsListType"] = value;
			}

			get
			{
				if (m_ViewState["FieldsListType"] == null)
					m_FieldsListType = 0;
				else
					m_FieldsListType = (int)m_ViewState["FieldsListType"];
				return (m_FieldsListType);
			}
		}
		 */

		public System.Collections.IDictionary DataObjectsContainer
		{
			get
			{
				return m_DataObjectsContainer;
			}
			set
			{
				m_DataObjectsContainer = value;
			}
		}

		[Browsable(true)]
		public string CollectionDataInstanceName
		{
			get
			{
				if (String.IsNullOrEmpty(m_CollectionDataInstanceName))
				{
					m_CollectionDataInstanceName = (string)this.m_ViewState["CollectionDataInstanceName"];
				}
				return m_CollectionDataInstanceName;
			}
			set
			{
				m_CollectionDataInstanceName = value;
				this.ViewState["CollectionDataInstanceName"] = value;
			}
		}

		[Browsable(true)]
		public string DataInstanceName
		{
			get
			{
				if (String.IsNullOrEmpty(m_DataInstanceName))
				{
					if (this.m_ViewState["DataInstanceName"] == null)
						DataInstanceName = this.DataObjectName;
					else
						m_DataInstanceName = (string)this.m_ViewState["DataInstanceName"];
				}
				return m_DataInstanceName;
			}
			set
			{
				m_DataInstanceName = value;
				this.m_ViewState["DataInstanceName"] = value;
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual string DataObjectName
		{
			get
			{
				if (Attributes["DataObjectName"] == null)
				{
					if (m_Data == null)

						return "";
					else
						return m_Data.GetType().ToString();
				}
				else
					return (Attributes["DataObjectName"]);
			}
			set
			{
				Attributes["DataObjectName"] = value;
			}
		}

		[Browsable(true)]
		public bool KeepDataInSession
		{
			get
			{
				if (m_ViewState["KeepDataInSession"] == null)
				{
					KeepDataInSession = true;
				}
				return ((bool)m_ViewState["KeepDataInSession"]);
			}
			set
			{
				m_ViewState["KeepDataInSession"] = value;
			}
		}
	}
}



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

2020 © iGenXSoft ProCG Generated Codes
pompy wtryskowe|cheap huarache shoes| bombas inyeccion|cheap jordans|cheap air max| cheap sneaker|wholesale jordans|cheap china jordans|cheap wholesale jordans