Ejemplo n.º 1
0
        /// <summary>
        /// 列表数据
        /// 菜单信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string Select_Menus(string id)
        {
            try
            {
                using (JSZX_ResourceEntities db = new JSZX_ResourceEntities())
                {
                    var linq =
                        from t in db.SPT_Menus(id)
                        select t;

                    List <SPT_Menus_Result> it = new List <SPT_Menus_Result>();
                    it = linq.ToList();

                    string ret = "";
                    // 判断是否取到数据
                    if (it != null && it.Count > 0)// 取到数据
                    {
                        ret += "{\"Table\":[";
                        for (int i = 0; i < it.Count; i++)
                        {
                            // 不是第一行 补逗号
                            if (i != 0)
                            {
                                ret += ",";
                            }

                            ret += "{"
                                   + "\"id\":\"" + it[i].id + "\""
                                   + ",\"pId\":\"" + it[i].pId + "\""
                                   + ",\"name\":\"" + it[i].name + "\""
                                   + ",\"checked\":\"" + it[i].is_checked + "\""
                                   + "}";
                        }
                        ret += "]}";
                    }

                    return(ret);
                }
            }
            catch (Exception ex)
            {
                return("");
            }
        }