diff --git a/ClassSearchAnalysis.cs b/ClassSearchAnalysis.cs
index 5a6308c..61f667e 100644
--- a/ClassSearchAnalysis.cs
+++ b/ClassSearchAnalysis.cs
@@ -69,6 +69,74 @@
return dt;
}
///
+ /// SQL查询不重复的值
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinctDataTable(out DataTable dt,string layerName,string filedObject)
+ {
+ string sql = "select distinct "+filedObject+" from " + layerName;
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
+ /// SQL查询不重复的值+排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinceDataTableOrder(out DataTable dt, string layerName, string filedObject)
+ {
+
+ }
+ ///
+ /// SQL查询,返回包含NULL的Table
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDataTableContainNull(out DataTable dt,GSOGlobeControl m_globeControl,
+ string layerName,string filedObject,List filedValueList)
+ {
+ string sql = "select " + getpipeLineFields.getFields(layerName, m_globeControl)
+ + " from " + layerName + " where " + filedObject + " = '";
+
+ for (int i = 0; i < filedValueList.Count; i++)
+ {
+ if (i == 0)
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql = sql.Replace("= '", "is null");
+ }
+ else
+ {
+ sql += filedValueList[i].ToString() + "' ";
+ }
+ }
+ else
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql += " or 材质 is null";
+ }
+ else
+ {
+ sql += " or 材质 = '" + filedValueList[i].ToString() + "'";
+ }
+ }
+ }
+
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
/// 关联查询
///
///
diff --git a/ClassSearchAnalysis.cs b/ClassSearchAnalysis.cs
index 5a6308c..61f667e 100644
--- a/ClassSearchAnalysis.cs
+++ b/ClassSearchAnalysis.cs
@@ -69,6 +69,74 @@
return dt;
}
///
+ /// SQL查询不重复的值
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinctDataTable(out DataTable dt,string layerName,string filedObject)
+ {
+ string sql = "select distinct "+filedObject+" from " + layerName;
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
+ /// SQL查询不重复的值+排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinceDataTableOrder(out DataTable dt, string layerName, string filedObject)
+ {
+
+ }
+ ///
+ /// SQL查询,返回包含NULL的Table
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDataTableContainNull(out DataTable dt,GSOGlobeControl m_globeControl,
+ string layerName,string filedObject,List filedValueList)
+ {
+ string sql = "select " + getpipeLineFields.getFields(layerName, m_globeControl)
+ + " from " + layerName + " where " + filedObject + " = '";
+
+ for (int i = 0; i < filedValueList.Count; i++)
+ {
+ if (i == 0)
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql = sql.Replace("= '", "is null");
+ }
+ else
+ {
+ sql += filedValueList[i].ToString() + "' ";
+ }
+ }
+ else
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql += " or 材质 is null";
+ }
+ else
+ {
+ sql += " or 材质 = '" + filedValueList[i].ToString() + "'";
+ }
+ }
+ }
+
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
/// 关联查询
///
///
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index a9a1898..221e34d 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/ClassSearchAnalysis.cs b/ClassSearchAnalysis.cs
index 5a6308c..61f667e 100644
--- a/ClassSearchAnalysis.cs
+++ b/ClassSearchAnalysis.cs
@@ -69,6 +69,74 @@
return dt;
}
///
+ /// SQL查询不重复的值
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinctDataTable(out DataTable dt,string layerName,string filedObject)
+ {
+ string sql = "select distinct "+filedObject+" from " + layerName;
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
+ /// SQL查询不重复的值+排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinceDataTableOrder(out DataTable dt, string layerName, string filedObject)
+ {
+
+ }
+ ///
+ /// SQL查询,返回包含NULL的Table
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDataTableContainNull(out DataTable dt,GSOGlobeControl m_globeControl,
+ string layerName,string filedObject,List filedValueList)
+ {
+ string sql = "select " + getpipeLineFields.getFields(layerName, m_globeControl)
+ + " from " + layerName + " where " + filedObject + " = '";
+
+ for (int i = 0; i < filedValueList.Count; i++)
+ {
+ if (i == 0)
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql = sql.Replace("= '", "is null");
+ }
+ else
+ {
+ sql += filedValueList[i].ToString() + "' ";
+ }
+ }
+ else
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql += " or 材质 is null";
+ }
+ else
+ {
+ sql += " or 材质 = '" + filedValueList[i].ToString() + "'";
+ }
+ }
+ }
+
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
/// 关联查询
///
///
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index a9a1898..221e34d 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/FrmMaterialSel.cs b/FrmMaterialSel.cs
index 03af994..a42bfb0 100644
--- a/FrmMaterialSel.cs
+++ b/FrmMaterialSel.cs
@@ -72,8 +72,9 @@
MessageBox.Show("图层不存在", "提示");
return;
}
- string sql = "select distinct 材质 from " + layer.Name;
- DataTable table = OledbHelper.QueryTable(sql);
+
+ ClassSearchAnalysis.ResultDistinctDataTable(out table, layer.Name, "材质");
+
if (table.Rows.Count > 0)
{
listBox1.Items.Clear();
@@ -138,38 +139,15 @@
MessageBox.Show("图层不存在", "提示");
return;
}
-
- string sql = "select " + getpipeLineFields.getFields(comboBoxEx1.Text, globeControl1)
- + " from " + layer.Name + " where 材质 = '";
+ List filedValueList = new List();
for (int i = 0; i < listBox2.Items.Count; i++)
{
- if (i == 0)
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql =sql.Replace("= '","is null");
- }
- else
- {
- sql += listBox2.Items[i].ToString() + "' ";
- }
- }
- else
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql += " or 材质 is null";
- }
- else
- {
- sql += " or 材质 = '" + listBox2.Items[i].ToString() + "'";
- }
- }
+ filedValueList.Add(listBox2.Items[i].ToString());
}
- table = OledbHelper.QueryTable(sql);
-
-
+ ClassSearchAnalysis.ResultDataTableContainNull(out table, globeControl1,
+ comboBoxEx1.Text.Trim(), "材质", filedValueList);
+
if (table != null && table.Rows.Count > 0)
{
strLable = comboBoxEx1.Text + " 共有:" + table.Rows.Count + "个";
diff --git a/ClassSearchAnalysis.cs b/ClassSearchAnalysis.cs
index 5a6308c..61f667e 100644
--- a/ClassSearchAnalysis.cs
+++ b/ClassSearchAnalysis.cs
@@ -69,6 +69,74 @@
return dt;
}
///
+ /// SQL查询不重复的值
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinctDataTable(out DataTable dt,string layerName,string filedObject)
+ {
+ string sql = "select distinct "+filedObject+" from " + layerName;
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
+ /// SQL查询不重复的值+排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinceDataTableOrder(out DataTable dt, string layerName, string filedObject)
+ {
+
+ }
+ ///
+ /// SQL查询,返回包含NULL的Table
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDataTableContainNull(out DataTable dt,GSOGlobeControl m_globeControl,
+ string layerName,string filedObject,List filedValueList)
+ {
+ string sql = "select " + getpipeLineFields.getFields(layerName, m_globeControl)
+ + " from " + layerName + " where " + filedObject + " = '";
+
+ for (int i = 0; i < filedValueList.Count; i++)
+ {
+ if (i == 0)
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql = sql.Replace("= '", "is null");
+ }
+ else
+ {
+ sql += filedValueList[i].ToString() + "' ";
+ }
+ }
+ else
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql += " or 材质 is null";
+ }
+ else
+ {
+ sql += " or 材质 = '" + filedValueList[i].ToString() + "'";
+ }
+ }
+ }
+
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
/// 关联查询
///
///
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index a9a1898..221e34d 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/FrmMaterialSel.cs b/FrmMaterialSel.cs
index 03af994..a42bfb0 100644
--- a/FrmMaterialSel.cs
+++ b/FrmMaterialSel.cs
@@ -72,8 +72,9 @@
MessageBox.Show("图层不存在", "提示");
return;
}
- string sql = "select distinct 材质 from " + layer.Name;
- DataTable table = OledbHelper.QueryTable(sql);
+
+ ClassSearchAnalysis.ResultDistinctDataTable(out table, layer.Name, "材质");
+
if (table.Rows.Count > 0)
{
listBox1.Items.Clear();
@@ -138,38 +139,15 @@
MessageBox.Show("图层不存在", "提示");
return;
}
-
- string sql = "select " + getpipeLineFields.getFields(comboBoxEx1.Text, globeControl1)
- + " from " + layer.Name + " where 材质 = '";
+ List filedValueList = new List();
for (int i = 0; i < listBox2.Items.Count; i++)
{
- if (i == 0)
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql =sql.Replace("= '","is null");
- }
- else
- {
- sql += listBox2.Items[i].ToString() + "' ";
- }
- }
- else
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql += " or 材质 is null";
- }
- else
- {
- sql += " or 材质 = '" + listBox2.Items[i].ToString() + "'";
- }
- }
+ filedValueList.Add(listBox2.Items[i].ToString());
}
- table = OledbHelper.QueryTable(sql);
-
-
+ ClassSearchAnalysis.ResultDataTableContainNull(out table, globeControl1,
+ comboBoxEx1.Text.Trim(), "材质", filedValueList);
+
if (table != null && table.Rows.Count > 0)
{
strLable = comboBoxEx1.Text + " 共有:" + table.Rows.Count + "个";
diff --git a/FrmQuerySQL.cs b/FrmQuerySQL.cs
index fcaabad..4260509 100644
--- a/FrmQuerySQL.cs
+++ b/FrmQuerySQL.cs
@@ -17,17 +17,19 @@
public partial class FrmQuerySQL : DevComponents.DotNetBar.Office2007Form
{
private GSOGlobeControl m_globeControl;
- private DataGridViewX m_dataGridViewX;
private GSODataset ds;
string sql;
public string currentLayerName;
-
static FrmQuerySQL frm;
- public static void ShowForm(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ DataTable table = new DataTable();
+ string strLable = "";
+ MainFrm.DataGridViewDelegate m_InitDataGridViewX1;
+
+ public static void ShowForm(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
if (frm == null)
{
- frm = new FrmQuerySQL(_ctl, _dgv);
+ frm = new FrmQuerySQL(_ctl, InitDataGridViewX1);
frm.Show(_ctl.Parent);
}
else
@@ -39,14 +41,14 @@
}
}
- public FrmQuerySQL(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ public FrmQuerySQL(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
InitializeComponent();
m_globeControl = _ctl;
- m_dataGridViewX = _dgv;
+ m_InitDataGridViewX1 = InitDataGridViewX1;
}
- #region 符号
+ #region 符号按钮双击事件
private void btn_equal_Click(object sender, EventArgs e)
{
textBox_WhereClause.Text += " =";
@@ -190,9 +192,7 @@
}
}
- string sqltype = "select distinct " + listBox_Field.SelectedItem.ToString() + " from " + ds.Name +" order by "+listBox_Field.SelectedItem.ToString()+"";
-
- DataTable table = OledbHelper.QueryTable(sqltype);
+ ClassSearchAnalysis.ResultDistinctDataTable(table, cbox_Layers.SelectedItem.ToString(),listBox_Field.SelectedItem.ToString());
for (int i = 0; i < table.Rows.Count; i++)
{
@@ -231,7 +231,6 @@
///
private void btn_Apply_Click(object sender, EventArgs e)
{
- m_dataGridViewX.Visible = true;
string fields = "";
int itemCount = listBox_Field.Items.Count;
for (int i = 0; i < itemCount; i++)
@@ -257,47 +256,22 @@
sql += " where " + textBox_WhereClause.Text;
}
+ currentLayerName = cbox_Layers.SelectedItem.ToString();
+
try
{
this.Cursor = Cursors.WaitCursor;
- DataTable table = OledbHelper.QueryTable(sql);
+ table = OledbHelper.QueryTable(sql);
if (table == null)
{
this.Cursor = Cursors.Default;
- MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!","提示");
+ MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!", "提示");
return;
}
-
- currentLayerName = cbox_Layers.SelectedItem.ToString();
- m_dataGridViewX.DataSource = table;
-
- MainFrm frm = (MainFrm)this.Owner;
- //显示表格
-
- frm.expandableSplitter2.Expanded = true;
- frm.panelOfTable.Visible = true;
-
- int count = m_dataGridViewX.Rows.Count;
- if (count != 0)
- {
- if (currentLayerName.Contains("管线"))
- {
- double featurelength = frm.PipeLength(currentLayerName, 0);// 统计管线的里程数
- frm.statusStrip2.Items[0].Text = " 管线类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录";
- frm.statusStrip2.Items[1].Text = " 管线里程:" + featurelength.ToString("0.00") + " 米";
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录"; ;
-
- frm.statusStrip2.Items[1].Text = " ";
- }
- MainFrm.m_CurrentQueryLayer = currentLayerName;
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 管线类型: " + currentLayerName + "|| 共有:" + 0 + " 条记录 || ";
+ else {
+ strLable = currentLayerName + " || 共有:" + table.Rows.Count + "条记录";
+ m_InitDataGridViewX1(table, strLable, currentLayerName, true);
}
this.Cursor = Cursors.Default;
@@ -359,13 +333,7 @@
///
private void Frm_QuerySQL_FormClosing(object sender, FormClosingEventArgs e)
{
- MainFrm mfrm = (MainFrm)this.Owner;
- mfrm.panelOfTable.Visible = false;
- mfrm.statusStrip2.Items[0].Text = " 类型:";
- mfrm.statusStrip2.Items[1].Text = " ";
- m_dataGridViewX.DataSource = null;
- m_dataGridViewX.Refresh();
-
+ m_InitDataGridViewX1(table, strLable, "", false);
frm = null;
}
}
diff --git a/ClassSearchAnalysis.cs b/ClassSearchAnalysis.cs
index 5a6308c..61f667e 100644
--- a/ClassSearchAnalysis.cs
+++ b/ClassSearchAnalysis.cs
@@ -69,6 +69,74 @@
return dt;
}
///
+ /// SQL查询不重复的值
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinctDataTable(out DataTable dt,string layerName,string filedObject)
+ {
+ string sql = "select distinct "+filedObject+" from " + layerName;
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
+ /// SQL查询不重复的值+排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinceDataTableOrder(out DataTable dt, string layerName, string filedObject)
+ {
+
+ }
+ ///
+ /// SQL查询,返回包含NULL的Table
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDataTableContainNull(out DataTable dt,GSOGlobeControl m_globeControl,
+ string layerName,string filedObject,List filedValueList)
+ {
+ string sql = "select " + getpipeLineFields.getFields(layerName, m_globeControl)
+ + " from " + layerName + " where " + filedObject + " = '";
+
+ for (int i = 0; i < filedValueList.Count; i++)
+ {
+ if (i == 0)
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql = sql.Replace("= '", "is null");
+ }
+ else
+ {
+ sql += filedValueList[i].ToString() + "' ";
+ }
+ }
+ else
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql += " or 材质 is null";
+ }
+ else
+ {
+ sql += " or 材质 = '" + filedValueList[i].ToString() + "'";
+ }
+ }
+ }
+
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
/// 关联查询
///
///
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index a9a1898..221e34d 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/FrmMaterialSel.cs b/FrmMaterialSel.cs
index 03af994..a42bfb0 100644
--- a/FrmMaterialSel.cs
+++ b/FrmMaterialSel.cs
@@ -72,8 +72,9 @@
MessageBox.Show("图层不存在", "提示");
return;
}
- string sql = "select distinct 材质 from " + layer.Name;
- DataTable table = OledbHelper.QueryTable(sql);
+
+ ClassSearchAnalysis.ResultDistinctDataTable(out table, layer.Name, "材质");
+
if (table.Rows.Count > 0)
{
listBox1.Items.Clear();
@@ -138,38 +139,15 @@
MessageBox.Show("图层不存在", "提示");
return;
}
-
- string sql = "select " + getpipeLineFields.getFields(comboBoxEx1.Text, globeControl1)
- + " from " + layer.Name + " where 材质 = '";
+ List filedValueList = new List();
for (int i = 0; i < listBox2.Items.Count; i++)
{
- if (i == 0)
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql =sql.Replace("= '","is null");
- }
- else
- {
- sql += listBox2.Items[i].ToString() + "' ";
- }
- }
- else
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql += " or 材质 is null";
- }
- else
- {
- sql += " or 材质 = '" + listBox2.Items[i].ToString() + "'";
- }
- }
+ filedValueList.Add(listBox2.Items[i].ToString());
}
- table = OledbHelper.QueryTable(sql);
-
-
+ ClassSearchAnalysis.ResultDataTableContainNull(out table, globeControl1,
+ comboBoxEx1.Text.Trim(), "材质", filedValueList);
+
if (table != null && table.Rows.Count > 0)
{
strLable = comboBoxEx1.Text + " 共有:" + table.Rows.Count + "个";
diff --git a/FrmQuerySQL.cs b/FrmQuerySQL.cs
index fcaabad..4260509 100644
--- a/FrmQuerySQL.cs
+++ b/FrmQuerySQL.cs
@@ -17,17 +17,19 @@
public partial class FrmQuerySQL : DevComponents.DotNetBar.Office2007Form
{
private GSOGlobeControl m_globeControl;
- private DataGridViewX m_dataGridViewX;
private GSODataset ds;
string sql;
public string currentLayerName;
-
static FrmQuerySQL frm;
- public static void ShowForm(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ DataTable table = new DataTable();
+ string strLable = "";
+ MainFrm.DataGridViewDelegate m_InitDataGridViewX1;
+
+ public static void ShowForm(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
if (frm == null)
{
- frm = new FrmQuerySQL(_ctl, _dgv);
+ frm = new FrmQuerySQL(_ctl, InitDataGridViewX1);
frm.Show(_ctl.Parent);
}
else
@@ -39,14 +41,14 @@
}
}
- public FrmQuerySQL(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ public FrmQuerySQL(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
InitializeComponent();
m_globeControl = _ctl;
- m_dataGridViewX = _dgv;
+ m_InitDataGridViewX1 = InitDataGridViewX1;
}
- #region 符号
+ #region 符号按钮双击事件
private void btn_equal_Click(object sender, EventArgs e)
{
textBox_WhereClause.Text += " =";
@@ -190,9 +192,7 @@
}
}
- string sqltype = "select distinct " + listBox_Field.SelectedItem.ToString() + " from " + ds.Name +" order by "+listBox_Field.SelectedItem.ToString()+"";
-
- DataTable table = OledbHelper.QueryTable(sqltype);
+ ClassSearchAnalysis.ResultDistinctDataTable(table, cbox_Layers.SelectedItem.ToString(),listBox_Field.SelectedItem.ToString());
for (int i = 0; i < table.Rows.Count; i++)
{
@@ -231,7 +231,6 @@
///
private void btn_Apply_Click(object sender, EventArgs e)
{
- m_dataGridViewX.Visible = true;
string fields = "";
int itemCount = listBox_Field.Items.Count;
for (int i = 0; i < itemCount; i++)
@@ -257,47 +256,22 @@
sql += " where " + textBox_WhereClause.Text;
}
+ currentLayerName = cbox_Layers.SelectedItem.ToString();
+
try
{
this.Cursor = Cursors.WaitCursor;
- DataTable table = OledbHelper.QueryTable(sql);
+ table = OledbHelper.QueryTable(sql);
if (table == null)
{
this.Cursor = Cursors.Default;
- MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!","提示");
+ MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!", "提示");
return;
}
-
- currentLayerName = cbox_Layers.SelectedItem.ToString();
- m_dataGridViewX.DataSource = table;
-
- MainFrm frm = (MainFrm)this.Owner;
- //显示表格
-
- frm.expandableSplitter2.Expanded = true;
- frm.panelOfTable.Visible = true;
-
- int count = m_dataGridViewX.Rows.Count;
- if (count != 0)
- {
- if (currentLayerName.Contains("管线"))
- {
- double featurelength = frm.PipeLength(currentLayerName, 0);// 统计管线的里程数
- frm.statusStrip2.Items[0].Text = " 管线类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录";
- frm.statusStrip2.Items[1].Text = " 管线里程:" + featurelength.ToString("0.00") + " 米";
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录"; ;
-
- frm.statusStrip2.Items[1].Text = " ";
- }
- MainFrm.m_CurrentQueryLayer = currentLayerName;
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 管线类型: " + currentLayerName + "|| 共有:" + 0 + " 条记录 || ";
+ else {
+ strLable = currentLayerName + " || 共有:" + table.Rows.Count + "条记录";
+ m_InitDataGridViewX1(table, strLable, currentLayerName, true);
}
this.Cursor = Cursors.Default;
@@ -359,13 +333,7 @@
///
private void Frm_QuerySQL_FormClosing(object sender, FormClosingEventArgs e)
{
- MainFrm mfrm = (MainFrm)this.Owner;
- mfrm.panelOfTable.Visible = false;
- mfrm.statusStrip2.Items[0].Text = " 类型:";
- mfrm.statusStrip2.Items[1].Text = " ";
- m_dataGridViewX.DataSource = null;
- m_dataGridViewX.Refresh();
-
+ m_InitDataGridViewX1(table, strLable, "", false);
frm = null;
}
}
diff --git a/FrmSetLatLonPos.cs b/FrmSetLatLonPos.cs
index d3dca83..0636619 100644
--- a/FrmSetLatLonPos.cs
+++ b/FrmSetLatLonPos.cs
@@ -129,13 +129,7 @@
textBox3.Text = "";
return;
}
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = m_strLon;
- //point3d.Y = m_strLat;
- //point3d.Z = m_strAlt;
-
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = m_strLon;
cameraState.Latitude = m_strLat;
@@ -209,12 +203,6 @@
textBox6.Text = "";
return;
}
-
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = result.X;
- //point3d.Y = result.Y;
- //point3d.Z = m_strAlt;
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = result.X;
cameraState.Latitude = result.Y;
diff --git a/ClassSearchAnalysis.cs b/ClassSearchAnalysis.cs
index 5a6308c..61f667e 100644
--- a/ClassSearchAnalysis.cs
+++ b/ClassSearchAnalysis.cs
@@ -69,6 +69,74 @@
return dt;
}
///
+ /// SQL查询不重复的值
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinctDataTable(out DataTable dt,string layerName,string filedObject)
+ {
+ string sql = "select distinct "+filedObject+" from " + layerName;
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
+ /// SQL查询不重复的值+排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinceDataTableOrder(out DataTable dt, string layerName, string filedObject)
+ {
+
+ }
+ ///
+ /// SQL查询,返回包含NULL的Table
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDataTableContainNull(out DataTable dt,GSOGlobeControl m_globeControl,
+ string layerName,string filedObject,List filedValueList)
+ {
+ string sql = "select " + getpipeLineFields.getFields(layerName, m_globeControl)
+ + " from " + layerName + " where " + filedObject + " = '";
+
+ for (int i = 0; i < filedValueList.Count; i++)
+ {
+ if (i == 0)
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql = sql.Replace("= '", "is null");
+ }
+ else
+ {
+ sql += filedValueList[i].ToString() + "' ";
+ }
+ }
+ else
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql += " or 材质 is null";
+ }
+ else
+ {
+ sql += " or 材质 = '" + filedValueList[i].ToString() + "'";
+ }
+ }
+ }
+
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
/// 关联查询
///
///
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index a9a1898..221e34d 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/FrmMaterialSel.cs b/FrmMaterialSel.cs
index 03af994..a42bfb0 100644
--- a/FrmMaterialSel.cs
+++ b/FrmMaterialSel.cs
@@ -72,8 +72,9 @@
MessageBox.Show("图层不存在", "提示");
return;
}
- string sql = "select distinct 材质 from " + layer.Name;
- DataTable table = OledbHelper.QueryTable(sql);
+
+ ClassSearchAnalysis.ResultDistinctDataTable(out table, layer.Name, "材质");
+
if (table.Rows.Count > 0)
{
listBox1.Items.Clear();
@@ -138,38 +139,15 @@
MessageBox.Show("图层不存在", "提示");
return;
}
-
- string sql = "select " + getpipeLineFields.getFields(comboBoxEx1.Text, globeControl1)
- + " from " + layer.Name + " where 材质 = '";
+ List filedValueList = new List();
for (int i = 0; i < listBox2.Items.Count; i++)
{
- if (i == 0)
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql =sql.Replace("= '","is null");
- }
- else
- {
- sql += listBox2.Items[i].ToString() + "' ";
- }
- }
- else
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql += " or 材质 is null";
- }
- else
- {
- sql += " or 材质 = '" + listBox2.Items[i].ToString() + "'";
- }
- }
+ filedValueList.Add(listBox2.Items[i].ToString());
}
- table = OledbHelper.QueryTable(sql);
-
-
+ ClassSearchAnalysis.ResultDataTableContainNull(out table, globeControl1,
+ comboBoxEx1.Text.Trim(), "材质", filedValueList);
+
if (table != null && table.Rows.Count > 0)
{
strLable = comboBoxEx1.Text + " 共有:" + table.Rows.Count + "个";
diff --git a/FrmQuerySQL.cs b/FrmQuerySQL.cs
index fcaabad..4260509 100644
--- a/FrmQuerySQL.cs
+++ b/FrmQuerySQL.cs
@@ -17,17 +17,19 @@
public partial class FrmQuerySQL : DevComponents.DotNetBar.Office2007Form
{
private GSOGlobeControl m_globeControl;
- private DataGridViewX m_dataGridViewX;
private GSODataset ds;
string sql;
public string currentLayerName;
-
static FrmQuerySQL frm;
- public static void ShowForm(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ DataTable table = new DataTable();
+ string strLable = "";
+ MainFrm.DataGridViewDelegate m_InitDataGridViewX1;
+
+ public static void ShowForm(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
if (frm == null)
{
- frm = new FrmQuerySQL(_ctl, _dgv);
+ frm = new FrmQuerySQL(_ctl, InitDataGridViewX1);
frm.Show(_ctl.Parent);
}
else
@@ -39,14 +41,14 @@
}
}
- public FrmQuerySQL(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ public FrmQuerySQL(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
InitializeComponent();
m_globeControl = _ctl;
- m_dataGridViewX = _dgv;
+ m_InitDataGridViewX1 = InitDataGridViewX1;
}
- #region 符号
+ #region 符号按钮双击事件
private void btn_equal_Click(object sender, EventArgs e)
{
textBox_WhereClause.Text += " =";
@@ -190,9 +192,7 @@
}
}
- string sqltype = "select distinct " + listBox_Field.SelectedItem.ToString() + " from " + ds.Name +" order by "+listBox_Field.SelectedItem.ToString()+"";
-
- DataTable table = OledbHelper.QueryTable(sqltype);
+ ClassSearchAnalysis.ResultDistinctDataTable(table, cbox_Layers.SelectedItem.ToString(),listBox_Field.SelectedItem.ToString());
for (int i = 0; i < table.Rows.Count; i++)
{
@@ -231,7 +231,6 @@
///
private void btn_Apply_Click(object sender, EventArgs e)
{
- m_dataGridViewX.Visible = true;
string fields = "";
int itemCount = listBox_Field.Items.Count;
for (int i = 0; i < itemCount; i++)
@@ -257,47 +256,22 @@
sql += " where " + textBox_WhereClause.Text;
}
+ currentLayerName = cbox_Layers.SelectedItem.ToString();
+
try
{
this.Cursor = Cursors.WaitCursor;
- DataTable table = OledbHelper.QueryTable(sql);
+ table = OledbHelper.QueryTable(sql);
if (table == null)
{
this.Cursor = Cursors.Default;
- MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!","提示");
+ MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!", "提示");
return;
}
-
- currentLayerName = cbox_Layers.SelectedItem.ToString();
- m_dataGridViewX.DataSource = table;
-
- MainFrm frm = (MainFrm)this.Owner;
- //显示表格
-
- frm.expandableSplitter2.Expanded = true;
- frm.panelOfTable.Visible = true;
-
- int count = m_dataGridViewX.Rows.Count;
- if (count != 0)
- {
- if (currentLayerName.Contains("管线"))
- {
- double featurelength = frm.PipeLength(currentLayerName, 0);// 统计管线的里程数
- frm.statusStrip2.Items[0].Text = " 管线类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录";
- frm.statusStrip2.Items[1].Text = " 管线里程:" + featurelength.ToString("0.00") + " 米";
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录"; ;
-
- frm.statusStrip2.Items[1].Text = " ";
- }
- MainFrm.m_CurrentQueryLayer = currentLayerName;
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 管线类型: " + currentLayerName + "|| 共有:" + 0 + " 条记录 || ";
+ else {
+ strLable = currentLayerName + " || 共有:" + table.Rows.Count + "条记录";
+ m_InitDataGridViewX1(table, strLable, currentLayerName, true);
}
this.Cursor = Cursors.Default;
@@ -359,13 +333,7 @@
///
private void Frm_QuerySQL_FormClosing(object sender, FormClosingEventArgs e)
{
- MainFrm mfrm = (MainFrm)this.Owner;
- mfrm.panelOfTable.Visible = false;
- mfrm.statusStrip2.Items[0].Text = " 类型:";
- mfrm.statusStrip2.Items[1].Text = " ";
- m_dataGridViewX.DataSource = null;
- m_dataGridViewX.Refresh();
-
+ m_InitDataGridViewX1(table, strLable, "", false);
frm = null;
}
}
diff --git a/FrmSetLatLonPos.cs b/FrmSetLatLonPos.cs
index d3dca83..0636619 100644
--- a/FrmSetLatLonPos.cs
+++ b/FrmSetLatLonPos.cs
@@ -129,13 +129,7 @@
textBox3.Text = "";
return;
}
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = m_strLon;
- //point3d.Y = m_strLat;
- //point3d.Z = m_strAlt;
-
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = m_strLon;
cameraState.Latitude = m_strLat;
@@ -209,12 +203,6 @@
textBox6.Text = "";
return;
}
-
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = result.X;
- //point3d.Y = result.Y;
- //point3d.Z = m_strAlt;
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = result.X;
cameraState.Latitude = result.Y;
diff --git a/MainFrm.cs b/MainFrm.cs
index 2df3aac..7a8dcd2 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -10124,7 +10124,7 @@
//日志记录
LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text);
- FrmQuerySQL.ShowForm(globeControl1, dataGridViewX1);
+ FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1));
}
///
/// 关联查询
diff --git a/ClassSearchAnalysis.cs b/ClassSearchAnalysis.cs
index 5a6308c..61f667e 100644
--- a/ClassSearchAnalysis.cs
+++ b/ClassSearchAnalysis.cs
@@ -69,6 +69,74 @@
return dt;
}
///
+ /// SQL查询不重复的值
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinctDataTable(out DataTable dt,string layerName,string filedObject)
+ {
+ string sql = "select distinct "+filedObject+" from " + layerName;
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
+ /// SQL查询不重复的值+排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinceDataTableOrder(out DataTable dt, string layerName, string filedObject)
+ {
+
+ }
+ ///
+ /// SQL查询,返回包含NULL的Table
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDataTableContainNull(out DataTable dt,GSOGlobeControl m_globeControl,
+ string layerName,string filedObject,List filedValueList)
+ {
+ string sql = "select " + getpipeLineFields.getFields(layerName, m_globeControl)
+ + " from " + layerName + " where " + filedObject + " = '";
+
+ for (int i = 0; i < filedValueList.Count; i++)
+ {
+ if (i == 0)
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql = sql.Replace("= '", "is null");
+ }
+ else
+ {
+ sql += filedValueList[i].ToString() + "' ";
+ }
+ }
+ else
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql += " or 材质 is null";
+ }
+ else
+ {
+ sql += " or 材质 = '" + filedValueList[i].ToString() + "'";
+ }
+ }
+ }
+
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
/// 关联查询
///
///
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index a9a1898..221e34d 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/FrmMaterialSel.cs b/FrmMaterialSel.cs
index 03af994..a42bfb0 100644
--- a/FrmMaterialSel.cs
+++ b/FrmMaterialSel.cs
@@ -72,8 +72,9 @@
MessageBox.Show("图层不存在", "提示");
return;
}
- string sql = "select distinct 材质 from " + layer.Name;
- DataTable table = OledbHelper.QueryTable(sql);
+
+ ClassSearchAnalysis.ResultDistinctDataTable(out table, layer.Name, "材质");
+
if (table.Rows.Count > 0)
{
listBox1.Items.Clear();
@@ -138,38 +139,15 @@
MessageBox.Show("图层不存在", "提示");
return;
}
-
- string sql = "select " + getpipeLineFields.getFields(comboBoxEx1.Text, globeControl1)
- + " from " + layer.Name + " where 材质 = '";
+ List filedValueList = new List();
for (int i = 0; i < listBox2.Items.Count; i++)
{
- if (i == 0)
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql =sql.Replace("= '","is null");
- }
- else
- {
- sql += listBox2.Items[i].ToString() + "' ";
- }
- }
- else
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql += " or 材质 is null";
- }
- else
- {
- sql += " or 材质 = '" + listBox2.Items[i].ToString() + "'";
- }
- }
+ filedValueList.Add(listBox2.Items[i].ToString());
}
- table = OledbHelper.QueryTable(sql);
-
-
+ ClassSearchAnalysis.ResultDataTableContainNull(out table, globeControl1,
+ comboBoxEx1.Text.Trim(), "材质", filedValueList);
+
if (table != null && table.Rows.Count > 0)
{
strLable = comboBoxEx1.Text + " 共有:" + table.Rows.Count + "个";
diff --git a/FrmQuerySQL.cs b/FrmQuerySQL.cs
index fcaabad..4260509 100644
--- a/FrmQuerySQL.cs
+++ b/FrmQuerySQL.cs
@@ -17,17 +17,19 @@
public partial class FrmQuerySQL : DevComponents.DotNetBar.Office2007Form
{
private GSOGlobeControl m_globeControl;
- private DataGridViewX m_dataGridViewX;
private GSODataset ds;
string sql;
public string currentLayerName;
-
static FrmQuerySQL frm;
- public static void ShowForm(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ DataTable table = new DataTable();
+ string strLable = "";
+ MainFrm.DataGridViewDelegate m_InitDataGridViewX1;
+
+ public static void ShowForm(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
if (frm == null)
{
- frm = new FrmQuerySQL(_ctl, _dgv);
+ frm = new FrmQuerySQL(_ctl, InitDataGridViewX1);
frm.Show(_ctl.Parent);
}
else
@@ -39,14 +41,14 @@
}
}
- public FrmQuerySQL(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ public FrmQuerySQL(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
InitializeComponent();
m_globeControl = _ctl;
- m_dataGridViewX = _dgv;
+ m_InitDataGridViewX1 = InitDataGridViewX1;
}
- #region 符号
+ #region 符号按钮双击事件
private void btn_equal_Click(object sender, EventArgs e)
{
textBox_WhereClause.Text += " =";
@@ -190,9 +192,7 @@
}
}
- string sqltype = "select distinct " + listBox_Field.SelectedItem.ToString() + " from " + ds.Name +" order by "+listBox_Field.SelectedItem.ToString()+"";
-
- DataTable table = OledbHelper.QueryTable(sqltype);
+ ClassSearchAnalysis.ResultDistinctDataTable(table, cbox_Layers.SelectedItem.ToString(),listBox_Field.SelectedItem.ToString());
for (int i = 0; i < table.Rows.Count; i++)
{
@@ -231,7 +231,6 @@
///
private void btn_Apply_Click(object sender, EventArgs e)
{
- m_dataGridViewX.Visible = true;
string fields = "";
int itemCount = listBox_Field.Items.Count;
for (int i = 0; i < itemCount; i++)
@@ -257,47 +256,22 @@
sql += " where " + textBox_WhereClause.Text;
}
+ currentLayerName = cbox_Layers.SelectedItem.ToString();
+
try
{
this.Cursor = Cursors.WaitCursor;
- DataTable table = OledbHelper.QueryTable(sql);
+ table = OledbHelper.QueryTable(sql);
if (table == null)
{
this.Cursor = Cursors.Default;
- MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!","提示");
+ MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!", "提示");
return;
}
-
- currentLayerName = cbox_Layers.SelectedItem.ToString();
- m_dataGridViewX.DataSource = table;
-
- MainFrm frm = (MainFrm)this.Owner;
- //显示表格
-
- frm.expandableSplitter2.Expanded = true;
- frm.panelOfTable.Visible = true;
-
- int count = m_dataGridViewX.Rows.Count;
- if (count != 0)
- {
- if (currentLayerName.Contains("管线"))
- {
- double featurelength = frm.PipeLength(currentLayerName, 0);// 统计管线的里程数
- frm.statusStrip2.Items[0].Text = " 管线类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录";
- frm.statusStrip2.Items[1].Text = " 管线里程:" + featurelength.ToString("0.00") + " 米";
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录"; ;
-
- frm.statusStrip2.Items[1].Text = " ";
- }
- MainFrm.m_CurrentQueryLayer = currentLayerName;
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 管线类型: " + currentLayerName + "|| 共有:" + 0 + " 条记录 || ";
+ else {
+ strLable = currentLayerName + " || 共有:" + table.Rows.Count + "条记录";
+ m_InitDataGridViewX1(table, strLable, currentLayerName, true);
}
this.Cursor = Cursors.Default;
@@ -359,13 +333,7 @@
///
private void Frm_QuerySQL_FormClosing(object sender, FormClosingEventArgs e)
{
- MainFrm mfrm = (MainFrm)this.Owner;
- mfrm.panelOfTable.Visible = false;
- mfrm.statusStrip2.Items[0].Text = " 类型:";
- mfrm.statusStrip2.Items[1].Text = " ";
- m_dataGridViewX.DataSource = null;
- m_dataGridViewX.Refresh();
-
+ m_InitDataGridViewX1(table, strLable, "", false);
frm = null;
}
}
diff --git a/FrmSetLatLonPos.cs b/FrmSetLatLonPos.cs
index d3dca83..0636619 100644
--- a/FrmSetLatLonPos.cs
+++ b/FrmSetLatLonPos.cs
@@ -129,13 +129,7 @@
textBox3.Text = "";
return;
}
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = m_strLon;
- //point3d.Y = m_strLat;
- //point3d.Z = m_strAlt;
-
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = m_strLon;
cameraState.Latitude = m_strLat;
@@ -209,12 +203,6 @@
textBox6.Text = "";
return;
}
-
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = result.X;
- //point3d.Y = result.Y;
- //point3d.Z = m_strAlt;
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = result.X;
cameraState.Latitude = result.Y;
diff --git a/MainFrm.cs b/MainFrm.cs
index 2df3aac..7a8dcd2 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -10124,7 +10124,7 @@
//日志记录
LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text);
- FrmQuerySQL.ShowForm(globeControl1, dataGridViewX1);
+ FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1));
}
///
/// 关联查询
diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe
index 325ce46..44feaae 100644
--- a/bin/x86/Debug/Cyberpipe.exe
+++ b/bin/x86/Debug/Cyberpipe.exe
Binary files differ
diff --git a/ClassSearchAnalysis.cs b/ClassSearchAnalysis.cs
index 5a6308c..61f667e 100644
--- a/ClassSearchAnalysis.cs
+++ b/ClassSearchAnalysis.cs
@@ -69,6 +69,74 @@
return dt;
}
///
+ /// SQL查询不重复的值
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinctDataTable(out DataTable dt,string layerName,string filedObject)
+ {
+ string sql = "select distinct "+filedObject+" from " + layerName;
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
+ /// SQL查询不重复的值+排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinceDataTableOrder(out DataTable dt, string layerName, string filedObject)
+ {
+
+ }
+ ///
+ /// SQL查询,返回包含NULL的Table
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDataTableContainNull(out DataTable dt,GSOGlobeControl m_globeControl,
+ string layerName,string filedObject,List filedValueList)
+ {
+ string sql = "select " + getpipeLineFields.getFields(layerName, m_globeControl)
+ + " from " + layerName + " where " + filedObject + " = '";
+
+ for (int i = 0; i < filedValueList.Count; i++)
+ {
+ if (i == 0)
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql = sql.Replace("= '", "is null");
+ }
+ else
+ {
+ sql += filedValueList[i].ToString() + "' ";
+ }
+ }
+ else
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql += " or 材质 is null";
+ }
+ else
+ {
+ sql += " or 材质 = '" + filedValueList[i].ToString() + "'";
+ }
+ }
+ }
+
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
/// 关联查询
///
///
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index a9a1898..221e34d 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/FrmMaterialSel.cs b/FrmMaterialSel.cs
index 03af994..a42bfb0 100644
--- a/FrmMaterialSel.cs
+++ b/FrmMaterialSel.cs
@@ -72,8 +72,9 @@
MessageBox.Show("图层不存在", "提示");
return;
}
- string sql = "select distinct 材质 from " + layer.Name;
- DataTable table = OledbHelper.QueryTable(sql);
+
+ ClassSearchAnalysis.ResultDistinctDataTable(out table, layer.Name, "材质");
+
if (table.Rows.Count > 0)
{
listBox1.Items.Clear();
@@ -138,38 +139,15 @@
MessageBox.Show("图层不存在", "提示");
return;
}
-
- string sql = "select " + getpipeLineFields.getFields(comboBoxEx1.Text, globeControl1)
- + " from " + layer.Name + " where 材质 = '";
+ List filedValueList = new List();
for (int i = 0; i < listBox2.Items.Count; i++)
{
- if (i == 0)
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql =sql.Replace("= '","is null");
- }
- else
- {
- sql += listBox2.Items[i].ToString() + "' ";
- }
- }
- else
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql += " or 材质 is null";
- }
- else
- {
- sql += " or 材质 = '" + listBox2.Items[i].ToString() + "'";
- }
- }
+ filedValueList.Add(listBox2.Items[i].ToString());
}
- table = OledbHelper.QueryTable(sql);
-
-
+ ClassSearchAnalysis.ResultDataTableContainNull(out table, globeControl1,
+ comboBoxEx1.Text.Trim(), "材质", filedValueList);
+
if (table != null && table.Rows.Count > 0)
{
strLable = comboBoxEx1.Text + " 共有:" + table.Rows.Count + "个";
diff --git a/FrmQuerySQL.cs b/FrmQuerySQL.cs
index fcaabad..4260509 100644
--- a/FrmQuerySQL.cs
+++ b/FrmQuerySQL.cs
@@ -17,17 +17,19 @@
public partial class FrmQuerySQL : DevComponents.DotNetBar.Office2007Form
{
private GSOGlobeControl m_globeControl;
- private DataGridViewX m_dataGridViewX;
private GSODataset ds;
string sql;
public string currentLayerName;
-
static FrmQuerySQL frm;
- public static void ShowForm(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ DataTable table = new DataTable();
+ string strLable = "";
+ MainFrm.DataGridViewDelegate m_InitDataGridViewX1;
+
+ public static void ShowForm(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
if (frm == null)
{
- frm = new FrmQuerySQL(_ctl, _dgv);
+ frm = new FrmQuerySQL(_ctl, InitDataGridViewX1);
frm.Show(_ctl.Parent);
}
else
@@ -39,14 +41,14 @@
}
}
- public FrmQuerySQL(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ public FrmQuerySQL(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
InitializeComponent();
m_globeControl = _ctl;
- m_dataGridViewX = _dgv;
+ m_InitDataGridViewX1 = InitDataGridViewX1;
}
- #region 符号
+ #region 符号按钮双击事件
private void btn_equal_Click(object sender, EventArgs e)
{
textBox_WhereClause.Text += " =";
@@ -190,9 +192,7 @@
}
}
- string sqltype = "select distinct " + listBox_Field.SelectedItem.ToString() + " from " + ds.Name +" order by "+listBox_Field.SelectedItem.ToString()+"";
-
- DataTable table = OledbHelper.QueryTable(sqltype);
+ ClassSearchAnalysis.ResultDistinctDataTable(table, cbox_Layers.SelectedItem.ToString(),listBox_Field.SelectedItem.ToString());
for (int i = 0; i < table.Rows.Count; i++)
{
@@ -231,7 +231,6 @@
///
private void btn_Apply_Click(object sender, EventArgs e)
{
- m_dataGridViewX.Visible = true;
string fields = "";
int itemCount = listBox_Field.Items.Count;
for (int i = 0; i < itemCount; i++)
@@ -257,47 +256,22 @@
sql += " where " + textBox_WhereClause.Text;
}
+ currentLayerName = cbox_Layers.SelectedItem.ToString();
+
try
{
this.Cursor = Cursors.WaitCursor;
- DataTable table = OledbHelper.QueryTable(sql);
+ table = OledbHelper.QueryTable(sql);
if (table == null)
{
this.Cursor = Cursors.Default;
- MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!","提示");
+ MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!", "提示");
return;
}
-
- currentLayerName = cbox_Layers.SelectedItem.ToString();
- m_dataGridViewX.DataSource = table;
-
- MainFrm frm = (MainFrm)this.Owner;
- //显示表格
-
- frm.expandableSplitter2.Expanded = true;
- frm.panelOfTable.Visible = true;
-
- int count = m_dataGridViewX.Rows.Count;
- if (count != 0)
- {
- if (currentLayerName.Contains("管线"))
- {
- double featurelength = frm.PipeLength(currentLayerName, 0);// 统计管线的里程数
- frm.statusStrip2.Items[0].Text = " 管线类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录";
- frm.statusStrip2.Items[1].Text = " 管线里程:" + featurelength.ToString("0.00") + " 米";
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录"; ;
-
- frm.statusStrip2.Items[1].Text = " ";
- }
- MainFrm.m_CurrentQueryLayer = currentLayerName;
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 管线类型: " + currentLayerName + "|| 共有:" + 0 + " 条记录 || ";
+ else {
+ strLable = currentLayerName + " || 共有:" + table.Rows.Count + "条记录";
+ m_InitDataGridViewX1(table, strLable, currentLayerName, true);
}
this.Cursor = Cursors.Default;
@@ -359,13 +333,7 @@
///
private void Frm_QuerySQL_FormClosing(object sender, FormClosingEventArgs e)
{
- MainFrm mfrm = (MainFrm)this.Owner;
- mfrm.panelOfTable.Visible = false;
- mfrm.statusStrip2.Items[0].Text = " 类型:";
- mfrm.statusStrip2.Items[1].Text = " ";
- m_dataGridViewX.DataSource = null;
- m_dataGridViewX.Refresh();
-
+ m_InitDataGridViewX1(table, strLable, "", false);
frm = null;
}
}
diff --git a/FrmSetLatLonPos.cs b/FrmSetLatLonPos.cs
index d3dca83..0636619 100644
--- a/FrmSetLatLonPos.cs
+++ b/FrmSetLatLonPos.cs
@@ -129,13 +129,7 @@
textBox3.Text = "";
return;
}
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = m_strLon;
- //point3d.Y = m_strLat;
- //point3d.Z = m_strAlt;
-
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = m_strLon;
cameraState.Latitude = m_strLat;
@@ -209,12 +203,6 @@
textBox6.Text = "";
return;
}
-
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = result.X;
- //point3d.Y = result.Y;
- //point3d.Z = m_strAlt;
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = result.X;
cameraState.Latitude = result.Y;
diff --git a/MainFrm.cs b/MainFrm.cs
index 2df3aac..7a8dcd2 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -10124,7 +10124,7 @@
//日志记录
LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text);
- FrmQuerySQL.ShowForm(globeControl1, dataGridViewX1);
+ FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1));
}
///
/// 关联查询
diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe
index 325ce46..44feaae 100644
--- a/bin/x86/Debug/Cyberpipe.exe
+++ b/bin/x86/Debug/Cyberpipe.exe
Binary files differ
diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb
index c66f40d..8516cd3 100644
--- a/bin/x86/Debug/Cyberpipe.pdb
+++ b/bin/x86/Debug/Cyberpipe.pdb
Binary files differ
diff --git a/ClassSearchAnalysis.cs b/ClassSearchAnalysis.cs
index 5a6308c..61f667e 100644
--- a/ClassSearchAnalysis.cs
+++ b/ClassSearchAnalysis.cs
@@ -69,6 +69,74 @@
return dt;
}
///
+ /// SQL查询不重复的值
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinctDataTable(out DataTable dt,string layerName,string filedObject)
+ {
+ string sql = "select distinct "+filedObject+" from " + layerName;
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
+ /// SQL查询不重复的值+排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinceDataTableOrder(out DataTable dt, string layerName, string filedObject)
+ {
+
+ }
+ ///
+ /// SQL查询,返回包含NULL的Table
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDataTableContainNull(out DataTable dt,GSOGlobeControl m_globeControl,
+ string layerName,string filedObject,List filedValueList)
+ {
+ string sql = "select " + getpipeLineFields.getFields(layerName, m_globeControl)
+ + " from " + layerName + " where " + filedObject + " = '";
+
+ for (int i = 0; i < filedValueList.Count; i++)
+ {
+ if (i == 0)
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql = sql.Replace("= '", "is null");
+ }
+ else
+ {
+ sql += filedValueList[i].ToString() + "' ";
+ }
+ }
+ else
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql += " or 材质 is null";
+ }
+ else
+ {
+ sql += " or 材质 = '" + filedValueList[i].ToString() + "'";
+ }
+ }
+ }
+
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
/// 关联查询
///
///
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index a9a1898..221e34d 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/FrmMaterialSel.cs b/FrmMaterialSel.cs
index 03af994..a42bfb0 100644
--- a/FrmMaterialSel.cs
+++ b/FrmMaterialSel.cs
@@ -72,8 +72,9 @@
MessageBox.Show("图层不存在", "提示");
return;
}
- string sql = "select distinct 材质 from " + layer.Name;
- DataTable table = OledbHelper.QueryTable(sql);
+
+ ClassSearchAnalysis.ResultDistinctDataTable(out table, layer.Name, "材质");
+
if (table.Rows.Count > 0)
{
listBox1.Items.Clear();
@@ -138,38 +139,15 @@
MessageBox.Show("图层不存在", "提示");
return;
}
-
- string sql = "select " + getpipeLineFields.getFields(comboBoxEx1.Text, globeControl1)
- + " from " + layer.Name + " where 材质 = '";
+ List filedValueList = new List();
for (int i = 0; i < listBox2.Items.Count; i++)
{
- if (i == 0)
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql =sql.Replace("= '","is null");
- }
- else
- {
- sql += listBox2.Items[i].ToString() + "' ";
- }
- }
- else
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql += " or 材质 is null";
- }
- else
- {
- sql += " or 材质 = '" + listBox2.Items[i].ToString() + "'";
- }
- }
+ filedValueList.Add(listBox2.Items[i].ToString());
}
- table = OledbHelper.QueryTable(sql);
-
-
+ ClassSearchAnalysis.ResultDataTableContainNull(out table, globeControl1,
+ comboBoxEx1.Text.Trim(), "材质", filedValueList);
+
if (table != null && table.Rows.Count > 0)
{
strLable = comboBoxEx1.Text + " 共有:" + table.Rows.Count + "个";
diff --git a/FrmQuerySQL.cs b/FrmQuerySQL.cs
index fcaabad..4260509 100644
--- a/FrmQuerySQL.cs
+++ b/FrmQuerySQL.cs
@@ -17,17 +17,19 @@
public partial class FrmQuerySQL : DevComponents.DotNetBar.Office2007Form
{
private GSOGlobeControl m_globeControl;
- private DataGridViewX m_dataGridViewX;
private GSODataset ds;
string sql;
public string currentLayerName;
-
static FrmQuerySQL frm;
- public static void ShowForm(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ DataTable table = new DataTable();
+ string strLable = "";
+ MainFrm.DataGridViewDelegate m_InitDataGridViewX1;
+
+ public static void ShowForm(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
if (frm == null)
{
- frm = new FrmQuerySQL(_ctl, _dgv);
+ frm = new FrmQuerySQL(_ctl, InitDataGridViewX1);
frm.Show(_ctl.Parent);
}
else
@@ -39,14 +41,14 @@
}
}
- public FrmQuerySQL(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ public FrmQuerySQL(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
InitializeComponent();
m_globeControl = _ctl;
- m_dataGridViewX = _dgv;
+ m_InitDataGridViewX1 = InitDataGridViewX1;
}
- #region 符号
+ #region 符号按钮双击事件
private void btn_equal_Click(object sender, EventArgs e)
{
textBox_WhereClause.Text += " =";
@@ -190,9 +192,7 @@
}
}
- string sqltype = "select distinct " + listBox_Field.SelectedItem.ToString() + " from " + ds.Name +" order by "+listBox_Field.SelectedItem.ToString()+"";
-
- DataTable table = OledbHelper.QueryTable(sqltype);
+ ClassSearchAnalysis.ResultDistinctDataTable(table, cbox_Layers.SelectedItem.ToString(),listBox_Field.SelectedItem.ToString());
for (int i = 0; i < table.Rows.Count; i++)
{
@@ -231,7 +231,6 @@
///
private void btn_Apply_Click(object sender, EventArgs e)
{
- m_dataGridViewX.Visible = true;
string fields = "";
int itemCount = listBox_Field.Items.Count;
for (int i = 0; i < itemCount; i++)
@@ -257,47 +256,22 @@
sql += " where " + textBox_WhereClause.Text;
}
+ currentLayerName = cbox_Layers.SelectedItem.ToString();
+
try
{
this.Cursor = Cursors.WaitCursor;
- DataTable table = OledbHelper.QueryTable(sql);
+ table = OledbHelper.QueryTable(sql);
if (table == null)
{
this.Cursor = Cursors.Default;
- MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!","提示");
+ MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!", "提示");
return;
}
-
- currentLayerName = cbox_Layers.SelectedItem.ToString();
- m_dataGridViewX.DataSource = table;
-
- MainFrm frm = (MainFrm)this.Owner;
- //显示表格
-
- frm.expandableSplitter2.Expanded = true;
- frm.panelOfTable.Visible = true;
-
- int count = m_dataGridViewX.Rows.Count;
- if (count != 0)
- {
- if (currentLayerName.Contains("管线"))
- {
- double featurelength = frm.PipeLength(currentLayerName, 0);// 统计管线的里程数
- frm.statusStrip2.Items[0].Text = " 管线类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录";
- frm.statusStrip2.Items[1].Text = " 管线里程:" + featurelength.ToString("0.00") + " 米";
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录"; ;
-
- frm.statusStrip2.Items[1].Text = " ";
- }
- MainFrm.m_CurrentQueryLayer = currentLayerName;
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 管线类型: " + currentLayerName + "|| 共有:" + 0 + " 条记录 || ";
+ else {
+ strLable = currentLayerName + " || 共有:" + table.Rows.Count + "条记录";
+ m_InitDataGridViewX1(table, strLable, currentLayerName, true);
}
this.Cursor = Cursors.Default;
@@ -359,13 +333,7 @@
///
private void Frm_QuerySQL_FormClosing(object sender, FormClosingEventArgs e)
{
- MainFrm mfrm = (MainFrm)this.Owner;
- mfrm.panelOfTable.Visible = false;
- mfrm.statusStrip2.Items[0].Text = " 类型:";
- mfrm.statusStrip2.Items[1].Text = " ";
- m_dataGridViewX.DataSource = null;
- m_dataGridViewX.Refresh();
-
+ m_InitDataGridViewX1(table, strLable, "", false);
frm = null;
}
}
diff --git a/FrmSetLatLonPos.cs b/FrmSetLatLonPos.cs
index d3dca83..0636619 100644
--- a/FrmSetLatLonPos.cs
+++ b/FrmSetLatLonPos.cs
@@ -129,13 +129,7 @@
textBox3.Text = "";
return;
}
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = m_strLon;
- //point3d.Y = m_strLat;
- //point3d.Z = m_strAlt;
-
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = m_strLon;
cameraState.Latitude = m_strLat;
@@ -209,12 +203,6 @@
textBox6.Text = "";
return;
}
-
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = result.X;
- //point3d.Y = result.Y;
- //point3d.Z = m_strAlt;
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = result.X;
cameraState.Latitude = result.Y;
diff --git a/MainFrm.cs b/MainFrm.cs
index 2df3aac..7a8dcd2 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -10124,7 +10124,7 @@
//日志记录
LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text);
- FrmQuerySQL.ShowForm(globeControl1, dataGridViewX1);
+ FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1));
}
///
/// 关联查询
diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe
index 325ce46..44feaae 100644
--- a/bin/x86/Debug/Cyberpipe.exe
+++ b/bin/x86/Debug/Cyberpipe.exe
Binary files differ
diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb
index c66f40d..8516cd3 100644
--- a/bin/x86/Debug/Cyberpipe.pdb
+++ b/bin/x86/Debug/Cyberpipe.pdb
Binary files differ
diff --git a/obj/x64/Debug/Cyberpipe.exe b/obj/x64/Debug/Cyberpipe.exe
index 325ce46..44feaae 100644
--- a/obj/x64/Debug/Cyberpipe.exe
+++ b/obj/x64/Debug/Cyberpipe.exe
Binary files differ
diff --git a/ClassSearchAnalysis.cs b/ClassSearchAnalysis.cs
index 5a6308c..61f667e 100644
--- a/ClassSearchAnalysis.cs
+++ b/ClassSearchAnalysis.cs
@@ -69,6 +69,74 @@
return dt;
}
///
+ /// SQL查询不重复的值
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinctDataTable(out DataTable dt,string layerName,string filedObject)
+ {
+ string sql = "select distinct "+filedObject+" from " + layerName;
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
+ /// SQL查询不重复的值+排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDistinceDataTableOrder(out DataTable dt, string layerName, string filedObject)
+ {
+
+ }
+ ///
+ /// SQL查询,返回包含NULL的Table
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static DataTable ResultDataTableContainNull(out DataTable dt,GSOGlobeControl m_globeControl,
+ string layerName,string filedObject,List filedValueList)
+ {
+ string sql = "select " + getpipeLineFields.getFields(layerName, m_globeControl)
+ + " from " + layerName + " where " + filedObject + " = '";
+
+ for (int i = 0; i < filedValueList.Count; i++)
+ {
+ if (i == 0)
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql = sql.Replace("= '", "is null");
+ }
+ else
+ {
+ sql += filedValueList[i].ToString() + "' ";
+ }
+ }
+ else
+ {
+ if (filedValueList[i].ToString() == "无")
+ {
+ sql += " or 材质 is null";
+ }
+ else
+ {
+ sql += " or 材质 = '" + filedValueList[i].ToString() + "'";
+ }
+ }
+ }
+
+ dt = OledbHelper.QueryTable(sql);
+ return dt;
+ }
+ ///
/// 关联查询
///
///
diff --git a/Cyberpipe.suo b/Cyberpipe.suo
index a9a1898..221e34d 100644
--- a/Cyberpipe.suo
+++ b/Cyberpipe.suo
Binary files differ
diff --git a/FrmMaterialSel.cs b/FrmMaterialSel.cs
index 03af994..a42bfb0 100644
--- a/FrmMaterialSel.cs
+++ b/FrmMaterialSel.cs
@@ -72,8 +72,9 @@
MessageBox.Show("图层不存在", "提示");
return;
}
- string sql = "select distinct 材质 from " + layer.Name;
- DataTable table = OledbHelper.QueryTable(sql);
+
+ ClassSearchAnalysis.ResultDistinctDataTable(out table, layer.Name, "材质");
+
if (table.Rows.Count > 0)
{
listBox1.Items.Clear();
@@ -138,38 +139,15 @@
MessageBox.Show("图层不存在", "提示");
return;
}
-
- string sql = "select " + getpipeLineFields.getFields(comboBoxEx1.Text, globeControl1)
- + " from " + layer.Name + " where 材质 = '";
+ List filedValueList = new List();
for (int i = 0; i < listBox2.Items.Count; i++)
{
- if (i == 0)
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql =sql.Replace("= '","is null");
- }
- else
- {
- sql += listBox2.Items[i].ToString() + "' ";
- }
- }
- else
- {
- if (listBox2.Items[i].ToString() == "无")
- {
- sql += " or 材质 is null";
- }
- else
- {
- sql += " or 材质 = '" + listBox2.Items[i].ToString() + "'";
- }
- }
+ filedValueList.Add(listBox2.Items[i].ToString());
}
- table = OledbHelper.QueryTable(sql);
-
-
+ ClassSearchAnalysis.ResultDataTableContainNull(out table, globeControl1,
+ comboBoxEx1.Text.Trim(), "材质", filedValueList);
+
if (table != null && table.Rows.Count > 0)
{
strLable = comboBoxEx1.Text + " 共有:" + table.Rows.Count + "个";
diff --git a/FrmQuerySQL.cs b/FrmQuerySQL.cs
index fcaabad..4260509 100644
--- a/FrmQuerySQL.cs
+++ b/FrmQuerySQL.cs
@@ -17,17 +17,19 @@
public partial class FrmQuerySQL : DevComponents.DotNetBar.Office2007Form
{
private GSOGlobeControl m_globeControl;
- private DataGridViewX m_dataGridViewX;
private GSODataset ds;
string sql;
public string currentLayerName;
-
static FrmQuerySQL frm;
- public static void ShowForm(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ DataTable table = new DataTable();
+ string strLable = "";
+ MainFrm.DataGridViewDelegate m_InitDataGridViewX1;
+
+ public static void ShowForm(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
if (frm == null)
{
- frm = new FrmQuerySQL(_ctl, _dgv);
+ frm = new FrmQuerySQL(_ctl, InitDataGridViewX1);
frm.Show(_ctl.Parent);
}
else
@@ -39,14 +41,14 @@
}
}
- public FrmQuerySQL(GSOGlobeControl _ctl, DataGridViewX _dgv)
+ public FrmQuerySQL(GSOGlobeControl _ctl, MainFrm.DataGridViewDelegate InitDataGridViewX1)
{
InitializeComponent();
m_globeControl = _ctl;
- m_dataGridViewX = _dgv;
+ m_InitDataGridViewX1 = InitDataGridViewX1;
}
- #region 符号
+ #region 符号按钮双击事件
private void btn_equal_Click(object sender, EventArgs e)
{
textBox_WhereClause.Text += " =";
@@ -190,9 +192,7 @@
}
}
- string sqltype = "select distinct " + listBox_Field.SelectedItem.ToString() + " from " + ds.Name +" order by "+listBox_Field.SelectedItem.ToString()+"";
-
- DataTable table = OledbHelper.QueryTable(sqltype);
+ ClassSearchAnalysis.ResultDistinctDataTable(table, cbox_Layers.SelectedItem.ToString(),listBox_Field.SelectedItem.ToString());
for (int i = 0; i < table.Rows.Count; i++)
{
@@ -231,7 +231,6 @@
///
private void btn_Apply_Click(object sender, EventArgs e)
{
- m_dataGridViewX.Visible = true;
string fields = "";
int itemCount = listBox_Field.Items.Count;
for (int i = 0; i < itemCount; i++)
@@ -257,47 +256,22 @@
sql += " where " + textBox_WhereClause.Text;
}
+ currentLayerName = cbox_Layers.SelectedItem.ToString();
+
try
{
this.Cursor = Cursors.WaitCursor;
- DataTable table = OledbHelper.QueryTable(sql);
+ table = OledbHelper.QueryTable(sql);
if (table == null)
{
this.Cursor = Cursors.Default;
- MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!","提示");
+ MessageBox.Show("sql语句不合法或者没有查询到符合条件的数据!", "提示");
return;
}
-
- currentLayerName = cbox_Layers.SelectedItem.ToString();
- m_dataGridViewX.DataSource = table;
-
- MainFrm frm = (MainFrm)this.Owner;
- //显示表格
-
- frm.expandableSplitter2.Expanded = true;
- frm.panelOfTable.Visible = true;
-
- int count = m_dataGridViewX.Rows.Count;
- if (count != 0)
- {
- if (currentLayerName.Contains("管线"))
- {
- double featurelength = frm.PipeLength(currentLayerName, 0);// 统计管线的里程数
- frm.statusStrip2.Items[0].Text = " 管线类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录";
- frm.statusStrip2.Items[1].Text = " 管线里程:" + featurelength.ToString("0.00") + " 米";
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 类型:" + currentLayerName + " || 共有:" + Convert.ToString(count) + "条记录"; ;
-
- frm.statusStrip2.Items[1].Text = " ";
- }
- MainFrm.m_CurrentQueryLayer = currentLayerName;
- }
- else
- {
- frm.statusStrip2.Items[0].Text = " 管线类型: " + currentLayerName + "|| 共有:" + 0 + " 条记录 || ";
+ else {
+ strLable = currentLayerName + " || 共有:" + table.Rows.Count + "条记录";
+ m_InitDataGridViewX1(table, strLable, currentLayerName, true);
}
this.Cursor = Cursors.Default;
@@ -359,13 +333,7 @@
///
private void Frm_QuerySQL_FormClosing(object sender, FormClosingEventArgs e)
{
- MainFrm mfrm = (MainFrm)this.Owner;
- mfrm.panelOfTable.Visible = false;
- mfrm.statusStrip2.Items[0].Text = " 类型:";
- mfrm.statusStrip2.Items[1].Text = " ";
- m_dataGridViewX.DataSource = null;
- m_dataGridViewX.Refresh();
-
+ m_InitDataGridViewX1(table, strLable, "", false);
frm = null;
}
}
diff --git a/FrmSetLatLonPos.cs b/FrmSetLatLonPos.cs
index d3dca83..0636619 100644
--- a/FrmSetLatLonPos.cs
+++ b/FrmSetLatLonPos.cs
@@ -129,13 +129,7 @@
textBox3.Text = "";
return;
}
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = m_strLon;
- //point3d.Y = m_strLat;
- //point3d.Z = m_strAlt;
-
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = m_strLon;
cameraState.Latitude = m_strLat;
@@ -209,12 +203,6 @@
textBox6.Text = "";
return;
}
-
- //GSOPoint3d point3d = new GSOPoint3d();
- //point3d.X = result.X;
- //point3d.Y = result.Y;
- //point3d.Z = m_strAlt;
- //globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
GSOCameraState cameraState = new GSOCameraState();
cameraState.Longitude = result.X;
cameraState.Latitude = result.Y;
diff --git a/MainFrm.cs b/MainFrm.cs
index 2df3aac..7a8dcd2 100644
--- a/MainFrm.cs
+++ b/MainFrm.cs
@@ -10124,7 +10124,7 @@
//日志记录
LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text);
- FrmQuerySQL.ShowForm(globeControl1, dataGridViewX1);
+ FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1));
}
///
/// 关联查询
diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe
index 325ce46..44feaae 100644
--- a/bin/x86/Debug/Cyberpipe.exe
+++ b/bin/x86/Debug/Cyberpipe.exe
Binary files differ
diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb
index c66f40d..8516cd3 100644
--- a/bin/x86/Debug/Cyberpipe.pdb
+++ b/bin/x86/Debug/Cyberpipe.pdb
Binary files differ
diff --git a/obj/x64/Debug/Cyberpipe.exe b/obj/x64/Debug/Cyberpipe.exe
index 325ce46..44feaae 100644
--- a/obj/x64/Debug/Cyberpipe.exe
+++ b/obj/x64/Debug/Cyberpipe.exe
Binary files differ
diff --git a/obj/x64/Debug/Cyberpipe.pdb b/obj/x64/Debug/Cyberpipe.pdb
index c66f40d..8516cd3 100644
--- a/obj/x64/Debug/Cyberpipe.pdb
+++ b/obj/x64/Debug/Cyberpipe.pdb
Binary files differ