Example #1
0
        protected void btnlogin_Click(object sender, EventArgs e)
        {
            username = uname.Text;
            password = pword.Text;

            CsUserlist userinfo = new CsUserlist(username, password);

            if (ConnectionClass.SignIn(userinfo))
            {
                FormsAuthentication.RedirectFromLoginPage(username, CheckBox.Checked);
            }



            else
            {
                Response.Write("<script type='text/javascript'>");
                Response.Write("alert('Please check your username and password');");
                Response.Write("</script>");
            }
        }
        public static bool SignIn(CsUserlist userinfo)
        {
            string aQuery = string.Format(@"SELECT count(username) from userlist where username=('{0}') and password=('{1}')",
                                          userinfo.username, userinfo.password);

            cmdString = new SqlCommand(aQuery, cntString);

            cntString.Open();

            try {
                int count = (int)cmdString.ExecuteScalar();

                cntString.Close();

                return(count > 0);
            }
            finally
            {
                cntString.Close();
            }
        }