Esempio n. 1
0
        //public ActionResult Create([Bind(Include = "id,ten,ngaytao,ngaycapnhat,nguoitao,daxoa,hinhanhloaisanpham,motasoluoc,ghichu,hienthi,thutuhien")] loaisanpham loaisanpham)
        public ActionResult Create([Bind(Include = "id,ten,hinhanhloaisanpham,motasoluoc,ghichu,hienthi,thutuhien")] loaisanpham loaisanpham)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    admin_account u = Session["User"] as admin_account;
                    loaisanpham.nguoitao    = u.id;
                    loaisanpham.ngaytao     = DateTime.Now;
                    loaisanpham.ngaycapnhat = DateTime.Now;
                    loaisanpham.daxoa       = false;
                    if (loaisanpham.hienthi == null)
                    {
                        loaisanpham.hienthi = true;
                    }

                    db.loaisanphams.Add(loaisanpham);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(loaisanpham));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "id,ten,loaisanpham,ngaytao,ngaycapnhat,nguoitao,motasoluoc,motachitiet,daxoa,ghichu,hienthi,hinhdaidien,hinhanhsanpham,thutuhien,gianiemyet,giaban,mathuonghieu")] sanpham sanpham, string[] addmore)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    admin_account u = Session["User"] as admin_account;
                    sanpham.nguoitao    = u.id;
                    sanpham.daxoa       = false;
                    sanpham.ngaytao     = DateTime.Now;
                    sanpham.ngaycapnhat = DateTime.Now;
                    db.sanphams.Add(sanpham);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.loaisanpham = new SelectList(db.loaisanphams, "id", "ten", sanpham.loaisanpham);
                return(View(sanpham));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "id,tentintuc,tentintuc_en,hinhdaidien,loaitintuc,ngaytao,ngaycapnhat,nguoitao,motasoluoc,motasoluoc_en,noidungtintuc,noidungtintuc_en,daxoa,ghichu,hienthi")] admin_tintuc admin_tintuc)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    admin_tintuc.ngaytao     = DateTime.Now;
                    admin_tintuc.ngaycapnhat = DateTime.Now;
                    if (Session["User"] != null)
                    {
                        admin_account u = Session["User"] as admin_account;
                        admin_tintuc.nguoitao = u.id;
                    }
                    db.admin_tintuc.Add(admin_tintuc);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.nguoitao   = new SelectList(db.admin_account, "id", "username", admin_tintuc.nguoitao);
                ViewBag.loaitintuc = new SelectList(db.admin_loaitintuc, "id", "tenloaitintuc", admin_tintuc.loaitintuc);
                return(View(admin_tintuc));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "id,tenbaigioithieu,tenbaigioithieu_en,noidung,noidung_en,hienthi,thutuhienthi,daxoa,nguoitao,ngaytao,ngaycapnhat,ghichu")] admin_gioithieu admin_gioithieu)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    admin_gioithieu.ngaytao     = DateTime.Now;
                    admin_gioithieu.ngaycapnhat = DateTime.Now;
                    if (Session["User"] != null)
                    {
                        admin_account u = Session["User"] as admin_account;
                        admin_gioithieu.nguoitao = u.id;
                    }
                    db.admin_gioithieu.Add(admin_gioithieu);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.nguoitao = new SelectList(db.admin_account, "id", "username", admin_gioithieu.nguoitao);
                return(View(admin_gioithieu));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "id,tenhinhanh,urlhinhanh,ngaytao,ngaycapnhat,nguoitao,loaihinhanh,thutuhien,daxoa,ghichu")] admin_hinhanh admin_hinhanh)
        {
            try
            {
                if (Session["User"] == null)
                {
                    return(RedirectToAction("Logout", "Account"));
                }
                if (ModelState.IsValid)
                {
                    if (Session["User"] != null)
                    {
                        admin_account u = Session["User"] as admin_account;
                        admin_hinhanh.nguoitao = u.id;
                    }
                    admin_hinhanh.ngaytao     = DateTime.Now;
                    admin_hinhanh.ngaycapnhat = DateTime.Now;
                    db.admin_hinhanh.Add(admin_hinhanh);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.nguoitao    = new SelectList(db.admin_account, "id", "username", admin_hinhanh.nguoitao);
                ViewBag.loaihinhanh = new SelectList(db.admin_loaihinhanh, "id", "tenloaihinhanh", admin_hinhanh.loaihinhanh);
                return(View(admin_hinhanh));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "tenhanhtrinh,tenhanhtrinh_en,hinhdaidien,loaihanhtrinh,ngaytao,thongtinthoigian,thongtindiadiem,diadiem_en,motasoluoc,motasoluoc_en,noidung,noidung_en,hienthi,nguoitao")] admin_hanhtrinh admin_hanhtrinh)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    admin_hanhtrinh.ngaycapnhat = DateTime.Now;
                    if (Session["User"] != null)
                    {
                        admin_account u = Session["User"] as admin_account;
                        admin_hanhtrinh.nguoitao = u.id;
                    }
                    db.admin_hanhtrinh.Add(admin_hanhtrinh);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.nguoitao      = new SelectList(db.admin_account, "id", "username", admin_hanhtrinh.nguoitao);
                ViewBag.loaihanhtrinh = new SelectList(db.admin_loaihanhtrinh, "id", "tenloaihanhtrinh", admin_hanhtrinh.loaihanhtrinh);
                return(View(admin_hanhtrinh));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 7
