Example #1
0
        public ActionResult GetCatoryTreeJson(string typecode, string tid = "", string keyword = "")
        {
            Operator user = OperatorProvider.Provider.Current();

            StringBuilder sb       = new StringBuilder();
            string        parentId = "0";

            if (!string.IsNullOrEmpty(tid))
            {
                StcategoryEntity hs = StcategoryBLL.GetEntity(tid);
                if (hs != null)
                {
                    DataTable dt = new ERCHTMS.Busines.BaseManage.DepartmentBLL().GetDataTable(string.Format("select id from HRS_STCATEGORY t where instr('{0}',encode)=1 and typecode='{1}'", hs.ENCODE, typecode));
                    foreach (DataRow dr in dt.Rows)
                    {
                        sb.AppendFormat("{0},", dr[0].ToString());
                    }
                }
            }
            var treeList = new List <TreeEntity>();
            var data     = StcategoryBLL.GetList("").Where(t => t.TYPECODE == typecode).OrderBy(t => t.ENCODE).ToList();

            if (!string.IsNullOrEmpty(keyword))
            {
                data = StcategoryBLL.GetList("").Where(t => t.TYPECODE == typecode && t.NAME.Contains(keyword.Trim())).OrderBy(t => t.ENCODE).ToList();
                if (data.Count() > 0)
                {
                    parentId = data.OrderBy(t => t.ENCODE).FirstOrDefault().PARENTID;
                }
            }
            foreach (StcategoryEntity item in data)
            {
                string     hasChild = StcategoryBLL.IsHasChild(item.ID) ? "1" : "0";
                TreeEntity tree     = new TreeEntity();
                tree.id             = item.ID;
                tree.text           = item.NAME;
                tree.value          = item.ID;
                tree.parentId       = item.PARENTID;
                tree.complete       = true;
                tree.hasChildren    = true;
                tree.Attribute      = "Code";
                tree.AttributeValue = item.ENCODE + "|" + hasChild;
                if (!string.IsNullOrEmpty(tid))
                {
                    if (sb.ToString().Contains(item.ID))
                    {
                        tree.isexpand = true;
                    }
                }
                else if (tree.parentId == parentId)
                {
                    tree.isexpand = true;
                }
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson(parentId)));
        }
Example #2
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, StcategoryEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #3
0
 public ActionResult SaveForm(string keyValue, StcategoryEntity entity)
 {
     StcategoryBLL.SaveForm(keyValue, entity);
     return(Success("操作成功。"));
 }