Ejemplo n.º 1
0
        /// <summary>
        /// 判断记录是否存在下级
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>true存在 false不存在 </returns>
        public static bool isExistsChild(T_SYS_BIOLOGICALTYPE_SW sw)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("Select 1 from T_SYS_BIOLOGICALTYPE Where 1=1");
            if (string.IsNullOrEmpty(sw.BIOLOCODE) == false)
            {
                string code = "";
                if (PublicCls.BioCodeIsJie(sw.BIOLOCODE))
                {
                    code = PublicCls.GetJieBioCode(sw.BIOLOCODE);
                }
                if (PublicCls.BioCodeIsMen(sw.BIOLOCODE))
                {
                    code = PublicCls.GetMenBioCode(sw.BIOLOCODE);
                }
                if (PublicCls.BioCodeIsGang(sw.BIOLOCODE))
                {
                    code = PublicCls.GetGangBioCode(sw.BIOLOCODE);
                }
                if (PublicCls.BioCodeIsMu(sw.BIOLOCODE))
                {
                    code = PublicCls.GetMuBioCode(sw.BIOLOCODE);
                }
                if (PublicCls.BioCodeIsKe(sw.BIOLOCODE))
                {
                    code = PublicCls.GetKeBioCode(sw.BIOLOCODE);
                }
                if (PublicCls.BioCodeIsShu(sw.BIOLOCODE))
                {
                    code = PublicCls.GetShuBioCode(sw.BIOLOCODE);
                }
                if (PublicCls.BioCodeIsZHong(sw.BIOLOCODE))
                {
                    code = PublicCls.GetZhongBioCode(sw.BIOLOCODE);
                }
                sb.AppendFormat(" AND Substring(BIOLOCODE,1,{0})= '{1}' AND BIOLOCODE <> '{2}'", ClsSql.EncodeSql(code).Length, ClsSql.EncodeSql(code), ClsSql.EncodeSql(sw.BIOLOCODE));
            }
            return(DataBaseClass.JudgeRecordExists(sb.ToString()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns></returns>
        public static DataTable getDT(T_SYS_BIOLOGICALTYPE_SW sw)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(" FROM  T_SYS_BIOLOGICALTYPE ");
            sb.AppendFormat(" WHERE  1=1");
            if (string.IsNullOrEmpty(sw.BIOLOCODE) == false)
            {
                string code = "";
                if (PublicCls.BioCodeIsJie(sw.BIOLOCODE))
                {
                    code = PublicCls.GetJieBioCode(sw.BIOLOCODE);
                    sb.AppendFormat(" AND Substring(BIOLOCODE,1,2) = '{0}'", code);
                    if (sw.IsOnlyGetChild)
                    {
                        sb.AppendFormat(" AND Substring(BIOLOCODE,3,2) <> '00' AND Substring(BIOLOCODE,5,10)='0000000000'");
                    }
                }
                else if (PublicCls.BioCodeIsMen(sw.BIOLOCODE))
                {
                    code = PublicCls.GetMenBioCode(sw.BIOLOCODE);
                    sb.AppendFormat(" AND Substring(BIOLOCODE,1,4) = '{0}'", code);
                    if (sw.IsOnlyGetChild)
                    {
                        sb.AppendFormat(" AND Substring(BIOLOCODE,5,2) <> '00' AND Substring(BIOLOCODE,7,8)='00000000'");
                    }
                }
                else if (PublicCls.BioCodeIsGang(sw.BIOLOCODE))
                {
                    code = PublicCls.GetGangBioCode(sw.BIOLOCODE);
                    sb.AppendFormat(" AND Substring(BIOLOCODE,1,6) = '{0}'", code);
                    if (sw.IsOnlyGetChild)
                    {
                        sb.AppendFormat(" AND Substring(BIOLOCODE,7,2) <> '00' AND Substring(BIOLOCODE,9,6)='000000'");
                    }
                }
                else if (PublicCls.BioCodeIsMu(sw.BIOLOCODE))
                {
                    code = PublicCls.GetMuBioCode(sw.BIOLOCODE);
                    sb.AppendFormat(" AND Substring(BIOLOCODE,1,8) = '{0}'", code);
                    if (sw.IsOnlyGetChild)
                    {
                        sb.AppendFormat(" AND Substring(BIOLOCODE,9,2) <> '00' AND Substring(BIOLOCODE,11,4)='0000'");
                    }
                }
                else if (PublicCls.BioCodeIsKe(sw.BIOLOCODE))
                {
                    code = PublicCls.GetKeBioCode(sw.BIOLOCODE);
                    sb.AppendFormat(" AND Substring(BIOLOCODE,1,10) = '{0}'", code);
                    if (sw.IsOnlyGetChild)
                    {
                        sb.AppendFormat(" AND Substring(BIOLOCODE,11,2) <> '00' AND Substring(BIOLOCODE,13,2)='00'");
                    }
                }
                else if (PublicCls.BioCodeIsShu(sw.BIOLOCODE))
                {
                    code = PublicCls.GetShuBioCode(sw.BIOLOCODE);
                    sb.AppendFormat(" AND Substring(BIOLOCODE,1,12) = '{0}'", code);
                    if (sw.IsOnlyGetChild)
                    {
                        sb.AppendFormat(" AND Substring(BIOLOCODE,13,2) <> '00'");
                    }
                }
                else
                {
                    code = PublicCls.GetShuBioCode(sw.BIOLOCODE);
                    if (sw.IsOnlyGetZhong)
                    {
                        sb.AppendFormat(" AND Substring(BIOLOCODE,1,12) = '{0}' AND Substring(BIOLOCODE,13,2)<>'00'", code.Substring(0, 12));
                    }
                    else
                    {
                        sb.AppendFormat(" AND  BIOLOCODE = '{0}'", ClsSql.EncodeSql(sw.BIOLOCODE));
                    }
                }
            }
            if (sw.IsOnlyGetKe)
            {
                sb.AppendFormat(" AND Substring(BIOLOCODE,1,8) <> '00000000' AND Substring(BIOLOCODE,9,2) <> '00' ");
            }
            if (sw.IsOnlyGetZhong)
            {
                sb.AppendFormat(" AND Substring(BIOLOCODE,13,2) <> '00'");
            }
            if (string.IsNullOrEmpty(sw.BIOLONAME) == false)
            {
                sb.AppendFormat(" AND BIOLONAME like '%{0}%'", ClsSql.EncodeSql(sw.BIOLONAME));
            }
            if (string.IsNullOrEmpty(sw.BIOLOENNAME) == false)
            {
                sb.AppendFormat(" AND BIOLOENNAME like '%{0}%'", ClsSql.EncodeSql(sw.BIOLOENNAME));
            }
            string  sql = "SELECT BIOLOCODE, BIOLONAME, BIOLOENNAME, ORDERBY " + sb.ToString() + " order by BIOLOCODE";
            DataSet ds  = DataBaseClass.FullDataSet(sql);

            return(ds.Tables[0]);
        }