Ejemplo n.º 1
0
        public ActionResult Search(STCheckEquipModels model)
        {
            var        data = GetSearchResult(model);
            DhtmlxGrid grid = new DhtmlxGrid();
            int        pos  = model.posStart.HasValue ? model.posStart.Value : 0;

            grid.AddPaging(data.TotalCount, pos);
            var buttons     = GetCurrentUserPathActions();
            var allSTUnit   = GetCurrentInstsST();
            var compayTypes = sysDictServcie.GetDictsByKey("customStatus");

            for (int i = 0; i < data.Results.Count; i++)
            {
                var           equip = data.Results[i];
                var           start = equip.timestart.HasValue? GetUIDtString(equip.timestart.Value, "yyyy-MM-dd"):"";
                var           end   = equip.timeend.HasValue? GetUIDtString(equip.timeend.Value, "yyyy-MM-dd"): "";
                DhtmlxGridRow row   = new DhtmlxGridRow(equip.id.ToString());
                row.AddCell("");
                row.AddCell(pos + i + 1);
                row.AddCell(equip.EquName + equip.Equtype + equip.Equspec);
                row.AddCell(sTCustomService.GetSTUnitByIdFromAll(allSTUnit, equip.customid));
                if (start != "" && end != "")
                {
                    row.AddCell(start + "至" + end);
                }
                else
                {
                    row.AddCell(string.Empty);
                }

                row.AddCell(SysDictUtility.GetKeyFromDic(compayTypes, equip.approvalstatus));
                Dictionary <string, string> dict = new Dictionary <string, string>();
                if (HaveButtonFromAll(buttons, "ApplyChange") && sTCheckEquipService.CanApplyChangeCustom(equip.approvalstatus))
                {
                    dict.Add("[申请修改]", "applyChange({0},\"{1}\")".Fmt(equip.id, equip.EquName));
                }

                if (HaveButtonFromAll(buttons, "ConfirmApplyChange") && (equip.approvalstatus == "5"))
                {
                    dict.Add("[审核申请修改]", "confirmApplyChange({0},\"{1}\")".Fmt(equip.id, equip.EquName));
                }
                row.AddLinkJsCells(dict);
                if (HaveButtonFromAll(buttons, "Edit") && (equip.approvalstatus == "0" || equip.approvalstatus == "5"))// && checkUnitService.CanEditCustom(custom.APPROVALSTATUS))
                {
                    row.AddCell(new DhtmlxGridCell("编辑", false).AddCellAttribute("title", "编辑"));
                }
                else
                {
                    row.AddCell(string.Empty);
                }
                row.AddCell(new DhtmlxGridCell("查看", false).AddCellAttribute("title", "查看"));
                grid.AddGridRow(row);
            }
            string str = grid.BuildRowXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting);

            return(Content(str, "text/xml"));
        }
Ejemplo n.º 2
0
        private SearchResult <STCheckUIModel> GetSearchResult(STCheckEquipModels model)
        {
            var predicate = PredicateBuilder.True <t_bp_Equipment_ST>();

            //过滤已经删除的机构
            predicate = predicate.And(tp => tp.data_status == null || tp.data_status != "-1");
            if (!model.EquName.IsNullOrEmpty())
            {
                predicate = predicate.And(t => t.EquName.Contains(model.EquName));
            }
            if (!model.EquType.IsNullOrEmpty())
            {
                predicate = predicate.And(t => t.equtype.Contains(model.EquType));
            }
            if (!model.Status.IsNullOrEmpty())
            {
                predicate = predicate.And(t => t.equtype == model.Status);
            }
            if (!model.CheckUnitName.IsNullOrEmpty())
            {
                predicate = predicate.And(t => t.customid == model.CheckUnitName);
            }

            int pos   = model.posStart.HasValue ? model.posStart.Value : 0;
            int count = model.count.HasValue ? model.count.Value : 30;

            PagingOptions <t_bp_Equipment_ST> pagingOption = new PagingOptions <t_bp_Equipment_ST>(pos, count, t => new { t.Id });
            var equips = rep.GetByConditonPage <STCheckUIModel>(predicate, r => new {
                r.Id,
                r.customid,
                r.EquName,
                r.equtype,
                r.equspec,
                r.timestart,
                r.timeend,
                r.approvalstatus
            }, pagingOption);

            return(new SearchResult <STCheckUIModel>(pagingOption.TotalItems, equips));
        }