예제 #1
0
        public IQueryable <OuterBoxes> GetOuterBoxes(SearchBoxParams p, bool canCheckAll)
        {
            var result = from b in db.OuterBoxes
                         where b.create_date >= p.beginDate &&
                         b.create_date <= p.endDate &&
                         b.account == p.account
                         //&& (b.item_name.Contains(p.itemInfo) || b.item_model.Contains(p.itemInfo))
                         && (p.hasUsed == "所有" || (p.hasUsed == "已使用" && b.bill_id != null) || (p.hasUsed == "未使用" && b.bill_id == null)) &&
                         (canCheckAll || (b.user_name + "A").Contains(p.userName))
                         select b;

            if (!string.IsNullOrEmpty(p.itemInfo))
            {
                result = result.Where(r => r.item_name.Contains(p.itemInfo) || r.item_model.Contains(p.itemInfo));
            }

            if (!string.IsNullOrWhiteSpace(p.boxNumber))
            {
                if (p.boxNumber.StartsWith("O"))
                {
                    result = result.Where(r => r.box_number_long.Contains(p.boxNumber));
                }
                else if (p.boxNumber.StartsWith("I"))
                {
                    result = from b in result
                             join i in db.InneBoxes on b.outer_box_id equals i.outer_box_id
                             where i.box_number_long.Contains(p.boxNumber)
                             select b;
                }
                else
                {
                    result = from b in result
                             join i in db.InneBoxes on b.outer_box_id equals i.outer_box_id into ti
                             from ib in ti.DefaultIfEmpty()
                             where (b.box_number_long.Contains(p.boxNumber) || ib.box_number_long.Contains(p.boxNumber))
                             select b;
                }
            }

            if (!string.IsNullOrWhiteSpace(p.poNo))
            {
                result = from b in result
                         join po in db.OuterBoxPOs on b.outer_box_id equals po.out_box_id
                         where po.po_number.Contains(p.poNo)
                         //where po.po_number==p.poNo
                         select b;
            }
            if (!string.IsNullOrWhiteSpace(p.billNo))
            {
                result = from b in result
                         join bill in db.DRBills on b.bill_id equals bill.bill_id
                         where bill.bill_no.Contains(p.billNo)
                         select b;
            }

            return(result.Distinct().OrderBy(r => r.create_date));
        }
예제 #2
0
        public JsonResult GetBoxNodes(FormCollection fc)
        {
            SearchBoxParams p = new SearchBoxParams();

            MyUtils.SetFieldValueToModel(fc, p);

            p.endDate  = p.endDate.AddDays(1);
            p.account  = currentAccount;
            p.itemInfo = p.itemInfo ?? "";
            p.userName = currentUser.userName;

            BoxSv sv = new BoxSv();

            if (p.id == null)
            {
                //搜索外箱信息
                try {
                    var result = sv.GetOuterBoxes(p, canCheckAll).OrderByDescending(r => r.create_date);
                    if (result.Count() < p.rows && p.page > 1)
                    {
                        p.page = 1;                                                               //应该是当前easyui的bug,翻页后,比如在第二页以后的页码中搜索箱子,结果有1行,但是page还是搜索时候的那个页码,导致页面加载不出箱子,在这里手动将页码调为1
                    }
                    var outerBoxes    = result.Skip((p.page - 1) * p.rows).Take(p.rows).ToList(); //外箱信息
                    var obIds         = outerBoxes.Select(o => o.outer_box_id).ToList();          //所有外箱id
                    var pos           = sv.GetBoxPos(obIds);                                      //po信息
                    var boxIdHasInner = sv.HasGotInnerBox(obIds);                                 //有内箱的外箱id集合
                    var billNoInfo    = new DRSv().GetBillIdAndNo(outerBoxes.Where(o => o.bill_id != null).Select(o => (int)o.bill_id).Distinct().ToList());

                    return(Json(new { suc = true, total = result.Count(), box = outerBoxes, po = pos, boxIdHasInner = boxIdHasInner, billNoInfo = billNoInfo }));
                }
                catch (Exception ex) {
                    return(Json(new SRM(ex)));
                }
            }
            else
            {
                //展开内箱信息
                try {
                    var innerboxes = sv.GetInnerBoxes(p.id);
                    return(Json(new { suc = true, box = innerboxes }));
                }
                catch (Exception ex) {
                    return(Json(new SRM(ex)));
                }
            }
        }