using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; using GeoScene.Globe; namespace Cyberpipe { public partial class FrmCodingQuery : Office2007Form { GSOGlobeControl globeControl1; List<string> layerNames = new List<string>(); DevComponents.DotNetBar.Controls.DataGridViewX dataGridView1; PanelEx panel; ToolStripStatusLabel toolStripNumbers; ToolStripStatusLabel toolStripFeatureLength; int value = 0; static FrmCodingQuery frm; public static void ShowForm(GSOGlobeControl _ctl, List<string> _list, DevComponents.DotNetBar.Controls.DataGridViewX _datagridview, PanelEx p, ToolStripStatusLabel t1, ToolStripStatusLabel t2) { if (frm == null) { frm = new FrmCodingQuery(_ctl, _list, _datagridview, p, t1, t2); frm.Show(_ctl.Parent); } else { if (frm.WindowState == FormWindowState.Minimized) { frm.WindowState = FormWindowState.Normal; } } } public FrmCodingQuery(GSOGlobeControl _ctl, List<string> _list, DevComponents.DotNetBar.Controls.DataGridViewX _datagridview, PanelEx p, ToolStripStatusLabel t1, ToolStripStatusLabel t2) { InitializeComponent(); globeControl1 = _ctl; layerNames = _list; dataGridView1 = _datagridview; panel = p; toolStripNumbers = t1; toolStripFeatureLength = t2; } private void FrmCodingQuery_Load(object sender, EventArgs e) { for (int i = 0; i < layerNames.Count; i++) { comboBoxEx1.Items.Add(layerNames[i]); } } private void FrmCodingQuery_Closing(object sender, FormClosingEventArgs e) { dataGridView1.DataSource = null; dataGridView1.Refresh(); panel.Visible = false; toolStripNumbers.Text = " 类型:"; toolStripFeatureLength.Text = " 管线里程:"; frm = null; } private void buttonX1_Click(object sender, EventArgs e)//查询 { if (comboBoxEx1.SelectedIndex == -1) { MessageBox.Show("请选择管线图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx1.Text.Trim()); if (layer == null) { MessageBox.Show("图层不存在", "提示"); return; } if (textBoxX1.Text == "" ) { MessageBox.Show("请输入管线编号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string sql = "select " + getpipeLineFields.getFields(comboBoxEx1.Text, globeControl1) + " from " + layer.Name + " where 编号 like " + "'%"+textBoxX1.Text+"%'"; DataTable table = OledbHelper.QueryTable(sql); if (table != null && table.Rows.Count > 0) { MainFrm.m_CurrentQueryLayer = comboBoxEx1.Text; dataGridView1.DataSource = table; panel.Visible = true; toolStripNumbers.Text = " 类型:" + comboBoxEx1.Text; toolStripFeatureLength.Text = " 共有:" + table.Rows.Count + "条"; } else { MessageBox.Show("没有查到符合条件的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); dataGridView1.DataSource = null; toolStripNumbers.Text = " 类型:"; toolStripFeatureLength.Text = " 管线里程:"; panel.Visible = false; } } private void buttonX2_Click(object sender, EventArgs e)//取消 { Close(); } } }