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

            sb.AppendFormat("select 1 from PEST_REPORT_CONTROL where 1=1");
            if (string.IsNullOrEmpty(sw.PEST_REPORT_CONTROLID) == false)
            {
                sb.AppendFormat(" and PEST_REPORT_CONTROLID='{0}'", ClsSql.EncodeSql(sw.PEST_REPORT_CONTROLID));
            }
            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));
            }
            if (string.IsNullOrEmpty(sw.CONTROLMETHODCODE) == false)
            {
                sb.AppendFormat(" and CONTROLMETHODCODE='{0}'", ClsSql.EncodeSql(sw.CONTROLMETHODCODE));
            }
            return(DataBaseClass.JudgeRecordExists(sb.ToString()));
        }
Example #2
0
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>参见模型</returns>
        public static DataTable getDT(PEST_REPORT_CONTROL_SW sw)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("SELECT * FROM PEST_REPORT_CONTROL 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));
            }
            if (!string.IsNullOrEmpty(sw.CONTROLMETHODCODE))
            {
                sb.AppendFormat(" AND CONTROLMETHODCODE = '{0}'", ClsSql.EncodeSql(sw.CONTROLMETHODCODE));
            }
            DataSet ds = DataBaseClass.FullDataSet(sb.ToString());

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

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                PEST_REPORT_CONTROL_Model m = new PEST_REPORT_CONTROL_Model();
                m.PEST_REPORT_CONTROLID = dt.Rows[i]["PEST_REPORT_CONTROLID"].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.CONTROLMETHODCODE = dt.Rows[i]["CONTROLMETHODCODE"].ToString();
                m.CONTROLAREA       = dt.Rows[i]["CONTROLAREA"].ToString();
                result.Add(m);
            }
            dt.Clear();
            dt.Dispose();
            return(result);
        }
Example #4
0
        /// <summary>
        /// 获取单条记录
        /// </summary>
        /// <param name="sw">参见模型PEST_REPORT_CONTROL_SW</param>
        /// <returns>参见模型PEST_REPORT_HAPPEN_Model</returns>
        public static PEST_REPORT_CONTROL_Model getModel(PEST_REPORT_CONTROL_SW sw)
        {
            DataTable dt = BaseDT.PEST_REPORT_CONTROL.getDT(sw);
            PEST_REPORT_CONTROL_Model m = new PEST_REPORT_CONTROL_Model();

            if (dt.Rows.Count > 0)
            {
                int i = 0;
                //数据库表字段
                m.PEST_REPORT_CONTROLID = dt.Rows[i]["PEST_REPORT_CONTROLID"].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.CONTROLMETHODCODE = dt.Rows[i]["CONTROLMETHODCODE"].ToString();
                m.CONTROLAREA       = dt.Rows[i]["CONTROLAREA"].ToString();
                //扩充字段
            }
            dt.Clear();
            dt.Dispose();
            return(m);
        }