Beispiel #1
0
    /// <summary>
    /// Loads the data from the database and stores it in session.
    /// </summary>
    private void LoadData()
    {
        //Load the data from the database.
        ApplicationConfigurationDatasetGateway appConfigGateway = InterpriseHelper.SelectAllStoreAppConfigs();

        //Sort the data.
        SortWebStoreAppConfig(appConfigGateway, this.SortExpressionViewState, this.SortDirectionViewState);
        //Cache the data in session.
        SessionStateSink.AdminAppConfigGateway = appConfigGateway;
    }
Beispiel #2
0
 /// <summary>
 /// Apply the search filter.
 /// </summary>
 /// <param name="appConfigGateway">The gateway containing the data to filter.</param>
 private void ApplyFilter(ApplicationConfigurationDatasetGateway appConfigGateway)
 {
     //See if the search has been blanked out.
     if (string.IsNullOrEmpty(txtSearch.Text.Trim()))
     {
         //Clear the row filter.
         appConfigGateway.EcommerceAppConfig.DefaultView.RowFilter = "";
     }
     else
     {
         //Apply the filter.
         appConfigGateway.EcommerceAppConfig.DefaultView.RowFilter = string.Format("{0} LIKE '%{1}%'",
                                                                                   DEFAULT_SEARCH_FIELD, EscapeFilterChars(txtSearch.Text));
     }
 }
Beispiel #3
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        //Get the cached gateway.
        ApplicationConfigurationDatasetGateway appConfigGateway = SessionStateSink.AdminAppConfigGateway;

        //Filter out the records.
        ApplyFilter(appConfigGateway);

        //Reset the sort back to the defaults.
        SortWebStoreAppConfig(appConfigGateway, DEFAULT_SORT_EXPRESSION, DEFAULT_SORT_DIRECTION);

        //Make sure we are not in edit mode.
        gvAppConfig.EditIndex = -1;
        //Reset the page index back to the first page.
        gvAppConfig.PageIndex = 0;
        //Re-bind the data.
        BindData();
    }
Beispiel #4
0
    /// <summary>
    /// Binds the data to the grid.
    /// </summary>
    private void BindData()
    {
        //Get the data out of session.
        ApplicationConfigurationDatasetGateway appConfigGateway = SessionStateSink.AdminAppConfigGateway;

        if (appConfigGateway != null)
        {
            //Get the EcommerceStoreAppConfig table and set it as the data source.
            ApplicationConfigurationDataset.EcommerceAppConfigDataTable table = appConfigGateway.EcommerceAppConfig;
            gvAppConfig.DataSource = table;
        }
        else
        {
            gvAppConfig.DataSource = null;
        }

        //Bind the data to the grid.
        gvAppConfig.DataBind();
    }
Beispiel #5
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        //Get the cached gateway.
        ApplicationConfigurationDatasetGateway appConfigGateway = SessionStateSink.AdminAppConfigGateway;

        //Get a new WebStoreAppConfigRow.
        ApplicationConfigurationDataset.EcommerceAppConfigRow newRow = InterpriseHelper.AddNewStoreAppConfigRow(appConfigGateway);

        //Set the values from the add form.
        newRow.BeginEdit();
        newRow.Name        = txtName.Text;
        newRow.GroupName   = txtGroupName.Text;
        newRow.ConfigValue = txtConfigValue.Text;
        newRow.Description = txtDescription.Text;
        newRow.EndEdit();

        //Attempt to save the new record.
        if (InterpriseHelper.SaveStoreAppConfigs(appConfigGateway))
        {
            //The new record was saved.

            //Show the commands and hide the add new form.
            pnlCommands.Visible = true;
            pnlAddNew.Visible   = false;

            //Re-bind the data.
            BindData();
        }
        else
        {
            //Record was not saved we need to show the violations.
            HandleViolations(newRow);

            //Reject any changes that were made.
            appConfigGateway.RejectChanges();
        }
    }
