forked from wenjy/HighWayIot
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
789 lines
28 KiB
C#
789 lines
28 KiB
C#
using HighWayIot.Repository.domain;
|
|
using HighWayIot.Repository.service;
|
|
using HighWayIot.Winform.Business;
|
|
using HighWayIot.Winform.MainForm;
|
|
using HighWayIot.Winform.UserControlPages.RecipeConfigPages;
|
|
using HighWayIot.Winform.UserControlPages.SysConfigPages;
|
|
using Models;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace HighWayIot.Winform.UserControlPages
|
|
{
|
|
public partial class RecipeConfigPage : UserControl
|
|
{
|
|
/// <summary>
|
|
/// 配方服务类实例
|
|
/// </summary>
|
|
private ZxRecipeService zxRecipeService = ZxRecipeService.Instance;
|
|
|
|
/// <summary>
|
|
/// 称重服务类实例
|
|
/// </summary>
|
|
private ZxWeightService zxWeightService = ZxWeightService.Instance;
|
|
|
|
/// <summary>
|
|
/// 配方服务类实例
|
|
/// </summary>
|
|
private ZxMaterialService zxMaterialService = ZxMaterialService.Instance;
|
|
|
|
/// <summary>
|
|
/// 配方字段服务类实例
|
|
/// </summary>
|
|
private ZxRecipeParaService zxRecipeParaService = ZxRecipeParaService.Instance;
|
|
|
|
/// <summary>
|
|
/// 工位配方字段服务类实例
|
|
/// </summary>
|
|
private ZxRecipePositionParaService zxRecipePositionParaService = ZxRecipePositionParaService.Instance;
|
|
|
|
/// <summary>
|
|
/// 配方字段实例
|
|
/// </summary>
|
|
private ZxRecipeParaEntity zxRecipeParaEntity = new ZxRecipeParaEntity();
|
|
|
|
/// <summary>
|
|
/// 工位配方字段实例
|
|
/// </summary>
|
|
private ZxRecipePositionParaEntity zxRecipePositionParaEntity = new ZxRecipePositionParaEntity();
|
|
|
|
/// <summary>
|
|
/// 配方字段实例剪切板
|
|
/// </summary>
|
|
private ZxRecipeParaEntity zxRecipeParaEntityCut;
|
|
|
|
/// <summary>
|
|
/// 称重DataGridView数据源
|
|
/// </summary>
|
|
private List<WeightDataSourceEntity> weightDataSourceEntities;
|
|
|
|
/// <summary>
|
|
/// 配方列表
|
|
/// </summary>
|
|
private List<ZxRecipeEntity> RecipeLists;
|
|
|
|
/// <summary>
|
|
/// 称量列表
|
|
/// </summary>
|
|
private List<ZxWeightEntity> WeightLists;
|
|
|
|
/// <summary>
|
|
/// 现所选配方号
|
|
/// </summary>
|
|
private string NowRecipeCode;
|
|
|
|
public RecipeConfigPage()
|
|
{
|
|
InitializeComponent();
|
|
Init();
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
RecipeDataGridView.AutoGenerateColumns = false;
|
|
WeightDataGridView.AutoGenerateColumns = false;
|
|
|
|
RecipeLists = zxRecipeService.GetRecipeInfos();
|
|
|
|
RecipeDataGridView.DataSource = null;
|
|
RecipeDataGridView.DataSource = RecipeLists;
|
|
|
|
NowRecipeCode = RecipeDataGridView.Rows[0].Cells["RecipeCode"].Value.ToString();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加配方信息
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void AddRecipeButton_Click(object sender, EventArgs e)
|
|
{
|
|
AddRecipeForm form = new AddRecipeForm();
|
|
form.ShowDialog();
|
|
RecipeLists = zxRecipeService.GetRecipeInfos();
|
|
RecipeDataGridView.DataSource = null;
|
|
RecipeDataGridView.DataSource = RecipeLists;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除配方信息
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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($"确定要删除编号为 [{NowRecipeCode}] 的配方信息?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (zxWeightService.GetWeightInfos(NowRecipeCode).Count > 0)
|
|
{
|
|
if (MessageBox.Show("是否要删除其关联的所有称量信息?", "确认", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
|
{
|
|
if (zxWeightService.DeleteWeightInfoByRecipeCode(NowRecipeCode))
|
|
{
|
|
MessageBox.Show("称量信息删除成功");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("称量信息删除失败!请检查数据库连接情况");
|
|
}
|
|
}
|
|
}
|
|
|
|
if (zxRecipeService.DeleteRecipeInfoById(id))
|
|
{
|
|
MessageBox.Show("配方信息删除成功!");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("配方信息删除失败!请检查数据库连接情况");
|
|
}
|
|
|
|
RecipeLists = zxRecipeService.GetRecipeInfos();
|
|
|
|
RecipeDataGridView.DataSource = null;
|
|
RecipeDataGridView.DataSource = RecipeLists;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改配方信息
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 刷新配方信息
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void RefreshRecipeButton_Click(object sender, EventArgs e)
|
|
{
|
|
RecipeLists = zxRecipeService.GetRecipeInfos();
|
|
RecipeDataGridView.DataSource = null;
|
|
RecipeDataGridView.DataSource = RecipeLists;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加称量信息
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void AddWeightButton_Click(object sender, EventArgs e)
|
|
{
|
|
if (RecipeDataGridView.CurrentRow == null)
|
|
{
|
|
MessageBox.Show("请先选择一条配方!");
|
|
return;
|
|
}
|
|
|
|
AddWeightForm form = new AddWeightForm(NowRecipeCode);
|
|
form.ShowDialog();
|
|
WeightLists = zxWeightService.GetWeightInfos(NowRecipeCode);
|
|
|
|
WeightToDataSource();
|
|
|
|
WeightDataGridView.DataSource = null;
|
|
WeightDataGridView.DataSource = weightDataSourceEntities;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除称量信息
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void DeleteWeightButton_Click(object sender, EventArgs e)
|
|
{
|
|
int a = WeightDataGridView.CurrentRow.Index;
|
|
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($"确定要删除配方编号为 [{NowRecipeCode}] 物料编码为 [{s2}] 的称重信息?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (zxWeightService.DeleteWeightInfoById(id))
|
|
{
|
|
MessageBox.Show("配方信息删除成功!");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("配方信息删除失败!请检查数据库连接情况");
|
|
}
|
|
|
|
WeightLists = zxWeightService.GetWeightInfos(NowRecipeCode);
|
|
|
|
WeightToDataSource();
|
|
|
|
WeightDataGridView.DataSource = null;
|
|
WeightDataGridView.DataSource = weightDataSourceEntities;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改称量信息
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void UpdateWeightButton_Click(object sender, EventArgs e)
|
|
{
|
|
DataGridViewRow nowRow = WeightDataGridView.CurrentRow;
|
|
|
|
|
|
|
|
if (MessageBox.Show($"确认要更改配方编号为 [{NowRecipeCode}] 物料编号为 [{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 = NowRecipeCode;
|
|
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(NowRecipeCode);
|
|
|
|
WeightToDataSource();
|
|
|
|
WeightDataGridView.DataSource = null;
|
|
WeightDataGridView.DataSource = weightDataSourceEntities;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 刷新称量信息
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void RefreshWeightButton_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
WeightLists = zxWeightService.GetWeightInfos(NowRecipeCode);
|
|
|
|
WeightToDataSource();
|
|
|
|
WeightDataGridView.DataSource = null;
|
|
WeightDataGridView.DataSource = weightDataSourceEntities;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 参数保存
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SaveParaButton_Click(object sender, EventArgs e)
|
|
{
|
|
//if (MessageBox.Show($"确定要保存配方编号为 [{s}] 的配方的参数?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
//{
|
|
// return;
|
|
//}
|
|
|
|
//获取前端的值
|
|
GetParaValue();
|
|
|
|
//搜索配方字段
|
|
var paraData = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(NowRecipeCode);
|
|
int flag = GetSelectIndex();
|
|
var positionParaData = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == NowRecipeCode && x.Position == flag);
|
|
//获得对应工位号
|
|
bool isSuccess = false;
|
|
//公共参数
|
|
//没有就插入
|
|
if (paraData.Count == 0)
|
|
{
|
|
if(zxRecipeParaService.InsertRecipeParaInfo(zxRecipeParaEntity))
|
|
{
|
|
isSuccess = true;
|
|
}
|
|
else
|
|
{
|
|
isSuccess = false;
|
|
}
|
|
}
|
|
//有就更改
|
|
else if (paraData.Count == 1)
|
|
{
|
|
zxRecipeParaEntity.Id = paraData[0].Id;
|
|
if (zxRecipeParaService.UpdateRecipeParaInfo(zxRecipeParaEntity))
|
|
{
|
|
isSuccess = true;
|
|
}
|
|
else
|
|
{
|
|
isSuccess = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("存在多条未删除的相同公共参数!请检查数据库。");
|
|
return;
|
|
}
|
|
|
|
//贴合参数
|
|
//没有就插入
|
|
if (positionParaData.Count == 0)
|
|
{
|
|
if (zxRecipePositionParaService.InsertRecipePositionParaInfo(zxRecipePositionParaEntity))
|
|
{
|
|
isSuccess = true;
|
|
}
|
|
else
|
|
{
|
|
isSuccess = false;
|
|
}
|
|
}
|
|
//有就更改
|
|
else if (positionParaData.Count == 1)
|
|
{
|
|
zxRecipePositionParaEntity.Id = positionParaData[0].Id;
|
|
if (zxRecipePositionParaService.UpdateRecipePositionParaInfo(zxRecipePositionParaEntity))
|
|
{
|
|
isSuccess = true;
|
|
}
|
|
else
|
|
{
|
|
isSuccess = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("存在多条未删除的相同贴合参数!请检查数据库。");
|
|
return;
|
|
}
|
|
|
|
if (isSuccess)
|
|
{
|
|
BaseForm.LogRefreshAction.Invoke("保存成功" + DateTime.Now.ToString());
|
|
}
|
|
else
|
|
{
|
|
BaseForm.LogRefreshAction.Invoke("保存失败" + DateTime.Now.ToString());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 参数复制
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void CopyParaButton_Click(object sender, EventArgs e)
|
|
{
|
|
//zxRecipeParaEntityCut = GetParaValue();
|
|
NowCopyLabel.Text = NowRecipeCode;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 参数粘贴
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void PasteParaButton_Click(object sender, EventArgs e)
|
|
{
|
|
if (zxRecipeParaEntityCut == null)
|
|
{
|
|
MessageBox.Show("剪切板为空!");
|
|
return;
|
|
}
|
|
//SetParaValue(zxRecipeParaEntityCut);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 参数清空
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ClearCutBoradButton_Click(object sender, EventArgs e)
|
|
{
|
|
zxRecipeParaEntityCut = null;
|
|
NowCopyLabel.Text = "N/A";
|
|
|
|
if (MessageBox.Show("是否要清空前端数据", "", MessageBoxButtons.YesNo) == DialogResult.OK)
|
|
{
|
|
//SetParaValue(new ZxRecipeParaEntity());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 所选配方内容更改事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void RecipeDataGridView_SelectionChanged(object sender, EventArgs e)
|
|
{
|
|
int a = RecipeDataGridView.CurrentRow.Index;
|
|
NowRecipeCode = RecipeDataGridView.Rows[a].Cells["RecipeCode"].Value.ToString();
|
|
|
|
WeightLists = zxWeightService.GetWeightInfos(NowRecipeCode);
|
|
|
|
WeightToDataSource();
|
|
|
|
WeightDataGridView.DataSource = null;
|
|
WeightDataGridView.DataSource = weightDataSourceEntities;
|
|
|
|
//设置参数
|
|
var paraData = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(NowRecipeCode);
|
|
int flag = GetSelectIndex();
|
|
var positionParaData = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == NowRecipeCode && x.Position == flag);
|
|
//没有就全0
|
|
if (paraData.Count == 0)
|
|
{
|
|
SetPublicParaValue(new ZxRecipeParaEntity());
|
|
}
|
|
//有就显示
|
|
else if (paraData.Count == 1)
|
|
{
|
|
SetPublicParaValue(paraData[0]);
|
|
}
|
|
//有多条设为第一条
|
|
else
|
|
{
|
|
MessageBox.Show("存在多条未删除的相同配方字段信息!将设置为第一条,请检查数据库。");
|
|
SetPublicParaValue(paraData[0]);
|
|
}
|
|
|
|
//没有就全0
|
|
if (positionParaData.Count == 0)
|
|
{
|
|
SetPrivateParaValue(new ZxRecipePositionParaEntity());
|
|
}
|
|
//有就显示
|
|
else if (positionParaData.Count == 1)
|
|
{
|
|
SetPrivateParaValue(positionParaData[0]);
|
|
}
|
|
//有多条设为第一条
|
|
else
|
|
{
|
|
MessageBox.Show("存在多条未删除的相同配方字段信息!将设置为第一条,请检查数据库。");
|
|
SetPrivateParaValue(positionParaData[0]);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 称重数据关联物料数据
|
|
/// </summary>
|
|
private void WeightToDataSource()
|
|
{
|
|
weightDataSourceEntities = new List<WeightDataSourceEntity>();
|
|
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,
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置显示的贴合参数字段值
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
private void SetPrivateParaValue(ZxRecipePositionParaEntity entity)
|
|
{
|
|
E1TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E1);
|
|
E2TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E2);
|
|
E3TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E3);
|
|
E4TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E4);
|
|
E5TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E5);
|
|
E6TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E6);
|
|
E7TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E7);
|
|
E8TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E8);
|
|
E9TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E9);
|
|
E10TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E10);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置公共参数
|
|
/// </summary>
|
|
/// <param name="paraEntity"></param>
|
|
private void SetPublicParaValue(ZxRecipeParaEntity paraEntity)
|
|
{
|
|
S0Check.Checked = paraEntity.S0 ?? false;
|
|
S1Check.Checked = paraEntity.S1 ?? false;
|
|
S2Check.Checked = paraEntity.S2 ?? false;
|
|
S3Check.Checked = paraEntity.S3 ?? false;
|
|
S4Check.Checked = paraEntity.S4 ?? false;
|
|
S5Check.Checked = paraEntity.S5 ?? false;
|
|
S6Check.Checked = paraEntity.S6 ?? false;
|
|
S7Check.Checked = paraEntity.S7 ?? false;
|
|
S8Check.Checked = paraEntity.S8 ?? false;
|
|
S9Check.Checked = paraEntity.S9 ?? false;
|
|
|
|
RimInchTextBox.Text = GeneralUtils.IntEmptyOrToString(paraEntity.RimInch);
|
|
LightWidthTextBox.Text = GeneralUtils.IntEmptyOrToString(paraEntity.LightWidth);
|
|
SlowDistanceTextBox.Text = GeneralUtils.IntEmptyOrToString(paraEntity.SlowDistance);
|
|
StopDistanceTextBox.Text = GeneralUtils.IntEmptyOrToString(paraEntity.StopDistance);
|
|
TireWeightTextBox.Text = GeneralUtils.IntEmptyOrToString(paraEntity.TireWeight);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取界面上的配方参数
|
|
/// </summary>
|
|
/// <returns>获取到的配方参数值</returns>
|
|
private void GetParaValue()
|
|
{
|
|
zxRecipePositionParaEntity.E1 = GeneralUtils.StringNullOrToInt(E1TextBox.Text);
|
|
zxRecipePositionParaEntity.E2 = GeneralUtils.StringNullOrToInt(E2TextBox.Text);
|
|
zxRecipePositionParaEntity.E3 = GeneralUtils.StringNullOrToInt(E3TextBox.Text);
|
|
zxRecipePositionParaEntity.E4 = GeneralUtils.StringNullOrToInt(E4TextBox.Text);
|
|
zxRecipePositionParaEntity.E5 = GeneralUtils.StringNullOrToInt(E5TextBox.Text);
|
|
zxRecipePositionParaEntity.E6 = GeneralUtils.StringNullOrToInt(E6TextBox.Text);
|
|
zxRecipePositionParaEntity.E7 = GeneralUtils.StringNullOrToInt(E7TextBox.Text);
|
|
zxRecipePositionParaEntity.E8 = GeneralUtils.StringNullOrToInt(E8TextBox.Text);
|
|
zxRecipePositionParaEntity.E9 = GeneralUtils.StringNullOrToInt(E9TextBox.Text);
|
|
zxRecipePositionParaEntity.E10 = GeneralUtils.StringNullOrToInt(E10TextBox.Text);
|
|
zxRecipePositionParaEntity.Position = GetSelectIndex();
|
|
zxRecipePositionParaEntity.RecipeCode = NowRecipeCode;
|
|
|
|
zxRecipeParaEntity.S0 = S0Check.Checked;
|
|
zxRecipeParaEntity.S1 = S1Check.Checked;
|
|
zxRecipeParaEntity.S2 = S2Check.Checked;
|
|
zxRecipeParaEntity.S3 = S3Check.Checked;
|
|
zxRecipeParaEntity.S4 = S4Check.Checked;
|
|
zxRecipeParaEntity.S5 = S5Check.Checked;
|
|
zxRecipeParaEntity.S6 = S6Check.Checked;
|
|
zxRecipeParaEntity.S7 = S7Check.Checked;
|
|
zxRecipeParaEntity.S8 = S8Check.Checked;
|
|
zxRecipeParaEntity.S9 = S9Check.Checked;
|
|
zxRecipeParaEntity.RimInch = GeneralUtils.StringNullOrToInt(RimInchTextBox.Text);
|
|
zxRecipeParaEntity.LightWidth = GeneralUtils.StringNullOrToInt(LightWidthTextBox.Text);
|
|
zxRecipeParaEntity.SlowDistance = GeneralUtils.StringNullOrToInt(SlowDistanceTextBox.Text);
|
|
zxRecipeParaEntity.StopDistance = GeneralUtils.StringNullOrToInt(StopDistanceTextBox.Text);
|
|
zxRecipeParaEntity.TireWeight = GeneralUtils.StringNullOrToInt(TireWeightTextBox.Text);
|
|
zxRecipeParaEntity.RecipeCode = NowRecipeCode;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 工位改变
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void PositionRadioBoxChange(object sender, EventArgs e)
|
|
{
|
|
RadioButton s = sender as RadioButton;
|
|
|
|
if (s.Checked)
|
|
{
|
|
int flag = GetSelectIndex();
|
|
|
|
SetParaView(flag);
|
|
if(flag < 10)
|
|
{
|
|
BodyRadioButton.Enabled = false;
|
|
SideRadioButton.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
BodyRadioButton.Enabled = true;
|
|
SideRadioButton.Enabled = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 读取数据库设置贴合参数字段
|
|
/// </summary>
|
|
/// <param name="flag"></param>
|
|
/// <param name="recipeCode"></param>
|
|
private void SetParaView(int flag)
|
|
{
|
|
zxRecipePositionParaEntity = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.Position == flag && x.RecipeCode == NowRecipeCode).FirstOrDefault();
|
|
if (zxRecipePositionParaEntity == null)
|
|
{
|
|
zxRecipePositionParaEntity = new ZxRecipePositionParaEntity();
|
|
}
|
|
SetPrivateParaValue(zxRecipePositionParaEntity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取选择的工位包边
|
|
/// </summary>
|
|
/// <returns>选的不对劲就返回0</returns>
|
|
private int GetSelectIndex()
|
|
{
|
|
if (Position1RadioButton.Checked)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
if (Position2RadioButton.Checked)
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
if (Position3RadioButton.Checked)
|
|
{
|
|
if (BodyRadioButton.Checked)
|
|
{
|
|
return 31;
|
|
}
|
|
|
|
if (SideRadioButton.Checked)
|
|
{
|
|
return 32;
|
|
}
|
|
}
|
|
|
|
if (Position4RadioButton.Checked)
|
|
{
|
|
if (BodyRadioButton.Checked)
|
|
{
|
|
return 41;
|
|
}
|
|
|
|
if (SideRadioButton.Checked)
|
|
{
|
|
return 42;
|
|
}
|
|
}
|
|
|
|
if (Position5RadioButton.Checked)
|
|
{
|
|
if (BodyRadioButton.Checked)
|
|
{
|
|
return 51;
|
|
}
|
|
|
|
if (SideRadioButton.Checked)
|
|
{
|
|
return 52;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
}
|