protected void btnSetPPStandard_Click(object sender, EventArgs e)
    {
        // Get the current configuration file.
        System.Configuration.Configuration config  = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
        PayPalStandardSettings             section = (PayPalStandardSettings)config.GetSection("PayPalStandardSettings");

        try {
            if (section != null)
            {
                section.UseSandbox    = chkUsePPStandardSandbox.Checked;
                section.BusinessEmail = txtBusinessEmail.Text;
                section.PDTID         = txtPDTID.Text;
                section.IsActive      = chkUsePPStandard.Checked;
                config.Save();
                ResultMessage2.ShowSuccess("PayPal Standard Settings Saved");
            }
            else
            {
                throw new Exception("There is no PayPalStandardSettings section in the Web.Config");
            }
        }
        catch (Exception x) {
            ResultMessage2.ShowFail("Cannot write to the Web.Config file; in order to have the application update the configuration, you have to allow write access to the ASNET account (or NETWORK SERVICE) and make sure the file is not marked as Read Only");
        }
    }
Beispiel #2
0
    protected void btnSaveSettings_Click(object sender, EventArgs e)
    {
        try
        {
            //save the config bits down to the web.config
            //get the provider, if there is one, and set the boxes
            System.Configuration.Configuration           config  = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
            Commerce.Providers.FulfillmentServiceSection section = (Commerce.Providers.FulfillmentServiceSection)config.GetSection("FulfillmentService");

            section.Providers.Clear();

            if (chkUseSimple.Checked)
            {
                ProviderSettings simpleProvider = new ProviderSettings("SimpleShippingProvider", "Commerce.Providers.SimpleShippingProvider");
                simpleProvider.Parameters.Add("connectionStringName", "CommerceTemplate");
                section.Providers.Add(simpleProvider);
                section.DefaultProvider = "SimpleShippingProvider";
            }

            if (chkUsePO.Checked)
            {
                ProviderSettings poProvider = new ProviderSettings("USPostalServiceShippingProvider", "Commerce.Providers.USPostalServiceShippingProvider");

                poProvider.Parameters.Add("connectionUrl", poURL.Text);
                poProvider.Parameters.Add("uspsUserName", poUserName.Text);
                poProvider.Parameters.Add("uspsPassword", poPassword.Text);
                poProvider.Parameters.Add("uspsAdditionalHandlingCharge", poHandling.Text);
                section.Providers.Add(poProvider);
                section.DefaultProvider = "USPostalServiceShippingProvider";
            }

            if (chkUseUPS.Checked)
            {
                ProviderSettings upsProvider = new ProviderSettings("UpsShippingProvider", "Commerce.Providers.UpsShippingProvider");
                upsProvider.Parameters.Add("connectionUrl", upsURL.Text);
                upsProvider.Parameters.Add("upsAccessKey", upsAccessKey.Text);
                upsProvider.Parameters.Add("upsUserName", upsUserName.Text);
                upsProvider.Parameters.Add("upsPassword", upsPassword.Text);
                upsProvider.Parameters.Add("upsPickupTypeCode", upsPickupTypeCode.Text);
                upsProvider.Parameters.Add("upsCustomerClassification", upsCustomerClass.Text);
                upsProvider.Parameters.Add("upsPackagingTypeCode", upsPackTypeCode.Text);
                upsProvider.Parameters.Add("upsAdditionalHandlingCharge", upsHandlingCharge.Text);
                section.Providers.Add(upsProvider);
                section.DefaultProvider = "UpsShippingProvider";
            }
            section.UseShipping         = chkUseShipping.Checked;
            section.ShipFromZip         = txtShipFromZip.Text;
            section.ShipFromCountryCode = ddlShipFromCountry.SelectedValue;
            section.ShipPackagingBuffer = 1;
            section.DimensionUnit       = txtDimensionUnits.Text;

            config.Save();
            ResultMessage2.ShowSuccess("Shipping Settings Updated");
        }
        catch (Exception x)
        {
            ResultMessage2.ShowFail("Your Web.Config must be set to be writable by ASPNET or NETWORK SERVICE - cannot save config");
        }
    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        //register them
        MembershipCreateStatus status;

        Membership.CreateUser(txtLogin.Text, txtPassword.Text, txtEmail.Text, txtQ.Text, txtA.Text, true, out status);

        //add the profile
        if (status == MembershipCreateStatus.Success)
        {
            Profile.FirstName = txtFirst.Text;
            Profile.LastName  = txtLast.Text;
            Profile.Email     = txtEmail.Text;


            btnRegister.Enabled = false;
            //set the cookie
            FormsAuthentication.SetAuthCookie(txtLogin.Text, true);



            if (fromPage != string.Empty && !fromPage.ToLower().Contains("register.aspx"))
            {
                Response.Redirect(fromPage);
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }
        else
        {
            if (status == MembershipCreateStatus.DuplicateEmail)
            {
                ResultMessage1.ShowFail("This email is already in our system");
            }
            if (status == MembershipCreateStatus.DuplicateUserName)
            {
                ResultMessage2.ShowFail("Need to use another login - this one's taken");
            }
            if (status == MembershipCreateStatus.InvalidEmail)
            {
                ResultMessage1.ShowFail("Invalid email address");
            }
            if (status == MembershipCreateStatus.InvalidPassword)
            {
                ResultMessage1.ShowFail("Invalid password. Needs to be 6 or more letters/numbers");
            }
            if (status == MembershipCreateStatus.UserRejected)
            {
                ResultMessage1.ShowFail("You cannot register at this time");
            }
        }
    }