Example #1
0
        public ActionResult List(string id, int page, int rows, string search, string sidx, string sord)
        {
            string filters = Request["filters"] == null ? "" : Request["filters"].ToString();
            string filtersSql = "";
            if (!string.IsNullOrEmpty(filters))
            {
                filtersSql = BulidJqGridSearch.BuildSearch(filters);
            }

            //string
            List<Bse_Employee> list = new List<Bse_Employee>();
            if (string.IsNullOrEmpty(id))
            {
                if (!string.IsNullOrEmpty(filtersSql))
                {
                    list = hrInstance.GetListByCode(" AND " + filtersSql);
                }else{
                    list = hrInstance.GetAll();
                }

            }
            else
            {
                if (!string.IsNullOrEmpty(filtersSql))
                {
                    list = hrInstance.GetStuffByDept(id, " AND " + filtersSql);
                }
                else
                {
                    list = hrInstance.GetStuffByDept(id);
                }

            }

            Bll_Bse_Dict dictInstance = new Bll_Bse_Dict();

            //字典替换
            foreach (var listmodel in list)
            {
                switch (listmodel.Emp_Gendar)
                {
                    case "G001": { listmodel.Emp_Gendar = "男"; break; }
                    case "G002": { listmodel.Emp_Gendar = "女"; break; }
                }

                if (!string.IsNullOrEmpty(listmodel.Emp_Title))
                {
                    var _model=dictInstance.GetModel(" and dict_key='STUFFTITLE' and dict_code='" + listmodel.Emp_Title + "'");
                    listmodel.Emp_Title = _model != null ? _model.Dict_Name : "";

                }

                if (!string.IsNullOrEmpty(listmodel.Emp_Duty))
                {
                    var _model = dictInstance.GetModel(" and dict_key='STUFFDUTYTYPE' and dict_code='" + listmodel.Emp_Duty + "'");
                    listmodel.Emp_Duty = _model != null ? _model.Dict_Name : "";
                }
            }
            var model = list.AsQueryable<Bse_Employee>();
            var result = JsonConvert.SerializeObject(model.ToJqGridData(page, rows, null, search, null), new JsonDateConverter("yyyy-MM-dd"));

            return JavaScript(result);
        }