Example #1
0
        /// <summary>
        /// 根据查询条件获取某一条用户信息记录,用于修改、删除、用户登录验证
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>参见模型</returns>
        public static WILD_BOTANYDISTRIBUTE_Model getModel(WILD_BOTANYDISTRIBUTE_SW sw)
        {
            DataTable dt   = BaseDT.WILD_BOTANYDISTRIBUTE.getDT(sw);//列表
            DataTable dt55 = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW {
                DICTTYPEID = "55"
            });                                                                              //数据中心族群
            DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW {
                SYSFLAG = ConfigCls.getSystemFlag()
            });                                                                                               //获取单位
            WILD_BOTANYDISTRIBUTE_Model m = new WILD_BOTANYDISTRIBUTE_Model();

            if (dt.Rows.Count > 0)
            {
                int i = 0;
                m.WILD_BOTANYDISTRIBUTEID = dt.Rows[i]["WILD_BOTANYDISTRIBUTEID"].ToString();
                m.BIOLOGICALTYPECODE      = dt.Rows[i]["BIOLOGICALTYPECODE"].ToString();
                m.BIOLOGICALTYPEName      = T_SYS_BIOLOGICALTYPECls.getName(m.BIOLOGICALTYPECODE);
                m.POPULATIONTYPE          = dt.Rows[i]["POPULATIONTYPE"].ToString();
                m.POPULATIONTYPEName      = BaseDT.T_SYS_DICT.getName(dt55, m.POPULATIONTYPE);
                m.WD          = dt.Rows[i]["WD"].ToString();
                m.JD          = dt.Rows[i]["JD"].ToString();
                m.BYORGNO     = dt.Rows[i]["BYORGNO"].ToString();
                m.BOTANYCOUNT = dt.Rows[i]["BOTANYCOUNT"].ToString();
                m.BOTANYAREA  = dt.Rows[i]["BOTANYAREA"].ToString();
                m.BYORGNOName = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO);
                m.MARK        = dt.Rows[i]["MARK"].ToString();
            }
            dt.Clear();
            dt.Dispose();
            dt55.Clear();
            dt55.Dispose();
            dtORG.Dispose();
            dtORG.Dispose();
            return(m);
        }
Example #2
0
        /// <summary>
        /// 获取记录
        /// </summary>
        /// <param name="sw"></param>
        /// <returns></returns>
        public static DataTable getDT(WILD_BOTANYDISTRIBUTE_SW sw)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(" FROM      WILD_BOTANYDISTRIBUTE");
            sb.AppendFormat(" WHERE   1=1");
            if (string.IsNullOrEmpty(sw.WILD_BOTANYDISTRIBUTEID) == false)
            {
                sb.AppendFormat(" AND WILD_BOTANYDISTRIBUTEID = '{0}'", ClsSql.EncodeSql(sw.WILD_BOTANYDISTRIBUTEID));
            }
            if (string.IsNullOrEmpty(sw.BIOLOGICALTYPECODE) == false)
            {
                sb.AppendFormat(" AND BIOLOGICALTYPECODE = '{0}'", ClsSql.EncodeSql(sw.BIOLOGICALTYPECODE));
            }
            if (string.IsNullOrEmpty(sw.POPULATIONTYPE) == false)
            {
                sb.AppendFormat(" AND POPULATIONTYPE  = '{0}'", ClsSql.EncodeSql(sw.POPULATIONTYPE));
            }
            if (string.IsNullOrEmpty(sw.ORGNO) == false)
            {
                sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.ORGNO));
            }
            if (string.IsNullOrEmpty(sw.BYORGNO) == false)
            {
                if (sw.BYORGNO.Substring(4, 11) == "00000000000")//获取所有市的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,4) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 4)));
                }
                else if (sw.BYORGNO.Substring(4, 11) == "xxxxxxxxxxx")//单独市
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,15) = '{0}')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 4) + "00000000000"));
                }
                else if (sw.BYORGNO.Substring(6, 9) == "xxxxxxxxx")//获取所有县的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,6) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6)));
                }
                else if (sw.BYORGNO.Substring(9, 6) == "000000")//获取所有乡镇的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,9) = '{0}'or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 9)));
                }
                else if (sw.BYORGNO.Substring(12, 3) == "000")//获取所有村的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,12) = '{0}'or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 12)));
                }
                else
                {
                    sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO));
                }
            }
            string sql = "SELECT WILD_BOTANYDISTRIBUTEID, BIOLOGICALTYPECODE, POPULATIONTYPE, JD, WD, BYORGNO, BOTANYCOUNT,BOTANYAREA, MARK"
                         + sb.ToString()
                         + " order by WILD_BOTANYDISTRIBUTEID desc";
            DataSet ds = DataBaseClass.FullDataSet(sql);

            return(ds.Tables[0]);
        }
