zoukankan      html  css  js  c++  java
  • 原创switch(T obj)选择语句如何判断是某一个对象

            /// <summary>
            /// 判断警单是否存在
            /// </summary>
            /// <typeparam name="T">对象类型</typeparam>
            /// <param name="ajbh">案件编号</param>
            /// <param name="obj">对象实例(T1,T2,T3)</param>
            /// <returns>true为存在,false为不存在</returns>
            public bool GetCase<T>( string ajbh, T obj )
            {
                if (string.IsNullOrEmpty( ajbh ))
                {
                    return true;
                }
                if (obj is Nullable)
                {
                    return true;
                }
                int count = 0;
                string sql = string.Empty;
                switch (obj.GetType().Name.ToLower())
                {
                    case "t1":
                        sql = string.Format( "select count(*) from t_case_1 t where t.bh='{0}'", ajbh );
                        break;
                    case "t2":
                        sql = string.Format( "select count(*) from t_case_2 t where t.bh='{0}'", ajbh );
                        break;
                    case "t3":
                        sql = string.Format( "select count(*) from t_case_3 t where t.bh='{0}'", ajbh );
                        break;
                }
    
                if (string.IsNullOrEmpty( sql ))
                {
                    return true;
                }
                using (DbCommand cmd = database.GetSqlStringCommand( sql ))
                {
                    count = Convert.ToInt32( database.ExecuteScalar( cmd ) );
                }
                if (count > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
  • 相关阅读:
    申论复习路线
    项目管理小拾
    物理隔离卡,双网通用安装
    生成css sprites
    图片压缩
    css预编译 sass
    小杂记
    遮罩层和弹出层(居中)
    布局之并列登高自适应高度解决方案
    slide逻辑
  • 原文地址:https://www.cnblogs.com/smthts/p/2610378.html
Copyright © 2011-2022 走看看