Example #1
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        if (!DataValidation())
        {
            return;
        }

        lblMessage.Visible = false;

        CustomerService.InsertNewCustomer(new Customer
        {
            CustomerGroupId   = CustomerGroupService.DefaultCustomerGroup,
            Password          = HttpUtility.HtmlEncode(txtPassword.Text),
            FirstName         = HttpUtility.HtmlEncode(txtFirstName.Text),
            LastName          = HttpUtility.HtmlEncode(txtLastName.Text),
            Phone             = HttpUtility.HtmlEncode(txtPhone.Text),
            SubscribedForNews = chkSubscribed4News.Checked,
            EMail             = HttpUtility.HtmlEncode(txtEmail.Text),
            CustomerRole      = Role.User
        });

        AuthorizeService.AuthorizeTheUser(txtEmail.Text, txtPassword.Text, false);

        //------------------------------------------

        var clsParam = new ClsMailParamOnRegistration
        {
            FirstName = HttpUtility.HtmlEncode(txtFirstName.Text),
            LastName  = HttpUtility.HtmlEncode(txtLastName.Text),
            RegDate   = AdvantShop.Localization.Culture.ConvertDate(DateTime.Now),
            Password  = HttpUtility.HtmlEncode(txtPassword.Text),
            Subsrcibe = chkSubscribed4News.Checked
                                               ? Resource.Client_Registration_Yes
                                               : Resource.Client_Registration_No,
            ShopURL = SettingsMain.SiteUrl
        };

        string message = SendMail.BuildMail(clsParam);

        if (CustomerSession.CurrentCustomer.IsVirtual)
        {
            ShowMessage(Notify.NotifyType.Error, Resource.Client_Registration_Whom + txtEmail.Text + '\r' + Resource.Client_Registration_Text + message);
        }
        else
        {
            SendMail.SendMailNow(txtEmail.Text,
                                 SettingsMain.SiteUrl + " - " +
                                 string.Format(Resource.Client_Registration_RegSuccessful, txtEmail.Text),
                                 message, true);
            SendMail.SendMailNow(SettingsMail.EmailForRegReport,
                                 SettingsMain.SiteUrl + " - " +
                                 string.Format(Resource.Client_Registration_RegSuccessful, txtEmail.Text),
                                 message, true);
        }

        Response.Redirect("myaccount.aspx");
    }
Example #2
0
    private void RegistrationNow()
    {
        try
        {
            if (CustomerService.CheckCustomerExist(PageData.OrderConfirmationData.Customer.EMail))
            {
                ShowMessage(Notify.NotifyType.Error, Resource.Client_Registration_CustomerExist);
            }


            Guid id = CustomerService.InsertNewCustomer(new Customer
            {
                CustomerGroupId   = CustomerGroupService.DefaultCustomerGroup,
                Password          = PageData.OrderConfirmationData.Customer.Password,
                FirstName         = PageData.OrderConfirmationData.Customer.FirstName,
                LastName          = PageData.OrderConfirmationData.Customer.LastName,
                Phone             = PageData.OrderConfirmationData.Customer.Phone,
                SubscribedForNews = false,
                EMail             = PageData.OrderConfirmationData.Customer.EMail,
                CustomerRole      = Role.User
            });

            if (id == Guid.Empty)
            {
                return;
            }
            PageData.OrderConfirmationData.Customer.Id = id;

            AuthorizeService.AuthorizeTheUser(PageData.OrderConfirmationData.Customer.EMail, PageData.OrderConfirmationData.Customer.Password, false);

            // Shipping contact -----------------------------
            var newContact = PageData.OrderConfirmationData.ShippingContact;
            CustomerService.AddContact(newContact, PageData.OrderConfirmationData.Customer.Id);

            // Billing contact ---------------------------
            if (!PageData.OrderConfirmationData.BillingIsShipping)
            {
                newContact = PageData.OrderConfirmationData.BillingContact;
                CustomerService.AddContact(newContact, PageData.OrderConfirmationData.Customer.Id);
            }

            //------------------------------------------

            var clsParam = new ClsMailParamOnRegistration
            {
                FirstName = PageData.OrderConfirmationData.Customer.FirstName,
                LastName  = PageData.OrderConfirmationData.Customer.LastName,
                RegDate   = AdvantShop.Localization.Culture.ConvertDate(DateTime.Now),
                Password  = PageData.OrderConfirmationData.Customer.Password,
                Subsrcibe = Resource.Client_Registration_No,
                ShopURL   = SettingsMain.SiteUrl
            };


            string message = SendMail.BuildMail(clsParam);

            if (CustomerSession.CurrentCustomer.IsVirtual)
            {
                ShowMessage(Notify.NotifyType.Notice, Resource.Client_Registration_Whom + PageData.OrderConfirmationData.Customer.EMail + '\r' + Resource.Client_Registration_Text + message);
            }
            else
            {
                SendMail.SendMailNow(PageData.OrderConfirmationData.Customer.EMail, SettingsMain.SiteUrl + " - " + string.Format(Resource.Client_Registration_RegSuccessful, PageData.OrderConfirmationData.Customer.EMail), message, true);
                SendMail.SendMailNow(SettingsMail.EmailForRegReport, SettingsMain.SiteUrl + " - " + string.Format(Resource.Client_Registration_RegSuccessful, PageData.OrderConfirmationData.Customer.EMail), message, true);
            }

            //------------------------------------------
        }
        catch (Exception ex)
        {
            Debug.LogError(ex);
            ShowMessage(Notify.NotifyType.Error, ex.Message + " at registration");
        }
    }