Example #3
0
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>参见模型</returns>
        public static IEnumerable <WILD_BOTANYDISTRIBUTE_Model> getListModel(WILD_BOTANYDISTRIBUTE_SW sw)
        {
            var       result = new List <WILD_BOTANYDISTRIBUTE_Model>();
            DataTable dt     = BaseDT.WILD_BOTANYDISTRIBUTE.getDT(sw);
            DataTable dt55   = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW {
                DICTTYPEID = "55"
            });                                                                              //数据中心族群
            DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW {
                SYSFLAG = ConfigCls.getSystemFlag()
            });                                                                                               //获取单位

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                WILD_BOTANYDISTRIBUTE_Model m = new WILD_BOTANYDISTRIBUTE_Model();
                m.WILD_BOTANYDISTRIBUTEID = dt.Rows[i]["WILD_BOTANYDISTRIBUTEID"].ToString();
                m.BIOLOGICALTYPECODE      = dt.Rows[i]["BIOLOGICALTYPECODE"].ToString();
                m.BIOLOGICALTYPEName      = T_SYS_BIOLOGICALTYPECls.getName(m.BIOLOGICALTYPECODE);
                m.POPULATIONTYPE          = dt.Rows[i]["POPULATIONTYPE"].ToString();
                m.POPULATIONTYPEName      = BaseDT.T_SYS_DICT.getName(dt55, m.POPULATIONTYPE);
                m.WD          = dt.Rows[i]["WD"].ToString();
                m.JD          = dt.Rows[i]["JD"].ToString();
                m.BYORGNO     = dt.Rows[i]["BYORGNO"].ToString();
                m.BOTANYCOUNT = dt.Rows[i]["BOTANYCOUNT"].ToString();
                m.BOTANYAREA  = dt.Rows[i]["BOTANYAREA"].ToString();
                if (m.BYORGNO.Substring(6, 9) != "000000000")
                {
                    m.BYORGNOName = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO);
                }
                m.ORGXSName = BaseDT.T_SYS_ORG.getSXName(dtORG, m.BYORGNO);
                m.MARK      = dt.Rows[i]["MARK"].ToString();
                result.Add(m);
            }
            dt.Clear();
            dt.Dispose();
            dt55.Clear();
            dt55.Dispose();
            dtORG.Dispose();
            dtORG.Dispose();
            return(result);
        }
Example #4
0
        /// <summary>
        /// 统计当前用户下植物的记录数量
        /// </summary>
        /// <param name="sw"></param>
        /// <returns></returns>
        public static string getNum(WILD_BOTANYDISTRIBUTE_SW sw)
        {
            string        total = "";
            StringBuilder sb    = new StringBuilder();

            sb.AppendFormat("    from    WILD_BOTANYDISTRIBUTE a ");
            sb.AppendFormat("where 1 = 1 ");
            if (sw.BYORGNO.Substring(4, 11) == "00000000000") //获取所有市的
            {
                sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,4) = '{0}' or BYORGNO is null or BYORGNO='')", 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}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6)));
            }
            else
            {
                sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,9) = '{0}')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 9)));
            }
            string sqlC = "select count(1) " + sb.ToString();

            total = (DataBaseClass.ReturnSqlField(sqlC)).ToString();
            return(total);
        }
Example #5
0
        /// <summary>
        ///获取分页列表
        /// </summary>
        /// <param name="sw"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public static DataTable getDT(WILD_BOTANYDISTRIBUTE_SW sw, out int total)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(" FROM      WILD_BOTANYDISTRIBUTE");
            sb.AppendFormat(" WHERE   1=1");
            if (string.IsNullOrEmpty(sw.WILD_BOTANYDISTRIBUTEID) == false)
            {
                sb.AppendFormat(" AND WILD_BOTANYDISTRIBUTEID = '{0}'", ClsSql.EncodeSql(sw.WILD_BOTANYDISTRIBUTEID));
            }
            if (string.IsNullOrEmpty(sw.BIOLOGICALTYPECODE) == false)
            {
                sb.AppendFormat(" AND BIOLOGICALTYPECODE = '{0}'", ClsSql.EncodeSql(sw.BIOLOGICALTYPECODE));
            }
            if (string.IsNullOrEmpty(sw.POPULATIONTYPE) == false)
            {
                sb.AppendFormat(" AND POPULATIONTYPE  = '{0}'", ClsSql.EncodeSql(sw.POPULATIONTYPE));
            }
            if (string.IsNullOrEmpty(sw.ORGNO) == false)
            {
                sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.ORGNO));
            }
            if (string.IsNullOrEmpty(sw.BYORGNO) == false)
            {
                if (sw.BYORGNO.Substring(4, 11) == "00000000000")//获取所有市的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,4) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 4)));
                }
                else if (sw.BYORGNO.Substring(4, 11) == "xxxxxxxxxxx")//单独市
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,15) = '{0}')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 4) + "00000000000"));
                }
                else if (sw.BYORGNO.Substring(6, 9) == "xxxxxxxxx")//获取所有县的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,6) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6)));
                }
                else if (sw.BYORGNO.Substring(9, 6) == "000000")//获取所有乡镇的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,9) = '{0}'or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 9)));
                }
                else if (sw.BYORGNO.Substring(12, 3) == "000")//获取所有村的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,12) = '{0}'or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 12)));
                }
                else
                {
                    sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO));
                }
            }
            string sql = "SELECT WILD_BOTANYDISTRIBUTEID, BIOLOGICALTYPECODE, POPULATIONTYPE, JD, WD, BYORGNO, BOTANYCOUNT,BOTANYAREA, MARK"
                         + sb.ToString()
                         + " order by BYORGNO,WILD_BOTANYDISTRIBUTEID  desc";
            string sqlC = "select count(1) " + sb.ToString();

            total      = int.Parse(DataBaseClass.ReturnSqlField(sqlC));
            sw.curPage = PagerCls.getCurPage(new PagerSW {
                curPage = sw.curPage, pageSize = sw.pageSize, rowCount = total
            });
            DataSet ds = DataBaseClass.FullDataSet(sql, (sw.curPage - 1) * sw.pageSize, sw.pageSize, "a");

            return(ds.Tables[0]);
        }