Ejemplo n.º 1
0
        //
        // GET: /SetInstitute/

        public ActionResult Index(string sortOrder, string CurrentSort, int?page)
        {
            int pageSize  = 10;
            int pageIndex = 1;

            pageIndex           = page.HasValue ? Convert.ToInt32(page) : 1;
            ViewBag.CurrentSort = sortOrder;
            //sortOrder = String.IsNullOrEmpty(sortOrder) ? "USER_NO" : sortOrder;
            IPagedList <SET_INSTITUTE> pagedIns   = null;
            IQueryable <SET_INSTITUTE> institutes = db.SET_INSTITUTE.AsQueryable();
            InsituteSearch             dcrSearch  = (Session["INSSearch"] == null) ? new InsituteSearch()
                : (InsituteSearch)Session["INSSearch"];

            if (Request.QueryString.HasKeys() && !page.HasValue)
            {
                Tuple <InsituteSearch, IQueryable <SET_INSTITUTE> > tmp = setSearch(institutes, dcrSearch, false);
                institutes = tmp.Item2;
                dcrSearch  = tmp.Item1;
            }
            else if (page.HasValue && dcrSearch.dirty)
            {
                dcrSearch = (InsituteSearch)Session["INSSearch"];
                Tuple <InsituteSearch, IQueryable <SET_INSTITUTE> > tmp = setSearch(institutes, dcrSearch, true);
                institutes = tmp.Item2;
                dcrSearch  = tmp.Item1;
            }
            else if (page.HasValue && Session["INSSearch"] == null)
            {
                dcrSearch = new InsituteSearch();
            }
            Session["INSSearch"] = dcrSearch;
            //pagedIns = institutes.OrderByDescending(m => m.INSERT_TIME).ToPagedList(pageIndex, pageSize);
            pagedIns          = institutes.OrderByDescending(m => m.INSTITUTE_NO).ToPagedList(pageIndex, pageSize);
            ViewBag.insSearch = dcrSearch;
            return(View(pagedIns));
        }
Ejemplo n.º 2
0
        public Tuple <InsituteSearch, IQueryable <SET_INSTITUTE> > setSearch(IQueryable <SET_INSTITUTE> dcrs, InsituteSearch dcrSearch, bool search)
        {
            dcrSearch = (dcrSearch.dirty) ? dcrSearch : new InsituteSearch();
            if (!string.IsNullOrEmpty(Request.QueryString["insName"]) || search)
            {
                dcrSearch.insName = (!search) ? Request.QueryString["insName"] : dcrSearch.insName;
                if (!string.IsNullOrEmpty(dcrSearch.insName))
                {
                    dcrs = dcrs.Where(s => s.INSTITUTE_NAME.Contains(dcrSearch.insName));
                }
            }
            else
            {
                dcrSearch.insName = "";
            }
            if (!string.IsNullOrEmpty(Request.QueryString["F_INSTITUTION_DB_ID"]) || search)
            {
                dcrSearch.F_INSTITUTION_DB_ID = (!search) ? Request.QueryString["F_INSTITUTION_DB_ID"] : dcrSearch.F_INSTITUTION_DB_ID;
                if (!string.IsNullOrEmpty(dcrSearch.F_INSTITUTION_DB_ID))
                {
                    dcrs = dcrs.Where(s => s.F_INSTITUTION_DB_ID.Contains(dcrSearch.F_INSTITUTION_DB_ID));
                }
            }
            else
            {
                dcrSearch.F_INSTITUTION_DB_ID = "";
            }
            if (!string.IsNullOrEmpty(Request.QueryString["insID"]) || search)
            {
                dcrSearch.insID = (!search) ? decimal.Parse(Request.QueryString["insID"]) : dcrSearch.insID;
                if (dcrSearch.insID != 0 || dcrSearch.insID != null)
                {
                    dcrs = dcrs.Where(s => s.INSTITUTE_NO == (dcrSearch.insID));
                }
            }
            else
            {
                dcrSearch.insID = null;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["EIIN_NUMBER"]) || search)
            {
                dcrSearch.EIIN_NUMBER = (!search) ? Request.QueryString["EIIN_NUMBER"] : dcrSearch.EIIN_NUMBER;
                if (!string.IsNullOrEmpty(dcrSearch.EIIN_NUMBER))
                {
                    dcrs = dcrs.Where(s => s.EIIN_NUMBER.Contains(dcrSearch.EIIN_NUMBER));
                }
            }
            else
            {
                dcrSearch.EIIN_NUMBER = "";
            }

            dcrSearch.dirty = true;
            return(new Tuple <InsituteSearch, IQueryable <SET_INSTITUTE> >(dcrSearch, dcrs));
        }