Пример #1
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        StoreRetriever storeRetriever = new StoreRetriever();
        Store          store          = storeRetriever.GetStore();

        if (ActionCode == null || ActionCode == string.Empty)
        {
            uxNewsletterSubScribeTR.Visible = true;
            uxNewsletterMessageTR.Visible   = false;
        }
        else
        {
            uxNewsletterSubScribeTR.Visible = false;
            uxNewsletterMessageTR.Visible   = true;
            switch (ActionCode.ToLower())
            {
            case "register":
                SendConfirmationEmail();
                break;

            case "registerbox":
                uxNewsletterSubScribeTR.Visible = true;
                SendConfirmationEmail();
                break;

            case "unsubscribe":
                if (DataAccessContext.NewsLetterRepository.DeleteEmail(Key, store))
                {
                    uxSubscribeLabel.Text = "[$UnsubscribeSuccess]";
                }
                else
                {
                    uxSubscribeLabel.Text = "[$UnsubscribeFail]";
                }
                uxEmailLabel.Text = Email;
                break;

            case "confirm":
                RegisterEmail();
                break;

            default:
                uxSubscribeLabel.Text = "";
                break;
            }
        }
    }
Пример #2
0
    private void RegisterEmail()
    {
        StoreRetriever storeRetriever = new StoreRetriever();
        Store          store          = storeRetriever.GetStore();

        if (Email == null | Email == string.Empty)
        {
            EmailDiv.Visible      = false;
            uxSubscribeLabel.Text = "[$RegisterEmpty]";
            return;
        }
        Regex emailregex = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
        Match m          = emailregex.Match(Email);

        if (m.Success)
        {
            string emailHash =
                SecurityUtilities.HashMD5(Email + WebConfiguration.SecretKey);

            NewsLetter newsLetter = DataAccessContext.NewsLetterRepository.GetOne(Email, store);
            if (newsLetter.IsNull)
            {
                newsLetter.Email     = Email;
                newsLetter.EmailHash = emailHash;
                newsLetter.JoinDate  = DateTime.Now;
                newsLetter.StoreID   = store.StoreID;
                DataAccessContext.NewsLetterRepository.Create(newsLetter);
                uxSubscribeLabel.Text           = "[$RegisterSuccess]";
                uxNewsletterSubScribeTR.Visible = false;
            }
            else
            {
                uxSubscribeLabel.Text = "[$RegisterAlready]";
            }
        }
        else
        {
            uxNewsletterSubScribeTR.Visible = true;
            uxSubscribeLabel.ForeColor      = System.Drawing.Color.Red;
            uxSubscribeLabel.Text           = "[$RegisterInvalidEmail]";
        }
        uxEmailLabel.Text = Email;
    }
Пример #3
0
    private void UpdateEmailSubscriber(string email, string emailOld)
    {
        StoreRetriever storeRetriever = new StoreRetriever();
        Store          store          = storeRetriever.GetStore();
        string         emailHash      = SecurityUtilities.HashMD5(email + WebConfiguration.SecretKey);

        if (uxSubscribeCheckBox.Checked)
        {
            NewsLetter newsLetterOld = DataAccessContext.NewsLetterRepository.GetOne(emailOld, store);
            NewsLetter newsLetter    = DataAccessContext.NewsLetterRepository.GetOne(email, store);

            if (newsLetterOld.IsNull)
            {
                if (newsLetter.IsNull)
                {
                    newsLetter.Email     = email;
                    newsLetter.EmailHash = emailHash;
                    newsLetter.JoinDate  = DateTime.Now;
                    newsLetter.StoreID   = store.StoreID;
                    DataAccessContext.NewsLetterRepository.Create(newsLetter);
                }
            }
            else
            {
                if (MoreThanOneUserSubscribeWithEmail(emailOld))
                {
                    // No need to delete old email
                    if (newsLetter.IsNull)
                    {
                        newsLetter.Email     = email;
                        newsLetter.EmailHash = emailHash;
                        newsLetter.JoinDate  = DateTime.Now;
                        newsLetter.StoreID   = store.StoreID;
                        DataAccessContext.NewsLetterRepository.Create(newsLetter);
                    }
                }
                else
                {
                    if (String.Compare(email, emailOld) != 0)
                    {
                        // No need to keep old email
                        if (newsLetter.IsNull)
                        {
                            newsLetterOld.EmailHash = emailHash;
                            DataAccessContext.NewsLetterRepository.Update(newsLetterOld, email, store.StoreID);
                        }
                        else
                        {
                            DataAccessContext.NewsLetterRepository.DeleteEmailNoHash(emailOld, store);
                        }
                    }
                }
            }
        }
        else
        {
            if (!MoreThanOneUserSubscribeWithEmail(email))
            {
                DataAccessContext.NewsLetterRepository.DeleteEmail(emailHash, store);
            }
        }
    }
