/// <summary> /// 根据屏幕坐标范围获取非派出所机构 /// </summary> /// <param name="minX"></param> /// <param name="minY"></param> /// <param name="maxX"></param> /// <param name="maxY"></param> /// <returns></returns> public List <PoliceOrg> GetNPcsPoliceOrgsByExtent(double minX, double minY, double maxX, double maxY) { List <PoliceOrg> result = new List <PoliceOrg>(); try { using (OleDbConnection conn = new OleDbConnection(this.zzjgDBConnectBuilder.ConnectionString)) { bool usepara = false; String sql = "select t.DW_CODE, t.MC, a.DZMC,a.DZJDZB,a.DZWDZB,t.LX from B_ZTK_SP_BZDZ_DX a, B_ZTK_SP_PCS t where t.LX in(10,20,30) AND a.DZBM=t.DZ"; if (minX >= 100 || maxX < 100) { usepara = true; sql = "select t.DW_CODE, t.MC, a.DZMC,a.DZJDZB,a.DZWDZB,t.LX from B_ZTK_SP_BZDZ_DX a, B_ZTK_SP_PCS t where t.LX in(10,20,30) AND a.DZBM=t.DZ and a.DZJDZB >= ? and a.DZWDZB >= ? and a.DZJDZB <= ? and a.DZWDZB <= ?"; } conn.Open(); OleDbCommand cmd = new OleDbCommand(sql, conn); if (usepara) { cmd.Parameters.Add(new OleDbParameter("@minX", OleDbType.Double)); cmd.Parameters[0].Value = minX; cmd.Parameters.Add(new OleDbParameter("@minY", OleDbType.Double)); cmd.Parameters[1].Value = minY; cmd.Parameters.Add(new OleDbParameter("@maxX", OleDbType.Double)); cmd.Parameters[2].Value = maxX; cmd.Parameters.Add(new OleDbParameter("@maxY", OleDbType.Double)); cmd.Parameters[3].Value = maxY; } OleDbDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { PoliceOrg info = new PoliceOrg(); //GPSID if (!reader.IsDBNull(0)) { info.Gajgdm = reader[0].ToString(); } if (!reader.IsDBNull(1)) { info.Gajgmc = reader[1].ToString(); } //if (!reader.IsDBNull(2)) //{ // info.Gajgjc = reader[2].ToString(); //} //sssjmc if (!reader.IsDBNull(3) && !reader.IsDBNull(4)) { double x, y; Double.TryParse(reader[3].ToString(), out x); if (x > 0) { info.GajgJD = x; } Double.TryParse(reader[4].ToString(), out y); if (y > 0) { info.GajgWD = y; } } //ssdwmc if (!reader.IsDBNull(5)) { info.Jglx = reader[5].ToString(); } if (info.GajgJD > 0 && info.GajgWD > 0 && info.GajgJD >= minX && info.GajgWD >= minY && info.GajgJD <= maxX && info.GajgWD <= maxY) { result.Add(info); } } } } catch (Exception ex) { throw ex; } return(result); }
public List <PoliceOrg> FindPoliceOrgsBySearch(String exp) { List <PoliceOrg> result = new List <PoliceOrg>(); try { using (OleDbConnection conn = new OleDbConnection(this.zzjgDBConnectBuilder.ConnectionString)) { //String sql = "select GAJGDM, GAJGMC, GAJGJC, GAJGJD, GAJGWD, JGLX from ZZJGXT.GAJG_BASEINFO t where GAJGMC like '%" + exp + "%' or GAJGDM like '%" + exp + "%'"; String sql = "select t.DW_CODE, t.MC, a.DZMC,a.DZJDZB,a.DZWDZB,t.LX from B_ZTK_SP_BZDZ_DX a, B_ZTK_SP_PCS t where t.LX in (10,20,30,40) AND a.DZBM=t.DZ AND (t.MC like '%'||?||'%' or t.DW_CODE like '%'||?||'%')"; conn.Open(); OleDbCommand cmd = new OleDbCommand(sql, conn); cmd.Parameters.Add(new OleDbParameter("@exp1", OleDbType.VarChar)); cmd.Parameters[0].Value = exp; cmd.Parameters.Add(new OleDbParameter("@exp2", OleDbType.VarChar)); cmd.Parameters[1].Value = exp; OleDbDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { PoliceOrg info = new PoliceOrg(); //GPSID if (!reader.IsDBNull(0)) { info.Gajgdm = reader[0].ToString(); } if (!reader.IsDBNull(1)) { info.Gajgmc = reader[1].ToString(); } //if (!reader.IsDBNull(2)) //{ // info.Gajgjc = reader[2].ToString(); //} //sssjmc if (!reader.IsDBNull(3)) { info.GajgJD = Convert.ToDouble(reader[3].ToString()); } //ssfjmc if (!reader.IsDBNull(4)) { info.GajgWD = Convert.ToDouble(reader[4].ToString()); } //ssdwmc if (!reader.IsDBNull(5)) { info.Jglx = reader[5].ToString(); } result.Add(info); } } } catch (Exception ex) { throw ex; } return(result); }
/// <summary> /// 获取所有公安机构 /// </summary> /// <returns></returns> public List <PoliceOrg> GetAllPoliceOrgs() { List <PoliceOrg> result = new List <PoliceOrg>(); try { using (OleDbConnection conn = new OleDbConnection(this.zzjgDBConnectBuilder.ConnectionString)) { String sql = "select t.DW_CODE, t.MC, a.DZMC,a.DZJDZB,a.DZWDZB,t.LX from B_ZTK_SP_BZDZ_DX a, B_ZTK_SP_PCS t where t.LX in (10,20,30,40) AND a.DZBM=t.DZ "; conn.Open(); OleDbCommand cmd = new OleDbCommand(sql, conn); OleDbDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { PoliceOrg info = new PoliceOrg(); //GPSID if (!reader.IsDBNull(0)) { info.Gajgdm = reader[0].ToString(); } if (!reader.IsDBNull(1)) { info.Gajgmc = reader[1].ToString(); } //if (!reader.IsDBNull(2)) //{ // info.Gajgjc = reader[2].ToString(); //} if (!reader.IsDBNull(3) && !reader.IsDBNull(4)) { double x, y; Double.TryParse(reader[3].ToString(), out x); if (x > 0) { info.GajgJD = x; } Double.TryParse(reader[4].ToString(), out y); if (y > 0) { info.GajgWD = y; } } //ssdwmc if (!reader.IsDBNull(5)) { info.Jglx = reader[5].ToString(); } result.Add(info); } } } catch (Exception ex) { throw ex; } return(result); }