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 GeoScene.Data; using GeoScene.Engine; using GeoScene.Globe; using DevComponents.DotNetBar; using System.Data.OracleClient; namespace Cyberpipe.EMS_Forms { public partial class Form_EventManager : Office2007Form { private GSOGlobeControl globeControl1; DataTable dt = new DataTable(); OracleConnection conn; private int currentpage = 1; private int lastpage = 1; private int pagesize = 11; public static bool IS_OPEN = false; public Form_EventManager(GSOGlobeControl globeControl1) { this.globeControl1 = globeControl1; globeControl1.Globe.MemoryLayer.ObjectMinVisiblePixelSize = -1; InitializeComponent(); } private void Form_EventManager_Load(object sender, EventArgs e) { try { this.dateTimePicker_end.Value = DateTime.Now; reloadGrid(currentpage); conn = OledbHelper.sqlConnection(); string com = "select * from PATROLER"; conn.Open(); OracleCommand cmd = new OracleCommand(com, conn); OracleDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { String name = Convert.ToString(dr["USERNAME"]); comboBox_name.Items.Add(name); } conn.Close(); if (Utility.userRole.IndexOf("事件编辑") == -1) { dataGridViewX_Event.Columns["编辑结果"].Visible = false; } IS_OPEN = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void reloadGrid(int pageIndex) { string userName = comboBox_name.Text.ToString(); string startTime = dateTimePicker_start.Value.ToString("yyyy-MM-dd"); string endTime = dateTimePicker_end.Value.AddDays(1).ToString("yyyy-MM-dd"); if (dateTimePicker_start.Value != null && dateTimePicker_end.Value != null) { int compare = DateTime.Compare(dateTimePicker_start.Value, dateTimePicker_end.Value); if (compare == 1) { MessageBox.Show("起始时间不能大于终止时间,请重新设置!", "提示"); return; } } string sqlcount = "select count(*) from ACCIDENT t where 1=1"; string sqlrows = "select * from (select rownum as rowno,dbid," + "ACCIDENTTIME," + "DESCRIBE," + "LATITUDE," + "LOCALE," + "LONGITUDE," + "PATROLERNAME," + "PATROLER_ID," + "TASK_ID," + "RESULT," + "'查看' as btn " + "from ACCIDENT where 1=1 "; if (!String.IsNullOrEmpty(comboBox_name.Text.Trim())) { sqlcount += " and PATROLERNAME='" + comboBox_name.Text.Trim() + "' "; sqlrows += " and PATROLERNAME='" + comboBox_name.Text.Trim() + "' "; } if (dateTimePicker_start.Value != null) { sqlcount += "and ACCIDENTTIME>=to_date('" + dateTimePicker_start.Value.ToShortDateString() + "','yyyy-MM-dd') "; sqlrows += "and ACCIDENTTIME>=to_date('" + dateTimePicker_start.Value.ToShortDateString() + "','yyyy-MM-dd') "; } if (dateTimePicker_end.Value != null) { DateTime time = dateTimePicker_end.Value; time = time.AddDays(1); sqlcount += "and ACCIDENTTIME<=to_date('" + time.ToShortDateString() + "','yyyy-MM-dd') "; sqlrows += "and ACCIDENTTIME<=to_date('" + time.ToShortDateString() + "','yyyy-MM-dd') "; } sqlrows += " and rownum<=" + (pagesize * pageIndex) + ") table_alias where table_alias.rowno>=" + ((pageIndex - 1) * pagesize + 1); int rows = int.Parse(OracleUtils.ExecuteScalar(OracleUtils.ConnectionString, CommandType.Text, sqlcount).ToString()); int pages = 0; if (rows % pagesize == 0) { pages = rows / pagesize; } else { pages = rows / pagesize + 1; } lastpage = pages; lab_page_msg.Text = "共" + rows + "条记录,每页" + pagesize + "条,第" + pageIndex + "页,共" + pages + "页"; combo_page_num.Items.Clear(); for (int i = 1; i <= pages; i++) { combo_page_num.Items.Add(new ComboBoxItem(i.ToString(), i.ToString())); } if (currentpage == 1) { btn_page_first.Enabled = false; btn_page_pre.Enabled = false; btn_page_last.Enabled = true; btn_page_next.Enabled = true; } else if (currentpage == lastpage) { btn_page_first.Enabled = true; btn_page_pre.Enabled = true; btn_page_last.Enabled = false; btn_page_next.Enabled = false; } else { btn_page_first.Enabled = true; btn_page_pre.Enabled = true; btn_page_last.Enabled = true; btn_page_next.Enabled = true; } DataTable table = OracleUtils.ExecuteDataset(OracleUtils.ConnectionString, CommandType.Text, sqlrows).Tables[0]; dataGridViewX_Event.DataSource = table; if (table.Rows.Count == 0) { MessageBox.Show("没有找到任何数据!", "提示"); } for (int i = 0; i < table.Rows.Count; i++) { if (dataGridViewX_Event.Rows[i].Cells["处理结果"].Value != null && !(dataGridViewX_Event.Rows[i].Cells["处理结果"].Value.ToString().Trim().Equals(""))) { dataGridViewX_Event.Rows[i].Cells["处理状态"].Value = "已处理"; } } } private void Form_EventManager_FormClosing(object sender, FormClosingEventArgs e) { globeControl1.Globe.MemoryLayer.RemoveAllFeature(); IS_OPEN = false; } private void dataGridViewX_Event_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1 && e.ColumnIndex != -1) { if (dataGridViewX_Event.Columns[e.ColumnIndex].HeaderText == "编辑结果") { try { int dbId = Convert.ToInt32(dataGridViewX_Event.Rows[e.RowIndex].Cells["编号"].Value); string result = Convert.ToString(dataGridViewX_Event.Rows[e.RowIndex].Cells["处理结果"].Value); EMS_Forms.Form_EventResult form = new Form_EventResult(dbId,result); currentpage = 1; form.refresh += new Form_EventResult.Handle(reloadGrid);//改变值的事件 form.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } } private void dataGridViewX_Event_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX_Event.HitTest(e.X, e.Y); if (hittestinfo.RowIndex > -1) { try { globeControl1.Globe.MemoryLayer.RemoveAllFeature(); this.WindowState = FormWindowState.Minimized; double x = Convert.ToDouble(dataGridViewX_Event.Rows[hittestinfo.RowIndex].Cells["经度"].Value); double y = Convert.ToDouble(dataGridViewX_Event.Rows[hittestinfo.RowIndex].Cells["纬度"].Value); string username = Convert.ToString(dataGridViewX_Event.Rows[hittestinfo.RowIndex].Cells["上报人员"].Value); string Atime = Convert.ToString(dataGridViewX_Event.Rows[hittestinfo.RowIndex].Cells["上报时间"].Value); string location = Convert.ToString(dataGridViewX_Event.Rows[hittestinfo.RowIndex].Cells["事件地点"].Value); string descp = Convert.ToString(dataGridViewX_Event.Rows[hittestinfo.RowIndex].Cells["事件描述"].Value); /////////////////////////////////////// /*******设置飞行与创建模型******/ EnumAltitudeMode altmode = EnumAltitudeMode.Absolute; GSOPoint3d p = new GSOPoint3d(); p.X = x; p.Y = y; //p.X = 120.608; //p.Y = 31.1907; p.Z = 0; GSOGeoModel model = new GSOGeoModel(); string filepath = Application.StartupPath + "/EMSgcm/小旗子/hongqi/hongqi.gcm"; model.FilePath = filepath; model.Position = p; model.AltitudeMode = EnumAltitudeMode.Absolute; GSOFeature f = new GSOFeature(); f.Geometry = model; f.Name = "事件:" + Atime; //double s = 0.1; //f.Geometry.Scale(s, s, s); GSOFeature newFeature = globeControl1.Globe.MemoryLayer.AddFeature(f); GSOLabel label = new GSOLabel(); label.Text = "上报人员:" + username + "\r\n" + "上报时间:" + Atime + "\r\n" + "上报地点:" + location + "\r\n" + "事件描述:" + descp; label.Style = new GSOLabelStyle(); label.Style.Opaque = 0.8; //设置标注的透明度,取值区间是0-1 label.Style.TracktionLineType = EnumTracktionLineType.Solid; label.Style.TextStyle.FontHeight = 20; label.Style.TextStyle.FontName = "黑体"; label.Style.TractionLineEndPos = new GSOPoint2d(80, 60); newFeature.Label = label; globeControl1.Globe.JumpToFeature(newFeature,3000); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } } private void buttonX_search_Click(object sender, EventArgs e) { try { currentpage = 1; reloadGrid(currentpage); } catch (Exception ex) { MessageBox.Show("查询失败:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } 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 combo_page_num_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(combo_page_num.Text)) { currentpage = int.Parse(combo_page_num.Text); 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); } } }