Example #1
0
        public PageListResultBO <WF_MODULE_BO> GetDaTaByPage(WF_MODULE_SEARCHBO searchModel, int pageIndex = 1, int pageSize = 20)
        {
            var query = from tbl in this.context.WF_MODULE
                        //join tblLuong in this.context.WF_STREAM on tbl.WF_STREAM_ID equals tblLuong.ID into jLuong
                        //from luongxuly in jLuong.DefaultIfEmpty()
                        select new WF_MODULE_BO
            {
                ID           = tbl.ID,
                MODULE_CODE  = tbl.MODULE_CODE,
                MODULE_TITLE = tbl.MODULE_TITLE,
                WF_STREAM_ID = tbl.WF_STREAM_ID,
                create_at    = tbl.create_at,
                create_by    = tbl.create_by,
                edit_at      = tbl.edit_at,
                edit_by      = tbl.edit_by,
                //TenLuong = luongxuly != null ? luongxuly.WF_NAME : "Chưa thiết lập",
            };

            if (searchModel != null)
            {
                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 <WF_MODULE_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 ActionResult Index()
        {
            var model = new IndexVM();

            WF_MODULEBusiness = Get <WF_MODULEBusiness>();
            var WF_STREAMBusiness = Get <WF_STREAMBusiness>();
            var searchmodel       = new WF_MODULE_SEARCHBO();

            SessionManager.SetValue("wfmoduleSearchModel", null);
            model.LstModule = WF_MODULEBusiness.GetDaTaByPage(null);
            foreach (var item in model.LstModule.ListItem)
            {
                var LstIds     = item.WF_STREAM_ID.ToListInt(',');
                var LstStreams = WF_STREAMBusiness.repository.All().Where(x => LstIds.Contains(x.ID)).ToList();
                foreach (var subitem in LstStreams)
                {
                    item.TenLuong += subitem.WF_NAME + ",";
                }
            }
            return(View(model));
        }
        public JsonResult getData(int indexPage, string sortQuery, int pageSize)
        {
            WF_MODULEBusiness = Get <WF_MODULEBusiness>();
            var searchModel = SessionManager.GetValue("wfmoduleSearchModel") as WF_MODULE_SEARCHBO;

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

            return(Json(data));
        }
        public JsonResult searchData(FormCollection form)
        {
            WF_MODULEBusiness = Get <WF_MODULEBusiness>();
            var searchModel = SessionManager.GetValue("wfmoduleSearchModel") as WF_MODULE_SEARCHBO;

            if (searchModel == null)
            {
                searchModel          = new WF_MODULE_SEARCHBO();
                searchModel.pageSize = 20;
            }
            searchModel.QR_ID = form["QR_ID"].ToIntOrZero();
            //searchModel.QR_WF_STREAM_ID = form["QR_WF_STREAM_ID"].ToIntOrZero();
            var idToaNha = form["TOANHA_ID"].ToIntOrZero();

            searchModel.QR_create_by    = form["QR_create_by"].ToLongOrZero();
            searchModel.QR_edit_by      = form["QR_edit_by"].ToLongOrZero();
            searchModel.QR_MODULE_CODE  = form["QR_MODULE_CODE"].ToString();
            searchModel.QR_MODULE_TITLE = form["QR_MODULE_TITLE"].ToString();
            SessionManager.SetValue("wfmoduleSearchModel", searchModel);
            var data = WF_MODULEBusiness.GetDaTaByPage(searchModel, 1, searchModel.pageSize);

            return(Json(data));
        }