Skip Navigation Links.

Northwind\WebControls\ToolBarWCCBase.cs

D:\Temp3\TestProjects\CSADO.Net\Northwind\WebControls\ToolBarWCCBase.cs
/*
 * This file was generated by ProCG version 2.0
 *
 * File name:	Northwind\WebControls\ToolBarWCCBase.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;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using Northwind.General;
using Northwind.Data;

namespace Northwind.WebControls
{
	/// <summary>
	/// Summary description for NorthwindToolBarWCCBase.
	/// </summary>
	[ToolboxData("<{0}:NorthwindToolBarWCCBase runat=server></{0}:NorthwindToolBarWCCBase>")]
	[Designer(typeof(Northwind.WebControls.NorthwindWebControlDesigner))]
	[ParseChildren(true)]
	[PersistChildren(false)]
	public class NorthwindToolBarWCCBase : System.Web.UI.WebControls.CompositeControl
	{
		protected string text;
		protected Hashtable m_FormButtonsTip;
		protected Hashtable m_GridButtonsTip;
		protected Hashtable m_DataControlButtonsTip;
		protected System.Web.UI.WebControls.Label m_MessageLabel;
		protected CToolbarAttributeCollection m_ToolbarAttributeCollection;
		protected CToolbarAttributeCollection m_UserToolbarAttributeCollection;
		protected CToolbarAttributeCollection m_ToolbarAttributeCollectionToCreateTheToolbarBy;
		
		protected NorthwindGrid m_Grid;
		protected NorthwindWCC m_WCC;
		protected CToolbarAttributeCollection m_EmptyToolbarAttributeCollection;
		public delegate void ToolBarDelegate(object sender, CommandEventArgs e);
		public event ToolBarDelegate ClickEvent;
		public delegate void GeneralWebEventHandler(Object sender, GeneralWebEvent args);
		public event GeneralWebEventHandler OnGeneralWebEvent;
		protected bool m_ToolbarCreated = false;
		public enum ToolBarTypeEnum
		{
			None = 0,
			Form = 1,
			DataControl = 2,
			Grid = 3,
			ChooseWindow = 4,
			CriteriaControl = 5
		}

		public NorthwindToolBarWCCBase()
			: base()
		{
			m_EmptyToolbarAttributeCollection = new CToolbarAttributeCollection();
		}

		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
			ClearAllMessages();
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public NorthwindGrid Grid
		{
			get
			{
				return (m_Grid);
			}
			set
			{
				m_Grid = value;
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public NorthwindWCC WCC
		{
			get
			{
				return (m_WCC);
			}
			set
			{
				m_WCC = value;
			}
		}

		/*
		public override string ID
		{
			get
			{
				if (this.Parent != null)
				{
					string id = this.NamingContainer.UniqueID + "_ToolBar";
					base.ID = id;
					return id;
				}
				else
					return base.ID;
			}
			set
			{

				base.ID = value;
			}
		}
		*/



		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

		public Label MessageLabel
		{
			get
			{
				if (m_MessageLabel == null)
				{
					m_MessageLabel = new Label();
					m_MessageLabel.ID = "Message";
					this.Controls.Add(m_MessageLabel);
				}
				return m_MessageLabel;
			}
		}



		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public int PageCount
		{
			get
			{
				if (Grid != null && Grid.PageCount > 1)
				{
					return Grid.PageCount;
				}
				else
					return (-1);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public int CurrentPageNum
		{
			get
			{
				if (Grid != null && Grid.CurrentPageIndex >= 0)
				{
					return Grid.CurrentPageIndex + 1;
				}
				else
					return (0);
			}
		}

		public void ShowToolbarItem(Northwind.General.GridButtonsEnum toolbarItem, bool bShow)
		{
			CToolbarAttribute toolbarAttribute = FindToolbar(toolbarItem);
			if (toolbarAttribute != null)
			{
				if (bShow)
					toolbarAttribute.Show = Northwind.General.ProCGYesNoEnum.YES;
				else
					toolbarAttribute.Show = Northwind.General.ProCGYesNoEnum.YES;
			}
		}

		public void Recreate()
		{
			CreateChildControls();
		}

		protected override void CreateChildControls()
		{
			if (this.Page == null) return;

			this.Controls.Clear();
			if (this.Grid != null)
				this.Grid.UpdateToolbarAttributes(ToolbarAttributeCollectionToCreateTheToolbarBy);
			if (this.WCC != null)
				this.WCC.UpdateToolbarAttributes(ToolbarAttributeCollectionToCreateTheToolbarBy);

			SendGeneralWebEvent(GeneralWebEvent.EventTypeEnum.BeforeCreateChildControls);
			WebControl toolbarItem;
			foreach (CToolbarAttribute toolbarAttribute in ToolbarAttributeCollectionToCreateTheToolbarBy)
			{

				if (toolbarAttribute.Show == Northwind.General.ProCGYesNoEnum.YES)
				{
					if (toolbarAttribute.Type == GridButtonsEnum.CUSTOM)
						toolbarItem = CreateCustomControl(toolbarAttribute);
					else
						toolbarItem = CreateButton(toolbarAttribute.Type);
				}
			}
			base.CreateChildControls();
			this.ChildControlsCreated = true;
			m_ToolbarCreated = true;
		}

		public bool ToolbarCreated
		{
			get
			{
				return m_ToolbarCreated;
			}
		}

		[Browsable(true)]
		[NotifyParentProperty(true)]
		public ToolBarTypeEnum ToolBarType
		{
			get
			{
				if (this.ViewState["ToolBarType"] == null)

					ToolBarType = ToolBarTypeEnum.None;
				return (ToolBarTypeEnum)this.ViewState["ToolBarType"];
			}
			set
			{
				if (this.ViewState["ToolBarType"] == null || (ToolBarTypeEnum)this.ViewState["ToolBarType"] != value)
				{
					this.ViewState["ToolBarType"] = value;
					/*
					if (ToolBarType != ToolBarTypeEnum.None)
					{
						if (this.ToolbarAttributeCollection.Count == 0) 
							CreateDefaultToolbarAttributeCollection();
					}
					*/
				}
			}
		}


		[Browsable(false)]
		public ImageButton EditLineButton
		{
			get
			{
				return (ImageButton)GetWebControl(GridButtonsEnum.EDIT_LINE);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton AddLineButton
		{
			get
			{
				return (ImageButton)GetWebControl(GridButtonsEnum.ADD_LINE);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton AddLineLikeButton
		{
			get
			{
				return (ImageButton)GetWebControl(GridButtonsEnum.ADD_LINE_LIKE);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton BackupButton
		{
			get
			{
				return (ImageButton)GetWebControl(GridButtonsEnum.BACKUP);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton DeleteLinesButton
		{
			get
			{
				return (ImageButton)GetWebControl(GridButtonsEnum.DELETE_LINES);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton UnDeleteLinesButton
		{
			get
			{
				return (ImageButton)GetWebControl(GridButtonsEnum.UN_DELETE_LINES);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton SelectButton
		{
			get
			{
				return (ImageButton)GetWebControl(GridButtonsEnum.SELECT);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton CancelSelectButton
		{
			get
			{
				return (ImageButton)GetWebControl(GridButtonsEnum.CANCEL_SELECT);
			}
		}


		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

		public ImageButton SelectAllButton
		{
			get
			{

				return (ImageButton)GetWebControl(GridButtonsEnum.SELECT_ALL);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton UnSelectAllButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.UN_SELECT_ALL);
			}
		}


		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton CopyButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.COPY);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton PasteButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.PASTE);
			}
		}


		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton DiscardChangesButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.DISCARD_CHANGES);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton SaveButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.SAVE);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton FirstPageButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.FIRST_PAGE);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton JumpBackButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.JUMP_BACK);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton BackPageButton
		{
			get
			{

				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.BACK_PAGE);
			}
		}


		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

		public ImageButton NextPageButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.NEXT_PAGE);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton JumpNextButton
		{
			get
			{

				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.JUMP_NEXT);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton LastPageButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.LAST_PAGE);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

		public ImageButton JumpToPageButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.JUMP_TO_PAGE);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public TextBox JumpToPageTextBox
		{
			get
			{
				EnsureChildControls();
				return (GetTextWebControl(GridButtonsEnum.JUMP_TO_PAGE));
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton PageSizeButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.PAGE_SIZE);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public TextBox PageSizeTextBox
		{
			get
			{
				EnsureChildControls();
				return (GetTextWebControl(GridButtonsEnum.PAGE_SIZE));
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public DropDownList EntitiesDropDownList
		{
			get
			{
				EnsureChildControls();
				return (DropDownList)GetWebControl(GridButtonsEnum.ENTITIES_LIST);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]


		public TextBox EntitiesTextBox
		{
			get
			{
				EnsureChildControls();
				return GetTextWebControl(GridButtonsEnum.ENTITIES_LIST);
			}
		}


		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton DigButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.DIG);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton OKButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.OK);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton CancelButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.CANCEL);
			}
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public ImageButton PrintButton
		{
			get
			{
				EnsureChildControls();
				return (ImageButton)GetWebControl(GridButtonsEnum.PRINT);
			}
		}

		protected ImageButton CreateButton(GridButtonsEnum buttonType)
		{
			if (this.Page == null) return null;

			System.Web.UI.WebControls.ImageButton buttonCreated = null;
			System.Web.UI.WebControls.TextBox textBoxCreated;
			System.Web.UI.WebControls.Label labelCreated;

			string webImageURL = Northwind.General.NorthwindGeneral.GetWebToolbarImagesURL(this.Page.Theme);
			string imageUrl;

			switch (buttonType)
			{
				case GridButtonsEnum.EDIT_LINE:
					buttonCreated = CreateToolbarButton(buttonType, webImageURL + "edit.png");
					break;

				case GridButtonsEnum.ADD_LINE:
					if (ToolBarType == ToolBarTypeEnum.Form)
						imageUrl = webImageURL + "add_record.png";
					else
						imageUrl = webImageURL + "add_line.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.ADD_LINE_LIKE:
					if (ToolBarType == ToolBarTypeEnum.Form)
						imageUrl = webImageURL + "duplicate_record.png";
					else
						imageUrl = webImageURL + "duplicate_line.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.DELETE_LINES:

					if (ToolBarType == ToolBarTypeEnum.Form || ToolBarType == ToolBarTypeEnum.DataControl)
					{
						imageUrl = webImageURL + "delete_record.png";
					}
					else
						imageUrl = webImageURL + "delete_selected.png";

					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					if (ToolBarType == ToolBarTypeEnum.Form || ToolBarType == ToolBarTypeEnum.DataControl)
					{
						buttonCreated.CausesValidation = false;
					}
					break;

				case GridButtonsEnum.UN_DELETE_LINES:
					imageUrl = webImageURL + "undelete_selected.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.SELECT:
					imageUrl = webImageURL + "select_line.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.CANCEL_SELECT:
					imageUrl = webImageURL + "cancel_select.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.SELECT_ALL:
					imageUrl = webImageURL + "select_all.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.UN_SELECT_ALL:
					imageUrl = webImageURL + "unselect_all.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.COPY:

					if (ToolBarType == ToolBarTypeEnum.Form || ToolBarType == ToolBarTypeEnum.DataControl)
						imageUrl = webImageURL + "copy.png";
					else
						imageUrl = webImageURL + "copy_selected_lines.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.PASTE:
					if (ToolBarType == ToolBarTypeEnum.Form || ToolBarType == ToolBarTypeEnum.DataControl)
						imageUrl = webImageURL + "paste.png";
					else
						imageUrl = webImageURL + "paste_selected_lines.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.DISCARD_CHANGES:
					imageUrl = webImageURL + "discard_changes.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					buttonCreated.CausesValidation = false;
					break;

				case GridButtonsEnum.SAVE:
					imageUrl = webImageURL + "save.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.FIRST_PAGE:
					imageUrl = webImageURL + "first_page.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);					
					break;

				case GridButtonsEnum.JUMP_BACK:
					imageUrl = webImageURL + "jump_back.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);					
					break;

				case GridButtonsEnum.BACK_PAGE:
					imageUrl = webImageURL + "back.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.NEXT_PAGE:
					imageUrl = webImageURL + "next.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.JUMP_NEXT:
					imageUrl = webImageURL + "jump_next.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.LAST_PAGE:
					imageUrl = webImageURL + "end.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.JUMP_TO_PAGE:
					imageUrl = webImageURL + "jump.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					textBoxCreated = NorthwindWebEnv.CreateTextBox();
					textBoxCreated.Width = 30;
					textBoxCreated.CssClass = "TextBoxInToolbarCss";
					textBoxCreated.Text = CurrentPageNum.ToString();
					textBoxCreated.ID = GridButtonsEnum.JUMP_TO_PAGE.ToString() + "Text";
					this.Controls.Add(textBoxCreated);

					labelCreated = new Label();
					labelCreated.Text = String.Format("/{0}", PageCount);
					labelCreated.Width = 30;
					labelCreated.ID = GridButtonsEnum.JUMP_TO_PAGE.ToString() + "Label";
					this.Controls.Add(labelCreated);					
					break;

				case GridButtonsEnum.PAGE_SIZE:
					imageUrl = webImageURL + "pagesize.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);

					textBoxCreated = NorthwindWebEnv.CreateTextBox();
					textBoxCreated.CssClass = "TextBoxInToolbarCss";
					textBoxCreated.Width = 30;

					textBoxCreated.ID = GridButtonsEnum.PAGE_SIZE.ToString() + "Text";
					this.Controls.Add(textBoxCreated);
					if (Grid != null)
					{
						textBoxCreated.Text = Grid.PageSize.ToString();
					}					
					break;

				case GridButtonsEnum.DIG:

					EditModeEnum editMode = EditModeEnum.ALL;

					if (Grid != null && Grid.RowsData != null)
					{
						editMode = NorthwindPage.DataManager.GetEditModeFor(NorthwindPage.User,Grid.RowsData.GetAtReturnsStructData(0));
					}
					else if (WCC != null && WCC.Data != null)
					{
						editMode = NorthwindPage.DataManager.GetEditModeFor(NorthwindPage.User, WCC.Data);
					}

					if (editMode == EditModeEnum.VIEW_ONLY)
						imageUrl = webImageURL + "view_details.png";
					else
						imageUrl = webImageURL + "edit_details.png";

					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					if (editMode == 0)
						buttonCreated.Visible = false;

					buttonCreated.CommandName = "Dig";
					break;

				case GridButtonsEnum.ENTITIES_LIST:
					CreateDropDownList(GridButtonsEnum.ENTITIES_LIST);					
					break;

				case GridButtonsEnum.OK:
					imageUrl = webImageURL + "search.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.CANCEL:
					imageUrl = webImageURL + "Cancel.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					buttonCreated.CausesValidation = false;
					break;

				case GridButtonsEnum.PRINT:
					if (ToolBarType == ToolBarTypeEnum.Form || ToolBarType == ToolBarTypeEnum.DataControl)
						imageUrl = webImageURL + "print.png";
					else
						imageUrl = webImageURL + "print.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					break;

				case GridButtonsEnum.BACKUP:
					imageUrl = webImageURL + "Backup.png";
					buttonCreated = CreateToolbarButton(buttonType, imageUrl);
					buttonCreated.CausesValidation = false;
					break;

				default:
					throw new Exception("Invalid Button type in CreateButton(" + buttonType.ToString() + ")");

			}
			if (buttonCreated != null)
			{
				SetDefaultButtonAttributes(buttonCreated);
				buttonCreated.Click += new ImageClickEventHandler(button_Click);
				if (this.Grid != null)
					NorthwindWebEnv.Trace(this, "ButtonCreated and Clicked set for " + buttonCreated.ID + " of Grid " + this.Grid.ID);
				else if (this.WCC != null)
					NorthwindWebEnv.Trace(this, "ButtonCreated and Clicked set for " + buttonCreated.ID + " of WCC " + this.WCC.ID);
				else
					NorthwindWebEnv.Trace(this, "ButtonCreated and Clicked set for " + buttonCreated.ID + " of Page " + this.Page.ID);

			}
			return (buttonCreated);
		}

		protected virtual ImageButton CreateToolbarButton(GridButtonsEnum buttonType, string imageName)
		{
			//if (this.Grid != null)
			//{
				ImageButton imageButton = new ImageButton();
				imageButton.ImageUrl = imageName;
				imageButton.CssClass = "ToolbarImageButton";
				imageButton.AlternateText = (string)ButtonsTip[buttonType];
				imageButton.ToolTip = (string)ButtonsTip[buttonType];
				imageButton.CommandName = buttonType.ToString();
				imageButton.ID = buttonType.ToString();
				imageButton.CausesValidation = false;
				this.Controls.Add(imageButton);
				if (buttonType == GridButtonsEnum.ADD_LINE)
					imageButton.CommandName = "AddRow";

				return imageButton;
			//}
			//else
			//{
			//    ToolbarButton toolbarButton = new ToolbarButton(buttonType.ToString(), buttonType.ToString());
			//    if (ToolBarType == ToolBarTypeEnum.Form)
			//    {
			//        toolbarButton.ButtonSize = ToolbarButtonSizeEnum.Large;
			//        toolbarButton.BGColor = ToolbarButtonBGColorEnum.Dark;
			//    }
			//    else
			//    {
			//        toolbarButton.ButtonSize = ToolbarButtonSizeEnum.Medium;
			//        toolbarButton.BGColor = ToolbarButtonBGColorEnum.Light;
			//    }
			//    return toolbarButton.ImageButton;
			//}
		}

		protected virtual WebControl CreateCustomControl(CToolbarAttribute toolbarAttribute)
		{
			switch (toolbarAttribute.ImplementAs)
			{
				case ImplementToolbarItemEnum.Button:
					Button buttonCreated = new Button();
					if (toolbarAttribute.Tip.Length > 1)
						buttonCreated.ToolTip = toolbarAttribute.Tip;
					buttonCreated.Text = toolbarAttribute.Text;
					buttonCreated.CssClass = "ToolbarButton";
					buttonCreated.CommandName = toolbarAttribute.Text;
					buttonCreated.ID = toolbarAttribute.Id;
					buttonCreated.Click += new EventHandler(CustomToolbarItemControl_Click);
					this.Controls.Add(buttonCreated);
					return buttonCreated;

				case ImplementToolbarItemEnum.ImageButton:
					ImageButton imageButtonCreated = new ImageButton();
					if (toolbarAttribute.Tip.Length > 1)
						imageButtonCreated.ToolTip = toolbarAttribute.Tip;
					imageButtonCreated.ImageUrl = toolbarAttribute.Text;
					imageButtonCreated.CssClass = "ToolbarImageButton";
					imageButtonCreated.CommandName = toolbarAttribute.Text;
					imageButtonCreated.ID = toolbarAttribute.Id;
					imageButtonCreated.Click += new ImageClickEventHandler(CustomImageButtonToolbar_Click);
					this.Controls.Add(imageButtonCreated);
					return imageButtonCreated;

				case ImplementToolbarItemEnum.Link:
					LinkButton linkeButtonCreated = new LinkButton();
					if (toolbarAttribute.Tip.Length > 1)
						linkeButtonCreated.ToolTip = toolbarAttribute.Tip;
					linkeButtonCreated.Text = toolbarAttribute.Text;
					linkeButtonCreated.CssClass = "ToolbarLink";
					linkeButtonCreated.CommandName = toolbarAttribute.Text;
					linkeButtonCreated.ID = toolbarAttribute.Id;
					linkeButtonCreated.Click += new EventHandler(CustomToolbarItemControl_Click);
					this.Controls.Add(linkeButtonCreated);
					return linkeButtonCreated;
					
				case ImplementToolbarItemEnum.DropDown:
					DropDownList dropDownListCreated = new DropDownList();
					if (toolbarAttribute.Text.Length > 0)
					{
						Label label = new Label();
						label.ID = toolbarAttribute.Id + "Label";
						label.Text = toolbarAttribute.Text;
						label.CssClass = "ToolbarLabel";
						this.Controls.Add(label);
					}
					dropDownListCreated.ToolTip = toolbarAttribute.Tip;
					dropDownListCreated.Text = toolbarAttribute.Text;
					dropDownListCreated.CssClass = "ToolbarDropDown";
					dropDownListCreated.AutoPostBack = true;
					dropDownListCreated.ID = toolbarAttribute.Id;
					dropDownListCreated.SelectedIndexChanged += new EventHandler(CustomeDropDownListCreated_SelectedIndexChanged);
					this.Controls.Add(dropDownListCreated);
					return dropDownListCreated;

				default:
					throw new Exception("Unsupported Implement toolbar type: " + toolbarAttribute.ImplementAs.ToString());
			}
		}

		public virtual void CustomeDropDownListCreated_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (this.Grid != null)
			{
				this.Grid.CustomToolbarItemControl_Click(sender);
			}
			else if (this.WCC != null)
			{
				this.WCC.CustomToolbarItemControl_Click(sender);
			}
			else
				(this.Page as NorthwindPage).OnCustomToolbarItemControlClicked(sender,null);
		}

		void CustomImageButtonToolbar_Click(object sender, ImageClickEventArgs e)
		{
			if (this.Grid != null)
			{
				this.Grid.CustomToolbarItemControl_Click(sender);
			}
			else if (this.WCC != null)
			{
				this.WCC.CustomToolbarItemControl_Click(sender);
			}
			else
				(this.Page as NorthwindPage).OnCustomToolbarItemControlClicked(sender, null);
		}

		void CustomToolbarItemControl_Click(object sender, EventArgs e)
		{
			if (this.Grid != null)
			{
				this.Grid.CustomToolbarItemControl_Click(sender);
			}
			else if (this.WCC != null)
			{
				this.WCC.CustomToolbarItemControl_Click(sender);
			}
			else
				(this.Page as NorthwindPage).OnCustomToolbarItemControlClicked(sender, null);
		}

		protected virtual WebControl GetCustomeWebControl(CToolbarAttribute toolbarAttribute)
		{
			try
			{
				WebControl webControl = (WebControl)this.FindControl(toolbarAttribute.Id);
				return (webControl);
			}
			catch (Exception ex)
			{
				int i = 5; // just to set a break point - for debug
				throw ex;
			}
		}

		protected Control GetWebControl(GridButtonsEnum buttonType)
		{
			Control webControl;
			try
			{
				EnsureChildControls();
				webControl = (Control)NorthwindWebEnv.FindControlRecursive(this, buttonType.ToString());
				return (webControl);
			}
			catch (Exception ex)
			{
				int i = 5; // just to set a break point - for debug
				throw ex;
			}
		}

		protected TextBox GetTextWebControl(GridButtonsEnum buttonType)
		{
			WebControl webControl;
			TextBox textBox;
			try
			{
				webControl = (WebControl)this.FindControl(buttonType.ToString() + "Text");
				textBox = (TextBox)webControl;
				return (textBox);
			}

			catch (Exception ex)
			{
				int i = 5;
				throw ex;
			}
		}

		public virtual WebControl GetWebControl(string id)
		{
			try
			{
				WebControl webControl = (WebControl)this.FindControl(id);
				return (webControl);
			}
			catch (Exception ex)
			{
				int i = 5; // just to set a break point - for debug
				throw ex;
			}
		}

		protected DropDownList CreateDropDownList(GridButtonsEnum buttonType)
		{
			DropDownList dropDownListCreated = null;
			TextBox textBoxCreated;

			switch (buttonType)
			{
				case GridButtonsEnum.ENTITIES_LIST:
					dropDownListCreated = new DropDownList();
					dropDownListCreated.CssClass = "entities_ddl";

					dropDownListCreated.AutoPostBack = true;
					dropDownListCreated.ID = GridButtonsEnum.ENTITIES_LIST.ToString();
					dropDownListCreated.EnableViewState = false;

					dropDownListCreated = dropDownListCreated;
					this.Controls.Add(dropDownListCreated);

					textBoxCreated = NorthwindWebEnv.CreateTextBox();
					textBoxCreated.ID = GridButtonsEnum.ENTITIES_LIST.ToString() + "Text";

					textBoxCreated.CssClass = "TextBoxOfDDLCss";
					textBoxCreated.Width = 40;
					this.Controls.Add(textBoxCreated);

					textBoxCreated.Attributes.Add("onchange", "SelectedValueTextChanged(" + dropDownListCreated.UniqueID.Replace(":", "_") + "," + textBoxCreated.UniqueID.Replace(":", "_") + ");");
					dropDownListCreated.Attributes.Add("onchange", textBoxCreated.UniqueID.Replace(":", "_") + @".value = this.options[this.selectedIndex].value;");

					if (!NorthwindGeneral.ShowCodeFieldWithComboBox)
						textBoxCreated.CssClass += " hidden";

					break;
				default:
					throw new Exception("Invalid DropDownList type in CreateDropDownList(" + buttonType.ToString() + ")");
			}
			return (dropDownListCreated);
		}


		protected void SetDefaultButtonAttributes(ImageButton buttonCreated)
		{
			buttonCreated.BorderWidth = 0;
			//buttonCreated.Width = 32;
			//buttonCreated.Height = 32;

		}


		/// <summary> 
		/// Render this control to the output parameter specified.
		/// </summary>
		/// <param name="output"> The HTML writer to write out to </param>
		protected override void Render(HtmlTextWriter output)
		{
			EnsureChildControls();
			//Recreate();
			bool bWasBotton = false;
			int lastGroupNum = 0;

			if (this.Grid != null)
				NorthwindWebEnv.Trace(this, "Render for " + this.ID + " of Grid " + this.Grid.ID);
			else if (this.WCC != null)
				NorthwindWebEnv.Trace(this, "Render for " + this.ID + " of WCC " + this.WCC.ID);
			else
				NorthwindWebEnv.Trace(this, "Render for " + this.ID + " of Page " + this.Page.ID);

			if (ToolBarType == ToolBarTypeEnum.Form)
			{
				output.Write("<div class='WCCWraper'>");
			}

			foreach (CToolbarAttribute toolbarAttribute in ToolbarAttributeCollectionToCreateTheToolbarBy)
			{
				if (toolbarAttribute.Show == Northwind.General.ProCGYesNoEnum.YES)
				{
					//if (bWasBotton) // anyhow add space at the beginning
					//{
					//    output.Write(HtmlTextWriter.SpaceChar);
					//}

					if (toolbarAttribute.GroupNum != lastGroupNum && lastGroupNum != -1 && lastGroupNum != 0)
					{
						output.Write(GroupSeperator);
						bWasBotton = false;
					}
					bWasBotton = RenderToolbarItem(toolbarAttribute, output);
					lastGroupNum = toolbarAttribute.GroupNum;
				}
			}

			output.Write("<br>");

			ErrorMessages.RenderControl(output);
			InformationMessages.RenderControl(output);

			if (ToolBarType == ToolBarTypeEnum.Form)
			{
				output.Write("</div>");
			}
			if (!this.DesignMode)
				InjectScripts(output);
		}

		virtual public void InjectScripts(HtmlTextWriter writer)
		{
			NorthwindPage espPage = (NorthwindPage)this.Page;
			if (espPage.ShowMessageBoxForControlsErrors && ErrorMessages.Text.Length > 0)
			{
				string scriptBlock =
					 @"	var prm = Sys.WebForms.PageRequestManager.getInstance();
						prm.add_endRequest(showErrors);				       
						function showErrors(sender, args)
						{
								alert(""" + ErrorMessages.Text + @""");
								prm.remove_endRequest(showErrors);	
						}";

				ScriptManager.RegisterStartupScript(this, typeof(NorthwindToolBarWCC), this.ID + "showInformationsInjected", scriptBlock, true);
				//ScriptManager.RegisterStartupScript(this.WCC, typeof(NorthwindWCC), this.ID + "showErrorsInjected", scriptBlock, true);
			}
			if (espPage.ShowMessageBoxForControlsInformations && InformationMessages.Text.Length > 0)
			{
				string scriptBlock =
					 @"	var prm = Sys.WebForms.PageRequestManager.getInstance();
						prm.add_endRequest(showInformations);				       
						function showInformations(sender, args)
						{
								alert(""" + InformationMessages.Text + @""");
								prm.remove_endRequest(showInformations);	
						}";
				ScriptManager.RegisterStartupScript(this, typeof(NorthwindToolBarWCC), this.ID + "showInformationsInjected", scriptBlock, true);
				//ScriptManager.RegisterStartupScript(this.WCC, typeof(NorthwindWCC), this.ID + "showErrorsInjected", scriptBlock, true);
			}

		}

		protected virtual bool RenderToolbarItem(CToolbarAttribute toolbarAttribute, HtmlTextWriter output)
		{
			EnsureChildControls();
			bool bWasBotton = false;
			Control webControl;
			bool isVisible = false;
			if (toolbarAttribute.Type == GridButtonsEnum.CUSTOM)
			{
				webControl = GetCustomeWebControl(toolbarAttribute);
				isVisible = webControl.Visible;
			}
			else
			{
				webControl = GetWebControl(toolbarAttribute.Type);
				if (webControl != null)
					isVisible = webControl.Visible;

			}
			if (webControl != null && isVisible && NeedToRenderToolbar(toolbarAttribute))
			{
				webControl.RenderControl(output);

				WebControl textWebControl = GetTextWebControl(toolbarAttribute.Type);
				if (textWebControl != null)
				{
					output.Write(HtmlTextWriter.SpaceChar);
					textWebControl.RenderControl(output);
				}
				webControl = (WebControl)this.FindControl(toolbarAttribute.Type.ToString() + "Label");
				if (webControl != null)
				{
					webControl.RenderControl(output);
				}

				bWasBotton = true;
			}

			return (bWasBotton);
		}

		protected virtual bool NeedToRenderToolbar(CToolbarAttribute toolbarAttribute)
		{
			bool needToRenderToolbar = true;
			if (toolbarAttribute.Show == ProCGYesNoEnum.NO)
				return false;

			switch (toolbarAttribute.Type)
			{
				case GridButtonsEnum.EDIT_LINE:
					if (!AllowEdit)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.ADD_LINE:
					if (!AllowAdd)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.ADD_LINE_LIKE:
					if (!AllowAdd)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.DELETE_LINES:
					if (!AllowDelete)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.UN_DELETE_LINES:
					if (!AllowDelete)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.SELECT:
					if (!AllowSelect)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.CANCEL_SELECT:
					if (!AllowSelect)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.SELECT_ALL:
					if (!AllowSelect)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.UN_SELECT_ALL:
					if (!AllowSelect)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.COPY:
					if (!AllowAdd)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.PASTE:
					if (!AllowAdd)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.DISCARD_CHANGES:
					if (!AllowAdd && !AllowDelete && !AllowEdit)
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.SAVE:
					if ((!AllowAdd) && (!AllowDelete) && (!AllowEdit))
					{
						needToRenderToolbar = false;
					}
					break;

				case GridButtonsEnum.FIRST_PAGE:
					break;

				case GridButtonsEnum.JUMP_BACK:
					break;

				case GridButtonsEnum.BACK_PAGE:
					break;

				case GridButtonsEnum.NEXT_PAGE:
					break;

				case GridButtonsEnum.JUMP_NEXT:
					break;

				case GridButtonsEnum.LAST_PAGE:
					break;
				case GridButtonsEnum.JUMP_TO_PAGE:
					if (PageCount <= 1)
					{
						needToRenderToolbar = false;
					}
					break;
				case GridButtonsEnum.PAGE_SIZE:
					break;

				case GridButtonsEnum.DIG:
					break;

				case GridButtonsEnum.ENTITIES_LIST:
					break;

				case GridButtonsEnum.OK:
					break;

				case GridButtonsEnum.CANCEL:
					break;

				case GridButtonsEnum.PRINT:
					break;
			}
			return needToRenderToolbar;
		}


		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual string GroupSeperator
		{
			get
			{
				return ("&nbsp;");
			}
		}

		public CToolbarAttribute FindToolbar(Northwind.General.GridButtonsEnum toolbarType)
		{
			CToolbarAttribute toolbarAttribute = ToolbarAttributeCollectionToCreateTheToolbarBy.FindToolbar(toolbarType);
			return (toolbarAttribute);
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual Hashtable ButtonsTip
		{
			get
			{

				Hashtable buttonsTip = null;

				switch (ToolBarType)
				{

					case ToolBarTypeEnum.Form:
						buttonsTip = GetFormButtonsTip();
						break;
					case ToolBarTypeEnum.None:
					case ToolBarTypeEnum.Grid:
					case ToolBarTypeEnum.ChooseWindow:
					case ToolBarTypeEnum.CriteriaControl:
						buttonsTip = GetGridButtonsTip();
						break;
					case ToolBarTypeEnum.DataControl:
						buttonsTip = GetDataControlButtonsTip();
						break;
				}

				return (buttonsTip);
			}

			set
			{
				switch (ToolBarType)
				{
					case ToolBarTypeEnum.Form:

						m_FormButtonsTip = value;
						break;
					case ToolBarTypeEnum.Grid:
					case ToolBarTypeEnum.ChooseWindow:
						m_GridButtonsTip = value;
						break;
					case ToolBarTypeEnum.DataControl:
						m_DataControlButtonsTip = value;
						break;
				}
			}
		}



		protected virtual Hashtable GetFormButtonsTip()
		{
			if (m_FormButtonsTip == null)
			{
				m_FormButtonsTip = new Hashtable();
				m_FormButtonsTip[GridButtonsEnum.EDIT_LINE] = "Edit";
				m_FormButtonsTip[GridButtonsEnum.ADD_LINE] = "Add " + MainObjectName;
				m_FormButtonsTip[GridButtonsEnum.ADD_LINE_LIKE] = "Duplicate " + MainObjectName;
				m_FormButtonsTip[GridButtonsEnum.DELETE_LINES] = "Delete " + MainObjectName;
				m_FormButtonsTip[GridButtonsEnum.UN_DELETE_LINES] = "Undelete " + MainObjectName; // n/a
				m_FormButtonsTip[GridButtonsEnum.SELECT_ALL] = "Not Applicable";
				m_FormButtonsTip[GridButtonsEnum.UN_SELECT_ALL] = "Not Applicable";
				m_FormButtonsTip[GridButtonsEnum.COPY] = "Copy current " + MainObjectName;
				m_FormButtonsTip[GridButtonsEnum.PASTE] = "Paste";
				m_FormButtonsTip[GridButtonsEnum.DISCARD_CHANGES] = "Discard Changes";
				m_FormButtonsTip[GridButtonsEnum.SAVE] = "Save Changes";
				m_FormButtonsTip[GridButtonsEnum.FIRST_PAGE] = "First page";
				m_FormButtonsTip[GridButtonsEnum.JUMP_BACK] = "Previuous pages";
				m_FormButtonsTip[GridButtonsEnum.BACK_PAGE] = "Previous page";
				m_FormButtonsTip[GridButtonsEnum.NEXT_PAGE] = "Next page";

				m_FormButtonsTip[GridButtonsEnum.JUMP_NEXT] = "Next pages";

				m_FormButtonsTip[GridButtonsEnum.LAST_PAGE] = "Last page";
				m_FormButtonsTip[GridButtonsEnum.JUMP_TO_PAGE] = "Jump to page";
				m_FormButtonsTip[GridButtonsEnum.PAGE_SIZE] = "Set page size";
				m_FormButtonsTip[GridButtonsEnum.DIG] = "Not Applicable";
				m_FormButtonsTip[GridButtonsEnum.BACKUP] = "Backup this with all it's descendants";
			}
			return (m_FormButtonsTip);
		}


		protected virtual Hashtable GetGridButtonsTip()
		{
			if (m_GridButtonsTip == null)
			{

				m_GridButtonsTip = new Hashtable();
				m_GridButtonsTip[GridButtonsEnum.EDIT_LINE] = "Edit selected " + MainObjectName;
				m_GridButtonsTip[GridButtonsEnum.ADD_LINE] = "Add " + MainObjectName;
				m_GridButtonsTip[GridButtonsEnum.ADD_LINE_LIKE] = "Duplicate " + MainObjectName;

				m_GridButtonsTip[GridButtonsEnum.DELETE_LINES] = "Delete selected " + MainObjectName + "s";
				m_GridButtonsTip[GridButtonsEnum.UN_DELETE_LINES] = "Undelete selected " + MainObjectName + "s";
				m_GridButtonsTip[GridButtonsEnum.SELECT] = "Select";
				m_GridButtonsTip[GridButtonsEnum.CANCEL_SELECT] = "Cancel Select";
				m_GridButtonsTip[GridButtonsEnum.SELECT_ALL] = "Select All";
				m_GridButtonsTip[GridButtonsEnum.UN_SELECT_ALL] = "Unselect All";
				m_GridButtonsTip[GridButtonsEnum.COPY] = "Copy selected " + MainObjectName + "s";
				m_GridButtonsTip[GridButtonsEnum.PASTE] = "Paste " + MainObjectName + "s";
				m_GridButtonsTip[GridButtonsEnum.DISCARD_CHANGES] = "Discard Changes";
				m_GridButtonsTip[GridButtonsEnum.SAVE] = "Save Changes";
				m_GridButtonsTip[GridButtonsEnum.FIRST_PAGE] = "First page";
				m_GridButtonsTip[GridButtonsEnum.JUMP_BACK] = "Previous Pages";
				m_GridButtonsTip[GridButtonsEnum.BACK_PAGE] = "Previous page";
				m_GridButtonsTip[GridButtonsEnum.NEXT_PAGE] = "Next page";
				m_GridButtonsTip[GridButtonsEnum.JUMP_NEXT] = "Next pages";
				m_GridButtonsTip[GridButtonsEnum.LAST_PAGE] = "Last page";
				m_GridButtonsTip[GridButtonsEnum.JUMP_TO_PAGE] = "Jump to page";

				m_GridButtonsTip[GridButtonsEnum.PAGE_SIZE] = "Set page size";
				m_GridButtonsTip[GridButtonsEnum.DIG] = "Edit Details";
				m_GridButtonsTip[GridButtonsEnum.PRINT] = "Print";
				m_GridButtonsTip[GridButtonsEnum.OK] = "Search";
				m_GridButtonsTip[GridButtonsEnum.BACKUP] = "Backup this with all it's descendants";
			}
			return (m_GridButtonsTip);
		}


		protected virtual Hashtable GetDataControlButtonsTip()
		{
			if (m_DataControlButtonsTip == null)
			{
				m_DataControlButtonsTip = new Hashtable();
				m_DataControlButtonsTip[GridButtonsEnum.EDIT_LINE] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.ADD_LINE] = "Not Applicable";


				m_DataControlButtonsTip[GridButtonsEnum.ADD_LINE_LIKE] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.DELETE_LINES] = "Delete " + MainObjectName;
				m_DataControlButtonsTip[GridButtonsEnum.UN_DELETE_LINES] = "Undelete " + MainObjectName;
				m_DataControlButtonsTip[GridButtonsEnum.SELECT_ALL] = "Not Applicable";

				m_DataControlButtonsTip[GridButtonsEnum.UN_SELECT_ALL] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.COPY] = "Copy " + MainObjectName;
				m_DataControlButtonsTip[GridButtonsEnum.PASTE] = "Paste";
				m_DataControlButtonsTip[GridButtonsEnum.DISCARD_CHANGES] = "Discrad Changes";
				m_DataControlButtonsTip[GridButtonsEnum.SAVE] = "Save Changes to Database";
				m_DataControlButtonsTip[GridButtonsEnum.FIRST_PAGE] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.JUMP_BACK] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.BACK_PAGE] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.NEXT_PAGE] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.JUMP_NEXT] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.LAST_PAGE] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.JUMP_TO_PAGE] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.PAGE_SIZE] = "Not Applicable";
				m_DataControlButtonsTip[GridButtonsEnum.DIG] = "Edit Details";
				m_DataControlButtonsTip[GridButtonsEnum.OK] = ""; // vv
				m_DataControlButtonsTip[GridButtonsEnum.CANCEL] = "";
				m_DataControlButtonsTip[GridButtonsEnum.PRINT] = "Print";
				m_DataControlButtonsTip[GridButtonsEnum.BACKUP] = "Backup this with all it's descendants";

			}
			return (m_DataControlButtonsTip);
		}

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

		public virtual string MainObjectName
		{
			get
			{
				if (this.ViewState["MainObjectName"] == null)
				{
					switch (ToolBarType)
					{

						case ToolBarTypeEnum.Form:
							MainObjectName = "Record";
							break;

						case ToolBarTypeEnum.Grid:
							if (Grid == null)
							{
								MainObjectName = "Not Set";
							}
							else
							{
								MainObjectName = this.Grid.RowDataObjectName.Substring(1); // was "Line";
								MainObjectName = NorthwindGeneral.ExpandFromCSName(MainObjectName);
							}
							break;


						case ToolBarTypeEnum.DataControl:
							MainObjectName = "Data";
							break;
					}
				}

				string mainObjectName = (string)this.ViewState["MainObjectName"];
				return (mainObjectName);
			}
			set
			{
				this.ViewState["MainObjectName"] = value;
			}
		}

		/*
		public virtual void Recreate()
		{
			CreateChildControls();
		}
		*/

		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

		public virtual string[] PropertiesToHide
		{
			get
			{
				/*
				if (ToolBarType == ToolBarTypeEnum.Grid)
				{
					string[] propetiesToHide = {"Property1,Property2,..."};
					return (propetiesToHide);
				}
				else if (ToolBarType == ToolBarTypeEnum.DataControl)
				{
					string[] propetiesToHide = {"Property1,Property2,..."};
					return (propetiesToHide);
				}
				else if (ToolBarType == ToolBarTypeEnum.Form)
				{
					string[] propetiesToHide = {"Property1,Property2,..."};
					return (propetiesToHide);
				}
				else 
					return null;
				*/
				return (null);
			}
		}


		[PersistenceMode(PersistenceMode.InnerProperty)]
		[NotifyParentProperty(true)]
		public CToolbarAttributeCollection ToolbarAttributeCollection
		{
			get
			{
				if (ToolBarType != ToolBarTypeEnum.None && DesignMode)
				{
					return m_EmptyToolbarAttributeCollection;
				}
				if (m_ToolbarAttributeCollection == null)
					m_ToolbarAttributeCollection = new CToolbarAttributeCollection();
				else
					m_ToolbarAttributeCollection.RemoveDuplicates();

				return (m_ToolbarAttributeCollection);
			}
			set
			{
				m_ToolbarAttributeCollection = value;
			}

		}

		[Browsable(false)]
		public CToolbarAttributeCollection UserToolbarAttributeCollection
		{
			get
			{
				if (m_UserToolbarAttributeCollection != null)
					return m_UserToolbarAttributeCollection;
				if (Grid != null || WCC != null)
				{
					LastValuesManager lastValuesManager = SessionManager.LastValuesManager;
					string uniqueName = string.Format("{0}_{1}_{2}", this.Page.GetType().Name, this.Grid != null ? Grid.ID : WCC.ID, this.ID);
					List<CStructData> toolbarAttributesList = lastValuesManager.GetStructDataList("ToolbarAttributes", uniqueName, typeof(CToolbarAttribute));
					if (toolbarAttributesList != null)
						m_UserToolbarAttributeCollection = new CToolbarAttributeCollection(toolbarAttributesList);
				}
				return m_UserToolbarAttributeCollection;
			}
			set
			{
				m_UserToolbarAttributeCollection = value;
				m_ToolbarAttributeCollectionToCreateTheToolbarBy = null;
			}
		}


		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public CToolbarAttributeCollection ToolbarAttributeCollectionToCreateTheToolbarBy
		{
			get
			{
				if (m_ToolbarAttributeCollectionToCreateTheToolbarBy != null)
					return m_ToolbarAttributeCollectionToCreateTheToolbarBy;
				if (UserToolbarAttributeCollection != null)
				{
					m_ToolbarAttributeCollectionToCreateTheToolbarBy = new CToolbarAttributeCollection();
					m_ToolbarAttributeCollectionToCreateTheToolbarBy.CopyFrom(UserToolbarAttributeCollection);
					return m_ToolbarAttributeCollectionToCreateTheToolbarBy;
				}
				if (m_ToolbarAttributeCollection == null || m_ToolbarAttributeCollection.Count == 0)
				{
					if (ToolBarType != ToolBarTypeEnum.None)
					{
						CreateDefaultToolbarAttributeCollection();
					}
				}
				if (m_ToolbarAttributeCollection != null)
				{
					m_ToolbarAttributeCollectionToCreateTheToolbarBy = new CToolbarAttributeCollection();
					m_ToolbarAttributeCollectionToCreateTheToolbarBy.CopyFrom(m_ToolbarAttributeCollection);
				}
				return (m_ToolbarAttributeCollectionToCreateTheToolbarBy);
			}
		}


		protected void CreateDefaultToolbarAttributeCollection()
		{

			m_ToolbarAttributeCollection = new CToolbarAttributeCollection();

			switch (this.ToolBarType)
			{
				case ToolBarTypeEnum.Form:
					AddDefaultFormToolbarAttributes();
					break;

				case ToolBarTypeEnum.DataControl:
					AddDefaultDataControlToolbarAttributes();
					break;

				case ToolBarTypeEnum.Grid:
					AddDefaultGridToolbarAttributes();
					break;

				case ToolBarTypeEnum.ChooseWindow:
					AddDefaultChooseWindowToolbarAttributes();
					break;

				case ToolBarTypeEnum.CriteriaControl:
					AddDefaultCriteriaControlToolbarAttributes();
					break;

			}

		}

		protected virtual void AddDefaultFormToolbarAttributes()
		{
			CToolbarAttribute toolbarAttribute;

			// Save
			toolbarAttribute = new CToolbarAttribute();

			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.SAVE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Discrad changes
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 20;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.DISCARD_CHANGES;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Delete 
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 30;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.DELETE_LINES;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Print 
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 40;
			toolbarAttribute.Show = ProCGYesNoEnum.NO;
			toolbarAttribute.Type = GridButtonsEnum.PRINT;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Add New
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 40;
			toolbarAttribute.Show = ProCGYesNoEnum.NO;
			toolbarAttribute.Type = GridButtonsEnum.ADD_LINE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Add New Like Current
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 50;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.ADD_LINE_LIKE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Backup
			if (SessionManager.UserExist && SessionManager.User.Type == (short)UserTypeEnum.DEBUG)
			{
				toolbarAttribute = new CToolbarAttribute();
				toolbarAttribute.GroupNum = 3;
				toolbarAttribute.OrderInGroup = 10;
				toolbarAttribute.Show = ProCGYesNoEnum.YES;
				toolbarAttribute.Type = GridButtonsEnum.BACKUP;
				toolbarAttribute.Id = toolbarAttribute.Type.ToString();
				m_ToolbarAttributeCollection.Add(toolbarAttribute);
			}

			// Buttons for Collection
			// Previous
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 2;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.BACK_PAGE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Next

			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 2;
			toolbarAttribute.OrderInGroup = 20;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;

			toolbarAttribute.Type = GridButtonsEnum.NEXT_PAGE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Entities list
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 2;
			toolbarAttribute.OrderInGroup = 30;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.ENTITIES_LIST;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);


		}

		protected virtual void AddDefaultDataControlToolbarAttributes()
		{
			CToolbarAttribute toolbarAttribute;

			// Edit Details
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 5;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.DIG;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Save
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.SAVE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Discrad changes
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 20;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.DISCARD_CHANGES;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Print 
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 30;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.PRINT;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Copy
			toolbarAttribute = new CToolbarAttribute();

			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 30;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;

			toolbarAttribute.Type = GridButtonsEnum.COPY;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Paste

			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 40;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.PASTE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Delete
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 50;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.DELETE_LINES;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();			
			m_ToolbarAttributeCollection.Add(toolbarAttribute);
			// 
		}


		protected virtual void AddDefaultGridToolbarAttributes()
		{

			CToolbarAttribute toolbarAttribute;

			// Edit Line
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 0;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.DIG;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Edit Line
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 10;

			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.EDIT_LINE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Add Line
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 20;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.ADD_LINE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Add Line Like
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 30;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.ADD_LINE_LIKE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Delete selected lines
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 40;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.DELETE_LINES;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Undelete selected lines
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 50;

			toolbarAttribute.Show = ProCGYesNoEnum.YES;

			toolbarAttribute.Type = GridButtonsEnum.UN_DELETE_LINES;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Select all lines 
			toolbarAttribute = new CToolbarAttribute();

			toolbarAttribute.GroupNum = 2;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.SELECT_ALL;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Unselect all lines 
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 2;

			toolbarAttribute.OrderInGroup = 20;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.UN_SELECT_ALL;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();

			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Unselect all lines 
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 2;
			toolbarAttribute.OrderInGroup = 30;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.UN_SELECT_ALL;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Copy
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 2;
			toolbarAttribute.OrderInGroup = 40;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.COPY;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Paste
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 2;
			toolbarAttribute.OrderInGroup = 50;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.PASTE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Discrad changes
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 3;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.DISCARD_CHANGES;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();

			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Save
			toolbarAttribute = new CToolbarAttribute();

			toolbarAttribute.GroupNum = 3;
			toolbarAttribute.OrderInGroup = 20;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.SAVE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();

			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// First page
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.FIRST_PAGE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);


			// Previous page
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 20;

			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.JUMP_BACK;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Next page
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 40;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.NEXT_PAGE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Last page
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 50;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.LAST_PAGE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Jump to  page
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 60;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.JUMP_TO_PAGE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Set page size
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 70;

			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.PAGE_SIZE;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();

			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Print 
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 5;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.NO;
			toolbarAttribute.Type = GridButtonsEnum.PRINT;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Change Layout
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 6;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.CUSTOM;
			toolbarAttribute.Id = "ChangeLayout";
			toolbarAttribute.Text = "My Layout";
			m_ToolbarAttributeCollection.Add(toolbarAttribute);
		}

		protected virtual void AddDefaultChooseWindowToolbarAttributes()
		{

			CToolbarAttribute toolbarAttribute;

			// Select
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.SELECT;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();

			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Cancel Select
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 20;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.CANCEL_SELECT;
			toolbarAttribute.Id = toolbarAttribute.Type.ToString();
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			/*
			// First page
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.FIRST_PAGE;
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Previous page
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 20;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.BACK_PAGE;
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Next page
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 40;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;

			toolbarAttribute.Type = GridButtonsEnum.NEXT_PAGE;
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Last page

			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 50;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.LAST_PAGE;
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Jump to  page
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;
			toolbarAttribute.OrderInGroup = 60;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.JUMP_TO_PAGE;
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Set page size
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 4;

			toolbarAttribute.OrderInGroup = 70;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.PAGE_SIZE;
			m_ToolbarAttributeCollection.Add(toolbarAttribute);
			*/
		}

		protected virtual void AddDefaultCriteriaControlToolbarAttributes()
		{

			CToolbarAttribute toolbarAttribute;

			// Search
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 1;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.CUSTOM;
			toolbarAttribute.Text = "Search";
			toolbarAttribute.Id = GridButtonsEnum.OK.ToString();
			toolbarAttribute.ImplementAs = ImplementToolbarItemEnum.Button;
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Clear
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 2;
			toolbarAttribute.OrderInGroup = 10;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.CUSTOM;
			toolbarAttribute.Text = "Clear";
			toolbarAttribute.Id = "Clear";
			toolbarAttribute.ImplementAs = ImplementToolbarItemEnum.Link;
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

			// Advanced
			toolbarAttribute = new CToolbarAttribute();
			toolbarAttribute.GroupNum = 2;
			toolbarAttribute.OrderInGroup = 20;
			toolbarAttribute.Show = ProCGYesNoEnum.YES;
			toolbarAttribute.Type = GridButtonsEnum.CUSTOM;
			toolbarAttribute.Text = "Advanced";
			toolbarAttribute.Id = "Advanced";
			toolbarAttribute.ImplementAs = ImplementToolbarItemEnum.Link;
			m_ToolbarAttributeCollection.Add(toolbarAttribute);

		}

		public virtual void HideAll()
		{
			foreach (Control control in this.Controls)
			{
				control.Visible = false;
			}
		}

		public virtual void ShowAll()
		{
			foreach (Control control in this.Controls)
			{
				control.Visible = true;
			}
		}


		protected virtual void OnClick(CommandEventArgs e)
		{
			// Has any objects registered interest with our event? 
			if (ClickEvent != null)
			{
				// Yes, notify all the objects in the delegate linked list
				ClickEvent(this, e);
			}
		}

		protected void button_Click(object sender, ImageClickEventArgs e)
		{
			CommandEventArgs commandEventArgs = new CommandEventArgs((sender as ImageButton).ID, sender);
			OnClick(commandEventArgs);
		}

		protected virtual void SendGeneralWebEvent(GeneralWebEvent.EventTypeEnum eventType)
		{
			// Has any objects registered interest with our event? 
			if (OnGeneralWebEvent != null)
			{
				GeneralWebEvent generalWebEvent = new GeneralWebEvent();
				generalWebEvent.EvenetType = eventType;
				// Yes, notify all the objects in the delegate linked list
				OnGeneralWebEvent(this, generalWebEvent);
			}
		}

		public EditModeEnum EditMode
		{
			get
			{
				if (WCC != null)
					return WCC.EditMode;
				if (Grid != null)
					return Grid.EditMode;

				if (ViewState["EditMode"] == null)
				{
					if (!DesignMode)
					{
						if (this.WCC != null)
							return WCC.EditMode;
						if (this.Grid != null)
							return Grid.EditMode;

						if (SessionManager.UserExist && SessionManager.User.Type == (short)UserTypeEnum.DEBUG)
							return EditModeEnum.ALL;
						else
							return EditModeEnum.VIEW_ONLY;
					}
					else
						return EditModeEnum.VIEW_ONLY;

				}
				return (EditModeEnum)ViewState["EditMode"];
			}
			set
			{
				ViewState["EditMode"] = value;
			}
		}

		[NotifyParentProperty(true)]
		public bool AllowEdit
		{
			get
			{
				if (WCC != null)
					return WCC.AllowEdit;
				if (Grid != null)
					return Grid.AllowEdit;

				if (ViewState["AllowEdit"] == null)
				{
					if (EditMode == EditModeEnum.ALL || EditMode == EditModeEnum.UPDATE)
						return true;
					else
						return false;
				}
				return (bool)ViewState["AllowEdit"];
			}
			set { ViewState["AllowEdit"] = value; }


		}

		[NotifyParentProperty(true)]
		public bool AllowAdd
		{
			get
			{
				//	WCC does not have AllowAdd;
				if (Grid != null)
					return Grid.AllowAdd;

				if (ViewState["AllowAdd"] == null)
				{
					if (EditMode == EditModeEnum.ALL)
						return true;
					else
						return false;
				}
				return (bool)ViewState["AllowAdd"]; ;
			}

			set { ViewState["AllowAdd"] = value; }
		}

		[NotifyParentProperty(true)]
		public bool AllowDelete
		{
			get
			{
				if (WCC != null)
					return WCC.AllowDelete;
				if (Grid != null)
					return Grid.AllowDelete;

				if (ViewState["AllowDelete"] == null)
				{
					if (EditMode == EditModeEnum.ALL)
						return true;
					else
						return false;
				}
				return (bool)ViewState["AllowDelete"];
			}
			set { ViewState["AllowDelete"] = value; }
		}

		[NotifyParentProperty(true)]
		public bool AllowSelect
		{
			get
			{
				//WCC does not have AllowSelect
				if (Grid != null)
					return Grid.AllowSelect;

				if (ViewState["AllowSelect"] == null)
					return true;
				return (bool)ViewState["AllowSelect"];
			}

			set { ViewState["AllowSelect"] = value; }
		}

		public Label ErrorMessages
		{
			get
			{
				Label errorMessages;
				errorMessages = (Label)NorthwindWebEnv.FindControlRecursive(this, "ErrorMessages");
				if (errorMessages == null)
				{
					errorMessages = new Label();
					errorMessages.ID = "ErrorMessages";
					errorMessages.CssClass = "ErrorMessages";
					this.Controls.Add(errorMessages);
				}

				return errorMessages;
			}
		}

		public override ControlCollection Controls
		{
			get
			{
				EnsureChildControls();
				return base.Controls;
			}
		}

		public Label InformationMessages
		{
			get
			{
				Label informationMessages;
				informationMessages = (Label)NorthwindWebEnv.FindControlRecursive(this, "InformationMessages");
				if (informationMessages == null)
				{
					informationMessages = new Label();
					informationMessages.ID = "InformationMessages";
					informationMessages.CssClass = "InformationMessages";
					this.Controls.Add(informationMessages);
				}
				return informationMessages;
			}
		}

		virtual public void AddInformationMessage(string informationMessage)
		{
			Label informationMessagesLabel = InformationMessages;
			if (informationMessagesLabel != null)
			{
				if (informationMessagesLabel.Text.Length > 0)
					informationMessagesLabel.Text += "<br/>";
				informationMessagesLabel.Text += informationMessage;
			}
		}

		virtual public void SetInformationMessage(string informationMessage)
		{
			ClearAllMessages();
			AddInformationMessage(informationMessage);
		}

		virtual public void AddErrorMessage(string errorMessage)
		{
			Label errorMessagesLabel = ErrorMessages;
			if (errorMessagesLabel != null)
			{
				if (errorMessagesLabel.Text.Length > 0)
					errorMessagesLabel.Text += "<br/>";
				errorMessagesLabel.Text += errorMessage;
			}
		}

		virtual public void SetErrorMessage(string errorMessage)
		{
			ClearAllMessages();
			AddErrorMessage(errorMessage);
		}

		public virtual void AddInformationMessages(System.Collections.Generic.List<string> list)
		{
			if (list == null) return;
			foreach (string message in list)
				AddInformationMessage(message);
		}

		public virtual void AddErrorMessages(System.Collections.Generic.List<string> list)
		{
			if (list == null) return;
			foreach (string message in list)
				AddErrorMessage(message);
		}
		
		virtual public void ClearAllMessages()
		{
			Label errorMessagesLabel = ErrorMessages;
			if (errorMessagesLabel != null)
				errorMessagesLabel.Text = "";
			Label informationMessagesLabel = InformationMessages;
			if (informationMessagesLabel != null)
				informationMessagesLabel.Text = "";
		}

		public override Page Page
		{
			get
			{
				if (base.Page != null)
					return base.Page;
				else if (WCC != null)
					return WCC.Page;
				else if (Grid != null)
					return Grid.Page;
				else
					return null;
					 
			}
			set
			{
				base.Page = value;
			}
		}

		public NorthwindPage NorthwindPage
		{
			get
			{
				return this.Page as NorthwindPage;
			}
		}
	}
}


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