Ejemplo n.º 1
0
        /// <summary>
        /// 递归加载分类
        /// </summary>
        /// <param name="dt">dt</param>
        /// <param name="code">code</param>
        /// <returns></returns>
        private static JArray GetTreeChild(DataTable dt, string code)
        {
            JArray childobjArray = new JArray();

            if (dt != null && dt.Rows.Count > 0)
            {
                DataRow[] dr = null;
                if (string.IsNullOrEmpty(code))
                {
                    dr = dt.Select("SUBSTRING(BIOLOGICALTYPECODE,11,2) <> '00' AND SUBSTRING(BIOLOGICALTYPECODE,13,2)='00'");
                }
                else
                {
                    string str = "";
                    if (PublicCls.BioCodeIsKe(code))
                    {
                        str = PublicCls.GetKeBioCode(code);
                        dr  = dt.Select("SUBSTRING(BIOLOGICALTYPECODE,1,10) = '" + str + "' AND SUBSTRING(BIOLOGICALTYPECODE,11,2)<>'00' AND SUBSTRING(BIOLOGICALTYPECODE,13,2)='00'");
                    }
                    else if (PublicCls.BioCodeIsShu(code))
                    {
                        str = PublicCls.GetShuBioCode(code);
                        dr  = dt.Select("SUBSTRING(BIOLOGICALTYPECODE,1,12) = '" + str + "' AND SUBSTRING(BIOLOGICALTYPECODE,13,2)<>'00'");
                    }
                    else
                    {
                        str = PublicCls.GetZhongBioCode(code);
                        dr  = dt.Select("SUBSTRING(BIOLOGICALTYPECODE,1,14) = '" + str + "' AND LEN(BIOLOGICALTYPECODE)>'" + code.Length + "'");
                    }
                }
                if (dr != null && dr.Count() > 0)
                {
                    for (int i = 0; i < dr.Count(); i++)
                    {
                        code = dr[i]["BIOLOGICALTYPECODE"].ToString();
                        JObject root = new JObject
                        {
                            { "id", dr[i]["BIOLOGICALTYPECODE"].ToString() },
                            { "text", dr[i]["BIOLOGICALTYPECODENAME"].ToString() },
                            { "state", "closed" }
                        };
                        root.Add("children", GetTreeChild(dt, code));
                        childobjArray.Add(root);
                    }
                }
            }
            return(childobjArray);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取所有科级及以下生物及对应地区、调查类型已关联的生物列表
        /// </summary>
        /// <param name="joinList"></param>
        /// <param name="dtbiolog"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        private static IEnumerable <T_SYS_BIOLOGICALTYPE_WILD_LOCALBOTANY_Model> GetWILD_LOCALBOTANYModel(List <WILD_LOCALBOTANY_Model> joinList, DataTable dtbiolog, string code)
        {
            var result = new List <T_SYS_BIOLOGICALTYPE_WILD_LOCALBOTANY_Model>();

            DataRow[] dr = null;
            if (string.IsNullOrEmpty(code))
            {
                dr = dtbiolog.Select("SUBSTRING(BIOLOCODE,9,2)<>'00' AND SUBSTRING(BIOLOCODE,11,4)='0000'");
            }
            else
            {
                string str = "";
                if (PublicCls.BioCodeIsKe(code))
                {
                    str = PublicCls.GetKeBioCode(code);
                    dr  = dtbiolog.Select("SUBSTRING(BIOLOCODE,1,10) = '" + str + "' AND SUBSTRING(BIOLOCODE,11,2)<>'00' AND SUBSTRING(BIOLOCODE,13,2)='00'");
                }
                else if (PublicCls.BioCodeIsShu(code))
                {
                    str = PublicCls.GetShuBioCode(code);
                    dr  = dtbiolog.Select("SUBSTRING(BIOLOCODE,1,12) = '" + str + "' AND SUBSTRING(BIOLOCODE,13,2)<>'00'");
                }
            }
            for (int i = 0; i < dr.Length; i++)
            {
                T_SYS_BIOLOGICALTYPE_WILD_LOCALBOTANY_Model m = new T_SYS_BIOLOGICALTYPE_WILD_LOCALBOTANY_Model();
                string chk = joinList.Exists(a => a.BIOLOGICALTYPECODE == dr[i]["BIOLOCODE"].ToString()) ? "1" : "0";
                m.isCheck   = chk;
                m.BIOLOCODE = dr[i]["BIOLOCODE"].ToString();
                m.BIOLONAME = dr[i]["BIOLONAME"].ToString();
                if (!PublicCls.BioCodeIsZHong(dr[i]["BIOLOCODE"].ToString()))
                {
                    m.subModel = GetWILD_LOCALBOTANYModel(joinList, dtbiolog, dr[i]["BIOLOCODE"].ToString());
                }
                result.Add(m);
            }
            return(result);
        }