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;
                }
            }
  • 相关阅读:
    java9
    java8
    java7
    java6
    java5
    java4
    java-list-分组
    Termux中安装gcc-7/gfortran-7实操过程,安装成功可以编译Fortran,c/c++
    安卓手机牛逼软件Termux中安装Archlinux,安装Jdk
    c++语言的组合类的使用,用组合类的方法计算两点间距离。
  • 原文地址:https://www.cnblogs.com/smthts/p/2610378.html
Copyright © 2011-2022 走看看