Boolean的常用显示操作

2014-12-31 15:03:18  访问(1906) 赞(0) 踩(0)


        /// <summary>
        /// bool转成"是"和"否"
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanShowText(bool theValue)
        {
            if (theValue == true)
                return "是";
            else
                return "否";
        }

        /// <summary>
        /// bool?转成""、"是"和"否"
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanNullShowText(bool? theValue)
        {
            if (theValue == null)
                return "";

            if (theValue == true)
                return "是";
            else
                return "否";
        }

        /// <summary>
        /// bool?转成"是"和"否"等输出
        /// </summary>
        /// <param name="theValue"></param>
        /// <param name="nullToDefault"></param>
        /// <returns></returns>
        public string BooleanNullShowText
            (
                bool? theValue, 
                string nullToDefault
            )
        {
            if (theValue == null)
                return nullToDefault;

            if (theValue == true)
                return "是";
            else
                return "否";
        }


        /// <summary>
        /// bool转成√和×输出
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanShowChar(bool theValue)
        {
            if (theValue == true)
            {
                return "√";
            }
            else
            {
                return "×";
            }
        }

        /// <summary>
        /// bool为True的时候输出√,否则输出""
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanShowTrueChar(bool theValue)
        {
            if (theValue == true)
            {
                return "√";
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// bool为True的时候输出√,否则输出""或"×" 
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanShowChar(bool theValue,bool falseShowEmpty)
        {
            if (theValue == true)
            {
                return "√";
            }
            else
            {
                if (falseShowEmpty)
                    return "";
                else
                    return "×";
            }
        }

        /// <summary>
        /// bool?转成""、√和×输出
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanNullShowChar(bool? theValue)
        {
            if (theValue == null)
                return "";

            if (theValue == true)
                return "√";
            else
                return "×";
        }

        /// <summary>
        /// bool?转成(nullToDefault)、√和×输出
        /// </summary>
        /// <param name="theValue"></param>
        /// <param name="nullToDefault"></param>
        /// <returns></returns>
        public string BooleanNullShowChar(bool? theValue, string nullToDefault)
        {
            if (theValue == null)
                return nullToDefault;

            if (theValue == true)
                return "√";
            else
                return "×";
        }



        /// <summary>
        /// bool转成图片输出
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanShowImage(bool theValue)
        {
            string src = hcGetPhyPath() + "/images/";

            if (theValue)
                src += "yes.gif";
            else
                src += "no.gif";

            return "<img src=\"" + src + "\" border=\"0\" alt=\"" + theValue.ToString().ToLower() + "\" style=\"border:0px;\" />";
        }

        /// <summary>
        /// bool?转成图片输出
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanNullShowImage(bool? theValue)
        {
            if (theValue == null)
                return "";

            string src = hcGetPhyPath() + "/images/";

            if (theValue == true)
                src += "yes.gif";
            else
                src += "no.gif";

            return "<img src=\"" + src + "\" border=\"0\" alt=\"" + theValue.ToString().ToLower() + "\" style=\"border:0px;\" />";
        }


        /// <summary>
        /// bool转成带颜色的文字输出“是”和“否”
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanShowColorText(bool theValue)
        {
            if (theValue == true)
            {
                return "<font color=\"blue\">是</font>";
            }
            else
            {
                return "<font color=\"red\">否</font>";
            }

        }

        /// <summary>
        /// bool转成带颜色的字符输出“√”和“×”
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanShowColorChar(bool theValue)
        {
            if (theValue == true)
            {
                return "<font color=\"blue\">√</font>";
            }
            else
            {
                return "<font color=\"red\">×</font>";
            }
        }



        /// <summary>
        /// bool转成带颜色的文字加粗输出“是”和“否”
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanShowColorBoldText(bool theValue)
        {
            if (theValue == true)
            {
                return "<font color=\"blue\"><b>是</b></font>";
            }
            else
            {
                return "<font color=\"red\"><b>否</b></font>";
            }

        }

        /// <summary>
        /// bool转成带颜色的字符加粗输出“√”和“×”
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanShowColorBoldChar(bool theValue)
        {
            if (theValue == true)
            {
                return "<font color=\"blue\"><b>√</b></font>";
            }
            else
            {
                return "<font color=\"red\"><b>×</b></font>";
            }
        }

        /// <summary>
        /// bool?转成带颜色的文字输出“是”和“否”
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanNullShowColorText(bool? theValue)
        {
            if (theValue == null)
                return "";

            if (theValue == true)
            {
                return "<font color=\"blue\">是</font>";
            }
            else
            {
                return "<font color=\"red\">否</font>";
            }
        }

        /// <summary>
        /// bool?转成带颜色的字符输出“√”和“×”
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanNullShowColorChar(bool? theValue)
        {
            if (theValue == null)
                return "";

            if (theValue == true)
            {
                return "<font color=\"blue\">√</font>";
            }
            else
            {
                return "<font color=\"red\">×</font>";
            }
        }


        /// <summary>
        /// bool?转成带颜色的文字加粗输出“是”和“否”
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanNullShowColorBoldText(bool? theValue)
        {
            if (theValue == null)
                return "";

            if (theValue == true)
            {
                return "<font color=\"blue\"><b>是</b></font>";
            }
            else
            {
                return "<font color=\"red\"><b>否</b></font>";
            }
        }

        /// <summary>
        /// bool?转成带颜色的字符加粗输出“√”和“×”
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanNullShowColorBoldChar(bool? theValue)
        { 
            if (theValue == null)
                return "";

            if (theValue == true)
            {
                return "<font color=\"blue\"><b>√</b></font>";
            }
            else
            {
                return "<font color=\"red\"><b>×</b></font>";
            }
        }


        /// <summary>
        /// bool转成对应的输出
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanShowByParams
            (
                bool theValue, 
                string strTrue, 
                string strFalse
            )
        {

            if (theValue == true)
            {
                return strTrue;
            }
            else
            {
                return strFalse;
            }
        }


        /// <summary>
        /// bool?转成对应的输出
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanNullShowByParams(bool? theValue,string strTrue,string strFalse)
        {
            if (theValue == null)
                return "";

            if (theValue == true)
            {
                return strTrue;
            }
            else
            {
                return strFalse;
            }
        }

        /// <summary>
        /// bool?转成对应的输出
        /// </summary>
        /// <param name="theValue"></param>
        /// <returns></returns>
        public string BooleanNullShowByParams(bool? theValue, string strTrue, string strFalse,string strNULL)
        {
            if (theValue == null)
                return strNULL;

            if (theValue == true)
            {
                return strTrue;
            }
            else
            {
                return strFalse;
            }
        }


标签:Boolean的常用显示操作 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)
 
  ┈全部┈  
 
(显示默认分类)