Пример #4
0
    private void PopulateControls()
    {
        Customer customer = DataAccessContext.CustomerRepository.GetOne(CurrentID);

        uxUserName.Text  = customer.UserName;
        uxFirstName.Text = customer.BillingAddress.FirstName;
        uxLastName.Text  = customer.BillingAddress.LastName;
        uxCompany.Text   = customer.BillingAddress.Company;
        uxAddress1.Text  = customer.BillingAddress.Address1;
        uxAddress2.Text  = customer.BillingAddress.Address2;
        uxCity.Text      = customer.BillingAddress.City;
        uxZip.Text       = customer.BillingAddress.Zip;

        uxCountryAndState.CurrentCountry = customer.BillingAddress.Country;
        uxCountryAndState.CurrentState   = customer.BillingAddress.State;

        uxPhone.Text = customer.BillingAddress.Phone;
        uxFax.Text   = customer.BillingAddress.Fax;
        uxEmail.Text = customer.Email;
        IsWholesale  = customer.IsWholesale;

        StoreRetriever storeRetriever = new StoreRetriever();
        NewsLetter     newsLetter     = DataAccessContext.NewsLetterRepository.GetOne(customer.Email, storeRetriever.GetStore());

        if (!newsLetter.IsNull)
        {
            uxSubscribeCheckBox.Checked = true;
        }
        else
        {
            uxSubscribeCheckBox.Checked = false;
        }
    }
Пример #5
0
    private void AddCustomer()
    {
        if (Page.IsValid)
        {
            StoreRetriever storeRetriever = new StoreRetriever();
            Store          store = storeRetriever.GetStore();
            bool           validateCountry, validateState, validateShippingCountry, validateShippingState;
            bool           validateBilling, validateShipping;
            validateBilling = uxCountryState.Validate(out validateCountry, out validateState);

            if (uxUseBillingAsShipping.Checked)
            {
                if (!validateBilling)
                {
                    uxBillingCountryStateDiv.Visible  = true;
                    uxBillingCountryStateMessage.Text = ValidateCountryAndState(validateCountry, validateState);
                    return;
                }
            }
            else
            {
                validateShipping = uxShippingCountryState.Validate(out validateShippingCountry, out validateShippingState);
                if (!validateBilling && !validateShipping)
                {
                    uxBillingCountryStateDiv.Visible   = true;
                    uxBillingCountryStateMessage.Text  = ValidateCountryAndState(validateCountry, validateState);
                    uxShippingCountryStateDiv.Visible  = true;
                    uxShippingCountryStateMessage.Text = ValidateCountryAndState(validateShippingCountry, validateShippingState);
                    return;
                }
                else if (!validateBilling)
                {
                    uxBillingCountryStateDiv.Visible  = true;
                    uxBillingCountryStateMessage.Text = ValidateCountryAndState(validateCountry, validateState);
                    return;
                }
                else if (!validateShipping)
                {
                    uxShippingCountryStateDiv.Visible  = true;
                    uxShippingCountryStateMessage.Text = ValidateCountryAndState(validateShippingCountry, validateShippingState);
                    return;
                }
            }

            MembershipUser user = Membership.GetUser(uxUserName.Text.Trim());
            if (user == null && !UsernameExits(uxUserName.Text.Trim()))
            {
                if (uxUseBillingAsShipping.Checked)
                {
                    CopyBillingDetailsToShipping();
                }

                if (uxSubscribeCheckBox.Checked)
                {
                    string Email     = uxEmail.Text.Trim();
                    string EmailHash =
                        SecurityUtilities.HashMD5(Email + WebConfiguration.SecretKey);
                    NewsLetter newsLetter = DataAccessContext.NewsLetterRepository.GetOne(Email, store);
                    if (newsLetter.IsNull)
                    {
                        newsLetter.Email     = Email;
                        newsLetter.EmailHash = EmailHash;
                        newsLetter.JoinDate  = DateTime.Now;
                        newsLetter.StoreID   = store.StoreID;
                        DataAccessContext.NewsLetterRepository.Create(newsLetter);
                    }
                }

                string id;

                Customer customer = SetUpCustomer();
                customer = DataAccessContext.CustomerRepository.Save(customer);
                id       = customer.CustomerID;

                Membership.CreateUser(uxUserName.Text.Trim(), uxPassword.Text, uxEmail.Text.Trim());
                Roles.AddUserToRole(uxUserName.Text, "Customers");

                if (IsCustomerAutoApprove)
                {
                    FormsAuthentication.SetAuthCookie(uxUserName.Text, false);
                }

                SetCartShippingAddress(customer);
                SetTaxExempt();
                try
                {
                    SendMailToCustomer(uxEmail.Text, uxUserName.Text);
                    SendMailToMerchant(uxEmail.Text, uxUserName.Text, id);
                    AffiliateHelper.UpdateAffiliateReference(uxUserName.Text);
                    RedirectPage();
                }
                catch (Exception)
                {
                    ErrorMessage = "[$SentErrorMessage]";
                    ClearData();
                }
            }
            else
            {
                ErrorMessage = "[$User Existed]";
            }
        }
    }