Newer
Older
GHFX_REFACTOR / FrmCodingQuery.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using GeoScene.Globe;

namespace Cyberpipe
{
    public partial class FrmCodingQuery : Office2007Form
    {
        GSOGlobeControl globeControl1;
        List<string> layerNames = new List<string>();
        private MainFrm.DataGridViewDelegate m_InitDataGridViewX1;
        static FrmCodingQuery frm;
        string strLable = "";
        DataTable table = new DataTable();

        public static void ShowForm(GSOGlobeControl _ctl, List<string> _list, MainFrm.DataGridViewDelegate InitDataGridViewX1)
        {
            if (frm == null)
            {
                frm = new FrmCodingQuery(_ctl, _list, InitDataGridViewX1);
                frm.Show(_ctl.Parent);
            }
            else
            {
                if (frm.WindowState == FormWindowState.Minimized)
                {
                    frm.WindowState = FormWindowState.Normal;
                }
            }
        }

        public FrmCodingQuery(GSOGlobeControl _ctl, List<string> _list, MainFrm.DataGridViewDelegate InitDataGridViewX1)
        {
            InitializeComponent();
            globeControl1 = _ctl;
            layerNames = _list;
            m_InitDataGridViewX1 = InitDataGridViewX1;
        }

        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)
        {
            m_InitDataGridViewX1(table, strLable, "", false);
            frm = null;
        }

        private void buttonX1_Click(object sender, EventArgs e)//查询
        {
            try
            {
                if (comboBoxEx1.SelectedIndex == -1)
                {
                    MessageBox.Show("请选择管线图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx1.Text.Trim());
                if (layer == null || textBoxX1.Text == "")
                {
                    MessageBox.Show("请输入查询条件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                ClassSearchAnalysis.ResultDataTable(out table, globeControl1, comboBoxEx1.Text.Trim(), "编号", textBoxX1.Text);
                if (table != null && table.Rows.Count > 0)
                {
                    strLable = comboBoxEx1.Text + "共有:" + table.Rows.Count + "条";
                    m_InitDataGridViewX1(table, strLable, comboBoxEx1.Text, true);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
//                LogHelper.WriteLog(typeof(FrmCodingQuery), ex.Message);
                LogHelper.Error(ex.Message);
            }
        }


        private void buttonX2_Click(object sender, EventArgs e)//取消
        {
            Close();
        }

    }
}