0
 // GET: Admin/Shared
 public ActionResult _LoginName()
 {
     try
     {
         if (Session["User"] != null)
         {
             admin_account u           = Session["User"] as admin_account;
             admin_account currentuser = db.admin_account.Find(u.id);
             currentuser.landangnhapcuoi = DateTime.Now;
             db.Entry(currentuser).State = EntityState.Modified;
             db.SaveChanges();
             ViewBag.LoginName = currentuser.hoten;
             return(PartialView("_LoginName"));
         }
         else
         {
             Session.Clear();
             return(PartialView("_LoginName"));
         }
     }
     catch (Exception ex)
     {
     }
     Session.Clear();
     return(PartialView("_LoginName"));
 }
Esempio n. 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            admin_account admin_account = db.admin_account.Find(id);

            db.admin_account.Remove(admin_account);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 9
0
 public ActionResult Edit([Bind(Include = "id,username,password,ngaytao,landangnhapcuoi,hoten,gioitinh,ghichu,quyen,daxoa")] admin_account admin_account)
 {
     if (ModelState.IsValid)
     {
         admin_account.landangnhapcuoi = DateTime.Now;
         db.Entry(admin_account).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(admin_account));
 }
Esempio n. 10
0
        // GET: Admin/admin_account/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            admin_account admin_account = db.admin_account.Find(id);

            if (admin_account == null)
            {
                return(HttpNotFound());
            }
            return(View(admin_account));
        }
