예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int entityTypeValue = 0;

        Int32.TryParse(Request.QueryString["EntityType"], out entityTypeValue);
        if (Enum.IsDefined(typeof(EntityType), entityTypeValue))
        {
            _selectedEntityType = (EntityType)entityTypeValue;
            _entityTypeDefined  = true;
        }

        if (_entityTypeDefined)
        {
            // load list control for given entity.
            Control controlToAdd = Page.LoadControl("~/Controls/List" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + "Instances.ascx");
            _lister = controlToAdd as IListControl;
            if (_lister != null)
            {
                phListControls.Controls.Add(controlToAdd);
            }
            phListArea.Visible = false;

            // load search control
            controlToAdd = Page.LoadControl("~/Controls/Search" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx");
            _searcher    = controlToAdd as ISearchControl;
            if (_searcher != null)
            {
                _searcher.AllowSingleEntitySearches = false;
                _searcher.AllowMultiEntitySearches  = true;
                _searcher.SearchClicked            += new EventHandler(searcher_SearchClicked);
                phSearchControls.Controls.Add(controlToAdd);
                phSearchArea.Visible = true;
            }

            bool?showSearchArea = (bool?)ViewState["showSearchArea"];
            if (showSearchArea.HasValue)
            {
                // stored in viewstate, show the correct area.
                phSearchArea.Visible = showSearchArea.Value;
                phListArea.Visible   = !showSearchArea.Value;
            }
        }

        if (!Page.IsPostBack)
        {
            if (_entityTypeDefined)
            {
                this.Title        += _selectedEntityType.ToString() + " instances";
                lblEntityName.Text = GeneralUtils.EntityTypeToEntityName(_selectedEntityType);
            }

            // check for user info
            if (SessionHelper.GetUserID() == string.Empty)
            {
                Response.Redirect("Login.aspx");
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int entityTypeValue = 0;

        Int32.TryParse(Request.QueryString["EntityType"], out entityTypeValue);
        if (Enum.IsDefined(typeof(EntityType), entityTypeValue))
        {
            _selectedEntityType = (EntityType)entityTypeValue;
            _entityTypeDefined  = true;
        }

        if (_entityTypeDefined)
        {
            // load edit control for given entity.
            Control      controlToAdd = Page.LoadControl("~/Controls/Edit" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx");
            IEditControl editor       = controlToAdd as IEditControl;
            if (editor != null)
            {
                editor.EditMode = FormViewMode.ReadOnly;
                phControls.Controls.Add(controlToAdd);
                controlToAdd = Page.LoadControl("~/Controls/Search" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx");
                ISearchControl searcher = controlToAdd as ISearchControl;
                if (searcher != null)
                {
                    if (Request.QueryString.Count > 1)
                    {
                        // get the filter based on the query string's PK fields. Use the search control for this, as it contains the logic for this.
                        PredicateExpression filter = searcher.CreateFilter(Request.QueryString);
                        editor.FilterToUse = filter;
                        controlToAdd       = Page.LoadControl("~/Controls/ViewRelatedTo" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx");
                        IViewRelatedControl relatedViewer = controlToAdd as IViewRelatedControl;
                        if (relatedViewer != null)
                        {
                            relatedViewer.FilterToUse = filter;
                            phRelatedEntities.Controls.Add(controlToAdd);
                        }
                    }
                }
            }
        }

        if (!Page.IsPostBack)
        {
            if (_entityTypeDefined)
            {
                this.Title        += _selectedEntityType.ToString() + " instance";
                lblEntityName.Text = GeneralUtils.EntityTypeToEntityName(_selectedEntityType);
            }

            // check for user info
            if (SessionHelper.GetUserID() == string.Empty)
            {
                Response.Redirect("Login.aspx");
            }
        }
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // add all entity types to the combo box.
            int[] values = (int[])Enum.GetValues(typeof(EntityType));
            for (int i = 0; i < values.Length; i++)
            {
                // add the item, but strip off the 'Entity' suffix
                cbxEntity.Items.Add(new ListItem(GeneralUtils.EntityTypeToEntityName((EntityType)i), i.ToString()));
            }

            // check for user info
            if (SessionHelper.GetUserID() == string.Empty)
            {
                Response.Redirect("Login.aspx");
            }

            #region get autiding simple text filename to use

            // look for SimpleTextAuditorTxtFileName setting at .config file
            string            _outputAuditFileName = string.Empty;
            AppSettingsReader appConfiguration     = new AppSettingsReader();
            try
            {
                _outputAuditFileName = (string)appConfiguration.GetValue("SimpleTextAuditorTxtFileName", typeof(string));
            }

            // SimpleTextAuditorTxtFileName not found! use default filename
            catch (InvalidOperationException)
            {
                _outputAuditFileName = "c:\\noraudit.txt";
            }

            this.lblAuditTextFileName.Text = _outputAuditFileName;

            #endregion
        }
    }
예제 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int entityTypeValue = 0;

        Int32.TryParse(Request.QueryString["EntityType"], out entityTypeValue);
        if (Enum.IsDefined(typeof(EntityType), entityTypeValue))
        {
            _selectedEntityType = (EntityType)entityTypeValue;
            _entityTypeDefined  = true;
        }

        if (_entityTypeDefined)
        {
            // load edit control for given entity.
            Control      controlToAdd = Page.LoadControl("~/Controls/Edit" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx");
            IEditControl editor       = controlToAdd as IEditControl;
            if (editor != null)
            {
                editor.EditMode = FormViewMode.Insert;
                phControls.Controls.Add(controlToAdd);
            }
        }

        if (!Page.IsPostBack)
        {
            if (_entityTypeDefined)
            {
                this.Title        += _selectedEntityType.ToString() + " instance";
                lblEntityName.Text = GeneralUtils.EntityTypeToEntityName(_selectedEntityType);
            }

            // check for user info
            if (SessionHelper.GetUserID() == string.Empty)
            {
                Response.Redirect("Login.aspx");
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int entityTypeValue = 0;

        Int32.TryParse(Request.QueryString["EntityType"], out entityTypeValue);
        if (Enum.IsDefined(typeof(EntityType), entityTypeValue))
        {
            _selectedEntityType = (EntityType)entityTypeValue;
            _entityTypeDefined  = true;
        }

        if (_entityTypeDefined)
        {
            // load edit control for given entity.
            Control controlToAdd = Page.LoadControl("~/Controls/Edit" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx");
            _editor = controlToAdd as IEditControl;
            if (_editor != null)
            {
                _editor.EditMode = FormViewMode.Edit;
                phEditControls.Controls.Add(controlToAdd);
            }
            phEditArea.Visible = false;

            // load search control
            controlToAdd = Page.LoadControl("~/Controls/Search" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx");
            _searcher    = controlToAdd as ISearchControl;
            if (_searcher != null)
            {
                if (Request.QueryString.Count == 1)
                {
                    // just entitytype specified.
                    _searcher.AllowSingleEntitySearches = true;
                    _searcher.AllowMultiEntitySearches  = false;
                    _searcher.SearchClicked            += new EventHandler(searcher_SearchClicked);
                    phSearchControls.Controls.Add(controlToAdd);
                    phSearchArea.Visible = true;
                }
                else
                {
                    // get the filter based on the query string's PK fields. Use the search control for this, as it contains the logic for this.
                    if (_editor != null)
                    {
                        _editor.FilterToUse  = _searcher.CreateFilter(Request.QueryString);
                        phSearchArea.Visible = false;
                        phEditArea.Visible   = true;
                    }
                }
            }
        }

        if (!Page.IsPostBack)
        {
            if (_entityTypeDefined)
            {
                this.Title        += _selectedEntityType.ToString() + " instance";
                lblEntityName.Text = GeneralUtils.EntityTypeToEntityName(_selectedEntityType);
            }

            // check for user info
            if (SessionHelper.GetUserID() == string.Empty)
            {
                Response.Redirect("Login.aspx");
            }
        }
    }