diff --git a/FrmFlagManagers.cs b/FrmFlagManagers.cs index e81b9a8..5e11dbb 100644 --- a/FrmFlagManagers.cs +++ b/FrmFlagManagers.cs @@ -8,6 +8,7 @@ using GeoScene.Engine; using System.IO; using System.Data.OracleClient; +using WHC.Pager.WinControl; namespace Cyberpipe { @@ -21,6 +22,8 @@ TreeNode layerManagerNode = null; string LSSYS_ID_VALUE = "标识器自增编号"; + string CURRENT_EXPORT_BUTTON = "导出当前页"; + public FrmFlagManagers(GSOGlobeControl _globeControl1) { globeControl1 = _globeControl1; @@ -35,7 +38,25 @@ void pager1_OnStartExport(object sender, EventArgs e) { - string where = GetSql(); + string exportButt = ((Pager)((WinGridViewPager)sender).ActiveControl).ActiveControl.Text; + string where; + + // 首先查询数据更新表格 + int pageIndex = winGridViewPager1.PagerInfo.CurrenetPageIndex; + LoadData(pageIndex); + + if (exportButt.Equals(CURRENT_EXPORT_BUTTON)) + { + // 导出当前页 + where = GetSql(pageIndex); + } else + { + // 导出全部数据行时可能会很慢 提示用户 + where = GetSql(); + MessageBox.Show(this, "导出全部页数据,总计共" + rows + "条记录,请耐心等待"); + } + + // 根据条件查询导出的数据 DataTable table = OracleUtils.ExecuteDataset(OracleUtils.ConnectionString, CommandType.Text, where).Tables[0]; winGridViewPager1.AllToExport = table; } @@ -210,10 +231,21 @@ { string sqlCount = "select count(1) from 标识器 where 使用状态 = '使用中'"; - string sqlData = "select 编号,标识器ID号,标识器型号,地面高程,标识器埋深,所属道路,LSSYS_ID as " + + string sqlData = "select 编号,标识器ID号,标识器型号,round(地面高程,2) as 地面高程,round(标识器埋深,2) as 标识器埋深,所属道路,LSSYS_ID as " + LSSYS_ID_VALUE + ",X坐标,Y坐标,使用状态,权属单位,备注 " + "from (select t.*,rownum row_num from 标识器 t where 使用状态 = '使用中' order by 编号)b " + " where 1=1"; + if (!String.IsNullOrEmpty(txt_no.Text.Trim())) + { + sqlCount += " and 编号 like '%" + txt_no.Text.Trim() + "%'"; + sqlData += " and 编号 like '%" + txt_no.Text.Trim() + "%'"; + } + if (null != combo_street.SelectedItem && !String.IsNullOrEmpty(combo_street.SelectedItem.ToString().Trim())) + { + sqlData += " and 所属道路='" + combo_street.SelectedItem.ToString().Trim() + "'"; + sqlCount += " and 所属道路='" + combo_street.SelectedItem.ToString().Trim() + "'"; + } + rows = int.Parse(OracleUtils.ExecuteScalar(OracleUtils.ConnectionString, CommandType.Text, sqlCount).ToString()); return sqlData; @@ -249,13 +281,11 @@ private void bindComboxStreet() { - ComboBoxItem item = new ComboBoxItem(); - - String sql = "select distinct t.所属道路 from 标识器 t where t.使用状态='使用中'"; + string sql = "select distinct t.所属道路 from 标识器 t where t.使用状态='使用中'"; DataTable table = OracleUtils.ExecuteDataset(OracleUtils.ConnectionString, CommandType.Text, sql).Tables[0]; foreach (DataRow row in table.Rows) { - item = new ComboBoxItem(); + ComboBoxItem item = new ComboBoxItem(); item.Text = row[0].ToString(); if (!item.Text.Equals("")) combo_street.Items.Add(item); diff --git a/FrmFlagManagers.cs b/FrmFlagManagers.cs index e81b9a8..5e11dbb 100644 --- a/FrmFlagManagers.cs +++ b/FrmFlagManagers.cs @@ -8,6 +8,7 @@ using GeoScene.Engine; using System.IO; using System.Data.OracleClient; +using WHC.Pager.WinControl; namespace Cyberpipe { @@ -21,6 +22,8 @@ TreeNode layerManagerNode = null; string LSSYS_ID_VALUE = "标识器自增编号"; + string CURRENT_EXPORT_BUTTON = "导出当前页"; + public FrmFlagManagers(GSOGlobeControl _globeControl1) { globeControl1 = _globeControl1; @@ -35,7 +38,25 @@ void pager1_OnStartExport(object sender, EventArgs e) { - string where = GetSql(); + string exportButt = ((Pager)((WinGridViewPager)sender).ActiveControl).ActiveControl.Text; + string where; + + // 首先查询数据更新表格 + int pageIndex = winGridViewPager1.PagerInfo.CurrenetPageIndex; + LoadData(pageIndex); + + if (exportButt.Equals(CURRENT_EXPORT_BUTTON)) + { + // 导出当前页 + where = GetSql(pageIndex); + } else + { + // 导出全部数据行时可能会很慢 提示用户 + where = GetSql(); + MessageBox.Show(this, "导出全部页数据,总计共" + rows + "条记录,请耐心等待"); + } + + // 根据条件查询导出的数据 DataTable table = OracleUtils.ExecuteDataset(OracleUtils.ConnectionString, CommandType.Text, where).Tables[0]; winGridViewPager1.AllToExport = table; } @@ -210,10 +231,21 @@ { string sqlCount = "select count(1) from 标识器 where 使用状态 = '使用中'"; - string sqlData = "select 编号,标识器ID号,标识器型号,地面高程,标识器埋深,所属道路,LSSYS_ID as " + + string sqlData = "select 编号,标识器ID号,标识器型号,round(地面高程,2) as 地面高程,round(标识器埋深,2) as 标识器埋深,所属道路,LSSYS_ID as " + LSSYS_ID_VALUE + ",X坐标,Y坐标,使用状态,权属单位,备注 " + "from (select t.*,rownum row_num from 标识器 t where 使用状态 = '使用中' order by 编号)b " + " where 1=1"; + if (!String.IsNullOrEmpty(txt_no.Text.Trim())) + { + sqlCount += " and 编号 like '%" + txt_no.Text.Trim() + "%'"; + sqlData += " and 编号 like '%" + txt_no.Text.Trim() + "%'"; + } + if (null != combo_street.SelectedItem && !String.IsNullOrEmpty(combo_street.SelectedItem.ToString().Trim())) + { + sqlData += " and 所属道路='" + combo_street.SelectedItem.ToString().Trim() + "'"; + sqlCount += " and 所属道路='" + combo_street.SelectedItem.ToString().Trim() + "'"; + } + rows = int.Parse(OracleUtils.ExecuteScalar(OracleUtils.ConnectionString, CommandType.Text, sqlCount).ToString()); return sqlData; @@ -249,13 +281,11 @@ private void bindComboxStreet() { - ComboBoxItem item = new ComboBoxItem(); - - String sql = "select distinct t.所属道路 from 标识器 t where t.使用状态='使用中'"; + string sql = "select distinct t.所属道路 from 标识器 t where t.使用状态='使用中'"; DataTable table = OracleUtils.ExecuteDataset(OracleUtils.ConnectionString, CommandType.Text, sql).Tables[0]; foreach (DataRow row in table.Rows) { - item = new ComboBoxItem(); + ComboBoxItem item = new ComboBoxItem(); item.Text = row[0].ToString(); if (!item.Text.Equals("")) combo_street.Items.Add(item); diff --git a/MainFrm.cs b/MainFrm.cs index 707f651..0a61081 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -7373,13 +7373,13 @@ private void ClearGZData() { - lendendGZ50.Visible = false; - lendendGZ42.Visible = false; - lendendGZ36.Visible = false; - lendendGZ26.Visible = false; - lendendGZ24_1.Visible = false; - lendendGZ24_2.Visible = false; - lendendGZ24_3.Visible = false; + if (lendendGZ50 != null) lendendGZ50.Visible = false; + if (lendendGZ42 != null) lendendGZ42.Visible = false; + if (lendendGZ36 != null) lendendGZ36.Visible = false; + if (lendendGZ26 != null) lendendGZ26.Visible = false; + if (lendendGZ24_1 != null) lendendGZ24_1.Visible = false; + if (lendendGZ24_2 != null) lendendGZ24_2.Visible = false; + if (lendendGZ24_3 != null) lendendGZ24_3.Visible = false; } #endregion