Newer
Older
GHFX_REFACTOR / Forms / FrmDianLiQuery.cs
wxn on 2 Nov 2016 7 KB 提交
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using GeoScene.Globe;
using System.Collections;
using GeoScene.Data;

namespace PipeLine.Forms
{
    public partial class FrmDianLiQuery : Office2007Form
    {
        private GSOGlobeControl globeControl1;
        private DevComponents.DotNetBar.Controls.DataGridViewX dataGridViewX1;
        private string pipeLineName = "电力管线";
        public FrmDianLiQuery(GSOGlobeControl ctl, DevComponents.DotNetBar.Controls.DataGridViewX d)
        {
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            InitializeComponent();
            globeControl1 = ctl;
            dataGridViewX1 = d;
        }

        private void btnSelDianli_Click(object sender, EventArgs e)
        {
            try
            {
                dataGridViewX1.Visible = true;
                string sql = "select " + Utility.Query_Fields["电力"] + " from " + pipeLineName + "";

                ArrayList filters = new ArrayList();

                if (combType.SelectedIndex > 0)
                {
                    string sql1 = " 埋设方式='" + combType.SelectedItem.ToString() + "'";
                    filters.Add(sql1);
                }

                if (combMaterial.SelectedIndex > 0)
                {
                    string sql2 = " 材质='" + combMaterial.SelectedItem.ToString() + "'";
                    filters.Add(sql2);
                }

                if (comboStart.SelectedIndex > 0)
                {
                    string sql10 = " 线路起点='" + comboStart.SelectedItem.ToString() + "'";
                    filters.Add(sql10);
                }

                if (comboEnd.SelectedIndex > 0)
                {
                    string sql11 = " 线路终点='" + comboEnd.SelectedItem.ToString() + "'";
                    filters.Add(sql11);
                }

                if (txtGuanJing.Text != "")
                {
                    string sql7 = " 管径_毫米=" + txtGuanJing.Text + "";
                    filters.Add(sql7);
                }

                if (combdianya.SelectedIndex > 0)
                {
                    string sql3 = " 电压='" + combdianya.SelectedItem.ToString() + "'";
                    filters.Add(sql3);
                }

                if (txtDeep1.Text != "")
                {
                    string sql4 = " 起始埋深>=" + txtDeep1.Text + "";
                    filters.Add(sql4);
                }

                if (txtDeep1.Text != "")
                {
                    string sql5 = "终止埋深>=" + txtDeep1.Text + "";
                    filters.Add(sql5);
                }

                if (combBuild1.SelectedItem != null && combBuild2.SelectedItem != null)
                {
                    string sql6 = "建设年代 between '" + combBuild1.SelectedItem.ToString() + "' and '" + combBuild2.SelectedItem.ToString() + "'";
                    filters.Add(sql6);
                }


                string[] aa = (string[])(filters.ToArray(typeof(string)));
                if (aa.Length > 0)
                    sql += " where " + string.Join(" and ", aa);


                DataTable table = OledbHelper.QueryTable(sql);
                dataGridViewX1.DataSource = table;
                dataGridViewX1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void FrmDianLiQuery_Load(object sender, EventArgs e)
        {
            dataGridViewX1.Visible = false;
            dataGridViewX1.ReadOnly = true;

            string sqltype = "select distinct 电压 from " + pipeLineName + "";
            DataTable table = OledbHelper.QueryTable(sqltype);
            combdianya.Items.Add("无");
            for (int i = 0; i < table.Rows.Count; i++)
            {
                DataRow dr = table.Rows[i];
                string colString1 = dr[0].ToString();
                if (colString1 == null || colString1.Trim() == "")
                    continue;
                combdianya.Items.Add(colString1);
            }

            string sqltype1 = "select distinct 材质 from " + pipeLineName + "";
            DataTable table1 = OledbHelper.QueryTable(sqltype1);
            combMaterial.Items.Add("无");
            for (int j = 0; j < table1.Rows.Count; j++)
            {
                DataRow dr = table1.Rows[j];
                string colString1 = dr[0].ToString();
                if (colString1 == null || colString1.Trim() == "")
                    continue;
                combMaterial.Items.Add(colString1);
            }

            string sqltype2 = "select distinct 埋设方式 from " + pipeLineName + "";
            DataTable table2 = OledbHelper.QueryTable(sqltype2);
            combType.Items.Add("无");
            for (int k = 0; k < table2.Rows.Count; k++)
            {
                DataRow dr = table2.Rows[k];
                string colString1 = dr[0].ToString();
                if (colString1 == null || colString1.Trim() == "")
                    continue;
                combType.Items.Add(colString1);
            }

            string sqltype3 = "select distinct 线路起点 from " + pipeLineName + "";
            DataTable table3 = OledbHelper.QueryTable(sqltype3);
            comboStart.Items.Add("无");
            for (int k = 0; k < table3.Rows.Count; k++)
            {
                DataRow dr = table3.Rows[k];
                string col = dr[0].ToString();
                if (col == null || col.Trim() == "")
                    continue;
                comboStart.Items.Add(col);
            }

            string sqltype4 = "select distinct 线路终点 from " + pipeLineName + "";
            DataTable table4 = OledbHelper.QueryTable(sqltype4);
            comboEnd.Items.Add("无");
            for (int k = 0; k < table4.Rows.Count; k++)
            {
                DataRow dr = table4.Rows[k];
                string col = dr[0].ToString();
                if (col == null || col.Trim() == "")
                    continue;
                comboEnd.Items.Add(col);
            }
        }
        GSOFeature feature;//当前处于选中的feature 

        private void FrmDianLiQuery_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (feature != null)
            {
                feature.HighLight = false;
            }
        }

        private void FlyToMenu_Click(object sender, EventArgs e)
        {
            if (feature != null)
            {
                globeControl1.Globe.FlyToFeature(feature);
            }
        }
        int count = 0;

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (count < 6)
            {
                count++;
                if (feature != null)
                {
                    if (count % 2 != 0)
                    {
                        feature.HighLight = true;
                        globeControl1.Refresh();
                    }
                    else
                    {
                        feature.HighLight = false;
                        globeControl1.Refresh();
                    }
                }
            }
            else
            {
                timer1.Stop();
                count = 0;
            }
        }

        private void LightMenu_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}