Beispiel #1
0
        /// <summary>
        /// 判断记录是否存在
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>true存在 false不存在 </returns>
        public static bool isExists(PEST_REPORT_HARM_SW sw)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("select 1 from PEST_REPORT_HARM where 1=1");
            if (string.IsNullOrEmpty(sw.PEST_REPORT_HARMID) == false)
            {
                sb.AppendFormat(" and PEST_REPORT_HARMID='{0}'", ClsSql.EncodeSql(sw.PEST_REPORT_HARMID));
            }
            if (string.IsNullOrEmpty(sw.BYORGNO) == false)
            {
                sb.AppendFormat(" and BYORGNO='{0}'", ClsSql.EncodeSql(sw.BYORGNO));
            }
            if (string.IsNullOrEmpty(sw.HAPPENYEAR) == false)
            {
                sb.AppendFormat(" and HAPPENYEAR='{0}'", ClsSql.EncodeSql(sw.HAPPENYEAR));
            }
            if (string.IsNullOrEmpty(sw.HAPPENMONTH) == false)
            {
                sb.AppendFormat(" and HAPPENMONTH='{0}'", ClsSql.EncodeSql(sw.HAPPENMONTH));
            }
            if (string.IsNullOrEmpty(sw.PESTBYCODE) == false)
            {
                sb.AppendFormat(" and PESTBYCODE='{0}'", ClsSql.EncodeSql(sw.PESTBYCODE));
            }
            return(DataBaseClass.JudgeRecordExists(sb.ToString()));
        }
Beispiel #2
0
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>参见模型</returns>
        public static DataTable getDT(PEST_REPORT_HARM_SW sw)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("SELECT * FROM PEST_REPORT_HARM WHERE 1=1");
            if (string.IsNullOrEmpty(sw.BYORGNO) == false)
            {
                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" && sw.BYORGNO.Substring(4, 11) != "00000000000") //获取所有县的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,6) = '{0}')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6)));
                }
                else if (sw.BYORGNO.Substring(9, 6) == "000000" && sw.BYORGNO.Substring(6, 9) != "000000000")   //获取所有乡镇的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,9) = '{0}')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 9)));
                }
                else if (sw.BYORGNO.Substring(9, 6) != "000000")   //获取所有村的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,12) = '{0}')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 12)));
                }
                else
                {
                    sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO));
                }
            }
            if (!string.IsNullOrEmpty(sw.HAPPENYEAR))
            {
                sb.AppendFormat(" AND HAPPENYEAR = '{0}'", ClsSql.EncodeSql(sw.HAPPENYEAR));
            }
            if (!string.IsNullOrEmpty(sw.HAPPENMONTH))
            {
                sb.AppendFormat(" AND HAPPENMONTH = '{0}'", ClsSql.EncodeSql(sw.HAPPENMONTH));
            }
            if (!string.IsNullOrEmpty(sw.PESTBYCODE))
            {
                sb.AppendFormat(" AND PESTBYCODE = '{0}'", ClsSql.EncodeSql(sw.PESTBYCODE));
            }
            DataSet ds = DataBaseClass.FullDataSet(sb.ToString());

            return(ds.Tables[0]);
        }
Beispiel #3
0
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="sw">参见模型PEST_REPORT_HAPPEN_SW</param>
        /// <returns>参见模型PEST_REPORT_HAPPEN_Model</returns>
        public static IEnumerable <PEST_REPORT_HARM_Model> getListModel(PEST_REPORT_HARM_SW sw)
        {
            var       result = new List <PEST_REPORT_HARM_Model>();
            DataTable dt     = BaseDT.PEST_REPORT_HARM.getDT(sw);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                PEST_REPORT_HARM_Model m = new PEST_REPORT_HARM_Model();
                m.PEST_REPORT_HARMID   = dt.Rows[i]["PEST_REPORT_HARMID"].ToString();
                m.BYORGNO              = dt.Rows[i]["BYORGNO"].ToString();
                m.HAPPENYEAR           = dt.Rows[i]["HAPPENYEAR"].ToString();
                m.HAPPENMONTH          = dt.Rows[i]["HAPPENMONTH"].ToString();
                m.PESTBYCODE           = dt.Rows[i]["PESTBYCODE"].ToString();
                m.DISASTERAREA         = dt.Rows[i]["DISASTERAREA"].ToString();
                m.FORECASTDISASTERAREA = dt.Rows[i]["FORECASTDISASTERAREA"].ToString();
                m.DIEPLATECOUNT        = dt.Rows[i]["DIEPLATECOUNT"].ToString();
                result.Add(m);
            }
            dt.Clear();
            dt.Dispose();
            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// 获取单条记录
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>参见模型</returns>
        public static PEST_REPORT_HARM_Model getModel(PEST_REPORT_HARM_SW sw)
        {
            DataTable dt             = BaseDT.PEST_REPORT_HARM.getDT(sw);
            PEST_REPORT_HARM_Model m = new PEST_REPORT_HARM_Model();

            if (dt.Rows.Count > 0)
            {
                int i = 0;
                //数据库表字段
                m.PEST_REPORT_HARMID   = dt.Rows[i]["PEST_REPORT_HARMID"].ToString();
                m.BYORGNO              = dt.Rows[i]["BYORGNO"].ToString();
                m.HAPPENYEAR           = dt.Rows[i]["HAPPENYEAR"].ToString();
                m.HAPPENMONTH          = dt.Rows[i]["HAPPENMONTH"].ToString();
                m.PESTBYCODE           = dt.Rows[i]["PESTBYCODE"].ToString();
                m.DISASTERAREA         = dt.Rows[i]["DISASTERAREA"].ToString();
                m.FORECASTDISASTERAREA = dt.Rows[i]["FORECASTDISASTERAREA"].ToString();
                m.DIEPLATECOUNT        = dt.Rows[i]["DIEPLATECOUNT"].ToString();
                //扩充字段
            }
            dt.Clear();
            dt.Dispose();
            return(m);
        }