コード例 #1
0
        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 <TRN_USER_SPECIMEN> pagedSpecimens = null;
            IQueryable <TRN_USER_SPECIMEN> specimens      = db.TRN_USER_SPECIMEN.AsQueryable();

            ViewBag.ZonalUsers  = db.SEC_USERS.Where(u => u.GEN_USER_TYPES.SHORT_NAME == "ZM");
            ViewBag.specs       = db.SET_SPECIMEN.Where(s => s.IS_ACTIVE == 1);
            ViewBag.currentDate = DateTime.Now.ToString("yyyy-MM-dd");
            ViewBag.futureDate  = DateTime.Now.AddDays(60).ToString("yyyy-MM-dd");
            SpecimenDistSearch specsearch = (Session["Specimen_search"] == null) ? new SpecimenDistSearch()
                : (SpecimenDistSearch)Session["Specimen_search"];

            if (Request.QueryString.HasKeys() && !page.HasValue)
            {
                Tuple <SpecimenDistSearch, IQueryable <TRN_USER_SPECIMEN> > tmp = setSearch(specimens, specsearch, false);
                specimens  = tmp.Item2;
                specsearch = tmp.Item1;
            }
            else if (page.HasValue && specsearch.dirty)
            {
                specsearch = (SpecimenDistSearch)Session["Specimen_search"];
                Tuple <SpecimenDistSearch, IQueryable <TRN_USER_SPECIMEN> > tmp = setSearch(specimens, specsearch, true);
                specimens  = tmp.Item2;
                specsearch = tmp.Item1;
            }
            else if (page.HasValue && Session["Specimen_search"] == null)
            {
                specsearch          = new SpecimenDistSearch();
                specsearch.isactive = "all";
            }
            else
            {
                specsearch.isactive = "all";
            }
            Session["Specimen_search"] = specsearch;
            pagedSpecimens             = specimens.OrderByDescending(m => m.INSERT_TIME).ToPagedList(pageIndex, pageSize);
            ViewBag.specSearch         = specsearch;
            ViewBag.USER_NO            = new SelectList(db.SEC_USERS.Where(a => a.USER_TYPE_NO ==
                                                                           (decimal)EUserTypes.ZonalManager)
                                                        .ToList(), "USER_NO", "USER_FULL_NAME");
            return(View(pagedSpecimens));
        }
コード例 #2
0
        //
        // GET: /SpecimenDistribution/
        public Tuple <SpecimenDistSearch, IQueryable <TRN_USER_SPECIMEN> > setSearch(IQueryable <TRN_USER_SPECIMEN> specimens, SpecimenDistSearch specsearch, bool search)
        {
            specsearch = (specsearch.dirty) ? specsearch :
                         new SpecimenDistSearch();
            if (!string.IsNullOrEmpty(Request.QueryString["USER_NO"]) || search)
            {
                specsearch.USER_NO = (!search) ? decimal.Parse(Request.QueryString["USER_NO"].ToString()) : specsearch.USER_NO;
                if (!string.IsNullOrEmpty(specsearch.USER_NO.ToString()))
                {
                    specimens = specimens.Where(s => s.SEC_USERS.USER_NO == (specsearch.USER_NO));
                }
            }
            else
            {
                specsearch.USER_NO = null;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["userno"]) || search)
            {
                specsearch.userno = (!search) ?decimal.Parse(Request.QueryString["userno"]):specsearch.userno;
                if (specsearch.userno != null && specsearch.userno != 0)
                {
                    specimens = specimens.Where(s => s.USER_NO == specsearch.userno);
                }
            }
            else
            {
                specsearch.userno = 0;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["AssignDateFrom"]) || search)
            {
                specsearch.AssignDateFrom = (!search) ?DateTime.Parse(Request.QueryString["AssignDateFrom"]):specsearch.AssignDateFrom;
                if (specsearch.AssignDateFrom != null)
                {
                    specimens = specimens.Where(s => s.ASSIGN_DATE >= specsearch.AssignDateFrom);
                }
            }
            else
            {
                specsearch.AssignDateFrom = null;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["AssignDateTo"]) || search)
            {
                specsearch.AssignDateTo = (!search) ? DateTime.Parse(Request.QueryString["AssignDateTo"]) : specsearch.AssignDateFrom;
                if (specsearch.AssignDateTo != null)
                {
                    specimens = specimens.Where(s => s.ASSIGN_DATE <= specsearch.AssignDateTo);
                }
            }
            else
            {
                specsearch.AssignDateTo = null;
            }

            specsearch.isactive = (!string.IsNullOrEmpty(Request.QueryString["Search_Active"])) ?
                                  Request.QueryString["Search_Active"] : specsearch.isactive;
            if (specsearch.isactive != "all")
            {
                specimens = specimens.Where(s => s.IS_ACTIVE == ((specsearch.isactive == "active") ? 1 : 0));
            }
            if (!string.IsNullOrEmpty(Request.QueryString["specimen_no"]) || search)
            {
                specsearch.specimen_no = (!search)?decimal.Parse(Request.QueryString["specimen_no"]):specsearch.specimen_no;
                if (specsearch.specimen_no != 0 && specsearch.specimen_no != null)
                {
                    specimens = specimens.Where(s => db.TRN_USER_SPECIMEN_DET
                                                .Where(det => det.SPECIMEN_NO == specsearch.specimen_no)
                                                .Select(det => det.USER_SPECIMEN_NO)
                                                .Contains(s.USER_SPECIMEN_NO)
                                                );
                }
            }
            else
            {
                specsearch.specimen_no = 0;
            }
            specsearch.dirty = true;
            return(new Tuple <SpecimenDistSearch, IQueryable <TRN_USER_SPECIMEN> >(specsearch, specimens));
        }