Exemplo n.º 1
0
    protected void btnSubscribe_Click(object sender, EventArgs e)
    {
        try
        {
            if (SubscribeService.IsExistInSubscribeEmails(txtEmail.Text))
            {
                //MultiView1.SetActiveView(ViewEmailSend);
                //lblError.Visible = true;
                ShowMessage(Notify.NotifyType.Error, Resources.Resource.Client_Subscribe_EmailAlreadyReg);
                return;
            }

            if (SubscribeService.IsExistInCustomerEmails(txtEmail.Text))
            {
                //MultiView1.SetActiveView(ViewEmailSend);
                //lblError.Visible = true;
                ShowMessage(Notify.NotifyType.Error, Resources.Resource.Client_Subscribe_EmailAlreadyReg);
                return;
            }

            string strActivateCode   = DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + DateTime.Now.Second.ToString();
            string strDeactivateCode = DateTime.Now.Millisecond.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString();

            SubscribeService.SubscribeInsertEmail(txtEmail.Text, strActivateCode, strDeactivateCode);
            string strLink  = "<a href=\'" + AdvantShop.Configuration.SettingsMain.SiteUrl + "/subscribe.aspx?ID=" + strActivateCode + "\'>" + AdvantShop.Configuration.SettingsMain.SiteUrl + "/subscribe.aspx?ID=" + strActivateCode + "</a>";
            var    clsParam = new ClsMailParamOnSubscribeActivate {
                Link = strLink
            };
            string message = SendMail.BuildMail(clsParam);


            SendMail.SendMailNow(txtEmail.Text, Resources.Resource.Client_Subscribe_NewSubscribe, message, true);

            MultiView1.SetActiveView(ViewEmailSend);
            //--------------------------

            txtEmail.Text   = string.Empty;
            lblInfo.Visible = true;
            lblInfo.Text    = Resources.Resource.Client_Subscribe_RegSuccess + @" <br /><br />" +
                              Resources.Resource.Client_Subscribe_Instruction;
            //ShowMessage(Notify.NotifyType.Notice, Resources.Resource.Client_Subscribe_RegSuccess + @" <br /><br />" + Resources.Resource.Client_Subscribe_Instruction);
            //lblInfo.ForeColor = System.Drawing.Color.Black;
        }
        catch (Exception ex)
        {
            AdvantShop.Diagnostics.Debug.LogError(ex);
            //lblError.Visible = true;
            ShowMessage(Notify.NotifyType.Error, ex.Message + @" at Subscribe");
        }
    }
Exemplo n.º 2
0
    protected void btnDeactivate_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(txtEmailAdress.Text))
        {
            ShowMessage(Notify.NotifyType.Error, Resources.Resource.Client_SubscribeDeactivate_NoEmail);
            return;
        }

        try
        {
            if (!SubscribeService.IsExistInSubscribeEmails(txtEmailAdress.Text))
            {
                ShowMessage(Notify.NotifyType.Error, Resources.Resource.Client_SubscribeDeactivate_EmailNotFound);
                return;
            }

            if (!string.IsNullOrEmpty(txtDeactivateReason.Text))
            {
                SubscribeService.SubscribeInsertDeactivateReason(txtDeactivateReason.Text);
            }

            var strDeactivateCode = SubscribeService.SubscribeGetDectivateCodeByEmail(txtEmailAdress.Text);

            string strLink = "<a href=\'" + SettingsMain.SiteUrl + "/subscribedeactivate.aspx?id=" + strDeactivateCode + "\'>" + SettingsMain.SiteUrl + "/subscribedeactivate.aspx?id=" + strDeactivateCode + "</a>";

            var clsParam = new ClsMailParamOnSubscribeDeactivate {
                Link = strLink
            };

            string message = SendMail.BuildMail(clsParam);

            SendMail.SendMailNow(txtEmailAdress.Text, Resources.Resource.Client_SubscribeDeactivate_DeactivateNews, message, true);

            MultiView1.SetActiveView(viewMessage);
            lblInfo.Text    = Resources.Resource.Client_SubscribeDeactivate_EmailSent;
            lblInfo.Visible = true;
        }
        catch (Exception ex)
        {
            AdvantShop.Diagnostics.Debug.LogError(ex);
            ShowMessage(Notify.NotifyType.Error, ex.Message + @" at Subscribe Diactivate");
        }
    }