diff --git a/FrmHongXianManage.Designer.cs b/FrmHongXianManage.Designer.cs new file mode 100644 index 0000000..91500b6 --- /dev/null +++ b/FrmHongXianManage.Designer.cs @@ -0,0 +1,189 @@ +using DevComponents.DotNetBar.Controls; +using DevComponents.DotNetBar; +using System.ComponentModel; +using GeoScene.Globe; + +namespace Cyberpipe +{ + partial class FrmHongXianManage + { + /// + /// Required designer variable. + /// + private IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + this.bar1 = new DevComponents.DotNetBar.Bar(); + this.labelItem1 = new DevComponents.DotNetBar.LabelItem(); + this.txt_hongxian_name = new DevComponents.DotNetBar.TextBoxItem(); + this.dataGridViewX1 = new DevComponents.DotNetBar.Controls.DataGridViewX(); + this.LSSYS_ID = new DevComponents.DotNetBar.Controls.DataGridViewLabelXColumn(); + this.LSSYS_GEOTYPE = new DevComponents.DotNetBar.Controls.DataGridViewLabelXColumn(); + this.hongXianName = new DevComponents.DotNetBar.Controls.DataGridViewLabelXColumn(); + this.importTime = new DevComponents.DotNetBar.Controls.DataGridViewLabelXColumn(); + this.btndel = new DevComponents.DotNetBar.Controls.DataGridViewButtonXColumn(); + ((System.ComponentModel.ISupportInitialize)(this.bar1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewX1)).BeginInit(); + this.SuspendLayout(); + // + // bar1 + // + this.bar1.AntiAlias = true; + this.bar1.Dock = System.Windows.Forms.DockStyle.Top; + this.bar1.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] { + this.labelItem1, + this.txt_hongxian_name,}); + this.bar1.Location = new System.Drawing.Point(0, 0); + this.bar1.Name = "bar1"; + this.bar1.Size = new System.Drawing.Size(470, 27); + this.bar1.Stretch = true; + this.bar1.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.bar1.TabIndex = 0; + this.bar1.TabStop = false; + this.bar1.Text = "bar1"; + // + // labelItem1 + // + this.labelItem1.Name = "labelItem1"; + this.labelItem1.Text = "红线名称"; + // + // txt_role_name + // + this.txt_hongxian_name.Name = "txt_hongxian_name"; + this.txt_hongxian_name.TextBoxWidth = 150; + this.txt_hongxian_name.WatermarkColor = System.Drawing.SystemColors.GrayText; + + // + // dataGridViewX1 + // + this.dataGridViewX1.AllowUserToAddRows = false; + this.dataGridViewX1.AllowUserToDeleteRows = false; + this.dataGridViewX1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridViewX1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewX1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.LSSYS_ID, + this.LSSYS_GEOTYPE, + this.hongXianName, + this.importTime, + this.btndel}); + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridViewX1.DefaultCellStyle = dataGridViewCellStyle1; + this.dataGridViewX1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewX1.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(170)))), ((int)(((byte)(170)))), ((int)(((byte)(170))))); + this.dataGridViewX1.Location = new System.Drawing.Point(0, 27); + this.dataGridViewX1.Name = "dataGridViewX1"; + this.dataGridViewX1.ReadOnly = true; + this.dataGridViewX1.RowTemplate.Height = 23; + this.dataGridViewX1.Size = new System.Drawing.Size(470, 272); + this.dataGridViewX1.TabIndex = 1; + this.dataGridViewX1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewX1_CellContentClick); + // + // LSSYS_ID + // + this.LSSYS_ID.DataPropertyName = "LSSYS_ID"; + this.LSSYS_ID.HeaderText = "LSSYS_ID"; + this.LSSYS_ID.Name = "LSSYS_ID"; + this.LSSYS_ID.ReadOnly = true; + // + // LSSYS_GEOTYPE + // + this.LSSYS_GEOTYPE.DataPropertyName = "LSSYS_GEOTYPE"; + this.LSSYS_GEOTYPE.HeaderText = "LSSYS_GEOTYPE"; + this.LSSYS_GEOTYPE.Name = "LSSYS_GEOTYPE"; + this.LSSYS_GEOTYPE.ReadOnly = true; + this.LSSYS_GEOTYPE.TextAlignment = System.Drawing.StringAlignment.Center; + // + // 文件名称 + // + this.hongXianName.DataPropertyName = "文件名称"; + this.hongXianName.HeaderText = "文件名称"; + this.hongXianName.Name = "文件名称"; + this.hongXianName.ReadOnly = true; + this.hongXianName.TextAlignment = System.Drawing.StringAlignment.Center; + + // + // 导入时间 + // + this.importTime.DataPropertyName = "导入时间"; + this.importTime.HeaderText = "导入时间"; + this.importTime.Name = "导入时间"; + this.importTime.ReadOnly = true; + this.importTime.TextAlignment = System.Drawing.StringAlignment.Center; + // + // btndel + // + this.btndel.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.btndel.HeaderText = "删除"; + this.btndel.Name = "btndel"; + this.btndel.ReadOnly = true; + this.btndel.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.btndel.Text = "删除"; + this.btndel.UseColumnTextForButtonValue = true; + this.btndel.Width = 35; + // + // FrmRoleInfoManager + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(470, 299); + this.Controls.Add(this.dataGridViewX1); + this.Controls.Add(this.bar1); + this.DoubleBuffered = true; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FrmHongXianManager"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "红线管理"; + //this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmRoleInfoManager_FormClosing); + this.Load += new System.EventHandler(this.FrmFrmHongXianManage_Load); + ((System.ComponentModel.ISupportInitialize)(this.bar1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewX1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Bar bar1; + private DataGridViewX dataGridViewX1; + private LabelItem labelItem1; + private TextBoxItem txt_hongxian_name; + private DataGridViewLabelXColumn LSSYS_ID; + private DataGridViewLabelXColumn LSSYS_GEOTYPE; + private DataGridViewLabelXColumn hongXianName; + private DataGridViewLabelXColumn importTime; + private DataGridViewButtonXColumn btndel; + + #region Windows Form Designer generated code + + #endregion + } +} \ No newline at end of file diff --git a/FrmHongXianManage.Designer.cs b/FrmHongXianManage.Designer.cs new file mode 100644 index 0000000..91500b6 --- /dev/null +++ b/FrmHongXianManage.Designer.cs @@ -0,0 +1,189 @@ +using DevComponents.DotNetBar.Controls; +using DevComponents.DotNetBar; +using System.ComponentModel; +using GeoScene.Globe; + +namespace Cyberpipe +{ + partial class FrmHongXianManage + { + /// + /// Required designer variable. + /// + private IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + this.bar1 = new DevComponents.DotNetBar.Bar(); + this.labelItem1 = new DevComponents.DotNetBar.LabelItem(); + this.txt_hongxian_name = new DevComponents.DotNetBar.TextBoxItem(); + this.dataGridViewX1 = new DevComponents.DotNetBar.Controls.DataGridViewX(); + this.LSSYS_ID = new DevComponents.DotNetBar.Controls.DataGridViewLabelXColumn(); + this.LSSYS_GEOTYPE = new DevComponents.DotNetBar.Controls.DataGridViewLabelXColumn(); + this.hongXianName = new DevComponents.DotNetBar.Controls.DataGridViewLabelXColumn(); + this.importTime = new DevComponents.DotNetBar.Controls.DataGridViewLabelXColumn(); + this.btndel = new DevComponents.DotNetBar.Controls.DataGridViewButtonXColumn(); + ((System.ComponentModel.ISupportInitialize)(this.bar1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewX1)).BeginInit(); + this.SuspendLayout(); + // + // bar1 + // + this.bar1.AntiAlias = true; + this.bar1.Dock = System.Windows.Forms.DockStyle.Top; + this.bar1.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] { + this.labelItem1, + this.txt_hongxian_name,}); + this.bar1.Location = new System.Drawing.Point(0, 0); + this.bar1.Name = "bar1"; + this.bar1.Size = new System.Drawing.Size(470, 27); + this.bar1.Stretch = true; + this.bar1.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.bar1.TabIndex = 0; + this.bar1.TabStop = false; + this.bar1.Text = "bar1"; + // + // labelItem1 + // + this.labelItem1.Name = "labelItem1"; + this.labelItem1.Text = "红线名称"; + // + // txt_role_name + // + this.txt_hongxian_name.Name = "txt_hongxian_name"; + this.txt_hongxian_name.TextBoxWidth = 150; + this.txt_hongxian_name.WatermarkColor = System.Drawing.SystemColors.GrayText; + + // + // dataGridViewX1 + // + this.dataGridViewX1.AllowUserToAddRows = false; + this.dataGridViewX1.AllowUserToDeleteRows = false; + this.dataGridViewX1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridViewX1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewX1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.LSSYS_ID, + this.LSSYS_GEOTYPE, + this.hongXianName, + this.importTime, + this.btndel}); + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridViewX1.DefaultCellStyle = dataGridViewCellStyle1; + this.dataGridViewX1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewX1.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(170)))), ((int)(((byte)(170)))), ((int)(((byte)(170))))); + this.dataGridViewX1.Location = new System.Drawing.Point(0, 27); + this.dataGridViewX1.Name = "dataGridViewX1"; + this.dataGridViewX1.ReadOnly = true; + this.dataGridViewX1.RowTemplate.Height = 23; + this.dataGridViewX1.Size = new System.Drawing.Size(470, 272); + this.dataGridViewX1.TabIndex = 1; + this.dataGridViewX1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewX1_CellContentClick); + // + // LSSYS_ID + // + this.LSSYS_ID.DataPropertyName = "LSSYS_ID"; + this.LSSYS_ID.HeaderText = "LSSYS_ID"; + this.LSSYS_ID.Name = "LSSYS_ID"; + this.LSSYS_ID.ReadOnly = true; + // + // LSSYS_GEOTYPE + // + this.LSSYS_GEOTYPE.DataPropertyName = "LSSYS_GEOTYPE"; + this.LSSYS_GEOTYPE.HeaderText = "LSSYS_GEOTYPE"; + this.LSSYS_GEOTYPE.Name = "LSSYS_GEOTYPE"; + this.LSSYS_GEOTYPE.ReadOnly = true; + this.LSSYS_GEOTYPE.TextAlignment = System.Drawing.StringAlignment.Center; + // + // 文件名称 + // + this.hongXianName.DataPropertyName = "文件名称"; + this.hongXianName.HeaderText = "文件名称"; + this.hongXianName.Name = "文件名称"; + this.hongXianName.ReadOnly = true; + this.hongXianName.TextAlignment = System.Drawing.StringAlignment.Center; + + // + // 导入时间 + // + this.importTime.DataPropertyName = "导入时间"; + this.importTime.HeaderText = "导入时间"; + this.importTime.Name = "导入时间"; + this.importTime.ReadOnly = true; + this.importTime.TextAlignment = System.Drawing.StringAlignment.Center; + // + // btndel + // + this.btndel.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.btndel.HeaderText = "删除"; + this.btndel.Name = "btndel"; + this.btndel.ReadOnly = true; + this.btndel.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.btndel.Text = "删除"; + this.btndel.UseColumnTextForButtonValue = true; + this.btndel.Width = 35; + // + // FrmRoleInfoManager + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(470, 299); + this.Controls.Add(this.dataGridViewX1); + this.Controls.Add(this.bar1); + this.DoubleBuffered = true; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FrmHongXianManager"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "红线管理"; + //this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmRoleInfoManager_FormClosing); + this.Load += new System.EventHandler(this.FrmFrmHongXianManage_Load); + ((System.ComponentModel.ISupportInitialize)(this.bar1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewX1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Bar bar1; + private DataGridViewX dataGridViewX1; + private LabelItem labelItem1; + private TextBoxItem txt_hongxian_name; + private DataGridViewLabelXColumn LSSYS_ID; + private DataGridViewLabelXColumn LSSYS_GEOTYPE; + private DataGridViewLabelXColumn hongXianName; + private DataGridViewLabelXColumn importTime; + private DataGridViewButtonXColumn btndel; + + #region Windows Form Designer generated code + + #endregion + } +} \ No newline at end of file diff --git a/FrmHongXianManage.cs b/FrmHongXianManage.cs new file mode 100644 index 0000000..c66d179 --- /dev/null +++ b/FrmHongXianManage.cs @@ -0,0 +1,125 @@ +using DevComponents.DotNetBar; +using DXFLibrary; +using GeoScene.Globe; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Cyberpipe +{ + public partial class FrmHongXianManage : Office2007Form + { + GSOGlobeControl _globeControl1; + MyTreeView _layerTree; + public FrmHongXianManage(GSOGlobeControl globeControl1, MyTreeView layerTree) + { + InitializeComponent(); + ///////// 待实现 + _globeControl1 = globeControl1; + _layerTree = layerTree; + } + + + private void FrmFrmHongXianManage_Load(object sender, EventArgs e) + { + reloadGrid(); + } + + private void reloadGrid() + { + string sql = "select LSSYS_ID,LSSYS_GEOTYPE,文件名称,导入时间 from 红线"; + DataTable dt = OracleUtils.ExecuteDataset(OracleUtils.ConnectionString, CommandType.Text, sql).Tables[0]; + dataGridViewX1.DataSource = dt; + } + + private void dataGridViewX1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + Debug.WriteLine("dataGridViewX1_CellContentClick"); + if (e.RowIndex < 0 || e.ColumnIndex < 0) + { + return; + } + + string cell = dataGridViewX1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); + if (cell.Equals("删除")) + { + try + { + string LSSYS_ID = dataGridViewX1.Rows[e.RowIndex].Cells["LSSYS_ID"].Value.ToString(); + string fileName = dataGridViewX1.Rows[e.RowIndex].Cells["文件名称"].Value.ToString(); + if (MessageBox.Show("确定删除?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + // 删除数据库里的数据 + string sql = "delete from 红线 where LSSYS_ID=" + LSSYS_ID; + OracleUtils.ExecuteNonQuery(OracleUtils.ConnectionString, CommandType.Text, sql); + reloadGrid(); + + + // 删除左侧树节点 和 图层数据 + // 获取 临时图层节点 + TreeNode linShiTuCengNode = _layerTree.TopNode; + foreach (TreeNode t in linShiTuCengNode.Nodes) { + // 根据节点text 和 文件名 获得该节点 + if (t.Text == fileName) { + Debug.WriteLine(t.Text); + if (!(t.Tag is GSOLayer)) return; + GSOLayer tempLayer = t.Tag as GSOLayer; + _globeControl1.Globe.Layers.Remove(tempLayer); + _globeControl1.Globe.Refresh(); + t.Remove(); + } + } + //if (nodes[0] != null) + //{ + // nodes[0].Remove(); + //} + + MessageBox.Show("删除成功!", "结果", MessageBoxButtons.OK, MessageBoxIcon.Information); + + + } + } + + + + catch (Exception ex) + { + MessageBox.Show("删除失败:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + + //递归查询,找到返回该节点 + private TreeNode FindNode(TreeNode node, string name) + { + //接受返回的节点 + TreeNode ret = null; + //循环查找 + foreach (TreeNode temp in node.Nodes) + { + //是否有子节点 + if (temp.Nodes.Count != 0) + { + //如果找到 + if ((ret = FindNode(temp, name)) != null) + { + return ret; + } + } + //如果找到 + if (string.Equals(temp.Text, name)) + { + return temp; + } + } + return ret; + } + } +}