// GET: CongVan_TaiLieu/ChiTiet
        public ActionResult ChiTiet(int id = 0)
        {
            TAILIEU dstailieu = db.TAILIEUx.SingleOrDefault(n => n.IdTL == id);

            dstailieu.LuotXem = dstailieu.LuotXem + 1;
            db.SaveChanges();
            if (dstailieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(dstailieu));
        }
Пример #2
0
 public ActionResult DangKy(TAIKHOAN tk)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         var checkMail = db.TAIKHOANs.SingleOrDefault(n => n.Email.Trim() == tk.Email.Trim());
         var checkTen  = db.TAIKHOANs.SingleOrDefault(n => n.HoTen.Trim() == tk.HoTen.Trim());
         if (checkTen == null)
         {
             if (checkMail == null)
             {
                 tk.Password       = MaHoaMd5.EncryptMD5(tk.Email + tk.Password);
                 tk.RetypePassword = MaHoaMd5.EncryptMD5(tk.Email + tk.RetypePassword);
                 tk.TrangThai      = "Hoạt động";
                 tk.Quyen          = "User";
                 db.TAIKHOANs.Add(tk);
                 db.SaveChanges();
                 ViewBag.tbDangKy = "Người dùng: " + tk.HoTen + " đăng ký thành công!";
                 return(View());
             }
             else
             {
                 ViewBag.tbTonTai = "Email: " + tk.Email + " đã tồn tại!";
                 return(View());
             }
         }
         else
         {
             ViewBag.tbTonTai = "Tên người dùng: " + tk.HoTen + " đã tồn tại!";
             return(View());
         }
     }
 }
