コード例 #1
0
        /// <summary>
        /// 获取报表数据列表
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns></returns>
        public static DataTable getDT(FIRERECORD_REPORT11_SW sw)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("SELECT *  FROM   FIRERECORD_REPORT11 WHERE   1=1");
            if (!string.IsNullOrEmpty(sw.FIRERECORD_REPORT11ID))
            {
                sb.AppendFormat(" AND FIRERECORD_REPORT11ID = '{0}'", sw.FIRERECORD_REPORT11ID);
            }
            if (!string.IsNullOrEmpty(sw.BYORGNO))
            {
                if (sw.BYORGNO.Substring(4, 11) == "00000000000")//获取所有市的
                {
                    sb.AppendFormat(" AND SUBSTRING(BYORGNO,1,4) = '{0}'", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 4)));
                }
                else if (sw.BYORGNO.Substring(6, 9) == "000000000")//获取所有县的
                {
                    sb.AppendFormat(" AND SUBSTRING(BYORGNO,1,6) = '{0}'", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6)));
                }
                else if (sw.BYORGNO.Substring(9, 6) == "000000")//获取所有乡镇的
                {
                    sb.AppendFormat(" AND SUBSTRING(BYORGNO,1,9) = '{0}'", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 9)));
                }
                else
                {
                    sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO));
                }
            }
            if (!string.IsNullOrEmpty(sw.REPORTYEAR))
            {
                sb.AppendFormat(" AND REPORTYEAR <= '{0}'", sw.REPORTYEAR);
            }
            if (!string.IsNullOrEmpty(sw.REPORTCODE))
            {
                sb.AppendFormat(" AND REPORTCODE = '{0}'", sw.REPORTCODE);
            }
            if (!string.IsNullOrEmpty(sw.REPORTVALUE))
            {
                sb.AppendFormat(" AND REPORTVALUE = '{0}'", sw.REPORTVALUE);
            }
            sb.AppendFormat(" ORDER BY FIRERECORD_REPORT11ID");
            DataSet ds = DataBaseClass.FullDataSet(sb.ToString());

            return(ds.Tables[0]);
        }
コード例 #2
0
        /// <summary>
        /// 判断记录是否存在
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>true存在 false不存在 </returns>
        public static bool isExists(FIRERECORD_REPORT11_SW sw)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("select 1 from FIRERECORD_REPORT11 where 1=1");
            if (string.IsNullOrEmpty(sw.FIRERECORD_REPORT11ID) == false)
            {
                sb.AppendFormat(" and FIRERECORD_REPORT11ID='{0}'", ClsSql.EncodeSql(sw.FIRERECORD_REPORT11ID));
            }
            if (string.IsNullOrEmpty(sw.BYORGNO) == false)
            {
                sb.AppendFormat(" and BYORGNO='{0}'", ClsSql.EncodeSql(sw.BYORGNO));
            }
            if (string.IsNullOrEmpty(sw.REPORTYEAR) == false)
            {
                sb.AppendFormat(" and REPORTYEAR='{0}'", ClsSql.EncodeSql(sw.REPORTYEAR));
            }
            if (string.IsNullOrEmpty(sw.REPORTCODE) == false)
            {
                sb.AppendFormat(" and REPORTCODE='{0}'", ClsSql.EncodeSql(sw.REPORTCODE));
            }

            return(DataBaseClass.JudgeRecordExists(sb.ToString()));
        }