using System; using System.Data; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; using GeoScene.Globe; namespace Cyberpipe { public delegate void AddNodeToLayerManagerNode(GSOLayer layer); public partial class FrmCheckHistory : Office2007Form { public event AddNodeToLayerManagerNode addNode; private GSOGlobeControl globeControl1; private GSOGlobeControl globeControl2; private GSOFeature hlfeature; private int count; private int currentPage = 1; private int lastPage = 1; private int pageSize = 16; public static bool isOpen; public FrmCheckHistory(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { InitializeComponent(); initForm(); this.globeControl1 = globeControl1; this.globeControl2 = globeControl2; } private void FrmCheckHistory_Load(object sender, EventArgs e) { reloadGrid(currentPage); isOpen = true; } private void reloadGrid(int currentPage) { string sqlCount = "select count(*) from casic_audit_result t where 1=1 "; string sqlData = "select * from (select rownum as rowno,t.dbid," + "t.sh_layer," + "t.sh_no," + "t.wt_layer," + "t.wt_no," + "t.sh_staff," + "t.sh_time," + "t.distance," + "case t.kind " + "when 'H' then" + "'水平'" + "when 'V' then" + "'垂直'" + "else" + "'其他'" + "end as kind " + "from casic_audit_result t where 1=1 "; if (!String.IsNullOrEmpty(combo_layer.Text)) { sqlData += "and t.sh_layer='" + combo_layer.Text + "' "; sqlCount += "and t.sh_layer='" + combo_layer.Text + "' "; } if (!String.IsNullOrEmpty(combo_no.Text)) { sqlData += "and t.sh_no='" + combo_no.Text + "' "; sqlCount += "and t.sh_no='" + combo_no.Text + "' "; } if (!String.IsNullOrEmpty(combo_kind.Text)) { if ("垂直".Equals(combo_kind.Text)) { sqlData += "and kind='V' "; sqlCount += "and kind='V' "; } if ("水平".Equals(combo_kind.Text)) { sqlData += "and kind='H' "; sqlCount += "and kind='H' "; } } if (!String.IsNullOrEmpty(combo_staff.Text)) { sqlData += "and t.sh_staff='" + combo_staff.Text + "' "; sqlCount += "and t.sh_staff='" + combo_staff.Text + "' "; } sqlData += " and rownum<=" + (pageSize * currentPage) + ") table_alias where table_alias.rowno>=" + ((currentPage - 1) * pageSize + 1); int rows = OledbHelper.ExecuteScalar(sqlCount); if (rows % pageSize == 0) { lastPage = rows / 16; } else { lastPage = rows / 16 + 1; } lab_page_msg.Text = "第" + currentPage + "页,共" + lastPage + "页"; if (combo_page.Items.Count == 0) { for (int i = 1; i <= lastPage; i++) { combo_page.Items.Add(i); //combo_page.Items.Add(new ComboBoxItem(i.ToString(), i.ToString())); } } if (combo_page.Items.Count < lastPage) { for (int i = combo_page.Items.Count + 1; i < lastPage; i++) { combo_page.Items.Add(i); //combo_page.Items.Add(new ComboBoxItem(i.ToString(), i.ToString())); } } if (lastPage == 1) { btn_page_first.Enabled = false; btn_page_pre.Enabled = false; btn_page_next.Enabled = false; btn_page_last.Enabled = false; } else if (currentPage == 1) { btn_page_first.Enabled = false; btn_page_pre.Enabled = false; btn_page_next.Enabled = true; btn_page_last.Enabled = true; } else if (currentPage == lastPage) { btn_page_first.Enabled = true; btn_page_pre.Enabled = true; btn_page_next.Enabled = false; btn_page_last.Enabled = false; } else { btn_page_first.Enabled = true; btn_page_pre.Enabled = true; btn_page_next.Enabled = true; btn_page_last.Enabled = true; } DataTable table = OledbHelper.ExecuteDataTable(sqlData); dataGridViewX1.DataSource = table; } private void initForm() { string sql = null; DataTable table = null; sql = "select distinct t.sh_layer from casic_audit_result t"; table = OledbHelper.ExecuteDataTable(sql); //combo_layer.Items.Add(new ComboBoxItem("", "")); foreach (DataRow row in table.Rows) { combo_layer.Items.Add(new ComboBoxItem(row[0].ToString(), row[0].ToString())); } sql = "select distinct t.sh_staff from casic_audit_result t"; table = OledbHelper.ExecuteDataTable(sql); //combo_staff.Items.Add(new ComboBoxItem("", "")); foreach (DataRow row in table.Rows) { combo_staff.Items.Add(new ComboBoxItem(row[0].ToString(), row[0].ToString())); } sql = "select distinct t.kind from casic_audit_result t"; table = OledbHelper.ExecuteDataTable(sql); //combo_kind.Items.Add(new ComboBoxItem("", "")); foreach (DataRow row in table.Rows) { if ("H".Equals(row[0].ToString())) { combo_kind.Items.Add(new ComboBoxItem("H", "水平")); } else if ("V".Equals(row[0].ToString())) { combo_kind.Items.Add(new ComboBoxItem("H", "垂直")); } else { combo_kind.Items.Add(new ComboBoxItem(row[0].ToString(), "其他")); } } } private void dataGridViewX1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } String layer = dataGridViewX1.Rows[e.RowIndex].Cells["SH_LAYER"].Value.ToString(); String no = dataGridViewX1.Rows[e.RowIndex].Cells["SH_NO"].Value.ToString(); if (!String.IsNullOrEmpty(layer) && !String.IsNullOrEmpty(no)) { GSOLayer gsoLayer = globeControl2.Globe.Layers.GetLayerByCaption(layer); if (null != gsoLayer) { //addNode(gsoLayer); globeControl1.Globe.Layers.Add(gsoLayer); globeControl1.Refresh(); } GSOLayer centerlayer = globeControl1.Globe.Layers.GetLayerByCaption(layer); if (centerlayer != null) { GSOFeatures feats = centerlayer.GetFeatureByName(no, true); for (int j = 0; j < feats.Length; j++) { if (no.Equals(feats[j].Name)) { GSOFeature rowFeature = feats[j]; if (rowFeature == null) continue; if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = rowFeature.Geometry as GSOGeoPolyline3D; double length = line.GetSpaceLength(true, 6378137);//线的长度; GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globeControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); globeControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; timer1.Start(); } else { globeControl1.Globe.JumpToFeature(rowFeature, 300); } } } } } } private void btn_query_Click(object sender, EventArgs e) { currentPage = 1; reloadGrid(currentPage); } private void timer1_Tick(object sender, EventArgs e) { if (hlfeature == null) return; if (count < 80) { count++; if (count % 2 != 0) { hlfeature.HighLight = true; } else { hlfeature.HighLight = false; } globeControl1.Refresh(); } else { timer1.Stop(); hlfeature.HighLight = false; count = 0; } } private void btn_page_first_Click(object sender, EventArgs e) { currentPage = 1; reloadGrid(currentPage); } private void btn_page_pre_Click(object sender, EventArgs e) { currentPage--; if (currentPage < 1) { currentPage = 1; } reloadGrid(currentPage); } private void btn_page_next_Click(object sender, EventArgs e) { currentPage++; if (currentPage > lastPage) { currentPage = lastPage; } reloadGrid(currentPage); } private void btn_page_last_Click(object sender, EventArgs e) { currentPage = lastPage; reloadGrid(currentPage); } private void combo_page_SelectedIndexChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(combo_page.Text)) { currentPage = int.Parse(combo_page.Text); reloadGrid(currentPage); } } private void combo_layer_SelectedIndexChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(combo_layer.Text.Trim())) { combo_no.Items.Clear(); string sql = "select distinct t.sh_no from casic_audit_result t where t.sh_layer='" + combo_layer.Text.Trim() + "'"; DataTable table = OledbHelper.ExecuteDataTable(sql); combo_no.Items.Add(new ComboBoxItem("", "")); foreach (DataRow row in table.Rows) { combo_no.Items.Add(new ComboBoxItem(row[0].ToString(), row[0].ToString())); } } } private void FrmCheckHistory_FormClosing(object sender, FormClosingEventArgs e) { isOpen = false; } } }