コード例 #1
0
ファイル: AdminAdd.aspx.cs プロジェクト: imewp/StudentManager
        protected void txtUserName_TextChanged(object sender, EventArgs e)
        {
            string name = txtUserName.Text;
            IList <admin_userEntity> admins = dal.Getadmin_usersbyCondition(" userName='******'");

            if (admins.Count > 0)
            {
                this.Page.RegisterStartupScript("", "<script>alert('该账号已存在!');</script>");
            }
        }
コード例 #2
0
ファイル: Login.aspx.cs プロジェクト: imewp/StudentManager
        protected void Submit_Click(object sender, EventArgs e)
        {
            string name = login_username.Value;
            string pwd  = login_password.Value;

            if (rbtnType.SelectedIndex == 0)
            {
                DALadmin_user            dal    = new DALadmin_user();
                IList <admin_userEntity> admins = dal.Getadmin_usersbyCondition(" userName='******' and userPassword='******'");
                if (admins.Count > 0)
                {
                    string trueName = admins[0].TrueName.ToString();
                    int    id       = admins[0].Id;

                    //修改登录次数
                    admin_userEntity admin = dal.Getadmin_user(id);
                    admin.LoginTimes++;
                    dal.Modadmin_user(admin);

                    Session["adminID"]  = name;
                    Session["TrueName"] = trueName;
                    Session["Pwd"]      = pwd;
                    Session["id"]       = id;
                    Response.Redirect("NewsManage.aspx");
                }
                else
                {
                    this.Page.RegisterStartupScript("", "<script>alert('登录失败!');</script>");
                }
            }
            else if (rbtnType.SelectedIndex == 1)
            {
                DALstudent_info            dal  = new DALstudent_info();
                IList <student_infoEntity> stus = dal.Getstudent_infosbyCondition(" studentId='" + name + "' and studentPassword='******'");
                if (stus.Count > 0)
                {
                    int id = stus[0].Id;

                    string phone    = stus[0].StudentPhoto;
                    string trueName = stus[0].StudentName.ToString();
                    Session["studentID"]   = name;
                    Session["StudentName"] = trueName;
                    Session["id"]          = id;
                    Session["Pwd"]         = pwd;
                    //Session["phone"] = phone;
                    Response.Redirect("NewsList.aspx");
                }
                else
                {
                    this.Page.RegisterStartupScript("", "<script>alert('登录失败!');</script>");
                }
            }
        }
コード例 #3
0
ファイル: Login.aspx.cs プロジェクト: caoerqing/StudentInfo_g
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["CheckCode"];
            string     uname  = uName.Value;
            string     pwd    = uPassword.Value;

            Session["uName"] = uname;
            if (style.SelectedItem.Text == "管理员")
            {
                DALadmin_user            dal   = new DALadmin_user();//定义一个admin_user表的对象
                IList <admin_userEntity> users = dal.Getadmin_usersbyCondition("userName='******'and userPassword='******'");

                if (users.Count > 0)//查找表中是否有相关的记录
                {
                    if (cookie.Value == vcode.Value)
                    {
                        ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('登陆成功!');location.href='index.aspx';</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('验证码错误!');</script>");
                    }
                }
                else
                {
                    this.Page.RegisterStartupScript("", "<script>alert('登陆失败!');</script>");
                }
            }
            else if (style.SelectedItem.Text == "学生")
            {
                DALstudent_info            dal   = new DALstudent_info();
                IList <student_infoEntity> users = dal.Getstudent_infosbyCondition("StudentId='" + uname + "'and studentPassword='******'");
                if (users.Count > 0)//查找表中是否有相关的记录
                {
                    if (cookie.Value == vcode.Value)
                    {
                        ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('登陆成功!');location.href='student.aspx';</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('验证码错误!');</script>");
                    }
                }
                else
                {
                    this.Page.RegisterStartupScript("", "<script>alert('登陆失败!');</script>");
                }
            }
            else
            {
                this.Page.RegisterStartupScript("", "<script>alert('请先选择用户类型!');</script>");
            }
        }
コード例 #4
0
        /// <summary>
        /// 加载数据信息
        /// </summary>
        public void LoadData()
        {
            string conditon = string.Empty;

            conditon = "(UserName is not null and UserName<>' ')";
            if (!string.IsNullOrEmpty(select.Value))
            {
                conditon += " and UserName='******'";
            }
            DALadmin_user            dal    = new DALadmin_user();
            IList <admin_userEntity> admins = dal.Getadmin_usersbyCondition(conditon);//按照条件来查询数据

            grdadmin.DataSource = admins;
            grdadmin.DataBind();
        }
コード例 #5
0
        /// <summary>
        /// 加载数据信息
        /// </summary>
        public void LoadData()
        {
            string conditon = string.Empty;

            conditon = "(UserName is not null and UserName<>' ')";
            if (!string.IsNullOrEmpty(user_name.Value))
            {
                conditon += " and UserName like'%" + user_name.Value + "%'";
            }
            DALadmin_user            dal    = new DALadmin_user();
            IList <admin_userEntity> admins = dal.Getadmin_usersbyCondition(conditon);//按照条件来查询数据

            GridView1.DataSource = admins;
            GridView1.DataBind();
        }
コード例 #6
0
ファイル: Login.aspx.cs プロジェクト: caoerqing/StudentInfo
        protected void btnsubmit_Click(object sender, EventArgs e)
        {
            HttpCookie cookie   = Request.Cookies["CheckCode"];
            string     username = user_name.Value;
            string     password = pass_word.Value;

            SQLDAL.DALadmin_user     dALadmin_User = new DALadmin_user();
            IList <admin_userEntity> users         = dALadmin_User.Getadmin_usersbyCondition("userName='******' and userPassword='******'");

            if (users.Count > 0 && cookie.Value == CheckCode.Value)
            {
                Session["uName"] = users[0].Id;
                Session["name"]  = username;
                ClientScript.RegisterStartupScript(GetType(), "", "<script>location.href='index.aspx';</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('用户名或密码或验证码错误');</script>");
            }
        }