Exemplo n.º 1
0
        // GET: Nguoidung/Details/5
        public ActionResult Details(int id)
        {
            DBNguoiDung db   = new DBNguoiDung();
            var         data = db.detail(id);

            return(View(data));
        }
Exemplo n.º 2
0
        // GET: Nguoidung
        public ActionResult Index()
        {
            DBNguoiDung db   = new DBNguoiDung();
            var         data = db.getList();

            return(View(data));
        }
Exemplo n.º 3
0
        public ActionResult Login(NguoiDung nguoidung)
        {
            ViewBag.Login_Message = "Sai tên đăng nhập hoặc mật khẩu, vui lòng thử lại.";
            try
            {
                DBNguoiDung db_user     = new DBNguoiDung();
                string      username    = nguoidung.TenNguoiDung;
                string      user_pw     = nguoidung.MatKhau;
                var         check_login = db_user.check_login(username, user_pw);


                if (check_login)
                {
                    //Set Session
                    var user_info = db_user.getInfoByUsername(username);

                    if (user_info.TenNguoiDung != "")
                    {
                        Session["username"]          = user_info.TenNguoiDung;
                        Session["user_logged_in"]    = true;
                        Session["user_logged_level"] = user_info.Quyen;

                        return(RedirectToAction("Index", "Caythuoc"));
                    }
                    else
                    {
                        ViewBag.Login_Message = "Người dùng không tồn tại. Vui lòng thử lại.";
                        return(View(nguoidung));
                    }
                }
                else
                {
                    //Wrong some things
                    ViewBag.Login_Message = "Check login.";
                    return(View(nguoidung));
                }

                // TODO: Add insert logic here
            }
            catch
            {
                return(View(nguoidung));
            }
        }
Exemplo n.º 4
0
        public ActionResult Create(NguoiDung nd)
        {
            DBNguoiDung db = new DBNguoiDung();

            try
            {
                // TODO: Add insert logic here
                if (db.add(nd))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(nd));
                }
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 5
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            DBNguoiDung db = new DBNguoiDung();

            try
            {
                // TODO: Add delete logic here
                if (db.delete(id))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 6
0
        public ActionResult Edit(NguoiDung nd)
        {
            DBNguoiDung db = new DBNguoiDung();

            try
            {
                // TODO: Add update logic here
                if (db.edit(nd))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }