Esempio n. 1
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();
        }
    }