Exemple #1
0
        public void Submit_DangKi(object sender, EventArgs e)
        {
            string name = Request.Form.Get("taikhoan");

            string matkhau = Request.Form.Get("matkhau");

            string testmatkhau = Request.Form.Get("testmatkhau");



            if (matkhau == testmatkhau)
            {
                if (CheckUser(name))
                {
                    var _db = new Models.BookContext();

                    var newUser = new Models.User
                    {
                        UserName = name,
                        Password = matkhau
                    };


                    _db.Users.Add(newUser);
                    _db.SaveChanges();

                    Response.Cookies.Add(new HttpCookie("taikhoan", name));
                    Response.Cookies.Add(new HttpCookie("matkhau", matkhau));
                    Response.Redirect("Default.aspx");
                }
                else
                {
                    message = "tai khoan da ton tai";
                }
            }
            else
            {
                message = "mat khau khong giong nhau";
            }
        }
Exemple #2
0
        public void Submit_Book(object sender, EventArgs e)
        {
            string name        = Request.Form.Get("BookName");
            int    cateId      = Int32.Parse(Request.Form.Get("CategoryId"));
            string description = Request.Form.Get("Description");
            string imagePath   = Request.Form.Get("ImagePath");
            string content     = Request.Form.Get("Content");


            var _db = new Models.BookContext();

            var newBook = new Models.Book
            {
                BookName    = name,
                Description = description,
                ImagePath   = imagePath,
                Content     = content,
                CategoryID  = cateId
            };


            _db.Books.Add(newBook);
            _db.SaveChanges();
        }