Example #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        Newsletter ad  = new Newsletter();
        MessageBox msg = new MessageBox();
        DataTable  dt  = ad.checknewsletter(TextBox1.Text);

        if (dt.Rows.Count == 0)
        {
            ad.addnewsletter(TextBox1.Text);
            TextBox1.Text = "";
            msg.Show("You have been successfully subscribed to our newsletter");
        }
        else
        {
            msg.Show("You are already subscribed to our newsletter");
        }
    }
Example #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int    i         = 0;
        string RandomKey = null;

        KeyGen            = new KeyGenerate();
        KeyGen.KeyLetters = "abcdefghjklmnpqrstuvwxyz";
        KeyGen.KeyNumbers = "23456789";
        KeyGen.KeyChars   = 9;
        int mExist  = 0;
        int mExist1 = 0;

        for (i = 0; i <= 1; i++)
        {
            RandomKey = KeyGen.Generate().ToUpper();
        }


        if (RadioButtonList1.SelectedItem.Value == "1")
        {
            MembershipUser mem = Membership.GetUser(TextBox1.Text);
            if (mem == null)
            {
                MembershipCreateStatus status;
                MembershipUser         newuser = Membership.CreateUser(TextBox1.Text, RandomKey, TextBox1.Text, "a", "a", true, out status);
                if (newuser == null)
                {
                    msg.Show(GetErrorMessage(status));
                }
                else
                {
                    ProfileCommon pc = (ProfileCommon)ProfileCommon.Create(TextBox1.Text, true);
                    Roles.AddUserToRole(TextBox1.Text, "user");

                    mailing mail = new mailing();
                    mail.mymail(TextBox1.Text, "Dear customer, you are successfully registered with ZartShop.com. Account details are as follows <br/>UserName : "******"<br>Password : "******"<br/><br/>Regards,<br/>ZartShop.com", "ZartShop Registration");

                    msg.Show("Registered successfully");
                    newsletter.addnewsletter(TextBox1.Text);
                    System.Threading.Thread.Sleep(1000);
                    FormsAuthentication.SetAuthCookie(TextBox1.Text, true);

                    Response.Redirect("shipping-address.aspx?id=" + RadioButtonList1.SelectedItem.Value.ToString());
                }
            }
            else
            {
                msg.Show("Email Id already registered");
            }
        }
        else
        {
            DataTable dt = ad.checkuser(TextBox1.Text, TextBox2.Text);
            if (dt.Rows.Count == 0)
            {
                msg.Show("Invalid username and password");
            }
            else
            {
                if (Request.QueryString["returnurl"] != null)
                {
                    string te1 = Request.QueryString["returnurl"].ToString();

                    try
                    {
                        FormsAuthentication.SetAuthCookie(TextBox1.Text, true);


                        Response.Redirect(te1);
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    string te = "shipping-address.aspx?id=" + RadioButtonList1.SelectedItem.Value.ToString();
                    FormsAuthentication.SetAuthCookie(TextBox1.Text, true);

                    Response.Redirect(te);
                }
            }
        }
    }