Beispiel #1
0
        public int AddSave(Book.Model.T_Base_User book)
        {
            Book.DAL.T_Base_User bookAddSave = new DAL.T_Base_User();
            int result = bookAddSave.AddSave(book);

            return(result);
        }
Beispiel #2
0
        public int AddSave(Book.Model.T_Base_User user)
        {
            SqlConnection co  = SQLServerOpen();
            SqlCommand    cmd = new SqlCommand();

            cmd.Connection  = co;
            cmd.CommandText = "insert into t_base_user values(@LoginName,@PassWord,@RoleId)";
            cmd.Parameters.AddWithValue("@LoginName", user.LoginName);
            cmd.Parameters.AddWithValue("@PassWord", user.PassWord);
            cmd.Parameters.AddWithValue("@RoleId", user.RoleId);
            int result = cmd.ExecuteNonQuery();

            cmd.Clone();
            co.Close();

            return(result);
        }
Beispiel #3
0
        public ActionResult Check(string LoginName, string Password)
        {
            Book.BLL.Home          bll  = new BLL.Home();
            Book.Model.T_Base_User user = bll.Check(LoginName, Password);


            //记录票据
            FormsAuthentication.SetAuthCookie(LoginName, true); //简单授权
            var authTicket = new FormsAuthenticationTicket(
                user.RoleId,                                    //角色
                LoginName,                                      //登录名
                DateTime.Now,                                   //当前时间
                DateTime.Now.AddMinutes(5),                     //保存时间
                true,                                           // 如果为 true,则创建持久 Cookie(跨浏览器会话保存的 Cookie);否则为 false。
                ""                                              //存储在票证中的用户特定的数据
                );
            HttpCookie authCookie = new HttpCookie(
                FormsAuthentication.FormsCookieName,
                FormsAuthentication.Encrypt(authTicket));

            Response.Cookies.Add(authCookie);
            return(RedirectToAction("/Index"));
        }