示例#1
0
        public JsonResult searchData(FormCollection form)
        {
            LOAITAILIEU_THUOCTINHBusiness = Get <LOAITAILIEU_THUOCTINHBusiness>();
            var searchModel = SessionManager.GetValue("thuoctinhSearch") as TAILIEU_THUOCTINH_SEARCH;

            if (searchModel == null)
            {
                searchModel          = new TAILIEU_THUOCTINH_SEARCH();
                searchModel.pageSize = 20;
            }

            searchModel.LOAI_TAILIEU  = form["LOAI_TAILIEU"].ToIntOrZero();
            searchModel.TEN_THUOCTINH = form["TEN_THUOCTINH"];
            if (!string.IsNullOrEmpty(form["TRANGTHAI"]))
            {
                searchModel.TRANGTHAI = form["TRANGTHAI"].Equals("1");
            }
            else
            {
                searchModel.TRANGTHAI = null;
            }
            SessionManager.SetValue("thuoctinhSearch", searchModel);
            var data = LOAITAILIEU_THUOCTINHBusiness.GetDaTaByPage(searchModel, 1, searchModel.pageSize);

            return(Json(data));
        }
示例#2
0
        public ActionResult Index()
        {
            LOAITAILIEU_THUOCTINHBusiness = Get <LOAITAILIEU_THUOCTINHBusiness>();
            SessionManager.SetValue("thuoctinhSearch", null);
            var data = LOAITAILIEU_THUOCTINHBusiness.GetDaTaByPage(null);
            TaiLieuThuocTinhModel model = new TaiLieuThuocTinhModel();

            model.ListLoaiTaiLieu = initDanhMuc();
            model.ListResult      = data;
            return(View(model));
        }
示例#3
0
        public JsonResult Delete(long id)
        {
            LOAITAILIEU_THUOCTINHBusiness = Get <LOAITAILIEU_THUOCTINHBusiness>();
            LOAITAILIEU_THUOCTINH ThuocTinh = LOAITAILIEU_THUOCTINHBusiness.Find(id);

            if (ThuocTinh == null)
            {
                return(Json(new { Type = "ERROR", Message = "Không tìm thấy thuộc tính cần xóa" }));
            }
            LOAITAILIEU_THUOCTINHBusiness.repository.Delete(id);
            LOAITAILIEU_THUOCTINHBusiness.Save();
            return(Json(new { Type = "SUCCESS", Message = "Xóa thuộc tính thành công" }));
        }
示例#4
0
        public PartialViewResult Edit(long id)
        {
            TaiLieuThuocTinhModel model = new TaiLieuThuocTinhModel();

            LOAITAILIEU_THUOCTINHBusiness = Get <LOAITAILIEU_THUOCTINHBusiness>();
            LOAITAILIEU_THUOCTINH ThuocTinh = LOAITAILIEU_THUOCTINHBusiness.Find(id);

            if (ThuocTinh == null)
            {
                ThuocTinh = new LOAITAILIEU_THUOCTINH();
            }
            model.ThuocTinh       = ThuocTinh;
            model.ListLoaiTaiLieu = initDanhMuc();
            return(PartialView("_Create", model));
        }
示例#5
0
        public JsonResult SaveItem(LOAITAILIEU_THUOCTINH ThuocTinh)
        {
            if (ThuocTinh.DANHMUC_ID == 0)
            {
                return(Json(new { Type = "ERROR", Message = "Bạn chưa chọn loại tài liệu cho thuộc tính" }, JsonRequestBehavior.AllowGet));
            }
            DM_DANHMUC_DATABusiness = Get <DM_DANHMUC_DATABusiness>();
            DM_DANHMUC_DATA DanhMuc = DM_DANHMUC_DATABusiness.Find(ThuocTinh.DANHMUC_ID);

            if (DanhMuc == null)
            {
                return(Json(new { Type = "ERROR", Message = "Không tìm thấy loại tài liệu được chọn" }, JsonRequestBehavior.AllowGet));
            }
            LOAITAILIEU_THUOCTINHBusiness = Get <LOAITAILIEU_THUOCTINHBusiness>();
            if (ThuocTinh.ID > 0)
            {
                #region Cập nhật thuộc tính
                var result = LOAITAILIEU_THUOCTINHBusiness.Find(ThuocTinh.ID);
                if (result == null)
                {
                    return(Json(new { Type = "ERROR", Message = "Không tìm thấy thuộc tính cần cập nhật" }, JsonRequestBehavior.AllowGet));
                }
                result.DANHMUC_ID    = ThuocTinh.DANHMUC_ID;
                result.MOTA          = ThuocTinh.MOTA;
                result.TEN_THUOCTINH = ThuocTinh.TEN_THUOCTINH;
                result.TRANGTHAI     = ThuocTinh.TRANGTHAI;
                LOAITAILIEU_THUOCTINHBusiness.Save(result);
                return(Json(new { Type = "SUCCESS", Message = "Cập nhật thuộc tính thành công" }, JsonRequestBehavior.AllowGet));

                #endregion
            }
            else
            {
                #region Thêm mới thuộc tính
                LOAITAILIEU_THUOCTINHBusiness.Save(ThuocTinh);
                #endregion
            }
            return(Json(new { Type = "SUCCESS", Message = "Thêm mới thuộc tính thành công" }, JsonRequestBehavior.AllowGet));
        }
示例#6
0
        public JsonResult getData(int indexPage, string sortQuery, int pageSize)
        {
            LOAITAILIEU_THUOCTINHBusiness = Get <LOAITAILIEU_THUOCTINHBusiness>();
            var searchModel = SessionManager.GetValue("thuoctinhSearch") as TAILIEU_THUOCTINH_SEARCH;

            if (!string.IsNullOrEmpty(sortQuery))
            {
                if (searchModel == null)
                {
                    searchModel = new TAILIEU_THUOCTINH_SEARCH();
                }
                searchModel.sortQuery = sortQuery;
                if (pageSize > 0)
                {
                    searchModel.pageSize = pageSize;
                }
                SessionManager.SetValue("thuoctinhSearch", searchModel);
            }
            var data = LOAITAILIEU_THUOCTINHBusiness.GetDaTaByPage(searchModel, indexPage, pageSize);

            return(Json(data));
        }