Exemple #1
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;
            }
        }
        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;
            }
        }
Exemple #3
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;
            }
        }
        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;
            }
        }
        public ActionResult Create([Bind(Include = "id,tenthanhvien,motasoluoc,chitiet,urlhinhanh,ngaytao,ngaycapnhat,nguoitao,daxoa,ghichu,nhomthanhvien,hienthi,tenthanhvien_en,motasoluoc_en,chitiet_en,thutuhienthi")] admin_thanhvien admin_thanhvien)
        {
            if (ModelState.IsValid)
            {
                db.admin_thanhvien.Add(admin_thanhvien);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.nguoitao      = new SelectList(db.admin_account, "id", "username", admin_thanhvien.nguoitao);
            ViewBag.nhomthanhvien = new SelectList(db.admin_nhomthanhvien, "id", "tennhomthanhvien", admin_thanhvien.nhomthanhvien);
            return(View(admin_thanhvien));
        }
        public ActionResult Create([Bind(Include = "id,username,password,ngaytao,landangnhapcuoi,hoten,gioitinh,ghichu,quyen,daxoa")] admin_account admin_account)
        {
            if (ModelState.IsValid)
            {
                admin_account.ngaytao         = DateTime.Now;
                admin_account.landangnhapcuoi = DateTime.Now;
                db.admin_account.Add(admin_account);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(admin_account));
        }
        public ActionResult Create([Bind(Include = "id,diachi,diachi_en,dienthoai,website,fax,mail,logo,diachigmap,baiviettrangchu,baiviettrangchu_en")] admin_thongtincodinh admin_thongtincodinh)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (ModelState.IsValid)
            {
                db.admin_thongtincodinh.Add(admin_thongtincodinh);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(admin_thongtincodinh));
        }
Exemple #8
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"));
 }
        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));
        }
Exemple #10
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));
        }
Exemple #12
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;
     }
 }
        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));
        }
        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());
            }
        }
Exemple #15
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"));
        }
        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));
        }