Beispiel #1
0
        public ActionResult UpdateSlide(Slide objSlide, HttpPostedFileBase fAnh)
        {
            var id = Convert.ToInt32(Request["Id"] + "");

            if (fAnh != null && fAnh.ContentLength > 0)
            {
                string tenAnh = Path.GetFileName(fAnh.FileName);
                fAnh.SaveAs(Server.MapPath("~/Content/Images/" + tenAnh));
                objSlide.Anh = tenAnh;
            }
            Slide objSlideOld = DataProvider.ShopEntities.Slides.Find(objSlide.Id);

            if (fAnh == null)
            {
                objSlide.Anh = objSlideOld.Anh;
            }
            objSlide.TenSlide = Request["TenSlide"] + "";
            objSlide.MoTa     = Request["Mota"] + "";
            objSlide.NgayTao  = objSlideOld.NgayTao;
            objSlide.DaDuyet  = objSlideOld.DaDuyet;
            DataProvider.ShopEntities.Entry <Slide>(objSlideOld).CurrentValues.SetValues(objSlide);
            DataProvider.ShopEntities.SaveChanges();
            NhatKyCommon.Them("Người dùng thực hiện chức năng Sửa Slide", "Sửa");
            return(RedirectToAction("DanhSach"));
        }
Beispiel #2
0
        public ActionResult Delete(int[] Id)
        {
            for (int i = 1; i <= Id.Count(); i++)
            {
                Slide objSlide = DataProvider.ShopEntities.Slides.Find(Id);
                DataProvider.ShopEntities.Slides.Remove(objSlide);
            }
            DataProvider.ShopEntities.SaveChanges();
            NhatKyCommon.Them("Người dùng thực hiện chức năng Xóa Tất cả các Slide", "Xóa tất cả");

            return(Json("Tất cả các nhật ký đã được xóa"));
        }
