public ActionResult Index()
        {
            DM_NHOMDANHMUCBusiness = Get <DM_NHOMDANHMUCBusiness>();
            var searchmodel = new DM_NHOMDANHMUC_SEARCHBO();

            SessionManager.SetValue("dmnhomdanhmucSearchModel", null);
            var data = DM_NHOMDANHMUCBusiness.GetDaTaByPage(null);

            return(View(data));
        }
Exemplo n.º 2
0
        public PageListResultBO <DM_NHOMDANHMUC_BO> GetDaTaByPage(DM_NHOMDANHMUC_SEARCHBO searchModel, int pageIndex = 1, int pageSize = 20)
        {
            var query = from tbl in this.context.DM_NHOMDANHMUC
                        select new DM_NHOMDANHMUC_BO
            {
                ID         = tbl.ID,
                GROUP_CODE = tbl.GROUP_CODE,
                GROUP_NAME = tbl.GROUP_NAME,
                TYPE       = tbl.TYPE,
            };

            if (searchModel != null)
            {
                if (!string.IsNullOrEmpty(searchModel.QR_CODE))
                {
                    query = query.Where(x => x.GROUP_CODE.Contains(searchModel.QR_CODE));
                }

                if (!string.IsNullOrEmpty(searchModel.QR_NAME))
                {
                    query = query.Where(x => x.GROUP_NAME.Contains(searchModel.QR_NAME));
                }

                if (!string.IsNullOrEmpty(searchModel.sortQuery))
                {
                    query = query.OrderBy(searchModel.sortQuery);
                }
                else
                {
                    query = query.OrderByDescending(x => x.ID);
                }
            }
            else
            {
                query = query.OrderByDescending(x => x.ID);
            }
            var resultmodel = new PageListResultBO <DM_NHOMDANHMUC_BO>();

            if (pageSize == -1)
            {
                var dataPageList = query.ToList();
                resultmodel.Count     = dataPageList.Count;
                resultmodel.TotalPage = 1;
                resultmodel.ListItem  = dataPageList;
            }
            else
            {
                var dataPageList = query.ToPagedList(pageIndex, pageSize);
                resultmodel.Count     = dataPageList.TotalItemCount;
                resultmodel.TotalPage = dataPageList.PageCount;
                resultmodel.ListItem  = dataPageList.ToList();
            }
            return(resultmodel);
        }
        public JsonResult searchData(FormCollection form)
        {
            DM_NHOMDANHMUCBusiness = Get <DM_NHOMDANHMUCBusiness>();
            var searchModel = SessionManager.GetValue("dmnhomdanhmucSearchModel") as DM_NHOMDANHMUC_SEARCHBO;

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


            searchModel.QR_CODE = form["QR_CODE"];
            searchModel.QR_NAME = form["QR_NAME"];
            SessionManager.SetValue("dmnhomdanhmucSearchModel", searchModel);

            var data = DM_NHOMDANHMUCBusiness.GetDaTaByPage(searchModel, 1, searchModel.pageSize);

            return(Json(data));
        }
        public JsonResult getData(int indexPage, string sortQuery, int pageSize)
        {
            DM_NHOMDANHMUCBusiness = Get <DM_NHOMDANHMUCBusiness>();
            var searchModel = SessionManager.GetValue("dmnhomdanhmucSearchModel") as DM_NHOMDANHMUC_SEARCHBO;

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

            return(Json(data));
        }