Esempio n. 11
0
 public ActionResult EditImg(string urlImgList)
 {
     try
     {
         var img_          = urlImgList.Split(';');
         var loaihinhanhId = Convert.ToInt32(Session["idLoaiHinhAnh"]);
         var listdel       = db.admin_hinhanh.Where(s => s.loaihinhanh == loaihinhanhId);
         foreach (var item1 in listdel)
         {
             using (var db1 = new WebApplication1Entities1())
             {
                 try
                 {
                     var objhinhanh = db1.admin_hinhanh.Find(item1.id);
                     db1.admin_hinhanh.Attach(objhinhanh);
                     db1.admin_hinhanh.Remove(objhinhanh);
                     db1.SaveChanges();
                 }
                 catch (Exception ex)
                 {
                     throw;
                 }
             }
         }
         using (var db2 = new WebApplication1Entities1())
         {
             foreach (var item in img_)
             {
                 if (item.Length > 0)
                 {
                     admin_hinhanh admin_hinhanh = new admin_hinhanh();
                     admin_hinhanh.tenhinhanh  = "img" + DateTime.Now.Year.ToString() + "" + DateTime.Now.Month + "" + DateTime.Now.Day;
                     admin_hinhanh.urlhinhanh  = item;
                     admin_hinhanh.ngaytao     = DateTime.Now;
                     admin_hinhanh.ngaycapnhat = DateTime.Now;
                     admin_account u = Session["User"] as admin_account;
                     admin_hinhanh.nguoitao    = u.id;
                     admin_hinhanh.loaihinhanh = loaihinhanhId;
                     db2.admin_hinhanh.Add(admin_hinhanh);
                     db2.SaveChanges();
                 }
             }
         }
         return(RedirectToAction("Edit", "LoaiHinhAnh", new { id = loaihinhanhId })); // Redirect to your NextView
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Esempio n. 12
0
        public ActionResult Logout()
        {
            admin_account u = new admin_account();

            u = Session["User"] as admin_account;
            try
            {
                if (u != null)
                {
                    u.landangnhapcuoi = DateTime.Now;
                    db.admin_account.Attach(u);
                    db.Entry(u).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
            Session["User"] = null;
            return(RedirectToAction("Login", "Account"));
        }
        public ActionResult Create([Bind(Include = "id,tenloaitintuc,ngaytao,ngaycapnhat,nguoitao,daxoa,hinhanhtintuc,motasoluoc,ghichu")] admin_loaitintuc admin_loaitintuc)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (ModelState.IsValid)
            {
                if (Session["User"] != null)
                {
                    admin_account u = Session["User"] as admin_account;
                    admin_loaitintuc.nguoitao = u.id;
                }
                admin_loaitintuc.ngaytao     = DateTime.Now;
                admin_loaitintuc.ngaycapnhat = DateTime.Now;
                db.admin_loaitintuc.Add(admin_loaitintuc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(admin_loaitintuc));
        }
Esempio n. 14
0
        public ActionResult Create([Bind(Include = "id,tenloaihanhtrinh,ngaytao,ngaycapnhat,hienthi,nguoitao")] admin_loaihanhtrinh admin_loaihanhtrinh)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (ModelState.IsValid)
            {
                if (Session["User"] != null)
                {
                    admin_account u = Session["User"] as admin_account;
                    admin_loaihanhtrinh.nguoitao = u.id;
                }
                admin_loaihanhtrinh.ngaytao     = DateTime.Now;
                admin_loaihanhtrinh.ngaycapnhat = DateTime.Now;
                db.admin_loaihanhtrinh.Add(admin_loaihanhtrinh);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.nguoitao = new SelectList(db.admin_account, "id", "username", admin_loaihanhtrinh.nguoitao);
            return(View(admin_loaihanhtrinh));
        }
        public ActionResult Create([Bind(Include = "id,tennhomthanhvien,motanhom,ngaytao,ngaycapnhat,nguoitao,daxoa,ghichu,hinhdaidien")] admin_nhomthanhvien admin_nhomthanhvien)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (ModelState.IsValid)
            {
                if (Session["User"] != null)
                {
                    admin_account u = Session["User"] as admin_account;
                    admin_nhomthanhvien.nguoitao = u.id;
                }
                admin_nhomthanhvien.ngaytao     = DateTime.Now;
                admin_nhomthanhvien.ngaycapnhat = DateTime.Now;
                db.admin_nhomthanhvien.Add(admin_nhomthanhvien);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.nguoitao = new SelectList(db.admin_account, "id", "username", admin_nhomthanhvien.nguoitao);
            return(View(admin_nhomthanhvien));
        }
Esempio n. 16
0
        public ActionResult Create([Bind(Include = "id,tenbailienhe,tenbailienhe_en,noidung,noidung_en,hienthi,daxoa,ngaytao,ngaycapnhat,nguoitao,thutuhienthi,ghichu")] admin_baivietlienhe admin_baivietlienhe)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (ModelState.IsValid)
            {
                admin_baivietlienhe.ngaytao     = DateTime.Now;
                admin_baivietlienhe.ngaycapnhat = DateTime.Now;
                if (Session["User"] != null)
                {
                    admin_account u = Session["User"] as admin_account;
                    admin_baivietlienhe.nguoitao = u.id;
                }
                db.admin_baivietlienhe.Add(admin_baivietlienhe);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.nguoitao = new SelectList(db.admin_account, "id", "username", admin_baivietlienhe.nguoitao);
            return(View(admin_baivietlienhe));
        }
Esempio n. 17
0
        public ActionResult Login(admin_account account)
        {
            admin_account u = db.admin_account.Where(m => m.username == account.username && m.password == account.password).FirstOrDefault();

            if (u != null)
            {
                Session["User"] = u;

                DateTime _now = System.DateTime.Now;
                u.landangnhapcuoi = _now;
                db.admin_account.Attach(u);
                db.Entry(u).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index", "HanhTrinh"));
            }
            else
            {
                Session["User"] = null;
                ViewBag.Message = "";
                ViewBag.Message = "Sai tài khoản hoặc mật khẩu";
                return(View());
            }
        }
Esempio n. 18
0
        public ActionResult UploadImageMethod()
        {
            if (Request.Files.Count != 0)
            {
                string uri = Request.RawUrl;
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFileBase file = Request.Files[i];
                    int    fileSize         = file.ContentLength;
                    string fileName         = file.FileName;
                    file.SaveAs(Server.MapPath("~/UserUpload/images/HinhAnh/" + fileName));
                    //ImageGallery imageGallery = new ImageGallery();
                    //imageGallery.ID = Guid.NewGuid();
                    //imageGallery.Name = fileName;
                    //imageGallery.ImagePath = "~/UserUpload/images/" + fileName;
                    //db.ImageGallery.Add(imageGallery);
                    //db.SaveChanges();

                    admin_hinhanh admin_hinhanh = new admin_hinhanh();
                    if (Session["User"] != null)
                    {
                        admin_account u = Session["User"] as admin_account;
                        admin_hinhanh.nguoitao = u.id;
                    }
                    admin_hinhanh.ngaytao     = DateTime.Now;
                    admin_hinhanh.ngaycapnhat = DateTime.Now;
                    admin_hinhanh.tenhinhanh  = fileName;
                    admin_hinhanh.urlhinhanh  = "/UserUpload/images/HinhAnh/" + fileName;
                    admin_hinhanh.loaihinhanh = Convert.ToInt32(Session["idLoaiHinhAnh"]);
                    db.admin_hinhanh.Add(admin_hinhanh);
                    db.SaveChanges();
                }
                return(Content("Success"));
            }
            return(Content("failed"));
        }
Esempio n. 19
0
        public ActionResult Create([Bind(Include = "id,tenbanner,urlbanner,motabanner,ghichu,ngaytao,ngaycapnhat,nguoitao,hienthi,thutuhien,daxoa,loaibanner")] banner banner)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (ModelState.IsValid)
            {
                if (Session["User"] != null)
                {
                    admin_account u = Session["User"] as admin_account;
                    banner.nguoitao = u.id;
                }
                banner.ngaytao     = DateTime.Now;
                banner.ngaycapnhat = DateTime.Now;
                db.banners.Add(banner);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.nguoitao   = new SelectList(db.admin_account, "id", "username", banner.nguoitao);
            ViewBag.loaibanner = new SelectList(db.loaibanners, "id", "tenloaibanner", banner.loaibanner);
            return(View(banner));
        }