Пример #3
0
 // POST: Admin/Video/Sua
 public ActionResult Sua(VIDEO vdo)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         VIDEO video = db.VIDEOs.SingleOrDefault(n => n.IdVideo == vdo.IdVideo);
         if (video != null)
         {
             video.TenVideo  = vdo.TenVideo;
             video.LinkVideo = vdo.LinkVideo;
             if (vdo.NgayDang == null)
             {
                 video.NgayDang = video.NgayDang;
             }
             else
             {
                 video.NgayDang = vdo.NgayDang;
             }
             video.IdAlbum      = vdo.IdAlbum;
             ViewBag.IdAlbum    = new SelectList(db.ALBUMs.ToList(), "IdAlbum", "TenAlbum", video.IdAlbum);
             ViewBag.IdTaiKhoan = new SelectList(db.TAIKHOANs.ToList(), "IdTK", "HoTen");
             video.IdTaiKhoan   = vdo.IdTaiKhoan;
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
Пример #4
0
 public ActionResult Them(LICHLAMVIEC llv)
 {
     if (llv.NgayDang == null)
     {
         llv.NgayDang = DateTime.Parse(DateTime.Now.ToString());
     }
     else
     {
         llv.NgayDang = llv.NgayDang;
     }
     llv.LuotXem  = 0;
     llv.NhacLich = "Mọi người chú ý thực hiện đầy đủ!";
     db.LICHLAMVIECs.Add(llv);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Sua(LICHLAMVIEC llv)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         LICHLAMVIEC lichlamviec = db.LICHLAMVIECs.SingleOrDefault(n => n.IdLLV == llv.IdLLV);
         if (lichlamviec != null)
         {
             lichlamviec.TieuDe      = llv.TieuDe;
             lichlamviec.LinkNoiDung = llv.LinkNoiDung;
             if (llv.NgayDang == null)
             {
                 lichlamviec.NgayDang = lichlamviec.NgayDang;
             }
             else
             {
                 lichlamviec.NgayDang = llv.NgayDang;
             }
             lichlamviec.NhacLich   = llv.NhacLich;
             lichlamviec.IdTaiKhoan = llv.IdTaiKhoan;
             ViewBag.IdTaiKhoan     = new SelectList(db.TAIKHOANs.ToList(), "IdTK", "HoTen", lichlamviec.IdTaiKhoan);
             db.SaveChanges();
         }
         return(RedirectToAction("Index", "LichLamViec"));
     }
 }
 public ActionResult Them(LICHLAMVIEC llv)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         if (llv.NgayDang == null)
         {
             llv.NgayDang = DateTime.Parse(DateTime.Now.ToString());
         }
         else
         {
             llv.NgayDang = llv.NgayDang;
         }
         if (llv.NhacLich == null)
         {
             llv.NhacLich = "Mọi người chú ý thực hiện đầy đủ!";
         }
         else
         {
             llv.NhacLich = llv.NhacLich;
         }
         llv.LuotXem        = 0;
         ViewBag.IdTaiKhoan = new SelectList(db.TAIKHOANs.ToList(), "IdTK", "HoTen");
         db.LICHLAMVIECs.Add(llv);
         db.SaveChanges();
         return(RedirectToAction("Index", "LichLamViec"));
     }
 }
        // POST: Admin/HinhAnh/Sua
        public ActionResult Sua(HINHANH ha)
        {
            using (Web_KTCKEntities db = new Web_KTCKEntities())
            {
                HINHANH hinhanh = db.HINHANHs.SingleOrDefault(n => n.IdHinhAnh == ha.IdHinhAnh);
                if (hinhanh != null)
                {
                    hinhanh.TenHinhAnh = ha.TenHinhAnh;
                    if (ha.NgayDang == null)
                    {
                        hinhanh.NgayDang = hinhanh.NgayDang;
                    }
                    else
                    {
                        hinhanh.NgayDang = ha.NgayDang;
                    }

                    hinhanh.HinhAnh1   = ha.HinhAnh1;
                    hinhanh.IdAlbum    = ha.IdAlbum;
                    ViewBag.IdAlbum    = new SelectList(db.ALBUMs.ToList(), "IdAlbum", "TenAlbum");
                    ViewBag.IdTaiKhoan = new SelectList(db.TAIKHOANs.ToList(), "IdTK", "HoTen");
                    hinhanh.IdTaiKhoan = ha.IdTaiKhoan;
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("Index"));
        }
 public ActionResult Them(BAIVIET bv)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         try
         {
             if (bv.NgayDang == null)
             {
                 bv.NgayDang = DateTime.Parse(DateTime.Now.ToString());
             }
             else
             {
                 bv.NgayDang = bv.NgayDang;
             }
             bv.NgayCapNhat     = null;
             bv.LuotXem         = 0;
             ViewBag.IdTheLoai  = new SelectList(db.THELOAIBAIVIETs.ToList(), "IdTheLoai", "TenTheLoai");
             ViewBag.IdTaiKhoan = new SelectList(db.TAIKHOANs.ToList(), "IdTK", "HoTen");
             db.BAIVIETs.Add(bv);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch
         {
             return(RedirectToAction("Index"));
         }
     }
 }
 public ActionResult Sua(CANBO cb)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         CANBO canbo = db.CANBOes.SingleOrDefault(n => n.IdCB == cb.IdCB);
         if (canbo != null)
         {
             canbo.HoTen   = cb.HoTen;
             canbo.ChucVu  = cb.ChucVu;
             canbo.BangCap = cb.BangCap;
             canbo.QueQuan = cb.QueQuan;
             canbo.Email   = cb.Email;
             if (cb.NgaySinh == null)
             {
                 canbo.NgaySinh = canbo.NgaySinh;
             }
             else
             {
                 canbo.NgaySinh = cb.NgaySinh;
             }
             canbo.NgayCapNhat  = DateTime.Parse(DateTime.Now.ToString());
             canbo.SoDT         = cb.SoDT;
             canbo.AnhMoTa      = cb.AnhMoTa;
             canbo.ChiTiet      = cb.ChiTiet;
             canbo.IdTaiKhoan   = cb.IdTaiKhoan;
             canbo.IdPhongBan   = cb.IdPhongBan;
             ViewBag.IdPhongBan = new SelectList(db.PHONGBANs.ToList(), "IdPB", "TenPhong", canbo.IdPhongBan);
             ViewBag.IdTaiKhoan = new SelectList(db.TAIKHOANs.ToList(), "IdTK", "HoTen");
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
Пример #10
0
 //POST: Admin/ThongBao/Sua
 public ActionResult Sua(THONGBAO tb)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         THONGBAO thongbao = db.THONGBAOs.SingleOrDefault(n => n.IdTB == tb.IdTB);
         if (thongbao != null)
         {
             thongbao.TieuDe  = tb.TieuDe;
             thongbao.NoiDung = tb.NoiDung;
             if (tb.NgayDang == null)
             {
                 thongbao.NgayDang = thongbao.NgayDang;
             }
             else
             {
                 thongbao.NgayDang = tb.NgayDang;
             }
             thongbao.TrangThai  = tb.TrangThai;
             thongbao.IdTaiKhoan = tb.IdTaiKhoan;
             ViewBag.IdTaiKhoan  = new SelectList(db.TAIKHOANs.ToList(), "IdTK", "HoTen");
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
Пример #11
0
 public ActionResult ThemBinhLuan(BINHLUAN bl)
 {
     try
     {
         bl.NgayBinhLuan = DateTime.Parse(DateTime.Now.ToString());
         bl.TrangThai    = "Hiển thị";
         bl.NoiDung      = bl.NoiDung;
         bl.UrlBaiViet   = bl.UrlBaiViet;
         db.BINHLUANs.Add(bl);
         db.SaveChanges();
         return(Redirect(Request.UrlReferrer.ToString()));
     }
     catch
     {
         return(RedirectToAction("Index"));
     }
 }
 // POST: Admin/CanBoNhanVien/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         CANBO canbo = db.CANBOes.SingleOrDefault(n => n.IdCB == id);
         db.CANBOes.Remove(canbo);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Пример #13
0
 // POST: Admin/TaiKhoan/Sua
 public ActionResult Sua(TAIKHOAN tk)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         TAIKHOAN taikhoan = db.TAIKHOANs.SingleOrDefault(n => n.IdTK == tk.IdTK);
         taikhoan.HoTen     = tk.HoTen;
         taikhoan.TrangThai = tk.TrangThai;
         taikhoan.Quyen     = tk.Quyen;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult Them(CANBO cb)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         cb.NgayCapNhat     = DateTime.Parse(DateTime.Now.ToString());
         ViewBag.IdPhongBan = new SelectList(db.PHONGBANs.ToList(), "IdPb", "TenPhongBan");
         ViewBag.IdTaiKhoan = new SelectList(db.TAIKHOANs.ToList(), "IdTK", "HoTen");
         db.CANBOes.Add(cb);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Пример #15
0
 //POST: Admin/ThongBao/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         THONGBAO tb = db.THONGBAOs.SingleOrDefault(n => n.IdTB == id);
         if (tb != null)
         {
             db.THONGBAOs.Remove(tb);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
Пример #16
0
 //POST: Admin/TheLoaiBaiViet/Sua
 public ActionResult Sua(THELOAIBAIVIET tlbv)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         THELOAIBAIVIET theloaibv = db.THELOAIBAIVIETs.SingleOrDefault(n => n.IdTheLoai == tlbv.IdTheLoai);
         if (theloaibv != null)
         {
             theloaibv.TenTheLoai = tlbv.TenTheLoai;
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
Пример #17
0
 //POST: Admin/TheLoaiBaiViet/Them
 public ActionResult Them(THELOAIBAIVIET tlbv)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         var checkTheLoai = db.THELOAIBAIVIETs.SingleOrDefault(n => n.TenTheLoai.Trim() == tlbv.TenTheLoai.Trim());
         if (checkTheLoai == null)
         {
             db.THELOAIBAIVIETs.Add(tlbv);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
Пример #18
0
 // POST: Admin/Video/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         VIDEO vdo = db.VIDEOs.SingleOrDefault(n => n.IdVideo == id);
         if (vdo != null)
         {
             db.VIDEOs.Remove(vdo);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
Пример #19
0
 public ActionResult Sua(PHONGBAN pb)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         PHONGBAN phongban = db.PHONGBANs.SingleOrDefault(n => n.IdPB == pb.IdPB);
         if (phongban != null)
         {
             phongban.TenPhong = pb.TenPhong;
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
 // POST: Admin/HinhAnh/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         HINHANH ha = db.HINHANHs.SingleOrDefault(n => n.IdHinhAnh == id);
         if (ha != null)
         {
             db.HINHANHs.Remove(ha);
             db.SaveChanges();
         }
     }
     return(RedirectToAction("Index"));
 }
 //POST: Admin/CongVanTaiLieu/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         TAILIEU tl = db.TAILIEUx.SingleOrDefault(n => n.IdTL == id);
         if (tl != null)
         {
             db.TAILIEUx.Remove(tl);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
 // POST: Admin/BaiViet/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         BAIVIET bv = db.BAIVIETs.SingleOrDefault(n => n.IdBV == id);
         if (bv != null)
         {
             db.BAIVIETs.Remove(bv);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
 //POST: Admin/LichLamViec/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         LICHLAMVIEC llv = db.LICHLAMVIECs.SingleOrDefault(n => n.IdLLV == id);
         if (llv != null)
         {
             db.LICHLAMVIECs.Remove(llv);
             db.SaveChanges();
         }
         return(RedirectToAction("Index", "LichLamViec"));
     }
 }
 //POST: Admin/BinhLuan/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         BINHLUAN bl = db.BINHLUANs.SingleOrDefault(n => n.IdBL == id);
         if (bl != null)
         {
             db.BINHLUANs.Remove(bl);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult Sua(BINHLUAN bl)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         BINHLUAN binhluan = db.BINHLUANs.SingleOrDefault(n => n.IdBL == bl.IdBL);
         if (binhluan != null)
         {
             binhluan.TrangThai = bl.TrangThai;
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
 // POST: Admin/Album
 public ActionResult Sua(ALBUM al)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         ALBUM album = db.ALBUMs.SingleOrDefault(n => n.IdAlbum == al.IdAlbum);
         if (album != null)
         {
             album.TenAlbum   = al.TenAlbum;
             album.AnhDaiDien = al.AnhDaiDien;
             db.SaveChanges();
         }
     }
     return(RedirectToAction("Index"));
 }
Пример #27
0
 public ActionResult Them(PHONGBAN pb)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         //Kiểm tra tên phòng có trùng k?
         var checkTenPhong = db.PHONGBANs.SingleOrDefault(x => x.TenPhong.Trim() == pb.TenPhong.Trim());
         // không trùng thì thêm mới
         if (checkTenPhong == null)
         {
             db.PHONGBANs.Add(pb);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
 // POST: Admin/Album
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         try
         {
             ALBUM al = db.ALBUMs.SingleOrDefault(n => n.IdAlbum == id);
             db.ALBUMs.Remove(al);
             db.SaveChanges();
         }
         catch
         {
         }
     }
     return(RedirectToAction("Index"));
 }
Пример #29
0
 //POST: Admin/TheLoaiBaiViet/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         try
         {
             THELOAIBAIVIET theloaibv = db.THELOAIBAIVIETs.SingleOrDefault(n => n.IdTheLoai == id);
             db.THELOAIBAIVIETs.Remove(theloaibv);
             db.SaveChanges();
         }
         catch
         {
         }
         return(RedirectToAction("Index"));
     }
 }
Пример #30
0
 // POST: Admin/PhongBan/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         try
         {
             PHONGBAN pb = db.PHONGBANs.SingleOrDefault(n => n.IdPB == id);
             db.PHONGBANs.Remove(pb);
             db.SaveChanges();
         }
         catch
         {
         }
         return(RedirectToAction("Index"));
     }
 }