接害类型加说明字段并增加编辑功能

dhzzyy
luoxingjian 5 months ago
parent 00f7cf1eb8
commit 4af55b0db9
  1. 5
      PEIS/Entity/DictHazardTypecs.cs
  2. 10
      PEIS/Model/Setting/HazardTypeModel.cs
  3. 9
      PEIS/PEIS.csproj
  4. 9
      PEIS/View/Setting/DictionaryTEditFrom.Designer.cs
  5. 322
      PEIS/View/Setting/HTypeEditForm.Designer.cs
  6. 205
      PEIS/View/Setting/HTypeEditForm.cs
  7. 139
      PEIS/View/Setting/HTypeEditForm.resx
  8. 37
      PEIS/View/Setting/HazardTypeForm.Designer.cs
  9. 58
      PEIS/View/Setting/HazardTypeForm.cs
  10. 3
      PEIS/View/Setting/HazardTypeForm.resx

@ -32,6 +32,11 @@ namespace PEIS.Entity
/// 国标
/// </summary>
public string Standard { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Describe { get; set; }
}
}

@ -42,5 +42,15 @@ namespace PEIS.Model.Setting
{
return DAOHelp.GetDataBySQL<DictHTypeFItem>($"Select * From Dict_HTypeFItem a where a.HID={hID}");
}
public List<DictHazardType> GetDictHByNamePID(Int64 pID, string name)
{
var result= DAOHelp.GetDataBySQL<DictHazardType>($@"Select * From Dict_HazardType a where a.ParentID={pID} and a.Name='{name}'");
return result == null ? new List<DictHazardType>() : result;
}
public List<DictHazardType> GetDictHByCodePID(Int64 pID, string code)
{
var result = DAOHelp.GetDataBySQL<DictHazardType>($@"Select * From Dict_HazardType a where a.ParentID={pID} and a.Code='{code}'");
return result == null ? new List<DictHazardType>() : result;
}
}
}

@ -446,6 +446,12 @@
<Compile Include="View\Setting\HazardTypeForm.Designer.cs">
<DependentUpon>HazardTypeForm.cs</DependentUpon>
</Compile>
<Compile Include="View\Setting\HTypeEditForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="View\Setting\HTypeEditForm.Designer.cs">
<DependentUpon>HTypeEditForm.cs</DependentUpon>
</Compile>
<Compile Include="View\Setting\IDictionaryView.cs" />
<Compile Include="View\Setting\IHazardTypeView.cs" />
<Compile Include="View\Setting\IPermissionView.cs" />
@ -654,6 +660,9 @@
<EmbeddedResource Include="View\Setting\HazardTypeForm.resx">
<DependentUpon>HazardTypeForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\Setting\HTypeEditForm.resx">
<DependentUpon>HTypeEditForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\Setting\PermissionForm.resx">
<DependentUpon>PermissionForm.cs</DependentUpon>
</EmbeddedResource>

@ -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();

@ -0,0 +1,322 @@
namespace PEIS.View.Setting
{
partial class HTypeEditForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

@ -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<DictHazardType> dictHazards;
private List<DictHazardType> 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<DictHazardType> hdList = new List<DictHazardType>();
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;
}
}
/// <summary>
/// 父节点
/// </summary>
/// <param name="sources"></param>
/// <param name="id"></param>
/// <param name="HdTypeList"></param>
private void GetParentData(List<DictHazardType> sources, Int64? id,ref List<DictHazardType> 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<DictHazardType> 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);
}
}
}
}

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="CancelBtn.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABGdBTUEAALGPC/xhBQAAAH1JREFUSEvt
lEEKgDAMBPNJf5GX+T+9aiM5REhDVlPx0AGhbXan4KE0+R8787Ixr7pNIx3p6raPBNt3IJfAHaSAZG9k
iplMSCSIZhCeyDt7hRXatY5rMOJ6uTD0AiOv/0We0Dt7RCSKZikygkzGBSki2Qu40IA6w5/ryccQnexo
4OWtCNeHAAAAAElFTkSuQmCC
</value>
</data>
<data name="ConfirmBtn.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
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
</value>
</data>
</root>

@ -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;
}
}

@ -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<DictHazardType>;
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<DictHazardType>());

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuBar1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
Loading…
Cancel
Save