D:\NorthwindForWeb\Northwind\CS\DotNet\ADO.Net\Northwind\WebControls\PageBase.cs
/*
* This file was generated by ProCG version 2.0
*
* File name: Northwind\WebControls\PageBase.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.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using Northwind.General;
using Northwind.Data;
using log4net;
using System.Text;
namespace Northwind.WebControls
{
/// <summary>
/// Summary description for NorthwindPage.
/// </summary>
public class NorthwindPageBase : System.Web.UI.Page
{
protected DataManager m_DataManager;
protected ComboBoxManager m_ComboBoxManager;
protected bool m_bComboBoxManagerWasAllocatedByMe;
protected static readonly ILog log = LogManager.GetLogger(typeof(NorthwindPageBase));
protected DbConnection m_DBConnection = null;
protected bool m_bDBConnectionWasCreatedByMe = false;
private PageTypeEnum pageType = PageTypeEnum.NONE;
public const string CODE_FIELD_ID = "CodeFieldId"; // used in Choose Window params
public const string DESCRIPTION_FIELD_ID = "DescriptionFieldId"; // used in Choose Window params
public NorthwindPageBase()
{
}
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public DbConnection DBConnection
{
get
{
if (m_DBConnection == null)
{
string dbConnectionString = "";
SessionManager.GetFromSession("DBConnectionString", ref dbConnectionString, null);
if (string.IsNullOrEmpty(dbConnectionString))
m_DBConnection = NorthwindGeneral.GetDefaultConnection();
else
m_DBConnection = NorthwindGeneral.GetDefaultConnection(dbConnectionString);
m_bDBConnectionWasCreatedByMe = true;
m_DBConnection.Open();
}
return m_DBConnection;
}
set
{
m_DBConnection = value;
m_bDBConnectionWasCreatedByMe = false;
}
}
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual DataManager DataManager
{
get
{
if (m_DataManager == null)
{
m_DataManager = new Northwind.Data.DataManager(this.DBConnection);
if (this.Session["GlobalParams"] != null)
{
m_DataManager.GlobalParams = this.Session["GlobalParams"] as Northwind.Data.CGlobalParams;
}
if (this.Session["User"] != null)
{
m_DataManager.SetCurrentNorthwindUser(this.Session["User"] as CNorthwindUser);
}
}
return m_DataManager;
}
}
/*
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual DataManager DataManager
{
get
{
if (m_DataManager == null)
m_DataManager = new Northwind.Data.DataManager();
return m_DataManager;
}
}
*/
public virtual ComboBoxManager ComboBoxManager
{
get
{
if (m_ComboBoxManager == null)
{
m_ComboBoxManager = ComboBoxManager.GetExistingInstance();
if (m_ComboBoxManager == null)
{
m_ComboBoxManager = new ComboBoxManager();
m_ComboBoxManager.DataManager = DataManager;
m_bComboBoxManagerWasAllocatedByMe = true;
}
}
return m_ComboBoxManager;
}
}
public PageTypeEnum PageType { get => pageType; protected set => pageType = value; }
protected override void OnLoadComplete(EventArgs e)
{
if (IsPostBack)
{
string eventArg = Request["__EVENTARGUMENT"];
if (eventArg != null && eventArg.Equals("RedirectCanceled"))
RedirectWasCanceled();
}
base.OnLoadComplete(e);
//ClearAllMessages();
}
protected override void OnUnload(EventArgs e)
{
if (m_DataManager != null)
m_DataManager.Dispose();
if (m_ComboBoxManager != null && m_bComboBoxManagerWasAllocatedByMe)
m_ComboBoxManager.Dispose();
/*
if (NorthwindGeneral.CompraeControlsTrees)
{
List<Control> currentControlsTree = NorthwindWebEnv.GetControlRecursive(this);
Session["ControlsTree"] = currentControlsTree;
}
* */
//base.OnUnload (e);
}
public virtual void CheckLogin()
{
CNorthwindUser currentUser = User; // create default user if in debug mode
if (User != null)
{
if (Page.Request.Url.ToString().IndexOf("ChangePassword.aspx") == -1)
{
if (SessionManager.User.NeedToChangePassword())
{
Page.Response.Redirect(NorthwindGeneral.GetChangePasswordPage(), true);
}
}
}
}
public virtual CNorthwindUser User
{
get
{
/*
if (!SessionManager.UserExist)
{
CWebSite website = DataManager.GetWebSite(1);
if (website != null && website.DebugMode != 0)
{
CNorthwindUser defaultUser = DataManager.GetUserById(website.DefaultUserId);
if (defaultUser != null)
{
SessionManager.User = defaultUser;
log.Info("User was set as default user from web table: " + defaultUser.UserName);
}
}
}
*/
if (!SessionManager.UserExist)
{
try
{
if (Page.Request.Url.ToString().IndexOf("Login.aspx") == -1)
{
Session["NextURL"] = Page.Request.Url.ToString();
log.Info("User does not exist Redirect to LoginPage : " + NorthwindGeneral.GetLoginPage());
if (Page.Parent == null)
Page.Response.Redirect(NorthwindGeneral.GetLoginPage(), true);
else
{
Page page = (Page)Page.Parent;
page.Response.Redirect(NorthwindGeneral.GetLoginPage(), true);
}
}
}
catch (Exception ex)
{
Page.Response.Redirect(NorthwindGeneral.GetLoginPage(), true);
log.Error("Exception in User property in NorthwindPage",ex);
}
}
return SessionManager.User;
}
set
{
if (value != null)
log.Info("User was set to Session "+value.UserName);
else
log.Info("User was set to NULL in Session ");
SessionManager.User = value;
}
}
public string WebRoot
{
get
{
return Northwind.General.NorthwindGeneral.GetWebServerRootURL();
}
}
/*
protected override void OnInitComplete(EventArgs e)
{
base.OnInitComplete(e);
SubscribeToPreInitGeneralWebEvent(this);
}
**/
/*
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
SubscribeToPreInitGeneralWebEvent(this);
}
*/
protected override void OnPreInit(EventArgs e)
{
if (Page.IsPostBack)
{
if (Context.Request.Form["selectedTheme"] != null)
{
string theme = Context.Request.Form["selectedTheme"];
Theme = theme;
}
}
else
{
if (string.IsNullOrEmpty(this.Theme))
this.Theme = "ThemeCameron";
}
base.OnPreInit(e);
//SubscribeToPreInitGeneralWebEvent(this); // vvvv
}
protected override void OnLoad(EventArgs e)
{
/*
if (NorthwindGeneral.CompraeControlsTrees && IsPostBack)
{
List<Control> currentControlsTree = NorthwindWebEnv.GetControlRecursive(this);
List<Control> originControlsTree = (List<Control>)Session["ControlsTree"];
}
*/
// for each WCC Grid subscribe to it's GeneralWebEvent
SubscribeToOnLoadGeneralWebEvent(this);
base.OnLoad(e);
ClearAllMessages();
}
public void SubscribeToPreInitGeneralWebEvent(System.Web.UI.Control root)
{
System.Web.UI.Control controlFound;
if (root != null)
{
if (root is PaginatorComposite)
return;
/*
if (root is ToolbarButton)
return;
*/
if (root.Controls.Count == 0)
return;
foreach (System.Web.UI.Control c in root.Controls)
{
//this.Trace.Write("Id = ", c.ID);
if (c is NorthwindWCC)
{
NorthwindWCC northwindWcc = (NorthwindWCC)c;
northwindWcc.OnGeneralWebEvent += new NorthwindWCC.GeneralWebEventHandler(OnPreInitGeneralWebEvent);
continue;
}
else if (c is NorthwindGrid)
{
NorthwindGrid northwindGrid = (NorthwindGrid)c;
northwindGrid.OnGeneralWebEvent += new NorthwindGrid.GeneralWebEventHandler(OnPreInitGeneralWebEvent);
continue;
}
else if (c is NorthwindToolBarWCC)
{
NorthwindToolBarWCC toolBar = (NorthwindToolBarWCC)c;
toolBar.OnGeneralWebEvent += new NorthwindToolBarWCC.GeneralWebEventHandler(OnPreInitGeneralWebEvent);
continue;
}
SubscribeToPreInitGeneralWebEvent(c); // vv I deleted this because it creates the NavigatorControl before the viewstate was set, check if everything is working now
}
}
}
public void SubscribeToOnLoadGeneralWebEvent(System.Web.UI.Control root)
{
System.Web.UI.Control controlFound;
if (root != null)
{
if (root.Controls.Count == 0)
return;
foreach (System.Web.UI.Control c in root.Controls)
{
if (c is NorthwindWCC)
{
NorthwindWCC northwindWcc = (NorthwindWCC)c;
northwindWcc.OnGeneralWebEvent += new NorthwindWCC.GeneralWebEventHandler(OnLoadGeneralWebEvent);
northwindWcc.PreRender += new EventHandler(OnPreRender);
if (northwindWcc.ToolBar != null)
{
NorthwindToolBarWCC northwindToolBarWCC = northwindWcc.ToolBar;
northwindToolBarWCC.OnGeneralWebEvent += new NorthwindToolBarWCC.GeneralWebEventHandler(OnLoadGeneralWebEvent);
northwindToolBarWCC.PreRender += new EventHandler(OnPreRender);
}
continue;
}
else if (c is NorthwindGrid)
{
NorthwindGrid northwindGrid = (NorthwindGrid)c;
northwindGrid.OnGeneralWebEvent += new NorthwindGrid.GeneralWebEventHandler(OnLoadGeneralWebEvent);
northwindGrid.PreRender += new EventHandler(OnPreRender);
if (northwindGrid.ToolBar != null)
{
NorthwindToolBarWCC northwindToolBarWCC = northwindGrid.ToolBar;
northwindToolBarWCC.OnGeneralWebEvent += new NorthwindToolBarWCC.GeneralWebEventHandler(OnLoadGeneralWebEvent);
northwindToolBarWCC.PreRender += new EventHandler(OnPreRender);
}
continue;
}
else if (c is NorthwindToolBarWCC)
{
NorthwindToolBarWCC northwindToolBarWCC = (NorthwindToolBarWCC)c;
northwindToolBarWCC.OnGeneralWebEvent += new NorthwindToolBarWCC.GeneralWebEventHandler(OnLoadGeneralWebEvent);
northwindToolBarWCC.PreRender += new EventHandler(OnPreRender);
continue;
}
SubscribeToOnLoadGeneralWebEvent(c);
}
}
}
protected virtual void OnPreInitGeneralWebEvent(object sender, GeneralWebEvent args)
{
if (args.EvenetType == GeneralWebEvent.EventTypeEnum.BeforeCreateChildControls)
{
if (sender is NorthwindWCC)
{
NorthwindWCC northwindWcc = (NorthwindWCC)sender;
CFieldAttributeCollection columns = northwindWcc.FieldsCollectionToCreateTheControlBy;
ChangeFieldAttributes(northwindWcc, columns);
if (northwindWcc.ShowToolBar)
{
ChangeToolbarAttributes(northwindWcc, northwindWcc.ToolBar, northwindWcc.ToolBar.ToolbarAttributeCollectionToCreateTheToolbarBy);
}
}
if (sender is NorthwindGrid)
{
NorthwindGrid northwindGrid = (NorthwindGrid)sender;
CFieldAttributeCollection columns = northwindGrid.FieldsCollectionToCreateTheGridBy;
ChangeFieldAttributes(northwindGrid, columns);
if (northwindGrid.ShowToolBar)
{
ChangeToolbarAttributes(northwindGrid, northwindGrid.ToolBar, northwindGrid.ToolBar.ToolbarAttributeCollectionToCreateTheToolbarBy);
}
}
if (sender is NorthwindToolBarWCC)
{
NorthwindToolBarWCC northwindToolBarWCC = (NorthwindToolBarWCC)sender;
CToolbarAttributeCollection toolbarAttributeCollection = northwindToolBarWCC.ToolbarAttributeCollectionToCreateTheToolbarBy;
if (northwindToolBarWCC.WCC != null)
ChangeToolbarAttributes(northwindToolBarWCC.WCC, northwindToolBarWCC, toolbarAttributeCollection);
if (northwindToolBarWCC.Grid != null)
ChangeToolbarAttributes(northwindToolBarWCC.Grid, northwindToolBarWCC, toolbarAttributeCollection);
else
ChangeToolbarAttributes(northwindToolBarWCC, toolbarAttributeCollection);
}
}
}
protected virtual void OnLoadGeneralWebEvent(object sender, GeneralWebEvent args)
{
if (args.EvenetType == GeneralWebEvent.EventTypeEnum.AfterGotDataByCriteria)
{
if (sender is NorthwindParamsWCC)
AfterGotDataByCriteria(sender as NorthwindParamsWCC, args);
else if (sender is NorthwindCriteriasWCC)
{
NorthwindCriteriasWCC northwindCriteriasWCC = (NorthwindCriteriasWCC)sender;
AfterGotDataByCriteria(sender as NorthwindCriteriasWCC, args);
}
else if (sender is NorthwindWCC)
{
NorthwindWCC northwindWcc = (NorthwindWCC)sender;
AfterGotDataByCriteria(northwindWcc, args);
}
else
throw new Exception("Event AfterGotDataByCriteria supported only for NorthwindParamsWCC");
}
else if (args.EvenetType == GeneralWebEvent.EventTypeEnum.NewRowWasInserted)
{
if (sender is NorthwindGrid)
{
NorthwindGrid northwindGrid = (NorthwindGrid)sender;
NewRowWasInserted(northwindGrid, args);
}
}
else if (args.EvenetType == GeneralWebEvent.EventTypeEnum.BeforeDisplayRow)
{
if (sender is NorthwindGrid)
{
NorthwindGrid northwindGrid = (NorthwindGrid)sender;
BeforeDisplayRow(northwindGrid, args);
}
}
}
protected virtual void AfterGotDataByCriteria(NorthwindWCC northwindWcc, GeneralWebEvent args)
{
}
protected virtual void AfterGotDataByCriteria(NorthwindParamsWCC northwindParamWCC, GeneralWebEvent args)
{
}
protected virtual void AfterGotDataByCriteria(NorthwindCriteriasWCC northwindCriteriasWCC, GeneralWebEvent args)
{
}
protected virtual void ChangeToolbarAttributes(NorthwindWCC northwindWCC, NorthwindToolBarWCC northwindToolBarWCC, CToolbarAttributeCollection toolbarAttributeCollection)
{
}
protected virtual void ChangeToolbarAttributes(NorthwindGrid northwindGrid, NorthwindToolBarWCC northwindToolBarWCC, CToolbarAttributeCollection toolbarAttributeCollection)
{
}
protected virtual void ChangeToolbarAttributes(NorthwindToolBarWCC northwindToolBarWCC, CToolbarAttributeCollection toolbarAttributeCollection)
{
}
protected virtual void NewRowWasInserted(NorthwindGrid northwindGrid, GeneralWebEvent args)
{
}
protected virtual void BeforeDisplayRow(NorthwindGrid northwindGrid, GeneralWebEvent args)
{
}
protected virtual void ChangeFieldAttributes(NorthwindGrid northwindGrid, CFieldAttributeCollection columns)
{
}
protected virtual void ChangeFieldAttributes(NorthwindWCC northwindWCC, CFieldAttributeCollection columns)
{
}
protected virtual void OnPreRender(object sender, EventArgs e)
{
}
protected override void OnInitComplete(EventArgs e)
{
AddDynamicControls();
base.OnInitComplete(e);
//ClearAllMessages();
SubscribeToPreInitGeneralWebEvent(this);
}
protected override void OnPreRenderComplete(EventArgs e)
{
if (InformationMessagesLabel != null && ErrorMessagesLable != null)
{
if (InformationMessagesLabel.Text.Length > 0 && ErrorMessagesLable.Text.Length > 0)
ErrorMessagesLable.Text += "<br/>";
}
if (!this.DesignMode)
InjectStartupScripts();
base.OnPreRenderComplete(e);
}
protected virtual void AddDynamicControls()
{
if (this.Form != null)
{
HiddenField nextURL = new HiddenField();
nextURL.ID = "NextURL";
this.Form.Controls.Add(nextURL);
}
}
public virtual HiddenField NextURL
{
get
{
HiddenField nextURL = (HiddenField)this.Page.Form.FindControl("NextURL");
return nextURL;
}
}
public virtual void KeepOldStateIncaseRedirectWasCancel()
{
}
public virtual void RedirectWasCanceled()
{
PostBackStr = "";
NextURL.Value = "";
}
public virtual void Redirect(string url, bool complete)
{
if (NextURL == null)
throw new Exception("NextURL hidden field not defined in page");
if (SomethingChanged)
{
NextURL.Value = url;
PostBackStr = Page.ClientScript.GetPostBackEventReference(this, "RedirectCanceled");
}
else
{
NextURL.Value = "";
PostBackStr = "";
this.Response.Redirect(url, true);
}
}
public virtual string PostBackStr
{
get
{
if (this.ViewState["PostBackStr"] != null)
return (string)this.ViewState["PostBackStr"];
else
return "";
}
set
{
this.ViewState["PostBackStr"] = value;
}
}
protected virtual void InjectStartupScripts()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type='text/javascript' language='javascript'>\n");
sb.Append(" function addLoadEvent(func) {\n");
sb.Append(" var oldonload = window.onload;\n");
sb.Append(" if (typeof window.onload != 'function') {\n");
sb.Append(" window.onload = func;\n");
sb.Append(" } else {\n");
sb.Append(" window.onload = function() {\n");
sb.Append(" if (oldonload) {\n");
sb.Append(" oldonload();\n");
sb.Append(" }\n");
sb.Append(" func();\n");
sb.Append(" }\n");
sb.Append(" }\n");
sb.Append(" }\n");
sb.Append("</script>\n");
Type t = this.GetType();
if (!ClientScript.IsClientScriptBlockRegistered(t, "addLoadEvent"))
{
ClientScript.RegisterClientScriptBlock(t, "addLoadEvent", sb.ToString());
}
sb.Remove(0, sb.Length);
sb.Append("<script type='text/javascript' language='javascript'>\n");
sb.Append(" function confirmExit() {\n");
sb.Append(" var NextURL = document.getElementById('NextURL');\n");
sb.Append(" if (NextURL != null && NextURL.value != '') {\n");
sb.Append(" var ok = confirm('You have attempted to leave this page, your changes will we lost. Are you sure?');\n");
sb.Append(" if (ok) {\n");
sb.Append(" var nextUrlValue = NextURL.value;\n");
sb.Append(" NextURL.value = '';\n");
sb.Append(" window.document.URL = nextUrlValue;\n");
sb.Append(" }\n");
sb.Append(" else {\n");
sb.Append(" " + PostBackStr + "\n");
sb.Append(" }\n");
sb.Append(" }\n");
sb.Append(" }\n");
sb.Append(" addLoadEvent(confirmExit);\n");
sb.Append("</script>\n");
//register with ClientScript
if (!ClientScript.IsClientScriptBlockRegistered(t, "confirmExit"))
{
ClientScript.RegisterClientScriptBlock(t, "confirmExit", sb.ToString());
}
if (ShowMessageBoxForFormsErrors)
{
if (ErrorMessagesLable != null && ErrorMessagesLable.Text.Length > 0)
{
InjectShowMessage(ErrorMessagesLable, ErrorMessagesLable.Text, "Error");
}
}
if (ShowMessageBoxForFormsInformations)
{
if (InformationMessagesLabel != null && InformationMessagesLabel.Text.Length > 0)
{
InjectShowMessage(InformationMessagesLabel, InformationMessagesLabel.Text, "Information");
}
}
}
public void InjectShowMessage(WebControl messageControl, string message, string messageType)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
String nessageForAlert = MessageForAlert(message);
// get a reference to ScriptManager and check if we have a partial postback
if (ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack)
{
// partial (asynchronous) postback occured
sb.Append(
@" var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(showMessages);");
sb.Append(
@" function showMessages(sender, args)
{");
sb.Append(
@" alert(""" + nessageForAlert + @""");
prm.remove_endRequest(showMessages);
}");
ScriptManager.RegisterStartupScript(messageControl, messageControl.GetType(), this.ID + "show" + messageType + @"Messages", sb.ToString().Replace("showMessages", "show" + messageType + "Messages"), true);
}
else
{
// regular full page postback occured
sb.Append("<script type='text/javascript' language='javascript'>\n");
sb.Append(" function showMessages() {\n");
sb.Append(" alert('" + nessageForAlert + "');\n");
sb.Append(" }\n");
sb.Append(" addLoadEvent(showMessages);\n");
sb.Append("</script>\n");
//register with ClientScript
if (!ClientScript.IsClientScriptBlockRegistered(this.GetType(), "show" + messageType + @"Messages"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "show" + messageType + @"Messages", sb.ToString());
}
}
}
public void InjectStartupScript(Northwind.General.PostBackMode postBackMode, Control control, string functionName, string functionText = null )
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
// get a reference to ScriptManager and check if we have a partial postback
if (ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack && (postBackMode == PostBackMode.Both || postBackMode == PostBackMode.AsyncPostBack))
{
// partial (asynchronous) postback occured
sb.Append(
@" var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest("+functionName+");");
if (functionText != null)
{
sb.Append(@" "+functionText);
}
ScriptManager.RegisterStartupScript(control, control.GetType(), this.ID + functionName, sb.ToString(),true);
}
else
{
// regular full page postback occured
sb.Append("<script type='text/javascript' language='javascript'>\n");
if (functionText != null)
sb.Append(" "+functionText);
sb.Append(" addLoadEvent("+functionName+");\n");
sb.Append("</script>\n");
//register with ClientScript
if (!ClientScript.IsClientScriptBlockRegistered(this.GetType(), functionName))
{
ClientScript.RegisterStartupScript(this.GetType(), functionName, sb.ToString());
}
}
}
public virtual void InjectFixedHeaderForGrid(NorthwindGrid grid)
{
StringBuilder sb = new StringBuilder();
sb.Append(string.Format(@"
function SetFixedHeader4{0}()
{{
var tableOffset = $('#{0}').offset().top;
var $header = $('#{0} tr.HeaderStyle').clone();
$('#{0} tr.HedaerStyle').css('font-style', 'italic');
var $fixedHeader = $('#{0}header-fixed').append($header);
$(window).bind('scroll', function() {{
var offset = $(this).scrollTop();
if (offset >= tableOffset && $fixedHeader.is(':hidden')) {{
$fixedHeader.show();
}}
else if (offset < tableOffset) {{
$fixedHeader.hide();
}}
}});
}}", grid.ClientID));
this.InjectStartupScript(PostBackMode.Both, grid, "SetFixedHeader4"+grid.ClientID, sb.ToString());
}
public virtual HtmlGenericControl GetContentUpdatePanel()
{
HtmlGenericControl contentUpdatePanel = (HtmlGenericControl)NorthwindWebEnv.FindControlRecursive(this, "FormToolBar");
return contentUpdatePanel;
}
public virtual string MessageForAlert(string message)
{
string newMessage = message.Replace("<br/>", @"\n");
newMessage = newMessage.Replace(" ", " ");
newMessage = newMessage.Replace("\'","\"");
return newMessage;
}
public virtual bool ShowMessageBoxForFormsErrors
{
get
{
return NorthwindGeneral.ShowMessageBoxForFormsErrors;
}
}
public virtual bool ShowMessageBoxForFormsInformations
{
get
{
return NorthwindGeneral.ShowMessageBoxForFormsInformations;
}
}
public virtual bool ShowMessageBoxForControlsErrors
{
get
{
return NorthwindGeneral.ShowMessageBoxForControlsErrors;
}
}
public virtual bool ShowMessageBoxForControlsInformations
{
get
{
return NorthwindGeneral.ShowMessageBoxForControlsInformations;
}
}
public virtual bool SomethingChanged
{
get
{
return false;
}
}
protected override void OnError(EventArgs e)
{
// At this point we have information about the error
HttpContext ctx = HttpContext.Current;
Exception exception = ctx.Server.GetLastError();
string errorInfo =
"<br>Offending URL: " + ctx.Request.Url.ToString() +
"<br>Source: " + exception.Source +
"<br>Message: " + exception.Message +
"<br>Stack trace: " + exception.StackTrace;
ctx.Response.Write(errorInfo);
try
{
log.Error("Exception", exception);
EventLog.WriteEntry("Northwind Web Application",
errorInfo, EventLogEntryType.Error);
}
catch (Exception)
{
// ignore - maybe the eveny viewer is full
}
// --------------------------------------------------
// To let the page finish running we clear the error
// --------------------------------------------------
//ctx.Server.ClearError();
base.OnError(e);
}
public virtual bool AllowNavigateToOtherEntity
{
get
{
if (this.ViewState["AllowNavigateToOtherEntity"] != null)
return (bool)this.ViewState["AllowNavigateToOtherEntity"];
return NorthwindGeneral.AllowNavigateToOtherEntity;
}
set
{
this.ViewState["AllowNavigateToOtherEntity"] = value;
}
}
private Label ErrorMessagesLable
{
get
{
Label errorMessages;
errorMessages = (Label)NorthwindWebEnv.FindControlRecursive(this, "ErrorMessages");
return errorMessages;
}
}
private Label InformationMessagesLabel
{
get
{
Label informationMessages;
informationMessages = (Label)NorthwindWebEnv.FindControlRecursive(this, "InformationMessages");
return informationMessages;
}
}
virtual public void AddInformationMessage(string informationMessage)
{
Label informationMessagesLabel = InformationMessagesLabel;
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 = ErrorMessagesLable;
if (errorMessagesLabel != null)
{
if (errorMessagesLabel.Text.Length > 0)
errorMessagesLabel.Text += "<br/>";
errorMessagesLabel.Text += errorMessage;
}
}
virtual public void AddErrorMessages(List<string> list)
{
foreach (string errorMessage in list)
{
AddErrorMessage(errorMessage);
}
}
virtual public void SetErrorMessage(string errorMessage)
{
ClearAllMessages();
AddErrorMessage(errorMessage);
}
virtual public void ClearAllMessages()
{
Label errorMessagesLabel = ErrorMessagesLable;
if (errorMessagesLabel != null)
errorMessagesLabel.Text = "";
Label informationMessagesLabel = InformationMessagesLabel;
if (informationMessagesLabel != null)
informationMessagesLabel.Text = "";
}
public virtual void OnCustomToolbarItemControlClicked(object sender, Control control)
{
}
public virtual TextBox GetShowEntityTextBoxControl()
{
TextBox showEntityTextBox;
showEntityTextBox = (TextBox)NorthwindWebEnv.FindControlRecursive(this, "ShowEntityTextBox");
return showEntityTextBox;
}
virtual public void OnGridItemCommand(NorthwindGrid northwindGrid, DataGridCommandEventArgs e)
{
}
virtual public void OnGridItemDataBound(NorthwindGrid northwindGrid, DataGridItemEventArgs e)
{
}
virtual public void UpdateToolbarAttributes(NorthwindWCC northwindWCC, CToolbarAttributeCollection toolbarAttributeCollection)
{
}
virtual public void UpdateToolbarAttributes(NorthwindGrid northwindGrid, CToolbarAttributeCollection toolbarAttributeCollection)
{
}
// TODO: check this two functions
// virtual public void UpdateToolbarAttributes(NorthwindListView espListView, CToolbarAttributeCollection toolbarAttributeCollection)
// {
// }
// public virtual void OnListViewItemCommand(NorthwindListView espListView, ListViewCommandEventArgs e)
// {
// }
public virtual void GetControlsData()
{
throw new NotImplementedException("GetControlsData in " + this.GetType().ToString());
}
}
}
// 29093 ProCG uses this line - don't edit it