diff --git a/HighWayIot.Log4net/LogHelper.cs b/HighWayIot.Log4net/LogHelper.cs
index c36ef08..dd53eba 100644
--- a/HighWayIot.Log4net/LogHelper.cs
+++ b/HighWayIot.Log4net/LogHelper.cs
@@ -66,7 +66,7 @@ namespace HighWayIot.Log4net
{
if (logPlc.IsInfoEnabled)
{
- logPlc.Info(msg);
+ logPlc.Debug(msg);
}
}
@@ -78,7 +78,7 @@ namespace HighWayIot.Log4net
{
if (logRfid.IsInfoEnabled)
{
- logRfid.Info(msg);
+ logRfid.Debug(msg);
}
}
@@ -98,7 +98,7 @@ namespace HighWayIot.Log4net
{
if (sqllog.IsInfoEnabled)
{
- sqllog.Info(msg);
+ sqllog.Debug(msg);
}
}
diff --git a/HighWayIot.Log4net/config/log4net.config b/HighWayIot.Log4net/config/log4net.config
index a5e25be..e2f5449 100644
--- a/HighWayIot.Log4net/config/log4net.config
+++ b/HighWayIot.Log4net/config/log4net.config
@@ -10,53 +10,67 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HighWayIot.Repository/domain/WeightDataSourceEntity.cs b/HighWayIot.Repository/domain/WeightDataSourceEntity.cs
index 93316fa..f956ed2 100644
--- a/HighWayIot.Repository/domain/WeightDataSourceEntity.cs
+++ b/HighWayIot.Repository/domain/WeightDataSourceEntity.cs
@@ -81,11 +81,5 @@ namespace HighWayIot.Repository.domain
/// 默认值:
///
public bool? IsUse { get; set; }
-
- ///
- /// 备 注:是否删除
- /// 默认值:
- ///
- public bool? IsDeleted { get; set; }
}
}
diff --git a/HighWayIot.Repository/domain/ZxMaterialEntity.cs b/HighWayIot.Repository/domain/ZxMaterialEntity.cs
index 043fdea..65f533f 100644
--- a/HighWayIot.Repository/domain/ZxMaterialEntity.cs
+++ b/HighWayIot.Repository/domain/ZxMaterialEntity.cs
@@ -10,12 +10,19 @@ namespace Models
[SugarTable("zx_material")]
public class ZxMaterialEntity
{
+ ///
+ /// 备 注:
+ /// 默认值:
+ ///
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+
///
/// 备 注:物料编码
/// 默认值:
///
- [SugarColumn(ColumnName = "material_code", IsPrimaryKey = true)]
- public string MaterialCode { get; set; } = null;
+ [SugarColumn(ColumnName = "material_code")]
+ public string MaterialCode { get; set; }
///
/// 备 注:物料名称
diff --git a/HighWayIot.Repository/domain/ZxRecipeEntity.cs b/HighWayIot.Repository/domain/ZxRecipeEntity.cs
index 24406ef..a07b536 100644
--- a/HighWayIot.Repository/domain/ZxRecipeEntity.cs
+++ b/HighWayIot.Repository/domain/ZxRecipeEntity.cs
@@ -10,11 +10,18 @@ namespace Models
[SugarTable("zx_recipe")]
public class ZxRecipeEntity
{
+ ///
+ /// 备 注:
+ /// 默认值:
+ ///
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+
///
/// 备 注:配方编号
/// 默认值:
///
- [SugarColumn(ColumnName = "recipe_code", IsPrimaryKey = true)]
+ [SugarColumn(ColumnName = "recipe_code")]
public string RecipeCode { get; set; }
///
diff --git a/HighWayIot.Repository/service/ZxMaterialChildTypeService.cs b/HighWayIot.Repository/service/ZxMaterialChildTypeService.cs
index 4a7fa00..10f4682 100644
--- a/HighWayIot.Repository/service/ZxMaterialChildTypeService.cs
+++ b/HighWayIot.Repository/service/ZxMaterialChildTypeService.cs
@@ -83,13 +83,14 @@ namespace HighWayIot.Repository.service
///
/// 按组删除物料子类别信息
///
- ///
+ /// 子类别信息ID数组
///
public bool DeleteGroup(int[] ids)
{
try
{
dynamic[] dynamicArray = ids.Select(x => (dynamic)x).ToArray();
+
return _repository.DeleteByIds(dynamicArray);
}
catch (Exception ex)
diff --git a/HighWayIot.Repository/service/ZxMaterialService.cs b/HighWayIot.Repository/service/ZxMaterialService.cs
index d5a0599..9613ce3 100644
--- a/HighWayIot.Repository/service/ZxMaterialService.cs
+++ b/HighWayIot.Repository/service/ZxMaterialService.cs
@@ -71,23 +71,41 @@ namespace HighWayIot.Repository.service
}
///
- /// 根据物料编号获取单条数据
+ /// 根据Id获取单条数据
///
- /// 物料编号
+ /// 物料编号
///
- public ZxMaterialEntity GetSingleEntityByCode(string materialCode)
+ public ZxMaterialEntity GetSingleEntityById(int id)
{
try
{
- return _repository.GetById(materialCode);
+ return _repository.GetById(id);
}
- catch(Exception ex)
+ catch (Exception ex)
{
log.Error("单条物料信息获取异常", ex);
return null;
}
}
+ ///
+ /// 根据MaterialCode获取数据
+ ///
+ /// 物料编号
+ ///
+ public List GetEntityByMaterialCode(string materialCode)
+ {
+ try
+ {
+ return _repository.GetList(x => x.MaterialCode == materialCode && x.IsDeleted == false);
+ }
+ catch (Exception ex)
+ {
+ log.Error("根据MaterialCode获取物料信息获取异常", ex);
+ return null;
+ }
+ }
+
///
/// 修改物料信息
///
@@ -127,13 +145,13 @@ namespace HighWayIot.Repository.service
///
/// 删除物料信息
///
- ///
+ ///
///
- public bool DeleteMaterialInfoByMaterialCode(string materialCode)
+ public bool DeleteMaterialInfoById(int id)
{
try
{
- ZxMaterialEntity e = _repository.GetById(materialCode);
+ ZxMaterialEntity e = _repository.GetById(id);
e.IsDeleted = true;
return _repository.Update(e);
}
diff --git a/HighWayIot.Repository/service/ZxRecipeService.cs b/HighWayIot.Repository/service/ZxRecipeService.cs
index 9aeff65..8945426 100644
--- a/HighWayIot.Repository/service/ZxRecipeService.cs
+++ b/HighWayIot.Repository/service/ZxRecipeService.cs
@@ -38,11 +38,31 @@ namespace HighWayIot.Repository.service
}
catch (Exception ex)
{
- log.Error("用户信息获取异常", ex);
+ log.Error("配方信息获取异常", ex);
return null;
}
}
+ ///
+ /// 根据配方编号查询配方信息
+ ///
+ /// 配方编号
+ ///
+ public List GetRecipeInfosByRecipeCode(string recipeCode)
+ {
+ try
+ {
+ List entity = _repository.GetList(x => x.IsDeleted == false && x.RecipeCode == recipeCode);
+ return entity;
+ }
+ catch (Exception ex)
+ {
+ log.Error("根据编号查询配方信息获取异常", ex);
+ return null;
+ }
+ }
+
+
///
/// 修改配方信息
///
@@ -56,7 +76,7 @@ namespace HighWayIot.Repository.service
}
catch(Exception ex)
{
- log.Error("用户信息修改异常", ex);
+ log.Error("配方信息修改异常", ex);
return false;
}
}
@@ -75,7 +95,7 @@ namespace HighWayIot.Repository.service
}
catch (Exception ex)
{
- log.Error("物料信息添加异常", ex);
+ log.Error("配方信息添加异常", ex);
return false;
}
}
@@ -83,19 +103,19 @@ namespace HighWayIot.Repository.service
///
/// 删除配方信息
///
- ///
+ ///
///
- public bool DeleteRecipeInfoByRecipeCode(string recipeCode)
+ public bool DeleteRecipeInfoById(int id)
{
try
{
- ZxRecipeEntity e = _repository.GetById(recipeCode);
+ ZxRecipeEntity e = _repository.GetById(id);
e.IsDeleted = true;
return _repository.Update(e);
}
catch (Exception ex)
{
- log.Error("物料信息删除异常", ex);
+ log.Error("配方信息删除异常", ex);
return false;
}
}
diff --git a/HighWayIot.Repository/service/ZxWeightService.cs b/HighWayIot.Repository/service/ZxWeightService.cs
index 26577ad..db684f3 100644
--- a/HighWayIot.Repository/service/ZxWeightService.cs
+++ b/HighWayIot.Repository/service/ZxWeightService.cs
@@ -83,9 +83,9 @@ namespace HighWayIot.Repository.service
///
/// 根据ID删除称量信息
///
- /// 配方号
+ /// ID
///
- public bool DeleteWeightInfoById(string id)
+ public bool DeleteWeightInfoById(int id)
{
try
{
@@ -113,6 +113,11 @@ namespace HighWayIot.Repository.service
es.ForEach(x => x.IsDeleted = true);
+ if (es.Count == 0)
+ {
+ return true;
+ }
+
return _repository.UpdateRange(es);
}
catch (Exception ex)
diff --git a/HighWayIot.Winform/Program.cs b/HighWayIot.Winform/Program.cs
index da013bf..adc471e 100644
--- a/HighWayIot.Winform/Program.cs
+++ b/HighWayIot.Winform/Program.cs
@@ -26,10 +26,11 @@ namespace HighWayIot.Winform
[STAThread]
static void Main()
{
-#if DEBUG
+
+ //Console.OutputEncoding = System.Text.Encoding.UTF8;
+ //Console.InputEncoding = System.Text.Encoding.UTF8;
+
AllocConsole();//调用系统API,调用控制台窗口
- Console.OutputEncoding = System.Text.Encoding.UTF8;
-#endif
// 设置控制台编码为系统默认编码(解决乱码问题)
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
@@ -42,9 +43,7 @@ namespace HighWayIot.Winform
logger.Info("登陆成功");
Application.Run(new BaseForm());
}
-#if DEBUG
FreeConsole();//释放控制台
-#endif
}
}
}
diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.Designer.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.Designer.cs
index e5f252d..ba24113 100644
--- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.Designer.cs
+++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.Designer.cs
@@ -93,6 +93,7 @@
//
// MaterialTypeComboBox
//
+ this.MaterialTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.MaterialTypeComboBox.FormattingEnabled = true;
this.MaterialTypeComboBox.Location = new System.Drawing.Point(128, 81);
this.MaterialTypeComboBox.Name = "MaterialTypeComboBox";
@@ -112,6 +113,7 @@
//
// ChildComboBox
//
+ this.ChildComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ChildComboBox.FormattingEnabled = true;
this.ChildComboBox.Location = new System.Drawing.Point(128, 107);
this.ChildComboBox.Name = "ChildComboBox";
diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs
index a2a1641..8081549 100644
--- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs
+++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs
@@ -68,9 +68,18 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
MessageBox.Show("物料编号不能为空!");
return;
}
+
+ string s = MaterialCodeTextBox.Text.Trim();
+
+ if(zxMaterialService.GetEntityByMaterialCode(s).Count > 0)
+ {
+ MessageBox.Show("已存在相同物料编号,添加失败");
+ return;
+ }
+
ZxMaterialEntity entity = new ZxMaterialEntity()
{
- MaterialCode = MaterialCodeTextBox.Text.Trim(),
+ MaterialCode = s,
MaterialName = MaterialNameTextBox.Text.Trim(),
MaterialType = MaterialTypeComboBox.Text.Trim(),
ChildType = ChildComboBox.Text,
@@ -80,7 +89,7 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
if (!zxMaterialService.InsertMaterialInfo(entity))
{
- MessageBox.Show("物料信息添加失败,请检查物料编号是否重复或为空!");
+ MessageBox.Show("物料信息添加失败!");
return;
}
diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.Designer.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.Designer.cs
index aacdb8c..530fc8c 100644
--- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.Designer.cs
+++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.Designer.cs
@@ -32,35 +32,39 @@ namespace HighWayIot.Winform.UserControlPages
private void InitializeComponent()
{
this.MaterialDataGridView = new System.Windows.Forms.DataGridView();
+ this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ 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.DataGridViewCheckBoxColumn();
this.AddMaterial = new System.Windows.Forms.Button();
this.ButtonPanel = new System.Windows.Forms.Panel();
+ this.IsUseCheckBox = new System.Windows.Forms.CheckBox();
+ this.IsAvailableUseCheckBox = new System.Windows.Forms.CheckBox();
+ this.ChildComboBox = new System.Windows.Forms.ComboBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.MaterialTypeComboBox = new System.Windows.Forms.ComboBox();
+ this.label2 = new System.Windows.Forms.Label();
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();
- 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.DataGridViewCheckBoxColumn();
- this.IsAvailableUseCheckBox = new System.Windows.Forms.CheckBox();
- this.IsUseCheckBox = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.MaterialDataGridView)).BeginInit();
this.ButtonPanel.SuspendLayout();
this.SuspendLayout();
//
// MaterialDataGridView
//
+ this.MaterialDataGridView.AllowUserToAddRows = false;
+ this.MaterialDataGridView.AllowUserToDeleteRows = false;
this.MaterialDataGridView.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.MaterialDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.MaterialDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.Id,
this.MaterialCode,
this.MaterialName,
this.MaterialType,
@@ -69,12 +73,62 @@ namespace HighWayIot.Winform.UserControlPages
this.MaterialDataGridView.Location = new System.Drawing.Point(0, 65);
this.MaterialDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.MaterialDataGridView.Name = "MaterialDataGridView";
+ this.MaterialDataGridView.ReadOnly = true;
this.MaterialDataGridView.RowHeadersVisible = false;
this.MaterialDataGridView.RowTemplate.Height = 25;
this.MaterialDataGridView.Size = new System.Drawing.Size(1350, 898);
this.MaterialDataGridView.TabIndex = 0;
this.MaterialDataGridView.Tag = "";
//
+ // Id
+ //
+ this.Id.DataPropertyName = "Id";
+ this.Id.HeaderText = "ID";
+ this.Id.Name = "Id";
+ this.Id.ReadOnly = true;
+ this.Id.Width = 50;
+ //
+ // MaterialCode
+ //
+ this.MaterialCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.MaterialCode.DataPropertyName = "MaterialCode";
+ this.MaterialCode.HeaderText = "物料编码";
+ this.MaterialCode.Name = "MaterialCode";
+ this.MaterialCode.ReadOnly = true;
+ //
+ // MaterialName
+ //
+ this.MaterialName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.MaterialName.DataPropertyName = "MaterialName";
+ this.MaterialName.HeaderText = "物料名称";
+ this.MaterialName.Name = "MaterialName";
+ this.MaterialName.ReadOnly = true;
+ //
+ // MaterialType
+ //
+ this.MaterialType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.MaterialType.DataPropertyName = "MaterialType";
+ this.MaterialType.HeaderText = "物料类型";
+ this.MaterialType.Name = "MaterialType";
+ this.MaterialType.ReadOnly = true;
+ //
+ // ChildType
+ //
+ this.ChildType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.ChildType.DataPropertyName = "ChildType";
+ this.ChildType.HeaderText = "物料子类型";
+ this.ChildType.Name = "ChildType";
+ this.ChildType.ReadOnly = true;
+ //
+ // IsUse
+ //
+ this.IsUse.DataPropertyName = "IsUse";
+ this.IsUse.HeaderText = "是否启用";
+ this.IsUse.Name = "IsUse";
+ this.IsUse.ReadOnly = true;
+ this.IsUse.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+ this.IsUse.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+ //
// AddMaterial
//
this.AddMaterial.Location = new System.Drawing.Point(11, 11);
@@ -108,6 +162,61 @@ namespace HighWayIot.Winform.UserControlPages
this.ButtonPanel.Size = new System.Drawing.Size(1350, 61);
this.ButtonPanel.TabIndex = 4;
//
+ // IsUseCheckBox
+ //
+ this.IsUseCheckBox.AutoSize = true;
+ this.IsUseCheckBox.Location = new System.Drawing.Point(1079, 34);
+ this.IsUseCheckBox.Name = "IsUseCheckBox";
+ this.IsUseCheckBox.Size = new System.Drawing.Size(72, 16);
+ this.IsUseCheckBox.TabIndex = 12;
+ this.IsUseCheckBox.Text = "是否启用";
+ this.IsUseCheckBox.UseVisualStyleBackColor = true;
+ //
+ // IsAvailableUseCheckBox
+ //
+ this.IsAvailableUseCheckBox.AutoSize = true;
+ this.IsAvailableUseCheckBox.Location = new System.Drawing.Point(1079, 11);
+ this.IsAvailableUseCheckBox.Name = "IsAvailableUseCheckBox";
+ this.IsAvailableUseCheckBox.Size = new System.Drawing.Size(120, 16);
+ this.IsAvailableUseCheckBox.TabIndex = 11;
+ this.IsAvailableUseCheckBox.Text = "是否查询启用状态";
+ this.IsAvailableUseCheckBox.UseVisualStyleBackColor = true;
+ //
+ // ChildComboBox
+ //
+ 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;
+ //
+ // label3
+ //
+ 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 = "子类型:";
+ //
+ // MaterialTypeComboBox
+ //
+ 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;
+ this.MaterialTypeComboBox.SelectedIndexChanged += new System.EventHandler(this.MaterialTypeComboBox_SelectedIndexChanged);
+ //
+ // label2
+ //
+ 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 = "物料类型:";
+ //
// MaterialNameTextbox
//
this.MaterialNameTextbox.Location = new System.Drawing.Point(526, 20);
@@ -157,97 +266,6 @@ namespace HighWayIot.Winform.UserControlPages
this.UpdateMaterial.UseVisualStyleBackColor = true;
this.UpdateMaterial.Click += new System.EventHandler(this.UpdateMaterial_Click);
//
- // label2
- //
- 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 = "物料类型:";
- //
- // MaterialTypeComboBox
- //
- 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;
- this.MaterialTypeComboBox.SelectedIndexChanged += new System.EventHandler(this.MaterialTypeComboBox_SelectedIndexChanged);
- //
- // ChildComboBox
- //
- 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;
- //
- // label3
- //
- 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 = "子类型:";
- //
- // 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";
- this.IsUse.Resizable = System.Windows.Forms.DataGridViewTriState.True;
- this.IsUse.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
- //
- // IsAvailableUseCheckBox
- //
- this.IsAvailableUseCheckBox.AutoSize = true;
- this.IsAvailableUseCheckBox.Location = new System.Drawing.Point(1079, 11);
- this.IsAvailableUseCheckBox.Name = "IsAvailableUseCheckBox";
- this.IsAvailableUseCheckBox.Size = new System.Drawing.Size(120, 16);
- this.IsAvailableUseCheckBox.TabIndex = 11;
- this.IsAvailableUseCheckBox.Text = "是否查询启用状态";
- this.IsAvailableUseCheckBox.UseVisualStyleBackColor = true;
- //
- // IsUseCheckBox
- //
- this.IsUseCheckBox.AutoSize = true;
- this.IsUseCheckBox.Location = new System.Drawing.Point(1079, 34);
- this.IsUseCheckBox.Name = "IsUseCheckBox";
- this.IsUseCheckBox.Size = new System.Drawing.Size(72, 16);
- this.IsUseCheckBox.TabIndex = 12;
- this.IsUseCheckBox.Text = "是否启用";
- this.IsUseCheckBox.UseVisualStyleBackColor = true;
- //
// MaterialConfigPage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -279,12 +297,13 @@ namespace HighWayIot.Winform.UserControlPages
private Label label3;
private ComboBox MaterialTypeComboBox;
private Label label2;
+ private CheckBox IsUseCheckBox;
+ private CheckBox IsAvailableUseCheckBox;
+ private DataGridViewTextBoxColumn Id;
private DataGridViewTextBoxColumn MaterialCode;
private DataGridViewTextBoxColumn MaterialName;
private DataGridViewTextBoxColumn MaterialType;
private DataGridViewTextBoxColumn ChildType;
private DataGridViewCheckBoxColumn IsUse;
- private CheckBox IsUseCheckBox;
- private CheckBox IsAvailableUseCheckBox;
}
}
diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs
index 4867029..19499d6 100644
--- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs
+++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs
@@ -1,4 +1,5 @@
-using HighWayIot.Repository.service;
+using HighWayIot.Log4net;
+using HighWayIot.Repository.service;
using HighWayIot.Winform.Business;
using HighWayIot.Winform.UserControlPages.SysConfigPages;
using Models;
@@ -17,6 +18,8 @@ namespace HighWayIot.Winform.UserControlPages
{
public partial class MaterialConfigPage : UserControl
{
+ LogHelper logHelper = LogHelper.Instance;
+
///
/// 物料子类型服务类实例
///
@@ -68,7 +71,7 @@ namespace HighWayIot.Winform.UserControlPages
MaterialDataGridView.DataSource = null;
MaterialDataGridView.DataSource = Lists;
}
-
+
///
/// 添加物料
///
@@ -92,6 +95,14 @@ namespace HighWayIot.Winform.UserControlPages
{
ZxMaterialEntity entity = new ZxMaterialEntity();
int a = MaterialDataGridView.CurrentRow.Index;
+ try
+ {
+ entity.Id = int.Parse(MaterialDataGridView.Rows[a].Cells["Id"].Value.ToString().Trim());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("物料更新ID转换发生错误");
+ }
entity.MaterialCode = MaterialDataGridView.Rows[a].Cells["MaterialCode"].Value.ToString();
entity.MaterialName = MaterialDataGridView.Rows[a].Cells["MaterialName"].Value.ToString();
entity.MaterialType = MaterialDataGridView.Rows[a].Cells["MaterialType"].Value.ToString();
@@ -115,15 +126,25 @@ namespace HighWayIot.Winform.UserControlPages
{
int a = MaterialDataGridView.CurrentRow.Index;
string s = MaterialDataGridView.Rows[a].Cells["MaterialCode"].Value.ToString();
+ int id;
+ try
+ {
+ id = int.Parse(MaterialDataGridView.Rows[a].Cells["Id"].Value.ToString());
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error("物料删除ID转换发生错误", ex);
+ return;
+ }
- if(MessageBox.Show($"是否要删除编号为{s}的物料?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
+ if (MessageBox.Show($"是否要删除编号为{s}的物料?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
{
return;
}
- if (!zxMaterialService.DeleteMaterialInfoByMaterialCode(s))
+ if (!zxMaterialService.DeleteMaterialInfoById(id))
{
- MessageBox.Show($"编号为{s}的物料删除失败" ,"提示");
+ MessageBox.Show($"编号为{s}的物料删除失败", "提示");
}
Lists = zxMaterialService.GetMaterialInfos();
diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.resx b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.resx
index fae432a..c5f03c6 100644
--- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.resx
+++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.resx
@@ -117,6 +117,9 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ True
+
True
diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.Designer.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.Designer.cs
index 4aaed6a..fb5a74d 100644
--- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.Designer.cs
+++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.Designer.cs
@@ -53,6 +53,7 @@
//
// ChildComboBox
//
+ this.ChildComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ChildComboBox.FormattingEnabled = true;
this.ChildComboBox.Location = new System.Drawing.Point(130, 105);
this.ChildComboBox.Name = "ChildComboBox";
@@ -80,6 +81,7 @@
//
// MaterialTypeComboBox
//
+ this.MaterialTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.MaterialTypeComboBox.FormattingEnabled = true;
this.MaterialTypeComboBox.Location = new System.Drawing.Point(130, 79);
this.MaterialTypeComboBox.Name = "MaterialTypeComboBox";
diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.cs
index d1db6f9..f4a6a2c 100644
--- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.cs
+++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.cs
@@ -95,6 +95,7 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
{
ZxMaterialEntity entity = new ZxMaterialEntity()
{
+ Id = _entity.Id,
MaterialName = MaterialNameTextBox.Text.Trim(),
MaterialCode = MaterialCodeTextBox.Text.Trim(),
MaterialType = MaterialTypeComboBox.Text.Trim(),
@@ -103,6 +104,18 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
IsDeleted = _entity.IsDeleted.Value,
};
+ if (string.IsNullOrEmpty(MaterialCodeTextBox.Text.Trim()))
+ {
+ MessageBox.Show("物料信息修改失败!物料编号不能为空!", "提示");
+ return;
+ }
+
+ if(zxMaterialService.GetEntityByMaterialCode(MaterialCodeTextBox.Text.Trim()).Count > 0 && MaterialCodeTextBox.Text.Trim() != _entity.MaterialCode)
+ {
+ MessageBox.Show("物料信息修改失败!物料编号不能重复!", "提示");
+ return;
+ }
+
if (zxMaterialService.UpdateMaterialInfo(entity))
{
MessageBox.Show("物料信息修改成功!", "提示");
diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.Designer.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.Designer.cs
index 4e301cc..ddee759 100644
--- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.Designer.cs
+++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.Designer.cs
@@ -93,7 +93,7 @@
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 12);
this.label2.TabIndex = 15;
- this.label2.Text = "配方代码:";
+ this.label2.Text = "配方编号:";
//
// RecipeCodeTextBox
//
@@ -134,7 +134,7 @@
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(65, 12);
this.label5.TabIndex = 26;
- this.label5.Text = "SPEC代码:";
+ this.label5.Text = "SPEC编号:";
//
// SpecCodeTextBox
//
diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.cs
index 6ec80d2..8645a0d 100644
--- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.cs
+++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.cs
@@ -34,9 +34,18 @@ namespace HighWayIot.Winform.UserControlPages.RecipeConfigPages
MessageBox.Show("配方编号不能为空!");
return;
}
+
+ string s = RecipeCodeTextBox.Text.Trim();
+
+ if (zxRecipeService.GetRecipeInfosByRecipeCode(s).Count > 0)
+ {
+ MessageBox.Show("配方编号重复!");
+ return;
+ }
+
ZxRecipeEntity zxRecipeEntity = new ZxRecipeEntity()
{
- RecipeCode = RecipeCodeTextBox.Text.Trim(),
+ RecipeCode = s,
RecipeName = RecipeNameTextBox.Text.Trim(),
RecipeSpecCode = SpecCodeTextBox.Text.Trim(),
RecipeSpecName = SpecNameTextBox.Text.Trim(),
diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs
index 4acccce..46373f0 100644
--- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs
+++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs
@@ -105,6 +105,14 @@ namespace HighWayIot.Winform.UserControlPages.RecipeConfigPages
IsDeleted = false,
};
+ var lists = zxWeightService.GetWeightInfos(RecipeCode);
+
+ if (lists.Where(x => x.MaterialCode == MaterialCodeComboBox.Text.Trim()).Count() >= 1)
+ {
+ MessageBox.Show("同一配方不能出现两种物料相同的称量信息!");
+ return;
+ }
+
if (!decimal.TryParse(SetThicknessTextBox.Text.Trim(), out decimal thickness))
{
MessageBox.Show("厚度请填入可带小数的阿拉伯数字");
@@ -206,13 +214,21 @@ namespace HighWayIot.Winform.UserControlPages.RecipeConfigPages
///
private void MaterialCodeComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
- ZxMaterialEntity entity = zxMaterialService.GetSingleEntityByCode(MaterialCodeComboBox.Text.Trim());
+ List entitys = zxMaterialService.GetEntityByMaterialCode(MaterialCodeComboBox.Text.Trim());
- if (entity == null)
+ if (entitys == null && entitys.Count == 0)
{
return;
}
+ if (entitys.Count > 1)
+ {
+ MessageBox.Show("请检查是否有多条物料编号相同的可用物料");
+ return;
+ }
+
+ ZxMaterialEntity entity = entitys[0];
+
MaterialNameComboBox.Text = entity.MaterialName;
MaterialTypeComboBox.Text = entity.MaterialType;
ChildTypeComboBox.Text = entity.ChildType;
diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs
index 954825c..eb0a885 100644
--- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs
+++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs
@@ -32,14 +32,28 @@ namespace HighWayIot.Winform.UserControlPages
private void InitializeComponent()
{
this.WeightDataGridView = new System.Windows.Forms.DataGridView();
+ this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.MaterialCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.MaterialName = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.MaterialType = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.MaterialChildType = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.SetThickness = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.SetWidth = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.SetLayer = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.SetWeight = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.SetError = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.WeightIsUse = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.AddRecipeButton = new System.Windows.Forms.Button();
this.ButtonPanel = new System.Windows.Forms.Panel();
+ this.label26 = new System.Windows.Forms.Label();
+ this.label25 = new System.Windows.Forms.Label();
this.RefreshRecipeButton = new System.Windows.Forms.Button();
this.UpdateRecipeButton = new System.Windows.Forms.Button();
this.DeleteRecipeButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.RecipeDataGridView = new System.Windows.Forms.DataGridView();
+ this.RId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.RecipeCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.RecipeName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.RecipeSpecCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -108,21 +122,12 @@ namespace HighWayIot.Winform.UserControlPages
this.SaveParaButton = new System.Windows.Forms.Button();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.panel1 = new System.Windows.Forms.Panel();
+ this.label24 = new System.Windows.Forms.Label();
this.RefreshWeightButton = new System.Windows.Forms.Button();
this.UpdateWeightButton = new System.Windows.Forms.Button();
this.AddWeightButton = new System.Windows.Forms.Button();
this.DeleteWeightButton = new System.Windows.Forms.Button();
- this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.MaterialCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.MaterialName = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.MaterialType = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.MaterialChildType = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.SetThickness = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.SetWidth = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.SetLayer = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.SetWeight = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.SetError = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.WeightIsUse = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+ this.label27 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.WeightDataGridView)).BeginInit();
this.ButtonPanel.SuspendLayout();
this.groupBox1.SuspendLayout();
@@ -166,6 +171,93 @@ namespace HighWayIot.Winform.UserControlPages
this.WeightDataGridView.TabIndex = 0;
this.WeightDataGridView.Tag = "";
//
+ // Id
+ //
+ this.Id.DataPropertyName = "Id";
+ this.Id.HeaderText = "编号";
+ this.Id.Name = "Id";
+ this.Id.ReadOnly = true;
+ this.Id.Width = 40;
+ //
+ // MaterialCode
+ //
+ this.MaterialCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.MaterialCode.DataPropertyName = "MaterialCode";
+ this.MaterialCode.HeaderText = "物料编码";
+ this.MaterialCode.Name = "MaterialCode";
+ this.MaterialCode.ReadOnly = true;
+ this.MaterialCode.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+ //
+ // MaterialName
+ //
+ this.MaterialName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.MaterialName.DataPropertyName = "MaterialName";
+ this.MaterialName.HeaderText = "物料名称";
+ this.MaterialName.Name = "MaterialName";
+ this.MaterialName.ReadOnly = true;
+ //
+ // MaterialType
+ //
+ this.MaterialType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.MaterialType.DataPropertyName = "MaterialType";
+ this.MaterialType.HeaderText = "物料类型";
+ this.MaterialType.Name = "MaterialType";
+ this.MaterialType.ReadOnly = true;
+ this.MaterialType.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+ //
+ // MaterialChildType
+ //
+ this.MaterialChildType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.MaterialChildType.DataPropertyName = "MaterialChildType";
+ this.MaterialChildType.HeaderText = "子类型";
+ this.MaterialChildType.Name = "MaterialChildType";
+ this.MaterialChildType.ReadOnly = true;
+ this.MaterialChildType.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+ //
+ // SetThickness
+ //
+ this.SetThickness.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.SetThickness.DataPropertyName = "SetThickness";
+ this.SetThickness.HeaderText = "厚度";
+ this.SetThickness.Name = "SetThickness";
+ //
+ // SetWidth
+ //
+ this.SetWidth.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.SetWidth.DataPropertyName = "SetWidth";
+ this.SetWidth.HeaderText = "宽度";
+ this.SetWidth.Name = "SetWidth";
+ //
+ // SetLayer
+ //
+ this.SetLayer.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.SetLayer.DataPropertyName = "SetLayer";
+ this.SetLayer.HeaderText = "层数";
+ this.SetLayer.Name = "SetLayer";
+ //
+ // SetWeight
+ //
+ this.SetWeight.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.SetWeight.DataPropertyName = "SetWeight";
+ this.SetWeight.HeaderText = "重量";
+ this.SetWeight.Name = "SetWeight";
+ //
+ // SetError
+ //
+ this.SetError.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.SetError.DataPropertyName = "SetError";
+ this.SetError.HeaderText = "公差";
+ this.SetError.Name = "SetError";
+ //
+ // WeightIsUse
+ //
+ this.WeightIsUse.DataPropertyName = "IsUse";
+ this.WeightIsUse.HeaderText = "启用";
+ this.WeightIsUse.Name = "WeightIsUse";
+ this.WeightIsUse.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+ this.WeightIsUse.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+ this.WeightIsUse.Width = 40;
+ //
// AddRecipeButton
//
this.AddRecipeButton.Location = new System.Drawing.Point(11, 9);
@@ -181,6 +273,8 @@ 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.label26);
+ this.ButtonPanel.Controls.Add(this.label25);
this.ButtonPanel.Controls.Add(this.RefreshRecipeButton);
this.ButtonPanel.Controls.Add(this.UpdateRecipeButton);
this.ButtonPanel.Controls.Add(this.AddRecipeButton);
@@ -191,9 +285,27 @@ namespace HighWayIot.Winform.UserControlPages
this.ButtonPanel.Size = new System.Drawing.Size(886, 58);
this.ButtonPanel.TabIndex = 4;
//
+ // label26
+ //
+ this.label26.AutoSize = true;
+ this.label26.Location = new System.Drawing.Point(338, 9);
+ this.label26.Name = "label26";
+ this.label26.Size = new System.Drawing.Size(269, 12);
+ this.label26.TabIndex = 7;
+ this.label26.Text = "双击单元格更改数值再点击修改按钮完成数值更改";
+ //
+ // label25
+ //
+ this.label25.AutoSize = true;
+ this.label25.Location = new System.Drawing.Point(338, 36);
+ this.label25.Name = "label25";
+ this.label25.Size = new System.Drawing.Size(101, 12);
+ this.label25.TabIndex = 6;
+ this.label25.Text = "配方编号不可更改";
+ //
// RefreshRecipeButton
//
- this.RefreshRecipeButton.Location = new System.Drawing.Point(229, 9);
+ this.RefreshRecipeButton.Location = new System.Drawing.Point(120, 9);
this.RefreshRecipeButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.RefreshRecipeButton.Name = "RefreshRecipeButton";
this.RefreshRecipeButton.Size = new System.Drawing.Size(103, 39);
@@ -204,7 +316,7 @@ namespace HighWayIot.Winform.UserControlPages
//
// UpdateRecipeButton
//
- this.UpdateRecipeButton.Location = new System.Drawing.Point(120, 9);
+ this.UpdateRecipeButton.Location = new System.Drawing.Point(229, 9);
this.UpdateRecipeButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.UpdateRecipeButton.Name = "UpdateRecipeButton";
this.UpdateRecipeButton.Size = new System.Drawing.Size(103, 39);
@@ -255,6 +367,7 @@ namespace HighWayIot.Winform.UserControlPages
this.RecipeDataGridView.AllowUserToDeleteRows = false;
this.RecipeDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.RecipeDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.RId,
this.RecipeCode,
this.RecipeName,
this.RecipeSpecCode,
@@ -274,12 +387,21 @@ namespace HighWayIot.Winform.UserControlPages
this.RecipeDataGridView.Tag = "";
this.RecipeDataGridView.SelectionChanged += new System.EventHandler(this.RecipeDataGridView_SelectionChanged);
//
+ // RId
+ //
+ this.RId.DataPropertyName = "Id";
+ this.RId.HeaderText = "ID";
+ this.RId.Name = "RId";
+ this.RId.ReadOnly = true;
+ this.RId.Width = 40;
+ //
// RecipeCode
//
this.RecipeCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.RecipeCode.DataPropertyName = "RecipeCode";
this.RecipeCode.HeaderText = "配方编号";
this.RecipeCode.Name = "RecipeCode";
+ this.RecipeCode.ReadOnly = true;
//
// RecipeName
//
@@ -369,7 +491,7 @@ namespace HighWayIot.Winform.UserControlPages
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 22.22222F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 22.22222F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 55.55556F));
- this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 179F));
+ this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 185F));
this.tableLayoutPanel3.Controls.Add(this.groupBox4, 0, 0);
this.tableLayoutPanel3.Controls.Add(this.groupBox5, 1, 0);
this.tableLayoutPanel3.Controls.Add(this.groupBox6, 2, 0);
@@ -397,7 +519,7 @@ namespace HighWayIot.Winform.UserControlPages
this.groupBox4.Location = new System.Drawing.Point(0, 0);
this.groupBox4.Margin = new System.Windows.Forms.Padding(0);
this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(352, 170);
+ this.groupBox4.Size = new System.Drawing.Size(351, 170);
this.groupBox4.TabIndex = 0;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "开炼机#1参数";
@@ -477,10 +599,10 @@ namespace HighWayIot.Winform.UserControlPages
this.groupBox5.Controls.Add(this.label7);
this.groupBox5.Controls.Add(this.E2P2TextBox);
this.groupBox5.Dock = System.Windows.Forms.DockStyle.Fill;
- this.groupBox5.Location = new System.Drawing.Point(352, 0);
+ this.groupBox5.Location = new System.Drawing.Point(351, 0);
this.groupBox5.Margin = new System.Windows.Forms.Padding(0);
this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(352, 170);
+ this.groupBox5.Size = new System.Drawing.Size(351, 170);
this.groupBox5.TabIndex = 1;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "开炼机#2参数";
@@ -581,10 +703,10 @@ namespace HighWayIot.Winform.UserControlPages
this.groupBox6.Controls.Add(this.label10);
this.groupBox6.Controls.Add(this.E3P2TextBox);
this.groupBox6.Dock = System.Windows.Forms.DockStyle.Fill;
- this.groupBox6.Location = new System.Drawing.Point(704, 0);
+ this.groupBox6.Location = new System.Drawing.Point(702, 0);
this.groupBox6.Margin = new System.Windows.Forms.Padding(0);
this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(882, 170);
+ this.groupBox6.Size = new System.Drawing.Size(878, 170);
this.groupBox6.TabIndex = 2;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "开炼机#3参数";
@@ -833,10 +955,10 @@ namespace HighWayIot.Winform.UserControlPages
this.groupBox7.Controls.Add(this.CopyParaButton);
this.groupBox7.Controls.Add(this.SaveParaButton);
this.groupBox7.Dock = System.Windows.Forms.DockStyle.Fill;
- this.groupBox7.Location = new System.Drawing.Point(1586, 0);
+ this.groupBox7.Location = new System.Drawing.Point(1580, 0);
this.groupBox7.Margin = new System.Windows.Forms.Padding(0);
this.groupBox7.Name = "groupBox7";
- this.groupBox7.Size = new System.Drawing.Size(181, 170);
+ this.groupBox7.Size = new System.Drawing.Size(187, 170);
this.groupBox7.TabIndex = 3;
this.groupBox7.TabStop = false;
this.groupBox7.Text = "参数操作";
@@ -924,6 +1046,8 @@ namespace HighWayIot.Winform.UserControlPages
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
+ this.panel1.Controls.Add(this.label27);
+ this.panel1.Controls.Add(this.label24);
this.panel1.Controls.Add(this.RefreshWeightButton);
this.panel1.Controls.Add(this.UpdateWeightButton);
this.panel1.Controls.Add(this.AddWeightButton);
@@ -934,9 +1058,18 @@ namespace HighWayIot.Winform.UserControlPages
this.panel1.Size = new System.Drawing.Size(887, 58);
this.panel1.TabIndex = 5;
//
+ // label24
+ //
+ this.label24.AutoSize = true;
+ this.label24.Location = new System.Drawing.Point(338, 36);
+ this.label24.Name = "label24";
+ this.label24.Size = new System.Drawing.Size(125, 12);
+ this.label24.TabIndex = 5;
+ this.label24.Text = "称量物料信息不可更改";
+ //
// RefreshWeightButton
//
- this.RefreshWeightButton.Location = new System.Drawing.Point(229, 9);
+ this.RefreshWeightButton.Location = new System.Drawing.Point(120, 9);
this.RefreshWeightButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.RefreshWeightButton.Name = "RefreshWeightButton";
this.RefreshWeightButton.Size = new System.Drawing.Size(103, 39);
@@ -947,7 +1080,7 @@ namespace HighWayIot.Winform.UserControlPages
//
// UpdateWeightButton
//
- this.UpdateWeightButton.Location = new System.Drawing.Point(120, 9);
+ this.UpdateWeightButton.Location = new System.Drawing.Point(229, 9);
this.UpdateWeightButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.UpdateWeightButton.Name = "UpdateWeightButton";
this.UpdateWeightButton.Size = new System.Drawing.Size(103, 39);
@@ -979,91 +1112,14 @@ namespace HighWayIot.Winform.UserControlPages
this.DeleteWeightButton.UseVisualStyleBackColor = true;
this.DeleteWeightButton.Click += new System.EventHandler(this.DeleteWeightButton_Click);
//
- // Id
- //
- this.Id.DataPropertyName = "Id";
- this.Id.HeaderText = "编号";
- this.Id.Name = "Id";
- this.Id.ReadOnly = true;
- this.Id.Width = 40;
- //
- // MaterialCode
- //
- this.MaterialCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.MaterialCode.DataPropertyName = "MaterialCode";
- this.MaterialCode.HeaderText = "物料编码";
- this.MaterialCode.Name = "MaterialCode";
- this.MaterialCode.Resizable = System.Windows.Forms.DataGridViewTriState.True;
- //
- // MaterialName
- //
- this.MaterialName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.MaterialName.DataPropertyName = "MaterialName";
- this.MaterialName.HeaderText = "物料名称";
- this.MaterialName.Name = "MaterialName";
- this.MaterialName.ReadOnly = true;
- //
- // MaterialType
- //
- this.MaterialType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.MaterialType.DataPropertyName = "MaterialType";
- this.MaterialType.HeaderText = "物料类型";
- this.MaterialType.Name = "MaterialType";
- this.MaterialType.ReadOnly = true;
- this.MaterialType.Resizable = System.Windows.Forms.DataGridViewTriState.True;
- //
- // MaterialChildType
- //
- this.MaterialChildType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.MaterialChildType.DataPropertyName = "MaterialChildType";
- this.MaterialChildType.HeaderText = "子类型";
- this.MaterialChildType.Name = "MaterialChildType";
- this.MaterialChildType.ReadOnly = true;
- this.MaterialChildType.Resizable = System.Windows.Forms.DataGridViewTriState.True;
- //
- // SetThickness
- //
- this.SetThickness.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.SetThickness.DataPropertyName = "SetThickness";
- this.SetThickness.HeaderText = "厚度";
- this.SetThickness.Name = "SetThickness";
- //
- // SetWidth
- //
- this.SetWidth.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.SetWidth.DataPropertyName = "SetWidth";
- this.SetWidth.HeaderText = "宽度";
- this.SetWidth.Name = "SetWidth";
- //
- // SetLayer
- //
- this.SetLayer.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.SetLayer.DataPropertyName = "SetLayer";
- this.SetLayer.HeaderText = "层数";
- this.SetLayer.Name = "SetLayer";
- //
- // SetWeight
- //
- this.SetWeight.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.SetWeight.DataPropertyName = "SetWeight";
- this.SetWeight.HeaderText = "重量";
- this.SetWeight.Name = "SetWeight";
- //
- // SetError
- //
- this.SetError.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.SetError.DataPropertyName = "SetError";
- this.SetError.HeaderText = "公差";
- this.SetError.Name = "SetError";
- //
- // WeightIsUse
+ // label27
//
- this.WeightIsUse.DataPropertyName = "IsUse";
- this.WeightIsUse.HeaderText = "启用";
- this.WeightIsUse.Name = "WeightIsUse";
- this.WeightIsUse.Resizable = System.Windows.Forms.DataGridViewTriState.True;
- this.WeightIsUse.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
- this.WeightIsUse.Width = 40;
+ this.label27.AutoSize = true;
+ this.label27.Location = new System.Drawing.Point(338, 9);
+ this.label27.Name = "label27";
+ this.label27.Size = new System.Drawing.Size(269, 12);
+ this.label27.TabIndex = 8;
+ this.label27.Text = "双击单元格更改数值再点击修改按钮完成数值更改";
//
// RecipeConfigPage
//
@@ -1078,6 +1134,7 @@ namespace HighWayIot.Winform.UserControlPages
this.Size = new System.Drawing.Size(1773, 1036);
((System.ComponentModel.ISupportInitialize)(this.WeightDataGridView)).EndInit();
this.ButtonPanel.ResumeLayout(false);
+ this.ButtonPanel.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.RecipeDataGridView)).EndInit();
@@ -1094,6 +1151,7 @@ namespace HighWayIot.Winform.UserControlPages
this.groupBox7.PerformLayout();
this.tableLayoutPanel2.ResumeLayout(false);
this.panel1.ResumeLayout(false);
+ this.panel1.PerformLayout();
this.ResumeLayout(false);
}
@@ -1173,14 +1231,6 @@ namespace HighWayIot.Winform.UserControlPages
private Label NowCopyLabel;
private Label label23;
private Button ClearCutBoradButton;
- private DataGridViewTextBoxColumn RecipeCode;
- private DataGridViewTextBoxColumn RecipeName;
- private DataGridViewTextBoxColumn RecipeSpecCode;
- private DataGridViewTextBoxColumn RecipeSpecName;
- private DataGridViewTextBoxColumn SizeKind;
- private DataGridViewTextBoxColumn FixedWidth;
- private DataGridViewTextBoxColumn WeightError;
- private DataGridViewCheckBoxColumn IsUse;
private DataGridViewTextBoxColumn Id;
private DataGridViewTextBoxColumn MaterialCode;
private DataGridViewTextBoxColumn MaterialName;
@@ -1192,5 +1242,18 @@ namespace HighWayIot.Winform.UserControlPages
private DataGridViewTextBoxColumn SetWeight;
private DataGridViewTextBoxColumn SetError;
private DataGridViewCheckBoxColumn WeightIsUse;
+ private DataGridViewTextBoxColumn RId;
+ private DataGridViewTextBoxColumn RecipeCode;
+ private DataGridViewTextBoxColumn RecipeName;
+ private DataGridViewTextBoxColumn RecipeSpecCode;
+ private DataGridViewTextBoxColumn RecipeSpecName;
+ private DataGridViewTextBoxColumn SizeKind;
+ private DataGridViewTextBoxColumn FixedWidth;
+ private DataGridViewTextBoxColumn WeightError;
+ private DataGridViewCheckBoxColumn IsUse;
+ private Label label24;
+ private Label label25;
+ private Label label26;
+ private Label label27;
}
}
diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs
index 130be67..0db24a7 100644
--- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs
+++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs
@@ -28,6 +28,11 @@ namespace HighWayIot.Winform.UserControlPages
///
ZxWeightService zxWeightService = ZxWeightService.Instance;
+ ///
+ /// 配方服务类实例
+ ///
+ ZxMaterialService zxMaterialService = ZxMaterialService.Instance;
+
///
/// 配方字段服务类实例
///
@@ -60,7 +65,7 @@ namespace HighWayIot.Winform.UserControlPages
WeightDataGridView.AutoGenerateColumns = false;
RecipeLists = zxRecipeService.GetRecipeInfos();
-
+
RecipeDataGridView.DataSource = null;
RecipeDataGridView.DataSource = RecipeLists;
}
@@ -86,7 +91,53 @@ namespace HighWayIot.Winform.UserControlPages
///
private void DeleteRecipeButton_Click(object sender, EventArgs e)
{
+ int a = RecipeDataGridView.CurrentRow.Index;
+
+ string s = RecipeDataGridView.Rows[a].Cells["RecipeCode"].Value.ToString();
+ int id;
+ try
+ {
+ id = int.Parse(RecipeDataGridView.Rows[a].Cells["RId"].Value.ToString());
+ }
+ catch(Exception ex)
+ {
+ MessageBox.Show("ID转换发生错误");
+ return;
+ }
+ if (MessageBox.Show($"确定要删除编号为 [{s}] 的配方信息?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
+ {
+ return;
+ }
+
+ if (zxWeightService.GetWeightInfos(s).Count > 0)
+ {
+ if (MessageBox.Show("是否要删除其关联的所有称量信息?", "确认", MessageBoxButtons.OKCancel) == DialogResult.OK)
+ {
+ if (zxWeightService.DeleteWeightInfoByRecipeCode(s))
+ {
+ MessageBox.Show("称量信息删除成功");
+ }
+ else
+ {
+ MessageBox.Show("称量信息删除失败!请检查数据库连接情况");
+ }
+ }
+ }
+
+ if (zxRecipeService.DeleteRecipeInfoById(id))
+ {
+ MessageBox.Show("配方信息删除成功!");
+ }
+ else
+ {
+ MessageBox.Show("配方信息删除失败!请检查数据库连接情况");
+ }
+
+ RecipeLists = zxRecipeService.GetRecipeInfos();
+
+ RecipeDataGridView.DataSource = null;
+ RecipeDataGridView.DataSource = RecipeLists;
}
///
@@ -96,7 +147,47 @@ namespace HighWayIot.Winform.UserControlPages
///
private void UpdateRecipeButton_Click(object sender, EventArgs e)
{
+ DataGridViewRow nowRow = RecipeDataGridView.CurrentRow;
+
+ if(MessageBox.Show($"确认要更改编号为 [{nowRow.Cells["RecipeCode"].Value.ToString()}] 配方的数据吗", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
+ {
+ return;
+ }
+
+ ZxRecipeEntity entity = new ZxRecipeEntity();
+
+ try
+ {
+ entity.Id = int.Parse(nowRow.Cells["RId"].Value.ToString().Trim());
+ entity.RecipeCode = nowRow.Cells["RecipeCode"].Value.ToString().Trim();
+ entity.RecipeName = nowRow.Cells["RecipeName"].Value.ToString().Trim();
+ entity.RecipeSpecCode = nowRow.Cells["RecipeSpecCode"].Value.ToString().Trim();
+ entity.RecipeSpecName = nowRow.Cells["RecipeSpecName"].Value.ToString().Trim();
+ entity.SizeKind = int.Parse(nowRow.Cells["SizeKind"].Value.ToString().Trim());
+ entity.FixedWidth = decimal.Parse(nowRow.Cells["FixedWidth"].Value.ToString().Trim());
+ entity.WeightError = int.Parse(nowRow.Cells["WeightError"].Value.ToString().Trim());
+ entity.IsUse = bool.Parse(nowRow.Cells["IsUse"].Value.ToString().Trim());
+ entity.IsDeleted = false;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("数据格式错误!");
+ return;
+ }
+ if (zxRecipeService.UpdateRecipeInfo(entity))
+ {
+ MessageBox.Show("配方更新成功!");
+ }
+ else
+ {
+ MessageBox.Show("配方更新失败!");
+ }
+
+ RecipeLists = zxRecipeService.GetRecipeInfos();
+
+ RecipeDataGridView.DataSource = null;
+ RecipeDataGridView.DataSource = RecipeLists;
}
///
@@ -106,7 +197,9 @@ namespace HighWayIot.Winform.UserControlPages
///
private void RefreshRecipeButton_Click(object sender, EventArgs e)
{
-
+ RecipeLists = zxRecipeService.GetRecipeInfos();
+ RecipeDataGridView.DataSource = null;
+ RecipeDataGridView.DataSource = RecipeLists;
}
///
@@ -116,7 +209,7 @@ namespace HighWayIot.Winform.UserControlPages
///
private void AddWeightButton_Click(object sender, EventArgs e)
{
- if(RecipeDataGridView.CurrentRow == null)
+ if (RecipeDataGridView.CurrentRow == null)
{
MessageBox.Show("请先选择一条配方!");
return;
@@ -127,8 +220,11 @@ namespace HighWayIot.Winform.UserControlPages
AddWeightForm form = new AddWeightForm(s);
form.ShowDialog();
WeightLists = zxWeightService.GetWeightInfos(s);
+
+ WeightToDataSource();
+
WeightDataGridView.DataSource = null;
- WeightDataGridView.DataSource = WeightLists;
+ WeightDataGridView.DataSource = weightDataSourceEntities;
}
///
@@ -138,7 +234,41 @@ namespace HighWayIot.Winform.UserControlPages
///
private void DeleteWeightButton_Click(object sender, EventArgs e)
{
+ int a = WeightDataGridView.CurrentRow.Index;
+ int b = RecipeDataGridView.CurrentRow.Index;
+ string s1 = RecipeDataGridView.Rows[b].Cells["RecipeCode"].Value.ToString();
+ string s2 = WeightDataGridView.Rows[a].Cells["MaterialCode"].Value.ToString();
+ int id;
+ try
+ {
+ id = int.Parse(WeightDataGridView.Rows[a].Cells["Id"].Value.ToString());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("ID转换发生错误");
+ return;
+ }
+
+ if (MessageBox.Show($"确定要删除配方编号为 [{s1}] 物料编码为 [{s2}] 的称重信息?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
+ {
+ return;
+ }
+
+ if (zxWeightService.DeleteWeightInfoById(id))
+ {
+ MessageBox.Show("配方信息删除成功!");
+ }
+ else
+ {
+ MessageBox.Show("配方信息删除失败!请检查数据库连接情况");
+ }
+ WeightLists = zxWeightService.GetWeightInfos(s1);
+
+ WeightToDataSource();
+
+ WeightDataGridView.DataSource = null;
+ WeightDataGridView.DataSource = weightDataSourceEntities;
}
///
@@ -148,7 +278,56 @@ namespace HighWayIot.Winform.UserControlPages
///
private void UpdateWeightButton_Click(object sender, EventArgs e)
{
+ DataGridViewRow nowRow = WeightDataGridView.CurrentRow;
+
+ int a = RecipeDataGridView.CurrentRow.Index;
+
+ string s = RecipeDataGridView.Rows[a].Cells["RecipeCode"].Value.ToString();
+ if (MessageBox.Show($"确认要更改配方编号为 [{s}] 物料编号为 [{nowRow.Cells["MaterialCode"].Value.ToString()}] 的数据吗"
+ , "确认"
+ , MessageBoxButtons.OKCancel)
+ == DialogResult.Cancel)
+ {
+ return;
+ }
+
+ ZxWeightEntity entity = new ZxWeightEntity();
+
+ try
+ {
+ entity.Id = int.Parse(nowRow.Cells["Id"].Value.ToString().Trim());
+ entity.RecipeCode = s;
+ entity.MaterialCode = nowRow.Cells["MaterialCode"].Value.ToString().Trim();
+ entity.SetThickness = decimal.Parse(nowRow.Cells["SetThickness"].Value.ToString().Trim());
+ entity.SetWidth = decimal.Parse(nowRow.Cells["SetWidth"].Value.ToString().Trim());
+ entity.SetLayer = int.Parse(nowRow.Cells["SetLayer"].Value.ToString().Trim());
+ entity.SetWeight = decimal.Parse(nowRow.Cells["SetWeight"].Value.ToString().Trim());
+ entity.SetError = decimal.Parse(nowRow.Cells["SetError"].Value.ToString().Trim());
+ entity.IsUse = bool.Parse(nowRow.Cells["WeightIsUse"].Value.ToString().Trim());
+ entity.IsDeleted = false;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("数据格式错误!");
+ return;
+ }
+
+ if (zxWeightService.UpdateWeightInfo(entity))
+ {
+ MessageBox.Show("称量信息更新成功!");
+ }
+ else
+ {
+ MessageBox.Show("称量信息更新失败!");
+ }
+
+ WeightLists = zxWeightService.GetWeightInfos(s);
+
+ WeightToDataSource();
+
+ WeightDataGridView.DataSource = null;
+ WeightDataGridView.DataSource = weightDataSourceEntities;
}
///
@@ -158,7 +337,15 @@ namespace HighWayIot.Winform.UserControlPages
///
private void RefreshWeightButton_Click(object sender, EventArgs e)
{
+ int a = RecipeDataGridView.CurrentRow.Index;
+ string s = RecipeDataGridView.Rows[a].Cells["RecipeCode"].Value.ToString();
+ WeightLists = zxWeightService.GetWeightInfos(s);
+
+ WeightToDataSource();
+
+ WeightDataGridView.DataSource = null;
+ WeightDataGridView.DataSource = weightDataSourceEntities;
}
///
@@ -213,17 +400,60 @@ namespace HighWayIot.Winform.UserControlPages
WeightLists = zxWeightService.GetWeightInfos(s);
+ WeightToDataSource();
+
WeightDataGridView.DataSource = null;
- WeightDataGridView.DataSource = WeightLists;
+ WeightDataGridView.DataSource = weightDataSourceEntities;
}
///
- /// 称重和物料数据联查
+ /// 称重数据关联物料数据
///
- private void WeighCombineMaterialData()
+ private void WeightToDataSource()
{
-
+ weightDataSourceEntities = new List();
+ foreach (var item in WeightLists)
+ {
+ var entitys = zxMaterialService.GetEntityByMaterialCode(item.MaterialCode);
+
+ if (entitys == null && entitys.Count == 0)
+ {
+ return;
+ }
+
+ if (entitys.Count > 1)
+ {
+ MessageBox.Show("请检查是否有多条物料编号相同的可用物料");
+ return;
+ }
+
+ ZxMaterialEntity material = entitys[0];
+
+ weightDataSourceEntities.Add(new WeightDataSourceEntity()
+ {
+ Id = item.Id,
+ RecipeCode = item.RecipeCode,
+ MaterialCode = item.MaterialCode,
+ MaterialName = material.MaterialName,
+ MaterialType = material.MaterialType,
+ MaterialChildType = material.ChildType,
+ SetThickness = item.SetThickness,
+ SetWidth = item.SetWidth,
+ SetLayer = item.SetLayer,
+ SetWeight = item.SetWeight,
+ SetError = item.SetError,
+ IsUse = item.IsUse,
+ });
+ }
}
+ ///
+ /// 所选单条Weight dataSource转为实体类
+ ///
+ //private ZxWeightEntity DataSourceToWeight()
+ //{
+ // int a = WeightDataGridView.CurrentRow.Index;
+ // foreach
+ //}
}
}
diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.resx b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.resx
index 3107fcf..fad953c 100644
--- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.resx
+++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.resx
@@ -150,6 +150,9 @@
True
+
+ True
+
True