示例#1
0
        public static void AvoidDuplicateEmail(SignUpInfo info)
        {
            string aQuery = string.Format(@"select * from userlist where email=('{0}')", info.eMailAddress);

            cmdString = new SqlCommand(aQuery, cntString);

            try
            {
                cntString.Open();

                SqlDataAdapter da = new SqlDataAdapter(cmdString);

                DataTable dt = new DataTable();

                DataSet ds = new DataSet();
                da.Fill(dt);
                ds.Tables.Add(dt);

                if (dt.Rows.Count > 0)
                {
                    info.eMailAddress = "EE";
                }
            }

            finally
            {
                cntString.Close();
            }
        }
示例#2
0
        protected void btn_Click(object sender, EventArgs e)
        {
            email    = eMail.Text;
            password = pWord.Text;

            SignUpInfo userinfo = new SignUpInfo(username, email, password);

            if (ConnectionClass.SignIn(userinfo))
            {
                FormsAuthentication.RedirectFromLoginPage(email, CheckBox.Checked);
                Session["login"] = email;
            }

            else
            {
                Response.Write("<script type='text/javascript'>");
                Response.Write("alert('Please check your email and password');");
                //Response.Write("document.location.href='login.aspx';");
                Response.Write("</script>");
            }

            ConnectionClass.SignIn(userinfo);


            /*ConnectionClass.SignIn(userinfo);
             *
             * if (userinfo.eMailAddress == "EM") //Email Matching
             * {
             *  Session["login"] = userinfo.userName;
             *
             *
             *
             *
             *
             *
             *  Response.Write("<script type='text/javascript'>");
             *  Response.Write("alert('welcome');");
             *  Response.Write("document.location.href='main.aspx';");
             *  Response.Write("</script>");
             * }
             *
             * else
             * {
             *
             *  Response.Write("<script type='text/javascript'>");
             *  Response.Write("alert('Please check your email and password');");
             *  //Response.Write("document.location.href='login.aspx';");
             *  Response.Write("</script>");
             * }
             *
             */
        }
示例#3
0
        /*public static void SignIn(SignUpInfo info)
         * {
         *  string cQuery = string.Format(@"select * from userlist where email= ('{0}') and password=('{1}')", info.eMailAddress, info.passWord);
         *  cmdString = new SqlCommand(cQuery, cntString);
         *
         *  try
         *  {
         *      cntString.Open();
         *      // cmdString.ExecuteNonQuery();
         *
         *      SqlDataAdapter da = new SqlDataAdapter(cmdString);
         *
         *      DataTable dt = new DataTable();
         *
         *      DataSet ds = new DataSet();
         *
         *      da.Fill(dt);
         *
         *      ds.Tables.Add(dt);
         *
         *      if (dt.Rows.Count > 0)
         *      {
         *          info.eMailAddress = "EM"; //Email Matching
         *          info.userName = dt.Rows[0]["username"].ToString();
         *      }
         *
         *      else
         *      {
         *          info.eMailAddress = "EMN"; //Email Not Matching
         *      }
         *  }
         *
         *  finally
         *  {
         *
         *      cntString.Close();
         *  }
         * } */

        public static bool SignIn(SignUpInfo info)
        {
            string cQuery = string.Format(@"select count(email) from userlist where email= ('{0}') and password=('{1}')", info.eMailAddress, info.passWord);

            cmdString = new SqlCommand(cQuery, cntString);

            cntString.Open();
            int count = (int)cmdString.ExecuteScalar();

            cntString.Close();

            return(count > 0);
        }
        protected void btn_Click(object sender, EventArgs e)
        {
            username = uName.Text;
            email    = eMail.Text;
            password = pWord.Text;


            if (Regex.IsMatch(email, "^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"))
            {
                emailcheck.Text = "Valid Email";

                SignUpInfo newUserInfo = new SignUpInfo(username, email, password);
                ConnectionClass.AvoidDuplicateEmail(newUserInfo);

                if (newUserInfo.eMailAddress == "EE")
                {
                    Response.Write("<script type='text/javascript'>");
                    Response.Write("alert('Please use other email');");
                    Response.Write("</script>");
                }

                else
                {
                    try
                    {
                        ConnectionClass.SignUp(newUserInfo);
                        ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Thank you for signup!'); document.location.href='login.aspx';</script>");
                    }

                    catch
                    {
                        Response.Write("<script type='text/javascript'>");
                        Response.Write("alert('Failed ');");
                        Response.Write("</script>");
                    }

                    finally
                    {
                    }
                }
            }

            else
            {
                emailcheck.Text      = "invalid email";
                emailcheck.ForeColor = System.Drawing.Color.Red;
            }
        }
示例#5
0
        public static void SignUp(SignUpInfo info)
        {
            string bQuery = string.Format(@"insert into userlist(username,email,password) values('{0}', '{1}', '{2}')", info.userName, info.eMailAddress, info.passWord);

            cmdString = new SqlCommand(bQuery, cntString);

            try
            {
                cntString.Open();
                cmdString.ExecuteNonQuery();
            }

            finally
            {
                cntString.Close();
            }
        }