diff --git a/HighWayIot.Repository/service/ZxMaterialChildTypeService.cs b/HighWayIot.Repository/service/ZxMaterialChildTypeService.cs index b56f9c6..4a7fa00 100644 --- a/HighWayIot.Repository/service/ZxMaterialChildTypeService.cs +++ b/HighWayIot.Repository/service/ZxMaterialChildTypeService.cs @@ -2,6 +2,7 @@ using HighWayIot.Repository.domain; using Models; using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -78,5 +79,24 @@ namespace HighWayIot.Repository.service return false; } } + + /// + /// 按组删除物料子类别信息 + /// + /// + /// + public bool DeleteGroup(int[] ids) + { + try + { + dynamic[] dynamicArray = ids.Select(x => (dynamic)x).ToArray(); + return _repository.DeleteByIds(dynamicArray); + } + catch (Exception ex) + { + log.Error("物料子类别组信息删除异常", ex); + return false; + } + } } } diff --git a/HighWayIot.Repository/service/ZxMaterialService.cs b/HighWayIot.Repository/service/ZxMaterialService.cs index 568aad5..321f173 100644 --- a/HighWayIot.Repository/service/ZxMaterialService.cs +++ b/HighWayIot.Repository/service/ZxMaterialService.cs @@ -29,11 +29,28 @@ namespace HighWayIot.Repository.service /// 查询所有物料信息 /// /// - public List GetMaterialInfos() + public List GetMaterialInfos(string materialName = null, string materialType = null, string childType = null) { try { List entity = _repository.GetList(x => x.IsDeleted == false); + if(!string.IsNullOrEmpty(materialName)) + { + entity = entity.Where(x => x.MaterialName.Contains(materialName)).ToList(); + } + + if(!string.IsNullOrEmpty(materialType)) + { + if(!string.IsNullOrEmpty(childType)) + { + entity.Where(x => x.MaterialType == materialType && x.ChildType == childType).ToList(); + } + else + { + entity.Where(x => x.MaterialType == materialType).ToList(); + } + } + return entity; } catch (Exception ex) diff --git a/HighWayIot.Repository/service/ZxMaterialTypeService.cs b/HighWayIot.Repository/service/ZxMaterialTypeService.cs index c8d9b31..f0e341a 100644 --- a/HighWayIot.Repository/service/ZxMaterialTypeService.cs +++ b/HighWayIot.Repository/service/ZxMaterialTypeService.cs @@ -43,6 +43,24 @@ namespace HighWayIot.Repository.service } } + /// + /// 查询所有物料类别信息 + /// + /// + public List GetMaterialTypeInfos(Expression> whereExpression) + { + try + { + List entity = _repository.GetList(whereExpression); + return entity; + } + catch (Exception ex) + { + log.Error("物料类别信息获取异常", ex); + return null; + } + } + /// /// 新增物料类别信息 /// diff --git a/HighWayIot.Winform/MainForm/LoginForm.cs b/HighWayIot.Winform/MainForm/LoginForm.cs index c441eeb..4358491 100644 --- a/HighWayIot.Winform/MainForm/LoginForm.cs +++ b/HighWayIot.Winform/MainForm/LoginForm.cs @@ -34,6 +34,7 @@ namespace HighWayIot.Winform.MainForm if (lists.Count == 1 && lists.First().Password == PassText.Text) { + //更新登录时间 lists.First().LastLoginTime = DateTime.Now; RoleBusiness.LoginUserName = UserText.Text; sysUserInfoService.UpdateUserInfo(lists.First()); diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.Designer.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.Designer.cs index c8bf757..281f9f7 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.Designer.cs @@ -98,6 +98,7 @@ this.MaterialTypeComboBox.Name = "MaterialTypeComboBox"; this.MaterialTypeComboBox.Size = new System.Drawing.Size(136, 20); this.MaterialTypeComboBox.TabIndex = 7; + this.MaterialTypeComboBox.SelectedIndexChanged += new System.EventHandler(this.MaterialTypeComboBox_SelectedIndexChanged); // // ConfrimAddButton // diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs index dcfd8eb..869b313 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs @@ -1,5 +1,6 @@ using HighWayIot.Repository.domain; using HighWayIot.Repository.service; +using Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -14,6 +15,26 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages { public partial class MaterialAddForm : Form { + /// + /// 物料子类型服务类实例 + /// + ZxMaterialChildTypeService zxMaterialChildTypeService = ZxMaterialChildTypeService.Instance; + + /// + /// 物料子类型数组 + /// + string[] MaterialChildTypeArray; + + /// + /// 物料类型服务类实例 + /// + ZxMaterialTypeService zxMaterialTypeService = ZxMaterialTypeService.Instance; + + /// + /// 物料类型数组 + /// + string[] MaterialTypeArray; + /// /// 物料数据库业务实例 /// @@ -22,6 +43,18 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages public MaterialAddForm() { InitializeComponent(); + Init(); + } + + private void Init() + { + //绑定物料类型 + MaterialTypeArray = zxMaterialTypeService.GetMaterialTypeInfos().Select(x => x.MaterialTypeName).ToArray(); + Array.Resize(ref MaterialTypeArray, MaterialTypeArray.Length + 1); + Array.Copy(MaterialTypeArray, 0, MaterialTypeArray, 1, MaterialTypeArray.Length - 1); + MaterialTypeArray[0] = string.Empty; + + MaterialTypeComboBox.DataSource = MaterialTypeArray; } /// @@ -31,9 +64,39 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages /// private void ConfrimAddButton_Click(object sender, EventArgs e) { - + ZxMaterialEntity entity = new ZxMaterialEntity() + { + MaterialCode = MaterialCodeTextBox.Text, + MaterialName = MaterialNameTextBox.Text, + MaterialType = MaterialTypeComboBox.Text, + ChildType = ChildComboBox.Text, + IsUse = IsUseCheckBox.Checked, + IsDeleted = false + }; + + if (!zxMaterialService.InsertMaterialInfo(entity)) + { + MessageBox.Show("物料信息添加失败,请尝试重新添加。"); + return; + } + this.Close(); this.Dispose(); } + + /// + /// 主物料类型选择改变事件 + /// + /// + /// + private void MaterialTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + MaterialChildTypeArray = zxMaterialChildTypeService.GetMaterialChildTypeInfos(x => x.MaterialTypeName == MaterialTypeComboBox.Text).Select(x => x.MaterialChlidTypeName).ToArray(); + Array.Resize(ref MaterialChildTypeArray, MaterialChildTypeArray.Length + 1); + Array.Copy(MaterialChildTypeArray, 0, MaterialChildTypeArray, 1, MaterialChildTypeArray.Length - 1); + MaterialChildTypeArray[0] = string.Empty; + + ChildComboBox.DataSource = MaterialChildTypeArray; + } } } diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.Designer.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.Designer.cs index 1635718..2448d61 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.Designer.cs @@ -32,18 +32,22 @@ namespace HighWayIot.Winform.UserControlPages private void InitializeComponent() { this.MaterialDataGridView = new System.Windows.Forms.DataGridView(); - this.AddMaterial = new System.Windows.Forms.Button(); - this.ButtonPanel = new System.Windows.Forms.Panel(); - this.UpdateMaterial = new System.Windows.Forms.Button(); - this.DeleteMaterial = new System.Windows.Forms.Button(); - this.SelectMaterial = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.MaterialNameTextbox = new System.Windows.Forms.TextBox(); this.MaterialCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.MaterialName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.MaterialType = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ChildType = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.IsUse = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.AddMaterial = new System.Windows.Forms.Button(); + this.ButtonPanel = new System.Windows.Forms.Panel(); + this.MaterialNameTextbox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.SelectMaterial = new System.Windows.Forms.Button(); + this.DeleteMaterial = new System.Windows.Forms.Button(); + this.UpdateMaterial = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.MaterialTypeComboBox = new System.Windows.Forms.ComboBox(); + this.ChildComboBox = new System.Windows.Forms.ComboBox(); + this.label3 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.MaterialDataGridView)).BeginInit(); this.ButtonPanel.SuspendLayout(); this.SuspendLayout(); @@ -69,6 +73,40 @@ namespace HighWayIot.Winform.UserControlPages this.MaterialDataGridView.TabIndex = 0; this.MaterialDataGridView.Tag = ""; // + // MaterialCode + // + this.MaterialCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.MaterialCode.DataPropertyName = "MaterialCode"; + this.MaterialCode.HeaderText = "物料编码"; + this.MaterialCode.Name = "MaterialCode"; + // + // MaterialName + // + this.MaterialName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.MaterialName.DataPropertyName = "MaterialName"; + this.MaterialName.HeaderText = "物料名称"; + this.MaterialName.Name = "MaterialName"; + // + // MaterialType + // + this.MaterialType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.MaterialType.DataPropertyName = "MaterialType"; + this.MaterialType.HeaderText = "物料类型"; + this.MaterialType.Name = "MaterialType"; + // + // ChildType + // + this.ChildType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ChildType.DataPropertyName = "ChildType"; + this.ChildType.HeaderText = "物料子类型"; + this.ChildType.Name = "ChildType"; + // + // IsUse + // + this.IsUse.DataPropertyName = "IsUse"; + this.IsUse.HeaderText = "是否启用"; + this.IsUse.Name = "IsUse"; + // // AddMaterial // this.AddMaterial.Location = new System.Drawing.Point(11, 11); @@ -84,6 +122,10 @@ namespace HighWayIot.Winform.UserControlPages // this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonPanel.Controls.Add(this.ChildComboBox); + this.ButtonPanel.Controls.Add(this.label3); + this.ButtonPanel.Controls.Add(this.MaterialTypeComboBox); + this.ButtonPanel.Controls.Add(this.label2); this.ButtonPanel.Controls.Add(this.MaterialNameTextbox); this.ButtonPanel.Controls.Add(this.label1); this.ButtonPanel.Controls.Add(this.SelectMaterial); @@ -96,27 +138,21 @@ namespace HighWayIot.Winform.UserControlPages this.ButtonPanel.Size = new System.Drawing.Size(1350, 61); this.ButtonPanel.TabIndex = 4; // - // UpdateMaterial + // MaterialNameTextbox // - this.UpdateMaterial.Location = new System.Drawing.Point(120, 11); - this.UpdateMaterial.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.UpdateMaterial.Name = "UpdateMaterial"; - this.UpdateMaterial.Size = new System.Drawing.Size(103, 39); - this.UpdateMaterial.TabIndex = 2; - this.UpdateMaterial.Text = "修改物料信息"; - this.UpdateMaterial.UseVisualStyleBackColor = true; - this.UpdateMaterial.Click += new System.EventHandler(this.UpdateMaterial_Click); + this.MaterialNameTextbox.Location = new System.Drawing.Point(526, 20); + this.MaterialNameTextbox.Name = "MaterialNameTextbox"; + this.MaterialNameTextbox.Size = new System.Drawing.Size(130, 21); + this.MaterialNameTextbox.TabIndex = 6; // - // DeleteMaterial + // label1 // - this.DeleteMaterial.Location = new System.Drawing.Point(229, 11); - this.DeleteMaterial.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.DeleteMaterial.Name = "DeleteMaterial"; - this.DeleteMaterial.Size = new System.Drawing.Size(103, 39); - this.DeleteMaterial.TabIndex = 3; - this.DeleteMaterial.Text = "删除物料信息"; - this.DeleteMaterial.UseVisualStyleBackColor = true; - this.DeleteMaterial.Click += new System.EventHandler(this.DeleteMaterial_Click); + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(456, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(65, 12); + this.label1.TabIndex = 5; + this.label1.Text = "物料名称:"; // // SelectMaterial // @@ -129,55 +165,61 @@ namespace HighWayIot.Winform.UserControlPages this.SelectMaterial.UseVisualStyleBackColor = true; this.SelectMaterial.Click += new System.EventHandler(this.SelectMaterial_Click); // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(456, 24); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(65, 12); - this.label1.TabIndex = 5; - this.label1.Text = "物料名称:"; - // - // MaterialNameTextbox + // DeleteMaterial // - this.MaterialNameTextbox.Location = new System.Drawing.Point(526, 20); - this.MaterialNameTextbox.Name = "MaterialNameTextbox"; - this.MaterialNameTextbox.Size = new System.Drawing.Size(130, 21); - this.MaterialNameTextbox.TabIndex = 6; + this.DeleteMaterial.Location = new System.Drawing.Point(229, 11); + this.DeleteMaterial.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.DeleteMaterial.Name = "DeleteMaterial"; + this.DeleteMaterial.Size = new System.Drawing.Size(103, 39); + this.DeleteMaterial.TabIndex = 3; + this.DeleteMaterial.Text = "删除物料信息"; + this.DeleteMaterial.UseVisualStyleBackColor = true; + this.DeleteMaterial.Click += new System.EventHandler(this.DeleteMaterial_Click); // - // MaterialCode + // UpdateMaterial // - this.MaterialCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.MaterialCode.DataPropertyName = "MaterialCode"; - this.MaterialCode.HeaderText = "物料编码"; - this.MaterialCode.Name = "MaterialCode"; + this.UpdateMaterial.Location = new System.Drawing.Point(120, 11); + this.UpdateMaterial.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.UpdateMaterial.Name = "UpdateMaterial"; + this.UpdateMaterial.Size = new System.Drawing.Size(103, 39); + this.UpdateMaterial.TabIndex = 2; + this.UpdateMaterial.Text = "修改物料信息"; + this.UpdateMaterial.UseVisualStyleBackColor = true; + this.UpdateMaterial.Click += new System.EventHandler(this.UpdateMaterial_Click); // - // MaterialName + // label2 // - this.MaterialName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.MaterialName.DataPropertyName = "MaterialName"; - this.MaterialName.HeaderText = "物料名称"; - this.MaterialName.Name = "MaterialName"; + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(672, 24); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(65, 12); + this.label2.TabIndex = 7; + this.label2.Text = "物料类型:"; // - // MaterialType + // MaterialTypeComboBox // - this.MaterialType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.MaterialType.DataPropertyName = "MaterialType"; - this.MaterialType.HeaderText = "物料类型"; - this.MaterialType.Name = "MaterialType"; + this.MaterialTypeComboBox.FormattingEnabled = true; + this.MaterialTypeComboBox.Location = new System.Drawing.Point(743, 20); + this.MaterialTypeComboBox.Name = "MaterialTypeComboBox"; + this.MaterialTypeComboBox.Size = new System.Drawing.Size(124, 20); + this.MaterialTypeComboBox.TabIndex = 8; // - // ChildType + // ChildComboBox // - this.ChildType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.ChildType.DataPropertyName = "ChildType"; - this.ChildType.HeaderText = "物料子类型"; - this.ChildType.Name = "ChildType"; + this.ChildComboBox.FormattingEnabled = true; + this.ChildComboBox.Location = new System.Drawing.Point(932, 20); + this.ChildComboBox.Name = "ChildComboBox"; + this.ChildComboBox.Size = new System.Drawing.Size(124, 20); + this.ChildComboBox.TabIndex = 10; // - // IsUse + // label3 // - this.IsUse.DataPropertyName = "IsUse"; - this.IsUse.HeaderText = "是否启用"; - this.IsUse.Name = "IsUse"; + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(873, 24); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(53, 12); + this.label3.TabIndex = 9; + this.label3.Text = "子类型:"; // // MaterialConfigPage // @@ -211,5 +253,9 @@ namespace HighWayIot.Winform.UserControlPages private DataGridViewTextBoxColumn MaterialType; private DataGridViewTextBoxColumn ChildType; private DataGridViewTextBoxColumn IsUse; + private ComboBox ChildComboBox; + private Label label3; + private ComboBox MaterialTypeComboBox; + private Label label2; } } diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs index c1571f9..9bd1c89 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs @@ -10,13 +10,20 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Windows.Forms.VisualStyles; namespace HighWayIot.Winform.UserControlPages { public partial class MaterialConfigPage : UserControl { + /// + /// 物料信息服务类实例 + /// ZxMaterialService zxMaterialService = ZxMaterialService.Instance; + /// + /// 物料信息列表 + /// List Lists; public MaterialConfigPage() @@ -29,6 +36,8 @@ namespace HighWayIot.Winform.UserControlPages { MaterialDataGridView.AutoGenerateColumns = false; + + Lists = zxMaterialService.GetMaterialInfos(); MaterialDataGridView.DataSource = null; @@ -91,7 +100,9 @@ namespace HighWayIot.Winform.UserControlPages /// private void SelectMaterial_Click(object sender, EventArgs e) { - + Lists = zxMaterialService.GetMaterialInfos(MaterialNameTextbox.Text.Trim(), MaterialTypeComboBox.Text.Trim(), ChildComboBox.Text.Trim()); + MaterialDataGridView.DataSource = null; + MaterialDataGridView.DataSource = Lists; } } } diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.Designer.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.Designer.cs index d1e72e6..0986562 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.Designer.cs @@ -29,80 +29,47 @@ private void InitializeComponent() { this.Controlpanel = new System.Windows.Forms.Panel(); - this.AddMaterialTypeButton = new System.Windows.Forms.Button(); - this.Datapanel = new System.Windows.Forms.Panel(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.groupBox4 = new System.Windows.Forms.GroupBox(); - this.DeleteMaterialTypeButton = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.MaterialTypeTextBox = new System.Windows.Forms.TextBox(); this.MaterialChildTypeTextBox = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.DeleteMaterialChildTypeButton = new System.Windows.Forms.Button(); this.AddMaterialChildTypeButton = new System.Windows.Forms.Button(); - this.MaterialTypeDataGridView = new System.Windows.Forms.DataGridView(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.MaterialTypeTextBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.DeleteMaterialTypeButton = new System.Windows.Forms.Button(); + this.AddMaterialTypeButton = new System.Windows.Forms.Button(); + this.Datapanel = new System.Windows.Forms.Panel(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); this.MaterialChildTypeDataGridView = new System.Windows.Forms.DataGridView(); - this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.MaterialTypeName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ChildId = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.MaterialChildTypeName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.MaterialTypeDataGridView = new System.Windows.Forms.DataGridView(); + this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MaterialTypeName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Controlpanel.SuspendLayout(); - this.Datapanel.SuspendLayout(); - this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); - this.groupBox3.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.Datapanel.SuspendLayout(); this.groupBox4.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.MaterialTypeDataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.MaterialChildTypeDataGridView)).BeginInit(); + this.groupBox3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.MaterialTypeDataGridView)).BeginInit(); this.SuspendLayout(); // // Controlpanel // + this.Controlpanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.Controlpanel.Controls.Add(this.groupBox2); this.Controlpanel.Controls.Add(this.groupBox1); - this.Controlpanel.Dock = System.Windows.Forms.DockStyle.Top; this.Controlpanel.Location = new System.Drawing.Point(0, 0); this.Controlpanel.Margin = new System.Windows.Forms.Padding(0); this.Controlpanel.Name = "Controlpanel"; this.Controlpanel.Size = new System.Drawing.Size(1145, 79); this.Controlpanel.TabIndex = 0; // - // AddMaterialTypeButton - // - this.AddMaterialTypeButton.Location = new System.Drawing.Point(6, 20); - this.AddMaterialTypeButton.Name = "AddMaterialTypeButton"; - this.AddMaterialTypeButton.Size = new System.Drawing.Size(97, 42); - this.AddMaterialTypeButton.TabIndex = 0; - this.AddMaterialTypeButton.Text = "物料类型添加"; - this.AddMaterialTypeButton.UseVisualStyleBackColor = true; - this.AddMaterialTypeButton.Click += new System.EventHandler(this.AddMaterialTypeButton_Click); - // - // Datapanel - // - this.Datapanel.Controls.Add(this.groupBox4); - this.Datapanel.Controls.Add(this.groupBox3); - this.Datapanel.Dock = System.Windows.Forms.DockStyle.Bottom; - this.Datapanel.Location = new System.Drawing.Point(0, 79); - this.Datapanel.Margin = new System.Windows.Forms.Padding(0); - this.Datapanel.Name = "Datapanel"; - this.Datapanel.Size = new System.Drawing.Size(1145, 710); - this.Datapanel.TabIndex = 1; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.MaterialTypeTextBox); - this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Controls.Add(this.DeleteMaterialTypeButton); - this.groupBox1.Controls.Add(this.AddMaterialTypeButton); - this.groupBox1.Location = new System.Drawing.Point(3, 3); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(569, 73); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "物料类别控制"; - // // groupBox2 // this.groupBox2.Controls.Add(this.MaterialChildTypeTextBox); @@ -116,52 +83,6 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "物料子类别控制"; // - // groupBox3 - // - this.groupBox3.Controls.Add(this.MaterialTypeDataGridView); - this.groupBox3.Location = new System.Drawing.Point(3, 3); - this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(569, 704); - this.groupBox3.TabIndex = 1; - this.groupBox3.TabStop = false; - this.groupBox3.Text = "物料类别"; - // - // groupBox4 - // - this.groupBox4.Controls.Add(this.MaterialChildTypeDataGridView); - this.groupBox4.Location = new System.Drawing.Point(578, 3); - this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(564, 704); - this.groupBox4.TabIndex = 2; - this.groupBox4.TabStop = false; - this.groupBox4.Text = "物料子类别"; - // - // DeleteMaterialTypeButton - // - this.DeleteMaterialTypeButton.Location = new System.Drawing.Point(468, 20); - this.DeleteMaterialTypeButton.Name = "DeleteMaterialTypeButton"; - this.DeleteMaterialTypeButton.Size = new System.Drawing.Size(95, 42); - this.DeleteMaterialTypeButton.TabIndex = 1; - this.DeleteMaterialTypeButton.Text = "物料类型删除"; - this.DeleteMaterialTypeButton.UseVisualStyleBackColor = true; - this.DeleteMaterialTypeButton.Click += new System.EventHandler(this.DeleteMaterialTypeButton_Click); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(107, 20); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(101, 12); - this.label1.TabIndex = 2; - this.label1.Text = "要添加类型的名称"; - // - // MaterialTypeTextBox - // - this.MaterialTypeTextBox.Location = new System.Drawing.Point(109, 41); - this.MaterialTypeTextBox.Name = "MaterialTypeTextBox"; - this.MaterialTypeTextBox.Size = new System.Drawing.Size(99, 21); - this.MaterialTypeTextBox.TabIndex = 3; - // // MaterialChildTypeTextBox // this.MaterialChildTypeTextBox.Location = new System.Drawing.Point(117, 41); @@ -198,23 +119,79 @@ this.AddMaterialChildTypeButton.UseVisualStyleBackColor = true; this.AddMaterialChildTypeButton.Click += new System.EventHandler(this.AddMaterialChildTypeButton_Click); // - // MaterialTypeDataGridView + // groupBox1 // - this.MaterialTypeDataGridView.AllowUserToAddRows = false; - this.MaterialTypeDataGridView.AllowUserToDeleteRows = false; - this.MaterialTypeDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.MaterialTypeDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.Id, - this.MaterialTypeName}); - this.MaterialTypeDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; - this.MaterialTypeDataGridView.Location = new System.Drawing.Point(3, 17); - this.MaterialTypeDataGridView.Name = "MaterialTypeDataGridView"; - this.MaterialTypeDataGridView.ReadOnly = true; - this.MaterialTypeDataGridView.RowHeadersVisible = false; - this.MaterialTypeDataGridView.RowTemplate.Height = 23; - this.MaterialTypeDataGridView.Size = new System.Drawing.Size(563, 684); - this.MaterialTypeDataGridView.TabIndex = 0; - this.MaterialTypeDataGridView.SelectionChanged += new System.EventHandler(this.MaterialTypeDataGridView_SelectionChanged); + this.groupBox1.Controls.Add(this.MaterialTypeTextBox); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.DeleteMaterialTypeButton); + this.groupBox1.Controls.Add(this.AddMaterialTypeButton); + this.groupBox1.Location = new System.Drawing.Point(3, 3); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(569, 73); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "物料类别控制"; + // + // MaterialTypeTextBox + // + this.MaterialTypeTextBox.Location = new System.Drawing.Point(109, 41); + this.MaterialTypeTextBox.Name = "MaterialTypeTextBox"; + this.MaterialTypeTextBox.Size = new System.Drawing.Size(99, 21); + this.MaterialTypeTextBox.TabIndex = 3; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(107, 20); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(101, 12); + this.label1.TabIndex = 2; + this.label1.Text = "要添加类型的名称"; + // + // DeleteMaterialTypeButton + // + this.DeleteMaterialTypeButton.Location = new System.Drawing.Point(468, 20); + this.DeleteMaterialTypeButton.Name = "DeleteMaterialTypeButton"; + this.DeleteMaterialTypeButton.Size = new System.Drawing.Size(95, 42); + this.DeleteMaterialTypeButton.TabIndex = 1; + this.DeleteMaterialTypeButton.Text = "物料类型删除"; + this.DeleteMaterialTypeButton.UseVisualStyleBackColor = true; + this.DeleteMaterialTypeButton.Click += new System.EventHandler(this.DeleteMaterialTypeButton_Click); + // + // AddMaterialTypeButton + // + this.AddMaterialTypeButton.Location = new System.Drawing.Point(6, 20); + this.AddMaterialTypeButton.Name = "AddMaterialTypeButton"; + this.AddMaterialTypeButton.Size = new System.Drawing.Size(97, 42); + this.AddMaterialTypeButton.TabIndex = 0; + this.AddMaterialTypeButton.Text = "物料类型添加"; + this.AddMaterialTypeButton.UseVisualStyleBackColor = true; + this.AddMaterialTypeButton.Click += new System.EventHandler(this.AddMaterialTypeButton_Click); + // + // Datapanel + // + this.Datapanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.Datapanel.Controls.Add(this.groupBox4); + this.Datapanel.Controls.Add(this.groupBox3); + this.Datapanel.Location = new System.Drawing.Point(0, 79); + this.Datapanel.Margin = new System.Windows.Forms.Padding(0); + this.Datapanel.Name = "Datapanel"; + this.Datapanel.Size = new System.Drawing.Size(1145, 710); + this.Datapanel.TabIndex = 1; + // + // groupBox4 + // + this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.groupBox4.Controls.Add(this.MaterialChildTypeDataGridView); + this.groupBox4.Location = new System.Drawing.Point(578, 3); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(564, 704); + this.groupBox4.TabIndex = 2; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "物料子类别"; // // MaterialChildTypeDataGridView // @@ -233,22 +210,6 @@ this.MaterialChildTypeDataGridView.Size = new System.Drawing.Size(558, 684); this.MaterialChildTypeDataGridView.TabIndex = 1; // - // Id - // - this.Id.DataPropertyName = "Id"; - this.Id.HeaderText = "Id"; - this.Id.Name = "Id"; - this.Id.ReadOnly = true; - this.Id.Width = 40; - // - // MaterialTypeName - // - this.MaterialTypeName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.MaterialTypeName.DataPropertyName = "MaterialTypeName"; - this.MaterialTypeName.HeaderText = "物料类型"; - this.MaterialTypeName.Name = "MaterialTypeName"; - this.MaterialTypeName.ReadOnly = true; - // // ChildId // this.ChildId.DataPropertyName = "Id"; @@ -265,6 +226,52 @@ this.MaterialChildTypeName.Name = "MaterialChildTypeName"; this.MaterialChildTypeName.ReadOnly = true; // + // groupBox3 + // + this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.groupBox3.Controls.Add(this.MaterialTypeDataGridView); + this.groupBox3.Location = new System.Drawing.Point(3, 3); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(569, 704); + this.groupBox3.TabIndex = 1; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "物料类别"; + // + // MaterialTypeDataGridView + // + this.MaterialTypeDataGridView.AllowUserToAddRows = false; + this.MaterialTypeDataGridView.AllowUserToDeleteRows = false; + this.MaterialTypeDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.MaterialTypeDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Id, + this.MaterialTypeName}); + this.MaterialTypeDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; + this.MaterialTypeDataGridView.Location = new System.Drawing.Point(3, 17); + this.MaterialTypeDataGridView.Name = "MaterialTypeDataGridView"; + this.MaterialTypeDataGridView.ReadOnly = true; + this.MaterialTypeDataGridView.RowHeadersVisible = false; + this.MaterialTypeDataGridView.RowTemplate.Height = 23; + this.MaterialTypeDataGridView.Size = new System.Drawing.Size(563, 684); + this.MaterialTypeDataGridView.TabIndex = 0; + this.MaterialTypeDataGridView.SelectionChanged += new System.EventHandler(this.MaterialTypeDataGridView_SelectionChanged); + // + // Id + // + this.Id.DataPropertyName = "Id"; + this.Id.HeaderText = "Id"; + this.Id.Name = "Id"; + this.Id.ReadOnly = true; + this.Id.Width = 40; + // + // MaterialTypeName + // + this.MaterialTypeName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.MaterialTypeName.DataPropertyName = "MaterialTypeName"; + this.MaterialTypeName.HeaderText = "物料类型"; + this.MaterialTypeName.Name = "MaterialTypeName"; + this.MaterialTypeName.ReadOnly = true; + // // MaterialTypeConfigPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -275,15 +282,15 @@ this.Name = "MaterialTypeConfigPage"; this.Size = new System.Drawing.Size(1145, 789); this.Controlpanel.ResumeLayout(false); - this.Datapanel.ResumeLayout(false); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); - this.groupBox3.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.Datapanel.ResumeLayout(false); this.groupBox4.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.MaterialTypeDataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.MaterialChildTypeDataGridView)).EndInit(); + this.groupBox3.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.MaterialTypeDataGridView)).EndInit(); this.ResumeLayout(false); } diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.cs index 1ed6368..d595cc5 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.cs +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.cs @@ -15,6 +15,7 @@ namespace HighWayIot.Winform.UserControlPages.MaterialConfigPages { public partial class MaterialTypeConfigPage : UserControl { + /// /// 物料子类型服务类实例 /// @@ -60,9 +61,23 @@ namespace HighWayIot.Winform.UserControlPages.MaterialConfigPages /// private void AddMaterialTypeButton_Click(object sender, EventArgs e) { + string material = MaterialTypeTextBox.Text.Trim(); + + if (string.IsNullOrEmpty(material)) + { + MessageBox.Show("物料类型不能为空!", "提示"); + return; + } + + if (zxMaterialTypeService.GetMaterialTypeInfos(x => x.MaterialTypeName == material).Count != 0) + { + MessageBox.Show("物料类型重复!", "提示"); + return; + } + zxMaterialTypeService.InsertMaterialTypeInfo(new ZxMaterialTypeEntity() { - MaterialTypeName = MaterialTypeTextBox.Text.Trim(), + MaterialTypeName = material, }); zxMaterialTypeList = zxMaterialTypeService.GetMaterialTypeInfos(); @@ -83,10 +98,24 @@ namespace HighWayIot.Winform.UserControlPages.MaterialConfigPages string s = MaterialTypeDataGridView.Rows[a].Cells["MaterialTypeName"].Value.ToString(); + string material = MaterialChildTypeTextBox.Text.Trim(); + + if (string.IsNullOrEmpty(material)) + { + MessageBox.Show("物料子类型不能为空!", "提示"); + return; + } + + if (zxMaterialChildTypeService.GetMaterialChildTypeInfos(x => x.MaterialTypeName == s && x.MaterialChlidTypeName == material).Count != 0) + { + MessageBox.Show("物料子类型重复!", "提示"); + return; + } + zxMaterialChildTypeService.InsertMaterialChildTypeInfo(new ZxMaterialChildTypeEntity() { MaterialTypeName = s, - MaterialChlidTypeName = MaterialChildTypeTextBox.Text.Trim(), + MaterialChlidTypeName = material, }); zxMaterialChildTypeList = zxMaterialChildTypeService.GetMaterialChildTypeInfos(x => x.MaterialTypeName == s); @@ -102,7 +131,39 @@ namespace HighWayIot.Winform.UserControlPages.MaterialConfigPages /// private void DeleteMaterialTypeButton_Click(object sender, EventArgs e) { + //获取选择的物料类型行 + int a = MaterialTypeDataGridView.CurrentRow.Index; + + string s = MaterialTypeDataGridView.Rows[a].Cells["MaterialTypeName"].Value.ToString(); + if (MessageBox.Show($"确定要删除{s}吗", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) + { + return; + } + + int[] intArray = zxMaterialChildTypeService.GetMaterialChildTypeInfos(x => x.MaterialTypeName == s).Select(x => x.Id).ToArray(); + if (intArray.Length != 0) + { + if (MessageBox.Show($"是否要删除其关联的所有子物料类型", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + if (!zxMaterialChildTypeService.DeleteGroup(intArray)) + { + MessageBox.Show("关联子物料类型删除失败!", "提示"); + } + } + } + + int id = int.Parse(MaterialTypeDataGridView.Rows[a].Cells["Id"].Value.ToString().Trim()); + + if (zxMaterialTypeService.DeleteMaterialTypeInfoById(id)) + { + MessageBox.Show("删除成功!", "提示"); + } + + zxMaterialTypeList = zxMaterialTypeService.GetMaterialTypeInfos(); + + MaterialTypeDataGridView.DataSource = null; + MaterialTypeDataGridView.DataSource = zxMaterialTypeList; } /// @@ -112,7 +173,30 @@ namespace HighWayIot.Winform.UserControlPages.MaterialConfigPages /// private void DeleteMaterialChildTypeButton_Click(object sender, EventArgs e) { + //获取选择的物料子类型行 + int a = MaterialChildTypeDataGridView.CurrentRow.Index; + + if (MessageBox.Show($"确定要删除{MaterialChildTypeDataGridView.Rows[a].Cells["MaterialChildTypeName"].Value.ToString()}吗", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) + { + return; + } + + int id = int.Parse(MaterialChildTypeDataGridView.Rows[a].Cells["ChildId"].Value.ToString().Trim()); + + if (zxMaterialChildTypeService.DeleteMaterialChildTypeInfoById(id)) + { + MessageBox.Show("删除成功!", "提示"); + } + + //获取选择的物料类型行 + a = MaterialTypeDataGridView.CurrentRow.Index; + + string s = MaterialTypeDataGridView.Rows[a].Cells["MaterialTypeName"].Value.ToString(); + zxMaterialChildTypeList = zxMaterialChildTypeService.GetMaterialChildTypeInfos(x => x.MaterialTypeName == s); + + MaterialChildTypeDataGridView.DataSource = null; + MaterialChildTypeDataGridView.DataSource = zxMaterialChildTypeList; } /// diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.resx b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.resx index f9ba3e8..6e7f45c 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.resx +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.resx @@ -129,6 +129,12 @@ True + + True + + + True + True diff --git a/HighWayIot.Winform/UserControlPages/SysConfigPages/RoleUpdateForm.resx b/HighWayIot.Winform/UserControlPages/SysConfigPages/RoleUpdateForm.resx index 19a14a1..af8c043 100644 --- a/HighWayIot.Winform/UserControlPages/SysConfigPages/RoleUpdateForm.resx +++ b/HighWayIot.Winform/UserControlPages/SysConfigPages/RoleUpdateForm.resx @@ -123,10 +123,4 @@ True - - True - - - True - \ No newline at end of file