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 FrmFittingQuery : Office2007Form { GSOGlobeControl globeControl1; List<string> layerNames = new List<string>(); DevComponents.DotNetBar.Controls.DataGridViewX dataGridView1; PanelEx panel; ToolStripStatusLabel toolStripNumbers; ToolStripStatusLabel toolStripFeatureLength; static FrmFittingQuery 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 FrmFittingQuery(_ctl, _list, _datagridview, p, t1, t2); frm.Show(_ctl.Parent); } else { if (frm.WindowState == FormWindowState.Minimized) { frm.WindowState = FormWindowState.Normal; } } } public FrmFittingQuery(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; } /// <summary> /// 查询按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX1_Click(object sender, EventArgs e) { if (comboBoxEx1.Text != "") { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx1.Text.Trim()); if (layer != null) { string sql = "select " + getpipeLineFields.getFields(comboBoxEx1.Text, globeControl1) + " from " + layer.Name; 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; } //this.Close(); } } else { MessageBox.Show("请选择图层!","提示"); } } /// <summary> /// 窗体初始化事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmFittingQuery_Load(object sender, EventArgs e) { for (int i = 0; i < layerNames.Count; i++) { comboBoxEx1.Items.Add(layerNames[i]); } } /// <summary> /// 取消按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX3_Click(object sender, EventArgs e) { Close(); } /// <summary> /// 窗体关闭事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmFittingQuery_FormClosing(object sender, FormClosingEventArgs e) { dataGridView1.DataSource = null; dataGridView1.Refresh(); panel.Visible = false; toolStripNumbers.Text = " 类型:"; toolStripFeatureLength.Text = " 管线里程:"; frm = null; } } }