/// <summary> /// 获取记录 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static DataTable getDT(TD_MOUNTAIN_SW sw) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" FROM MOUNTAIN"); sb.AppendFormat(" WHERE 1=1"); if (string.IsNullOrEmpty(sw.OBJECTID) == false) { sb.AppendFormat(" AND OBJECTID = '{0}'", ClsSql.EncodeSql(sw.OBJECTID)); } if (string.IsNullOrEmpty(sw.ORGNO) == false) { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.ORGNO)); } if (string.IsNullOrEmpty(sw.NAME) == false) { sb.AppendFormat(" AND NAME like '%{0}%'", ClsSql.EncodeSql(sw.NAME)); } if (string.IsNullOrEmpty(sw.type) == false) { sb.AppendFormat(" AND TYPE = '{0}'", ClsSql.EncodeSql(sw.type)); } if (!string.IsNullOrEmpty(sw.BYORGNO)) { 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")//获取所有县的 { 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 OBJECTID,NAME,BYORGNO,BYORGNOXS,DISPLAY_X,DISPLAY_Y,Shape,VILLAGE,TYPE" + sb.ToString() + " order by BYORGNO,OBJECTID"; DataSet ds = SDEDataBaseClass.FullDataSet(sql); return(ds.Tables[0]); }
/// <summary> /// 根据查询条件获取某一条用户信息记录,用于修改、删除、用户登录验证 /// </summary> /// <param name="sw">参见模型</param> /// <returns>参见模型</returns> public static TD_MOUNTAIN_Model getModel(TD_MOUNTAIN_SW sw) { var result = new List <TD_MOUNTAIN_Model>(); DataTable dt = BaseDT.SDE.TD_MOUNTAIN.getDT(sw);//列表 DataTable dt51 = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW { DICTTYPEID = "51" }); //类型 DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { SYSFLAG = ConfigCls.getSystemFlag() }); //获取单位 TD_MOUNTAIN_Model m = new TD_MOUNTAIN_Model(); if (dt.Rows.Count > 0) { int i = 0; m.OBJECTID = dt.Rows[i]["OBJECTID"].ToString(); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); m.BYORGNOXS = dt.Rows[i]["BYORGNOXS"].ToString(); m.ORGXSNAME = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNOXS); m.ORGNAME = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO); m.NAME = dt.Rows[i]["NAME"].ToString(); string jd = dt.Rows[i]["DISPLAY_X"].ToString(); string wd = dt.Rows[i]["DISPLAY_Y"].ToString(); m.JD = Convert.ToDouble(jd).ToString("F6"); m.WD = Convert.ToDouble(wd).ToString("F6"); m.VILLAGE = dt.Rows[i]["VILLAGE"].ToString(); m.Shape = dt.Rows[i]["Shape"].ToString(); m.TYPE = dt.Rows[i]["TYPE"].ToString(); m.TYPENAME = BaseDT.T_SYS_DICT.getName(dt51, m.TYPE); } dt.Clear(); dt.Dispose(); dtORG.Clear(); dtORG.Dispose(); return(m); }
/// <summary> /// 获取分页列表 /// </summary> /// <param name="sw"></param> /// <param name="total"></param> /// <returns></returns> public static DataTable getDT(TD_MOUNTAIN_SW sw, out int total) { StringBuilder sb = new StringBuilder(); if (string.IsNullOrEmpty(sw.type) == false) { if (sw.type == "1") { sb.Append(" select OBJECTID,BYORGNO,NAME,BYORGNOXS,DISPLAY_X,DISPLAY_Y,Shape,VILLAGE,[TYPE] from CUNZHUDI "); sb.AppendFormat(" WHERE 1=1"); if (string.IsNullOrEmpty(sw.type) == false) { sb.AppendFormat(" AND TYPE = '{0}'", ClsSql.EncodeSql(sw.type)); } if (string.IsNullOrEmpty(sw.type) == false) { sb.AppendFormat(" AND [TYPE] = '{0}'", ClsSql.EncodeSql(sw.type)); } if (string.IsNullOrEmpty(sw.ORGNO) == false) { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.ORGNO)); } if (string.IsNullOrEmpty(sw.NAME) == false) { sb.AppendFormat(" AND NAME like '%{0}%'", ClsSql.EncodeSql(sw.NAME)); } 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(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}' )", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6))); } else { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO)); } } } else { sb.Append("select OBJECTID,BYORGNO,NAME,BYORGNOXS,DISPLAY_X,DISPLAY_Y,Shape,VILLAGE,[TYPE] from MOUNTAIN "); sb.AppendFormat(" WHERE 1=1"); if (string.IsNullOrEmpty(sw.type) == false) { sb.AppendFormat(" AND TYPE = '{0}'", ClsSql.EncodeSql(sw.type)); } if (string.IsNullOrEmpty(sw.type) == false) { sb.AppendFormat(" AND [TYPE] = '{0}'", ClsSql.EncodeSql(sw.type)); } if (string.IsNullOrEmpty(sw.ORGNO) == false) { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.ORGNO)); } if (string.IsNullOrEmpty(sw.NAME) == false) { sb.AppendFormat(" AND NAME like '%{0}%'", ClsSql.EncodeSql(sw.NAME)); } 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(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}' )", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6))); } else { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO)); } } } } else { sb.Append(" select OBJECTID,BYORGNO,NAME,BYORGNOXS,DISPLAY_X,DISPLAY_Y,Shape,VILLAGE,[TYPE] from CUNZHUDI "); sb.AppendFormat(" WHERE 1=1"); sb.AppendFormat(" AND [TYPE] = '{0}'", "1"); if (string.IsNullOrEmpty(sw.ORGNO) == false) { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.ORGNO)); } if (string.IsNullOrEmpty(sw.NAME) == false) { sb.AppendFormat(" AND NAME like '%{0}%'", ClsSql.EncodeSql(sw.NAME)); } 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(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}' )", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6))); } else { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO)); } } sb.AppendFormat(" union all "); sb.Append("select OBJECTID,BYORGNO,NAME,BYORGNOXS,DISPLAY_X,DISPLAY_Y,Shape,VILLAGE,[TYPE] from MOUNTAIN "); sb.AppendFormat(" WHERE 1=1"); if (string.IsNullOrEmpty(sw.type) == false) { sb.AppendFormat(" AND [TYPE] = '{0}'", ClsSql.EncodeSql(sw.type)); } if (string.IsNullOrEmpty(sw.ORGNO) == false) { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.ORGNO)); } if (string.IsNullOrEmpty(sw.NAME) == false) { sb.AppendFormat(" AND NAME like '%{0}%'", ClsSql.EncodeSql(sw.NAME)); } 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(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}' )", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6))); } else { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO)); } } } string sql = "select OBJECTID,BYORGNO,NAME,BYORGNOXS,DISPLAY_X,DISPLAY_Y,Shape,VILLAGE,[TYPE] from ( " + sb.ToString() + " ) aa order by BYORGNO,OBJECTID desc"; string sqlC = "select count(1) from (" + sb.ToString() + ")ee"; total = int.Parse(SDEDataBaseClass.ReturnSqlField(sqlC)); sw.curPage = PagerCls.getCurPage(new PagerSW { curPage = sw.curPage, pageSize = sw.pageSize, rowCount = total }); DataSet ds = SDEDataBaseClass.FullDataSet(sql, (sw.curPage - 1) * sw.pageSize, sw.pageSize, "a"); return(ds.Tables[0]); }