diff --git a/PEIS/Entity/DictHazardTypecs.cs b/PEIS/Entity/DictHazardTypecs.cs index 5156085..89b2140 100644 --- a/PEIS/Entity/DictHazardTypecs.cs +++ b/PEIS/Entity/DictHazardTypecs.cs @@ -32,6 +32,11 @@ namespace PEIS.Entity /// 国标 /// public string Standard { get; set; } + /// + /// 描述 + /// + public string Describe { get; set; } + } } diff --git a/PEIS/Model/Setting/HazardTypeModel.cs b/PEIS/Model/Setting/HazardTypeModel.cs index 95c1538..992ae1a 100644 --- a/PEIS/Model/Setting/HazardTypeModel.cs +++ b/PEIS/Model/Setting/HazardTypeModel.cs @@ -42,5 +42,15 @@ namespace PEIS.Model.Setting { return DAOHelp.GetDataBySQL($"Select * From Dict_HTypeFItem a where a.HID={hID}"); } + public List GetDictHByNamePID(Int64 pID, string name) + { + var result= DAOHelp.GetDataBySQL($@"Select * From Dict_HazardType a where a.ParentID={pID} and a.Name='{name}'"); + return result == null ? new List() : result; + } + public List GetDictHByCodePID(Int64 pID, string code) + { + var result = DAOHelp.GetDataBySQL($@"Select * From Dict_HazardType a where a.ParentID={pID} and a.Code='{code}'"); + return result == null ? new List() : result; + } } } diff --git a/PEIS/PEIS.csproj b/PEIS/PEIS.csproj index 33b09fe..4d0ef66 100644 --- a/PEIS/PEIS.csproj +++ b/PEIS/PEIS.csproj @@ -446,6 +446,12 @@ HazardTypeForm.cs + + Form + + + HTypeEditForm.cs + @@ -654,6 +660,9 @@ HazardTypeForm.cs + + HTypeEditForm.cs + PermissionForm.cs diff --git a/PEIS/View/Setting/DictionaryTEditFrom.Designer.cs b/PEIS/View/Setting/DictionaryTEditFrom.Designer.cs index e428343..ac8064b 100644 --- a/PEIS/View/Setting/DictionaryTEditFrom.Designer.cs +++ b/PEIS/View/Setting/DictionaryTEditFrom.Designer.cs @@ -86,6 +86,11 @@ // numericUpDown1 // this.numericUpDown1.Location = new System.Drawing.Point(117, 77); + this.numericUpDown1.Maximum = new decimal(new int[] { + -1981284353, + -1966660860, + 0, + 0}); this.numericUpDown1.Name = "numericUpDown1"; this.numericUpDown1.Size = new System.Drawing.Size(174, 21); this.numericUpDown1.TabIndex = 6; @@ -170,7 +175,7 @@ this.ConfirmBtn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.ConfirmBtn.UseVisualStyleBackColor = true; // - // DictionaryType + // DictionaryTEditFrom // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -179,7 +184,7 @@ this.Controls.Add(this.panel1); this.Controls.Add(this.panel2); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Name = "DictionaryType"; + this.Name = "DictionaryTEditFrom"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "字典分类"; ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); diff --git a/PEIS/View/Setting/HTypeEditForm.Designer.cs b/PEIS/View/Setting/HTypeEditForm.Designer.cs new file mode 100644 index 0000000..8c37750 --- /dev/null +++ b/PEIS/View/Setting/HTypeEditForm.Designer.cs @@ -0,0 +1,322 @@ +namespace PEIS.View.Setting +{ + partial class HTypeEditForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.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.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HTypeEditForm)); + this.panel2 = new System.Windows.Forms.Panel(); + this.CancelBtn = new System.Windows.Forms.Button(); + this.ConfirmBtn = new System.Windows.Forms.Button(); + this.panel1 = new System.Windows.Forms.Panel(); + this.tStandard = new System.Windows.Forms.TextBox(); + this.lable100 = new System.Windows.Forms.Label(); + this.tDescribe = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.nSort = new System.Windows.Forms.NumericUpDown(); + this.trParentID = new DevExpress.XtraEditors.TreeListLookUpEdit(); + this.treeListLookUpEdit1TreeList = new DevExpress.XtraTreeList.TreeList(); + this.ID = new DevExpress.XtraTreeList.Columns.TreeListColumn(); + this.PID = new DevExpress.XtraTreeList.Columns.TreeListColumn(); + this.trName = new DevExpress.XtraTreeList.Columns.TreeListColumn(); + this.trCode = new DevExpress.XtraTreeList.Columns.TreeListColumn(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.tCode = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.tName = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.panel2.SuspendLayout(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nSort)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trParentID.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.treeListLookUpEdit1TreeList)).BeginInit(); + this.SuspendLayout(); + // + // panel2 + // + this.panel2.BackColor = System.Drawing.Color.White; + this.panel2.Controls.Add(this.CancelBtn); + this.panel2.Controls.Add(this.ConfirmBtn); + this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel2.Location = new System.Drawing.Point(0, 319); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(386, 32); + this.panel2.TabIndex = 11; + // + // CancelBtn + // + this.CancelBtn.Image = ((System.Drawing.Image)(resources.GetObject("CancelBtn.Image"))); + this.CancelBtn.Location = new System.Drawing.Point(193, 0); + this.CancelBtn.Margin = new System.Windows.Forms.Padding(2, 4, 2, 4); + this.CancelBtn.Name = "CancelBtn"; + this.CancelBtn.Size = new System.Drawing.Size(91, 31); + this.CancelBtn.TabIndex = 20; + this.CancelBtn.Text = "取消"; + this.CancelBtn.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.CancelBtn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.CancelBtn.UseVisualStyleBackColor = true; + // + // ConfirmBtn + // + this.ConfirmBtn.Image = ((System.Drawing.Image)(resources.GetObject("ConfirmBtn.Image"))); + this.ConfirmBtn.Location = new System.Drawing.Point(49, 0); + this.ConfirmBtn.Margin = new System.Windows.Forms.Padding(2, 4, 2, 4); + this.ConfirmBtn.Name = "ConfirmBtn"; + this.ConfirmBtn.Size = new System.Drawing.Size(90, 31); + this.ConfirmBtn.TabIndex = 19; + this.ConfirmBtn.Text = "确认"; + this.ConfirmBtn.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.ConfirmBtn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.ConfirmBtn.UseVisualStyleBackColor = true; + // + // panel1 + // + this.panel1.Controls.Add(this.tStandard); + this.panel1.Controls.Add(this.lable100); + this.panel1.Controls.Add(this.tDescribe); + this.panel1.Controls.Add(this.label5); + this.panel1.Controls.Add(this.nSort); + this.panel1.Controls.Add(this.trParentID); + this.panel1.Controls.Add(this.label4); + this.panel1.Controls.Add(this.label3); + this.panel1.Controls.Add(this.tCode); + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.tName); + this.panel1.Controls.Add(this.label1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(386, 319); + this.panel1.TabIndex = 12; + // + // tStandard + // + this.tStandard.Location = new System.Drawing.Point(106, 92); + this.tStandard.Name = "tStandard"; + this.tStandard.Size = new System.Drawing.Size(196, 21); + this.tStandard.TabIndex = 13; + // + // lable100 + // + this.lable100.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.lable100.Location = new System.Drawing.Point(24, 90); + this.lable100.Name = "lable100"; + this.lable100.Size = new System.Drawing.Size(78, 23); + this.lable100.TabIndex = 12; + this.lable100.Text = "国标:"; + this.lable100.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // tDescribe + // + this.tDescribe.Location = new System.Drawing.Point(106, 148); + this.tDescribe.Multiline = true; + this.tDescribe.Name = "tDescribe"; + this.tDescribe.Size = new System.Drawing.Size(195, 140); + this.tDescribe.TabIndex = 11; + // + // label5 + // + this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(24, 148); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(78, 23); + this.label5.TabIndex = 10; + this.label5.Text = "描述:"; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // nSort + // + this.nSort.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.nSort.Location = new System.Drawing.Point(107, 119); + this.nSort.Maximum = new decimal(new int[] { + 1661992959, + 1808227885, + 5, + 0}); + this.nSort.Name = "nSort"; + this.nSort.Size = new System.Drawing.Size(195, 23); + this.nSort.TabIndex = 9; + this.nSort.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // trParentID + // + this.trParentID.EditValue = ""; + this.trParentID.Location = new System.Drawing.Point(107, 12); + this.trParentID.Name = "trParentID"; + this.trParentID.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { + new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); + this.trParentID.Properties.DisplayMember = "Name"; + this.trParentID.Properties.KeyMember = "ID"; + this.trParentID.Properties.NullText = ""; + this.trParentID.Properties.TreeList = this.treeListLookUpEdit1TreeList; + this.trParentID.Properties.ValueMember = "ID"; + this.trParentID.Size = new System.Drawing.Size(196, 20); + this.trParentID.TabIndex = 8; + // + // treeListLookUpEdit1TreeList + // + this.treeListLookUpEdit1TreeList.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { + this.ID, + this.PID, + this.trName, + this.trCode}); + this.treeListLookUpEdit1TreeList.Location = new System.Drawing.Point(8, 44); + this.treeListLookUpEdit1TreeList.Name = "treeListLookUpEdit1TreeList"; + this.treeListLookUpEdit1TreeList.OptionsView.ShowIndentAsRowStyle = true; + this.treeListLookUpEdit1TreeList.Size = new System.Drawing.Size(400, 200); + this.treeListLookUpEdit1TreeList.TabIndex = 0; + // + // ID + // + this.ID.Caption = "主键"; + this.ID.FieldName = "ID"; + this.ID.Name = "ID"; + // + // PID + // + this.PID.Caption = "分类ID"; + this.PID.FieldName = "ParentID"; + this.PID.Name = "PID"; + // + // trName + // + this.trName.Caption = "名字"; + this.trName.FieldName = "Name"; + this.trName.Name = "trName"; + this.trName.Visible = true; + this.trName.VisibleIndex = 0; + // + // trCode + // + this.trCode.Caption = "编码"; + this.trCode.FieldName = "Code"; + this.trCode.Name = "trCode"; + this.trCode.Visible = true; + this.trCode.VisibleIndex = 1; + // + // label4 + // + this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(23, 11); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(78, 23); + this.label4.TabIndex = 7; + this.label4.Text = "父节点:"; + this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // label3 + // + this.label3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(24, 119); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(78, 23); + this.label3.TabIndex = 6; + this.label3.Text = "顺序:"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // tCode + // + this.tCode.Location = new System.Drawing.Point(107, 65); + this.tCode.Name = "tCode"; + this.tCode.Size = new System.Drawing.Size(196, 21); + this.tCode.TabIndex = 5; + // + // label2 + // + this.label2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(23, 65); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(78, 23); + this.label2.TabIndex = 4; + this.label2.Text = "编码:"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // tName + // + this.tName.Location = new System.Drawing.Point(107, 40); + this.tName.Name = "tName"; + this.tName.Size = new System.Drawing.Size(196, 21); + this.tName.TabIndex = 3; + // + // label1 + // + this.label1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(23, 38); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(78, 23); + this.label1.TabIndex = 2; + this.label1.Text = "名称:"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // HTypeEditForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(386, 351); + this.Controls.Add(this.panel1); + this.Controls.Add(this.panel2); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "HTypeEditForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "HTypeEditForm"; + this.panel2.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nSort)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trParentID.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.treeListLookUpEdit1TreeList)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Button CancelBtn; + private System.Windows.Forms.Button ConfirmBtn; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox tName; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox tCode; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private DevExpress.XtraEditors.TreeListLookUpEdit trParentID; + private DevExpress.XtraTreeList.TreeList treeListLookUpEdit1TreeList; + private DevExpress.XtraTreeList.Columns.TreeListColumn ID; + private DevExpress.XtraTreeList.Columns.TreeListColumn PID; + private DevExpress.XtraTreeList.Columns.TreeListColumn trName; + private DevExpress.XtraTreeList.Columns.TreeListColumn trCode; + private System.Windows.Forms.NumericUpDown nSort; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox tDescribe; + private System.Windows.Forms.TextBox tStandard; + private System.Windows.Forms.Label lable100; + } +} \ No newline at end of file diff --git a/PEIS/View/Setting/HTypeEditForm.cs b/PEIS/View/Setting/HTypeEditForm.cs new file mode 100644 index 0000000..8ff6971 --- /dev/null +++ b/PEIS/View/Setting/HTypeEditForm.cs @@ -0,0 +1,205 @@ +using DevExpress.XtraEditors; +using PEIS.Entity; +using PEIS.Model.Setting; +using PEIS.Utils; +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; + +namespace PEIS.View.Setting +{ + public partial class HTypeEditForm : Form + { + public List dictHazards; + private List treeHazards; + public DictHazardType editHType=null; + public HTypeEditForm() + { + InitializeComponent(); + CancelBtn.Click += CancelBtn_Click; + ConfirmBtn.Click += ConfirmBtn_Click; + trParentID.EditValueChanged += TreeListLookUpEdit1_EditValueChanged; + Shown += DictionaryDEditFrom_Shown; + } + + private void TreeListLookUpEdit1_EditValueChanged(object sender, EventArgs e) + { + var treeListLookUpEdit = sender as TreeListLookUpEdit; + var editValue = treeListLookUpEdit.EditValue?.ToString(); + if (!string.IsNullOrEmpty(editValue)) + { + var id = Int64.Parse(editValue); + var hazard = treeHazards.Where(p => p.ParentID == id).FirstOrDefault(); + if (hazard != null) + { + Global.Msg("info", "请选择最下级"); + treeListLookUpEdit.EditValue = ""; + return; + } + var maxDictHazards=dictHazards.Where(p => p.ParentID == id).OrderByDescending(p => p.Code).FirstOrDefault(); + if (editHType==null) + { + nSort.Value = maxDictHazards==null?1:maxDictHazards.Sort+1; + if (maxDictHazards!=null&&!string.IsNullOrEmpty(maxDictHazards.Code)) + { + var prefixDictHazards = maxDictHazards.Code.Split('-')[0]; + var suffixDictHazards =int.Parse(maxDictHazards.Code.Split('-')[1]); + var strValue = prefixDictHazards + "-" + (suffixDictHazards + 1); + tCode.Text = strValue; + } + } + } + + } + private void DictionaryDEditFrom_Shown(object sender, EventArgs e) + { + List hdList = new List(); + GetParentData(dictHazards,null, ref hdList); + treeHazards = hdList; + + treeListLookUpEdit1TreeList.DataSource = hdList.ConvertAll(p => (object)p); + if (editHType != null) + { + trParentID.EditValue = editHType.ParentID; + tName.Text = editHType.Name; + tCode.Text = editHType.Code; + tStandard.Text = editHType.Standard; + nSort.Value = editHType.Sort; + tDescribe.Text = editHType.Describe; + + //tCode.Enabled = false; + trParentID.Enabled = false; + } + } + /// + /// 父节点 + /// + /// + /// + /// + private void GetParentData(List sources, Int64? id,ref List HdTypeList ) + { + var childen= sources.Where(p => p.ParentID == id).ToList(); + if (childen.Count>0) + { + var current= sources.Where(p => p.ID == id).ToList(); + HdTypeList.AddRange(current); + foreach (var item in childen) + { + GetParentData(sources, item.ID, ref HdTypeList); + } + } + } + private void ConfirmBtn_Click(object sender, EventArgs e) + { + DictHazardType dictHazardType = new DictHazardType(); + bool result = false; + if (string.IsNullOrEmpty(trParentID.EditValue?.ToString())) + { + Global.Msg("info", "父节点不能为空"); + return; + } + if (string.IsNullOrEmpty(tName.Text.Trim())) + { + Global.Msg("info", "接害类型名称不能为空"); + return; + } + if (string.IsNullOrEmpty(tCode.Text.Trim())) + { + Global.Msg("info", "接害类型编码不能为空"); + return; + } + HazardTypeModel hazardType = new HazardTypeModel(); + if (editHType != null) + { + dictHazardType.ID = editHType.ID; + dictHazardType.ParentID = Int64.Parse(trParentID.EditValue.ToString()); + dictHazardType.Name = tName.Text.Trim(); + dictHazardType.Code = tCode.Text.Trim(); + if (!dictHazardType.Name.Equals(editHType.Name)) + { + var dictHByNamePID = hazardType.GetDictHByNamePID((Int64)dictHazardType.ParentID, dictHazardType.Name); + if (dictHByNamePID.Count > 0) + { + string strName = ""; + GetParentName(treeHazards, dictHazardType.ParentID, ref strName); + Global.Msg("info", $"{strName},接害类型名称已经存在"); + return; + } + } + if (!dictHazardType.Code.Equals(editHType.Code)) + { + var dictHByCodePID = hazardType.GetDictHByCodePID((Int64)dictHazardType.ParentID, dictHazardType.Code); + if (dictHByCodePID.Count > 0) + { + string strName = ""; + GetParentName(treeHazards, dictHazardType.ParentID, ref strName); + Global.Msg("info", $"{strName},接害类型编码已经存在"); + return; + } + } + dictHazardType.Standard = tStandard.Text.Trim(); + dictHazardType.Sort = int.Parse(nSort.Value.ToString()); + dictHazardType.Describe = tDescribe.Text.Trim(); + result=dictHazardType.Update(); + } + else { + dictHazardType.ParentID = Int64.Parse(trParentID.EditValue.ToString()); + dictHazardType.Name = tName.Text.Trim(); + dictHazardType.Code = tCode.Text.Trim(); + var dictHByNamePID=hazardType.GetDictHByNamePID((Int64)dictHazardType.ParentID, dictHazardType.Name); + if (dictHByNamePID.Count>0) + { + string strName = ""; + GetParentName(treeHazards, dictHazardType.ParentID, ref strName); + Global.Msg("info", $"{strName},接害类型名称已经存在"); + return; + } + var dictHByCodePID = hazardType.GetDictHByCodePID((Int64)dictHazardType.ParentID, dictHazardType.Code); + if (dictHByCodePID.Count > 0) + { + string strName = ""; + GetParentName(treeHazards, dictHazardType.ParentID, ref strName); + Global.Msg("info", $"{strName},接害类型编码已经存在"); + return; + } + dictHazardType.Standard = tStandard.Text.Trim(); + dictHazardType.Sort = int.Parse(nSort.Value.ToString()); + dictHazardType.Describe = tDescribe.Text.Trim(); + result = dictHazardType.Save(); + } + if (result) + { + DialogResult = DialogResult.OK; + Close(); + } + } + + private void CancelBtn_Click(object sender, EventArgs e) + { + Close(); + } + + public void GetParentName(List treesoucus, Int64? pID, ref string strName) + { + var query=treesoucus.Where(p => p.ID == pID).FirstOrDefault(); + if (query!=null) + { + if (!string.IsNullOrEmpty(strName)) + { + strName = query.Name + "-" + strName; + } + else { + strName = query.Name; + } + GetParentName(treesoucus, query.ParentID, ref strName); + } + } + + } +} diff --git a/PEIS/View/Setting/HTypeEditForm.resx b/PEIS/View/Setting/HTypeEditForm.resx new file mode 100644 index 0000000..2fa380b --- /dev/null +++ b/PEIS/View/Setting/HTypeEditForm.resx @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABGdBTUEAALGPC/xhBQAAAH1JREFUSEvt + lEEKgDAMBPNJf5GX+T+9aiM5REhDVlPx0AGhbXan4KE0+R8787Ixr7pNIx3p6raPBNt3IJfAHaSAZG9k + iplMSCSIZhCeyDt7hRXatY5rMOJ6uTD0AiOv/0We0Dt7RCSKZikygkzGBSki2Qu40IA6w5/ryccQnexo + 4OWtCNeHAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABGdBTUEAALGPC/xhBQAAAPJJREFUSEtj + GAWjgCRgP/9/KJRJfWA/73+kw7z//4GWmEKFqAeAhsaCDAfiy3az/2tChakDgC5PhBp+3m7+f1WoMHUA + 0OWpUMPP2Mz7rwQVpg4AujwTavgJl4X/5aDChIHD3P8NUCZOAHR5Ltjwuf+POE3/Lw0VJgyAmtKhGnFa + AnR5IdTlB5xn/xeHChMPgBpX4bIE6PJSqNwe54X/haHCpAO4JfP/10OFQC6vBIvN+78DKC4AFSYfwC0B + +gTo8looe4vDqv88UCWUA7glELzBsu8/J1SKegBsyfz/a4xn/meFCtEANPxngrJGwShABwwMAJBYlx6C + WXdWAAAAAElFTkSuQmCC + + + \ No newline at end of file diff --git a/PEIS/View/Setting/HazardTypeForm.Designer.cs b/PEIS/View/Setting/HazardTypeForm.Designer.cs index fe16a5c..412ab37 100644 --- a/PEIS/View/Setting/HazardTypeForm.Designer.cs +++ b/PEIS/View/Setting/HazardTypeForm.Designer.cs @@ -36,6 +36,7 @@ this.trCode = new DevExpress.XtraTreeList.Columns.TreeListColumn(); this.trSort = new DevExpress.XtraTreeList.Columns.TreeListColumn(); this.trStandard = new DevExpress.XtraTreeList.Columns.TreeListColumn(); + this.trDescribe = new DevExpress.XtraTreeList.Columns.TreeListColumn(); this.panel2 = new System.Windows.Forms.Panel(); this.opMenuHdType = new PEIS.View.UControl.OpMenu(); this.label2 = new System.Windows.Forms.Label(); @@ -75,6 +76,7 @@ this.panel4 = new System.Windows.Forms.Panel(); this.opMenuItem = new PEIS.View.UControl.OpMenu(); this.label3 = new System.Windows.Forms.Label(); + this.contextMenuBar1 = new FastReport.DevComponents.DotNetBar.ContextMenuBar(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -88,6 +90,7 @@ ((System.ComponentModel.ISupportInitialize)(this.gCFeelItem)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gVFeelItem)).BeginInit(); this.panel4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.contextMenuBar1)).BeginInit(); this.SuspendLayout(); // // splitContainer1 @@ -118,10 +121,12 @@ this.trName, this.trCode, this.trSort, - this.trStandard}); + this.trStandard, + this.trDescribe}); this.treeList1.Dock = System.Windows.Forms.DockStyle.Fill; this.treeList1.Location = new System.Drawing.Point(0, 46); this.treeList1.Name = "treeList1"; + this.treeList1.OptionsMenu.EnableColumnMenu = false; this.treeList1.OptionsView.AutoWidth = false; this.treeList1.Size = new System.Drawing.Size(266, 697); this.treeList1.TabIndex = 1; @@ -206,6 +211,20 @@ this.trStandard.VisibleIndex = 2; this.trStandard.Width = 150; // + // trDescribe + // + this.trDescribe.Caption = "描述"; + this.trDescribe.FieldName = "Describe"; + this.trDescribe.Name = "trDescribe"; + this.trDescribe.OptionsColumn.AllowEdit = false; + this.trDescribe.OptionsColumn.AllowFocus = false; + this.trDescribe.OptionsColumn.AllowSort = false; + this.trDescribe.OptionsFilter.AllowAutoFilter = false; + this.trDescribe.OptionsFilter.AllowFilter = false; + this.trDescribe.Visible = true; + this.trDescribe.VisibleIndex = 3; + this.trDescribe.Width = 200; + // // panel2 // this.panel2.Controls.Add(this.opMenuHdType); @@ -269,6 +288,7 @@ this.DeptName2}); this.gVHFeelItem.GridControl = this.gCHFeelItem; this.gVHFeelItem.Name = "gVHFeelItem"; + this.gVHFeelItem.OptionsMenu.EnableColumnMenu = false; this.gVHFeelItem.OptionsView.ShowGroupPanel = false; this.gVHFeelItem.OptionsView.ShowPreviewRowLines = DevExpress.Utils.DefaultBoolean.False; this.gVHFeelItem.OptionsView.ShowVerticalLines = DevExpress.Utils.DefaultBoolean.False; @@ -505,6 +525,7 @@ this.IsHide}); this.gVFeelItem.GridControl = this.gCFeelItem; this.gVFeelItem.Name = "gVFeelItem"; + this.gVFeelItem.OptionsMenu.EnableColumnMenu = false; this.gVFeelItem.OptionsView.ShowGroupPanel = false; this.gVFeelItem.OptionsView.ShowPreviewRowLines = DevExpress.Utils.DefaultBoolean.False; this.gVFeelItem.OptionsView.ShowVerticalLines = DevExpress.Utils.DefaultBoolean.False; @@ -707,6 +728,17 @@ this.label3.Text = "检查项目"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // contextMenuBar1 + // + this.contextMenuBar1.DockSide = FastReport.DevComponents.DotNetBar.eDockSide.Top; + this.contextMenuBar1.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); + this.contextMenuBar1.Location = new System.Drawing.Point(0, 0); + this.contextMenuBar1.Name = "contextMenuBar1"; + this.contextMenuBar1.Size = new System.Drawing.Size(0, 24); + this.contextMenuBar1.TabIndex = 0; + this.contextMenuBar1.TabStop = false; + this.contextMenuBar1.WrapItemsDock = true; + // // HazardTypeForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); @@ -730,6 +762,7 @@ ((System.ComponentModel.ISupportInitialize)(this.gCFeelItem)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gVFeelItem)).EndInit(); this.panel4.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.contextMenuBar1)).EndInit(); this.ResumeLayout(false); } @@ -783,5 +816,7 @@ private DevExpress.XtraTreeList.Columns.TreeListColumn trCode; private DevExpress.XtraTreeList.Columns.TreeListColumn trSort; private DevExpress.XtraTreeList.Columns.TreeListColumn trStandard; + private DevExpress.XtraTreeList.Columns.TreeListColumn trDescribe; + private FastReport.DevComponents.DotNetBar.ContextMenuBar contextMenuBar1; } } \ No newline at end of file diff --git a/PEIS/View/Setting/HazardTypeForm.cs b/PEIS/View/Setting/HazardTypeForm.cs index 8c0bc75..71f9495 100644 --- a/PEIS/View/Setting/HazardTypeForm.cs +++ b/PEIS/View/Setting/HazardTypeForm.cs @@ -1,4 +1,6 @@ -using DevExpress.XtraTreeList.Nodes; +using DevExpress.XtraBars; +using DevExpress.XtraTreeList; +using DevExpress.XtraTreeList.Nodes; using PEIS.Base; using PEIS.Entity; using PEIS.Event; @@ -31,6 +33,7 @@ namespace PEIS.View.Setting opMenuHdType.TsmiRefresh.Click += TsmiRefresh_Click; treeList1.FocusedNodeChanged += TreeList1_FocusedNodeChanged; + treeList1.MouseDown += TreeList1_MouseDown; //gVHazardType.FocusedRowChanged += GVHazardType_FocusedRowChanged; //关联菜单 opMenuRelation.TsmiRefresh.Visible = true; @@ -55,8 +58,6 @@ namespace PEIS.View.Setting Shown += HazardTypeForm_Shown; } - - private void HazardTypeForm_Shown(object sender, EventArgs e) { ThreadPool.QueueUserWorkItem(s => @@ -66,6 +67,57 @@ namespace PEIS.View.Setting }); } #region 接害类型 + private void TreeList1_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + treeList1.ContextMenuStrip = null; + + TreeListHitInfo hInfo = treeList1.CalcHitInfo(new Point(e.X, e.Y)); + TreeListNode node = hInfo.Node; + //treeList1.FocusedNode = node; + if (node != null) + { + ContextMenuStrip contextMenuStrip1 = new ContextMenuStrip(); + contextMenuStrip1.ItemClicked += ContextMenuStrip1_ItemClicked; + contextMenuStrip1.Items.Add("添加").Name = "添加"; + if (!node.HasChildren) + { + contextMenuStrip1.Items.Add("修改").Name = "修改"; + } + treeList1.ContextMenuStrip = contextMenuStrip1; + } + } + } + private void ContextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + HTypeEditForm hTypeEdit = new HTypeEditForm(); + var dictHazards = treeList1.DataSource as List; + if (dictHazards.Count==0) + { + Global.Msg("info", "没有接害类型分类无法操作"); + return; + } + hTypeEdit.dictHazards = dictHazards; + if (e.ClickedItem.Name == "添加") + { + hTypeEdit.Text = "接害类型-添加"; + } + if (e.ClickedItem.Name == "修改") + { + var hazardTypeRow = treeList1.GetFocusedRow() as DictHazardType; + hTypeEdit.editHType = hazardTypeRow; + hTypeEdit.Text = "接害类型-修改"; + } + + var dialogResult = hTypeEdit.ShowDialog(); + if (dialogResult==DialogResult.OK) + { + LoadHazardType(); + } + } + + public void LoadHazardType() { GetHazardTypeItem?.Invoke(this,new Args()); diff --git a/PEIS/View/Setting/HazardTypeForm.resx b/PEIS/View/Setting/HazardTypeForm.resx index 1af7de1..11cedf8 100644 --- a/PEIS/View/Setting/HazardTypeForm.resx +++ b/PEIS/View/Setting/HazardTypeForm.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file