Beispiel #6
0
    protected void gvAppConfig_Sorting(object sender, GridViewSortEventArgs e)
    {
        //See if the requested sort expression matches what we have cached.
        if (this.SortExpressionViewState == e.SortExpression)
        {
            //See what the current direction is and flip it.
            if (this.SortDirectionViewState == SortDirection.Ascending)
            {
                this.SortDirectionViewState = SortDirection.Descending;
            }
            else
            {
                this.SortDirectionViewState = SortDirection.Ascending;
            }
        }
        else
        {
            //We have a new sort expression so reset the direction to ascending.
            this.SortDirectionViewState = SortDirection.Ascending;
        }

        //Update the sort expression.
        this.SortExpressionViewState = e.SortExpression;

        //Get the cached gateway.
        ApplicationConfigurationDatasetGateway appConfigGateway = SessionStateSink.AdminAppConfigGateway;

        //Sort the records.
        SortWebStoreAppConfig(appConfigGateway, this.SortExpressionViewState, this.SortDirectionViewState);

        //Make sure we are not in edit mode.
        gvAppConfig.EditIndex = -1;
        //Reset back to the first page.
        gvAppConfig.PageIndex = 0;
        //Re-bind the data.
        BindData();
    }
Beispiel #7
0
 /// <summary>
 /// Sorts the web store app config table.
 /// </summary>
 /// <param name="appConfigGateway">The <see cref="ApplicationConfigurationDatasetGateway"/> containing the
 /// web store app config table.</param>
 /// <param name="strColumnName">The name of the column to sort on.</param>
 /// <param name="directionToSort">The direction to sort.</param>
 private void SortWebStoreAppConfig(ApplicationConfigurationDatasetGateway appConfigGateway, string strColumnName,
                                    SortDirection directionToSort)
 {
     //Sort the records.
     appConfigGateway.EcommerceAppConfig.DefaultView.Sort = GetSortString(strColumnName, directionToSort);
 }
Beispiel #8
0
    protected void gvAppConfig_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //Get the dataset.
        ApplicationConfigurationDatasetGateway appConfigGateway = SessionStateSink.AdminAppConfigGateway;

        //Get the updating row from the grid.
        GridViewRow gridRow = gvAppConfig.Rows[e.RowIndex];

        //Get the matching row from the table.

        //ApplicationConfigurationDataset.EcommerceStoreAppConfigRow rowToUpdate = GetRowToUpdate(
        //    appConfigGateway.EcommerceStoreAppConfig, (Guid)gvAppConfig.DataKeys[e.RowIndex]["AppConfigGUID"]);

        ApplicationConfigurationDataset.EcommerceAppConfigRow rowToUpdate = GetRowToUpdate(
            appConfigGateway.EcommerceAppConfig, (Guid)gvAppConfig.DataKeys[e.RowIndex]["AppConfigGUID"]);

        //Update the record with the data from the grid.
        rowToUpdate.BeginEdit();
        rowToUpdate.Name        = ((TextBox)gridRow.Cells[1].FindControl("txtName")).Text;
        rowToUpdate.GroupName   = ((TextBox)gridRow.Cells[2].FindControl("txtGroupName")).Text;
        rowToUpdate.ConfigValue = ((TextBox)gridRow.Cells[3].FindControl("txtConfigValue")).Text;
        rowToUpdate.Description = ((TextBox)gridRow.Cells[4].FindControl("txtDescription")).Text;
        rowToUpdate.EndEdit();

        try
        {
            //Save the changes
            if (InterpriseHelper.SaveStoreAppConfigs(appConfigGateway))
            {
                //Take the item out of edit mode.
                gvAppConfig.EditIndex = -1;
                //Re-bind the data.
                BindData();
            }
            else
            {
                //Record was not saved we need to show the violations.
                HandleViolations(rowToUpdate);

                //Reject any changes that were made.
                appConfigGateway.RejectChanges();
            }
        }
        catch (DataConcurrencyException)
        {
            //We had a concurrency error.

            //Re-load the data from the database (This will also apply the current sort).
            LoadData();
            //Apply the current filter.
            ApplyFilter(SessionStateSink.AdminAppConfigGateway);

            //Add the conncurency violation.
            m_violations.Add("The record you were working with was modified by another user."
                             + " Your changes have been lost and the record has been refreshed with the new data.");

            //Take the item out of edit mode.
            gvAppConfig.EditIndex = -1;
            //Re-bind the data.
            BindData();
        }
    }