コード例 #1
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);
        }