Beispiel #3
0
        public JsonResult Xoa(int id)
        {
            ChucNang objChucNang = DataProvider.ShopEntities.ChucNangs.Where(p => p.Id == id).First();

            if (objChucNang != null)
            {
                //Thực hiện xóa
                DataProvider.ShopEntities.ChucNangs.Remove(objChucNang);
                //Lưu thay đổi
                DataProvider.ShopEntities.SaveChanges();
            }
            // Nhât ký xóa
            // 1.Thêm mới 2.Sửa 3.Xóa
            NhatKyCommon.Them("Người dùng thực hiện hành động Xóa chức năng", "Xóa");
            return(Json(objChucNang, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public JsonResult Xoa(int id)
        {
            ChuongTrinhUuDai objChuongTrinh = DataProvider.ShopEntities.ChuongTrinhUuDais.Where(p => p.Id == id).First();

            if (objChuongTrinh != null)
            {
                //Thực hiện xóa
                DataProvider.ShopEntities.ChuongTrinhUuDais.Remove(objChuongTrinh);
                //Lưu thay đổi
                DataProvider.ShopEntities.SaveChanges();
            }
            // Nhật ký xóa
            // 1.Thêm mới 2 Sửa 3.Xóa
            NhatKyCommon.Them("Người dùng thực hiện chức năng Xóa Chương trình khuyến mãi chi tiết", "Xóa");
            return(Json(objChuongTrinh, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        public JsonResult Xoa(int id)
        {
            Slide objSlide = DataProvider.ShopEntities.Slides.Where(p => p.Id == id).First();

            if (objSlide != null)
            {
                //Thực hiện xóa
                DataProvider.ShopEntities.Slides.Remove(objSlide);
                //Lưu thay đổi
                DataProvider.ShopEntities.SaveChanges();
            }

            // Nhật ký xóa
            // 1.Thêm mới 2 Sửa 3.Xóa
            NhatKyCommon.Them("Người dùng thực hiện chức năng Xóa Slide", "Xóa");
            return(Json(objSlide, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        public ActionResult AddSlide(Slide objSlide, HttpPostedFileBase fAnh)
        {
            objSlide.TenSlide = Request["TenSlide"] + "";
            objSlide.MoTa     = Request["MoTa"] + "";
            objSlide.DaDuyet  = false;
            objSlide.NgayTao  = DateTime.Now;


            if (fAnh != null && fAnh.ContentLength > 0)
            {
                string tenAnh = Path.GetFileName(fAnh.FileName);
                fAnh.SaveAs(Server.MapPath("~/Content/Images/" + tenAnh));
                objSlide.Anh = tenAnh;
            }
            DataProvider.ShopEntities.Slides.Add(objSlide);
            DataProvider.ShopEntities.SaveChanges();
            NhatKyCommon.Them("Người dùng thực hiện chức năng Thêm Mới Slide", "Thêm Mới");
            return(RedirectToAction("DanhSach"));
        }
Beispiel #7
0
        public JsonResult ThemChuongTrinhJson()
        {
            var data = Request.Form;
            //Khai báo 1 đối tượng
            ChuongTrinhUuDai objUuDai = new ChuongTrinhUuDai();

            //Gán giá trị
            objUuDai.TenChuongTrinh = data["tenCT"];
            objUuDai.MoTa           = data["moTa"];
            objUuDai.NgayTao        = DateTime.Now;
            objUuDai.TuNgay         = Convert.ToDateTime(data["BatDau"]);
            objUuDai.DenNgay        = Convert.ToDateTime(data["KetThuc"]);
            objUuDai.DaDuyet        = Convert.ToBoolean(data["daduyet"]);
            var id = Convert.ToInt32(data["id"]);

            if (id > 0)//TH sửa
            {
                objUuDai.Id = id;
                //Lấy đối tượng cũ
                ChuongTrinhUuDai objChuongTrinhld = DataProvider.ShopEntities.ChuongTrinhUuDais.Where(p => p.Id == id).First();
                DataProvider.ShopEntities.Entry(objChuongTrinhld).CurrentValues.SetValues(objUuDai);
                DataProvider.ShopEntities.SaveChanges();
                // nhật ký sửa
                // 1.Thêm mới 2 Sửa 3.Xóa
                NhatKyCommon.Them("Người dùng thực hiện chức năng Sửa Chương trình khuyến mãi", "Sửa");
            }
            else
            {
                //Thực hiện thêm và lưu sự thay đổi
                DataProvider.ShopEntities.ChuongTrinhUuDais.Add(objUuDai);
                DataProvider.ShopEntities.SaveChanges();
                // Nhật ký thêm
                // 1.Thêm mới 2 Sửa 3.Xóa
                NhatKyCommon.Them("Người dùng thực hiện chức năng Thêm mới Chương trình khuyến mãi", "Thêm Mới");
            }


            return(Json(objUuDai, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Login(NguoiDung objNguoiDungLogin)
        {
            if (ModelState.IsValid)
            {
                var passwordMD5 = Encryptor.MD5Hash(objNguoiDungLogin.MatKhau);
                var obj         = DataProvider.ShopEntities.NguoiDungs.Where(p => p.TaiKhoan.Equals(objNguoiDungLogin.TaiKhoan)).FirstOrDefault();
                if (obj != null)
                {
                    if (obj.MatKhau == passwordMD5)
                    {
                        Session["HoTen"]    = obj.HoTen.ToString();
                        Session["VaiTroId"] = obj.VaiTroId.ToString();
                        Session["userid"]   = obj.Id.ToString();
                        //Luu ca objNguoiDung
                        Session["useronline"] = obj;

                        //Lưu thông tin vào biến
                        Common.UserInfo = obj;
                        Common.UserId   = obj.Id;

                        //Ghi log
                        NhatKyCommon.Them("Đăng nhập hệ thống thành công", "Đăng nhập");
                        return(RedirectToAction("Login"));
                    }
                    else
                    {
                        ViewBag.ThongBao = "Sai mật khẩu";
                        return(View());
                    }
                }
                else
                {
                    ViewBag.ThongBao = "Không tồn tại tài khoản này trong hệ thống";
                    return(View());
                }
            }
            return(View(objNguoiDungLogin));
        }
Beispiel #9
0
        public JsonResult ThemChucNangJson()
        {
            var data = Request.Form;
            //Khai báo 1 đối tượng
            ChucNang objChucNang = new ChucNang();

            //Gán giá trị
            objChucNang.TenChucNang = data["tenCN"];
            objChucNang.MoTa        = data["moTa"];
            objChucNang.TenForm     = data["tenForm"];
            objChucNang.Module      = Convert.ToInt32(data["module"]);
            var id = Convert.ToInt32(data["id"]);

            if (id > 0)//TH sửa
            {
                objChucNang.Id = id;
                //Lấy đối tượng cũ
                ChucNang objChuDeOld = DataProvider.ShopEntities.ChucNangs.Where(p => p.Id == id).First();
                DataProvider.ShopEntities.Entry(objChuDeOld).CurrentValues.SetValues(objChucNang);
                DataProvider.ShopEntities.SaveChanges();

                // Nhật ký sửa
                // 1.Thêm mới 2.Sửa 3.Xóa
                NhatKyCommon.Them("nguoi dung thực hiện hành động Sửa Chức năng", "Sửa");
            }
            else
            {
                //Thực hiện thêm và lưu sự thay đổi
                DataProvider.ShopEntities.ChucNangs.Add(objChucNang);
                DataProvider.ShopEntities.SaveChanges();

                // Nhật ký thêm
                // 1.Thêm mới 2.Sửa 3.Xóa
                NhatKyCommon.Them("Người dùng thực hiện hành động Thêm mới chức năng", "Thêm mới");
            }
            return(Json(objChucNang, JsonRequestBehavior.AllowGet));
        }
Beispiel #10
0
        public JsonResult ThemChuongTrinhJson()
        {
            var data = Request.Form;
            //Khai báo 1 đối tượng
            ChuongTrinhChiTiet objChiTiet = new ChuongTrinhChiTiet();

            // Gán giá trị
            objChiTiet.ChuongTrinhId = Convert.ToInt32(data["IdChuongtrinh"]);
            objChiTiet.SanPhamId     = Convert.ToInt32(data["IdSanPham"]);
            objChiTiet.GiamGia       = Convert.ToDouble(data["GiamGia"]);
            var id = Convert.ToInt32(data["id"]);

            if (id > 0)//TH sửa
            {
                objChiTiet.Id = id;
                // Lấy đối tượng cũ
                ChuongTrinhChiTiet objChuongTrinhld = DataProvider.ShopEntities.ChuongTrinhChiTiets.Where(p => p.Id == id).First();
                DataProvider.ShopEntities.Entry(objChuongTrinhld).CurrentValues.SetValues(objChiTiet);
                DataProvider.ShopEntities.SaveChanges();

                // nhật ký sửa
                // 1.Thêm mới 2 Sửa 3.Xóa
                NhatKyCommon.Them("Người dùng thực hiện chức năng Sửa Chương trình khuyến mãi chi tiết", "Sửa");
            }
            else
            {
                // Thực hiện thêm và lưu sự thay đổi
                DataProvider.ShopEntities.ChuongTrinhChiTiets.Add(objChiTiet);
                DataProvider.ShopEntities.SaveChanges();
                // nhật ký thêm mới
                // 1.Thêm mới 2 Sửa 3.Xóa
                NhatKyCommon.Them("Người dùng thực hiện chức năng Thêm Mới Chương trình khuyến mãi chi tiết", "Thêm Mới");
            }


            return(Json(objChiTiet, JsonRequestBehavior.AllowGet));
        }