|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Data;
|
|
|
using Mesnac.Action.Base;
|
|
|
using Mesnac.Controls.Base;
|
|
|
using Mesnac.Controls.Default;
|
|
|
using System.Windows.Forms;
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.Feeding.Qingquan.Technology
|
|
|
{
|
|
|
public class SaveRecipe : FeedingAction, IAction
|
|
|
{
|
|
|
#region 业务必须信息
|
|
|
|
|
|
#region 配方信息实体
|
|
|
/// <summary>
|
|
|
/// 配方信息
|
|
|
/// </summary>
|
|
|
private class RecipeInfo
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 序号
|
|
|
/// </summary>
|
|
|
public string ObjID { get; set; }
|
|
|
/// <summary>
|
|
|
/// 机台号
|
|
|
/// </summary>
|
|
|
public string RecipeEquipCode { get; set; }
|
|
|
/// <summary>
|
|
|
/// 配方物料代码
|
|
|
/// </summary>
|
|
|
public string RecipeMaterialCode { get; set; }
|
|
|
/// <summary>
|
|
|
/// 配方物料名称
|
|
|
/// </summary>
|
|
|
public string RecipeMaterialName { get; set; }
|
|
|
/// <summary>
|
|
|
/// 配方物料版本
|
|
|
/// </summary>
|
|
|
public string RecipeVersionID { get; set; }
|
|
|
/// <summary>
|
|
|
/// 配方状态
|
|
|
/// </summary>
|
|
|
public string RecipeState { get; set; }
|
|
|
/// <summary>
|
|
|
/// 配方类型
|
|
|
/// </summary>
|
|
|
public string RecipeType { get; set; }
|
|
|
/// <summary>
|
|
|
/// 超温排胶最短时间
|
|
|
/// </summary>
|
|
|
public double? OverTempMinTime { get; set; }
|
|
|
/// <summary>
|
|
|
/// 超时排胶时间
|
|
|
/// </summary>
|
|
|
public double? OverTimeSetTime { get; set; }
|
|
|
/// <summary>
|
|
|
/// 超温排胶温度
|
|
|
/// </summary>
|
|
|
public double? OverTempSetTemp { get; set; }
|
|
|
/// <summary>
|
|
|
/// 最高进料温度
|
|
|
/// </summary>
|
|
|
public double? InPolyMaxTemp { get; set; }
|
|
|
/// <summary>
|
|
|
/// 加胶时间
|
|
|
/// </summary>
|
|
|
public double? InPolySetTime { get; set; }
|
|
|
/// <summary>
|
|
|
/// 是否使用三区温度
|
|
|
/// </summary>
|
|
|
public int IsUseAreaTemp { get; set; }
|
|
|
/// <summary>
|
|
|
/// 侧壁温度
|
|
|
/// </summary>
|
|
|
public double? SideTemp { get; set; }
|
|
|
/// <summary>
|
|
|
/// 转子温度
|
|
|
/// </summary>
|
|
|
public double? RollTemp { get; set; }
|
|
|
/// <summary>
|
|
|
/// 卸料门温度
|
|
|
/// </summary>
|
|
|
public double? DdoorTemp { get; set; }
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 配方称量实体
|
|
|
/// <summary>
|
|
|
/// 配方称量信息
|
|
|
/// </summary>
|
|
|
private class RecipeWeight
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 索引号
|
|
|
/// </summary>
|
|
|
public int Index { get; set; }
|
|
|
/// <summary>
|
|
|
/// 称量类型
|
|
|
/// </summary>
|
|
|
public int WeightType { get; set; }
|
|
|
/// <summary>
|
|
|
/// 称量序号
|
|
|
/// </summary>
|
|
|
public int WeightID { get; set; }
|
|
|
/// <summary>
|
|
|
/// 称量动作
|
|
|
/// </summary>
|
|
|
public string ActCode { get; set; }
|
|
|
/// <summary>
|
|
|
/// 称量物料名称
|
|
|
/// </summary>
|
|
|
public string MaterialName { get; set; }
|
|
|
/// <summary>
|
|
|
/// 称量物料代码
|
|
|
/// </summary>
|
|
|
public string MaterialCode { get; set; }
|
|
|
/// <summary>
|
|
|
/// 设定重量
|
|
|
/// </summary>
|
|
|
public double? SetWeight { get; set; }
|
|
|
/// <summary>
|
|
|
/// 允许误差
|
|
|
/// </summary>
|
|
|
public double? ErrorAllow { get; set; }
|
|
|
/// <summary>
|
|
|
/// 胶类型
|
|
|
/// </summary>
|
|
|
public string AutoPloy { get; set; }
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 配方密炼实体
|
|
|
|
|
|
/// <summary>
|
|
|
/// 配方密炼信息
|
|
|
/// </summary>
|
|
|
private class RecipeMixing
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 序号
|
|
|
/// </summary>
|
|
|
public int Index { get; set; }
|
|
|
/// <summary>
|
|
|
/// 密炼序号
|
|
|
/// </summary>
|
|
|
public int MixingStep { get; set; }
|
|
|
/// <summary>
|
|
|
/// 动作名称
|
|
|
/// </summary>
|
|
|
public string ActionName { get; set; }
|
|
|
/// <summary>
|
|
|
/// 动作代码
|
|
|
/// </summary>
|
|
|
public string ActionCode { get; set; }
|
|
|
/// <summary>
|
|
|
/// 条件名称
|
|
|
/// </summary>
|
|
|
public string TermName { get; set; }
|
|
|
/// <summary>
|
|
|
/// 条件代码
|
|
|
/// </summary>
|
|
|
public string TermCode { get; set; }
|
|
|
/// <summary>
|
|
|
/// 时间
|
|
|
/// </summary>
|
|
|
public double? MixingTime { get; set; }
|
|
|
/// <summary>
|
|
|
/// 温度
|
|
|
/// </summary>
|
|
|
public double? MixingTemp { get; set; }
|
|
|
/// <summary>
|
|
|
/// 功率
|
|
|
/// </summary>
|
|
|
public double? MixingPower { get; set; }
|
|
|
/// <summary>
|
|
|
/// 能量
|
|
|
/// </summary>
|
|
|
public double? MixingEnergy { get; set; }
|
|
|
/// <summary>
|
|
|
/// 压力
|
|
|
/// </summary>
|
|
|
public double? MixingPress { get; set; }
|
|
|
/// <summary>
|
|
|
/// 转速
|
|
|
/// </summary>
|
|
|
public double? MixingSpeed { get; set; }
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 空值判断
|
|
|
/// <summary>
|
|
|
/// 空值判断
|
|
|
/// </summary>
|
|
|
/// <param name="value">要判断的对象</param>
|
|
|
/// <returns>为空返回true,否则返回false</returns>
|
|
|
private bool ValueIsNull(object value)
|
|
|
{
|
|
|
if (value == null || value == DBNull.Value
|
|
|
|| string.IsNullOrWhiteSpace(value.ToString()))
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取配方界面字段值
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取配方界面字段值
|
|
|
/// </summary>
|
|
|
/// <param name="key">界面字段的业务标识</param>
|
|
|
/// <returns>返回字符串格式的配方界面字段值</returns>
|
|
|
private string getRecipeInfoValueString(string key)
|
|
|
{
|
|
|
string Result = string.Empty;
|
|
|
DbMCControl control = null;
|
|
|
List<DbMCControl> controls = base.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, string.Format("[pmt_recipe].[{0}]", key));
|
|
|
foreach (DbMCControl c in controls)
|
|
|
{
|
|
|
if (c.BaseControl.DbOptionType == DbOptionTypes.Modify ||
|
|
|
c.BaseControl.DbOptionType == DbOptionTypes.QueryAndModify)
|
|
|
{
|
|
|
control = c;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (control != null)
|
|
|
{
|
|
|
object value = control.BaseControl.MCValue;
|
|
|
if (value != null)
|
|
|
{
|
|
|
return value.ToString();
|
|
|
}
|
|
|
}
|
|
|
return Result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取配方界面字段值
|
|
|
/// </summary>
|
|
|
/// <param name="key">界面字段的业务标识</param>
|
|
|
/// <returns>返回int格式的配方界面字段值</returns>
|
|
|
private int getRecipeInfoValueInt(string key)
|
|
|
{
|
|
|
int Result = 0;
|
|
|
string ss = getRecipeInfoValueString(key);
|
|
|
if (int.TryParse(ss, out Result))
|
|
|
{
|
|
|
return Result;
|
|
|
}
|
|
|
return Result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取配方界面字段值
|
|
|
/// </summary>
|
|
|
/// <param name="key">界面字段的业务标识</param>
|
|
|
/// <returns>返回double格式的配方界面字段值</returns>
|
|
|
private double getRecipeInfoValueDouble(string key)
|
|
|
{
|
|
|
double Result = 0;
|
|
|
string ss = getRecipeInfoValueString(key);
|
|
|
if (double.TryParse(ss, out Result))
|
|
|
{
|
|
|
return Result;
|
|
|
}
|
|
|
return Result;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 从配方维护界面获取配方主信息
|
|
|
/// <summary>
|
|
|
/// 从配方维护界面获取配方主信息
|
|
|
/// </summary>
|
|
|
/// <returns>返回配方主信息实体</returns>
|
|
|
private RecipeInfo getRecipeInfo()
|
|
|
{
|
|
|
RecipeInfo Result = new RecipeInfo();
|
|
|
Result.RecipeEquipCode = base.CurrEquipCode;
|
|
|
Result.ObjID = getRecipeInfoValueString("ObjID");
|
|
|
Result.IsUseAreaTemp = getRecipeInfoValueInt("if_not");
|
|
|
Result.SideTemp = getRecipeInfoValueDouble("sds_temp");
|
|
|
Result.RollTemp = getRecipeInfoValueDouble("zz_temp");
|
|
|
Result.DdoorTemp = getRecipeInfoValueDouble("xlm_temp");
|
|
|
Result.OverTimeSetTime = getRecipeInfoValueDouble("mini_time");
|
|
|
Result.OverTempSetTemp = getRecipeInfoValueDouble("over_temp");
|
|
|
Result.OverTempMinTime = getRecipeInfoValueDouble("expire_time");
|
|
|
Result.RecipeState = getRecipeInfoValueString("recipe_state");
|
|
|
Result.RecipeType = getRecipeInfoValueString("RecipeType");
|
|
|
Result.RecipeMaterialName = getRecipeInfoValueString("mater_name");
|
|
|
Result.RecipeMaterialCode = getRecipeInfoValueString("mater_code");
|
|
|
Result.RecipeVersionID = getRecipeInfoValueString("edt_code");
|
|
|
Result.InPolyMaxTemp = getRecipeInfoValueDouble("max_temp");
|
|
|
//Result.InPolySetTime = getRecipeInfoValueDouble("InPolySetTime");
|
|
|
return Result;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 从配方界面获取配方称量信息
|
|
|
/// <summary>
|
|
|
/// 获取配方称量信息
|
|
|
/// </summary>
|
|
|
/// <returns>返回称量实体列表</returns>
|
|
|
private List<RecipeWeight> getRecipeWeightInfo()
|
|
|
{
|
|
|
List<RecipeWeight> Result = new List<RecipeWeight>();
|
|
|
List<MCDataGridView> gridList = GetTControls<MCDataGridView>();
|
|
|
foreach (MCDataGridView grid in gridList)
|
|
|
{
|
|
|
if (grid.MCKey != null && grid.MCKey.ToLower().StartsWith("PmtWeight.".ToLower()))
|
|
|
{
|
|
|
int iType = 0;
|
|
|
if (int.TryParse(grid.MCKey.Substring("PmtWeight.".Length).Trim(), out iType))
|
|
|
{
|
|
|
int idx = 0;
|
|
|
foreach (DataGridViewRow row in grid.Rows)
|
|
|
{
|
|
|
RecipeWeight weight = new RecipeWeight();
|
|
|
for (int i = 0; i < grid.ColumnCount; i++)
|
|
|
{
|
|
|
weight.WeightType = iType;
|
|
|
#region WeightID
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("SeqInx", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
int d = 0;
|
|
|
if (int.TryParse(row.Cells[i].Value.ToString(), out d))
|
|
|
{
|
|
|
weight.Index = d;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region ActCode
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("act_code", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
weight.ActCode = row.Cells[i].Value.ToString();
|
|
|
}
|
|
|
#endregion
|
|
|
#region MaterialName,MaterialCode
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("child_code", StringComparison.CurrentCultureIgnoreCase)
|
|
|
&& (grid.Columns[i] is System.Windows.Forms.DataGridViewComboBoxColumn))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
weight.MaterialCode = row.Cells[i].Value.ToString();
|
|
|
//weight.MaterialName = row.Cells[i].FormattedValue.ToString();
|
|
|
weight.MaterialName = this.GetMaterName(weight.MaterialCode);
|
|
|
}
|
|
|
#endregion
|
|
|
#region SetWeight
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("set_weight", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
double d = 0;
|
|
|
if (double.TryParse(row.Cells[i].Value.ToString(), out d))
|
|
|
{
|
|
|
weight.SetWeight = d;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region ErrorAllow
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("error_allow", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
double d = 0;
|
|
|
if (double.TryParse(row.Cells[i].Value.ToString(), out d))
|
|
|
{
|
|
|
weight.ErrorAllow = d;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region Auto_ploy
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("Auto_ploy", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
weight.AutoPloy = "0";
|
|
|
continue;
|
|
|
}
|
|
|
weight.AutoPloy = row.Cells[i].Value.ToString();
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
if (string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
weight.WeightID = idx;
|
|
|
Result.Add(weight);
|
|
|
idx++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return Result;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 从配方界面获取配方密炼信息
|
|
|
/// <summary>
|
|
|
/// 从配方界面获取配方密炼信息
|
|
|
/// </summary>
|
|
|
/// <returns>返回密炼实体列表</returns>
|
|
|
private List<RecipeMixing> getRecipeMixingInfo()
|
|
|
{
|
|
|
List<RecipeMixing> Result = new List<RecipeMixing>();
|
|
|
List<MCDataGridView> gridList = GetTControls<MCDataGridView>();
|
|
|
foreach (MCDataGridView grid in gridList)
|
|
|
{
|
|
|
if (grid.MCKey != null && grid.MCKey.ToLower() == "PmtMixing".ToLower())
|
|
|
{
|
|
|
int idx = 0;
|
|
|
foreach (DataGridViewRow row in grid.Rows)
|
|
|
{
|
|
|
RecipeMixing mixing = new RecipeMixing();
|
|
|
for (int i = 0; i < grid.ColumnCount; i++)
|
|
|
{
|
|
|
#region MixingStep
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("SeqInx", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
int d = 0;
|
|
|
if (int.TryParse(row.Cells[i].Value.ToString(), out d))
|
|
|
{
|
|
|
mixing.Index = d;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region ActionCode
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("act_code", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
mixing.ActionCode = row.Cells[i].Value.ToString();
|
|
|
mixing.ActionName = row.Cells[i].FormattedValue.ToString();
|
|
|
}
|
|
|
#endregion
|
|
|
#region TermCode
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("term_code", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
mixing.TermCode = row.Cells[i].Value.ToString();
|
|
|
mixing.TermName = row.Cells[i].FormattedValue.ToString();
|
|
|
}
|
|
|
#endregion
|
|
|
#region MixingTime
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("set_time", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
double d = 0;
|
|
|
if (double.TryParse(row.Cells[i].Value.ToString(), out d))
|
|
|
{
|
|
|
mixing.MixingTime = d;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region MixingTemp
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("set_temp", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
double d = 0;
|
|
|
if (double.TryParse(row.Cells[i].Value.ToString(), out d))
|
|
|
{
|
|
|
mixing.MixingTemp = d;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region MixingPower
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("set_power", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
double d = 0;
|
|
|
if (double.TryParse(row.Cells[i].Value.ToString(), out d))
|
|
|
{
|
|
|
mixing.MixingPower = d;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region MixingEnergy
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("set_ener", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
double d = 0;
|
|
|
if (double.TryParse(row.Cells[i].Value.ToString(), out d))
|
|
|
{
|
|
|
mixing.MixingEnergy = d;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region MixingPress
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("set_pres", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
double d = 0;
|
|
|
if (double.TryParse(row.Cells[i].Value.ToString(), out d))
|
|
|
{
|
|
|
mixing.MixingPress = d;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region MixingSpeed
|
|
|
if (grid.Columns[i].DataPropertyName.Equals("set_rota", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
if (ValueIsNull(row.Cells[i].Value))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
double d = 0;
|
|
|
if (double.TryParse(row.Cells[i].Value.ToString(), out d))
|
|
|
{
|
|
|
mixing.MixingSpeed = d;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
mixing.MixingStep = idx;
|
|
|
Result.Add(mixing);
|
|
|
idx++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return Result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 业务验证
|
|
|
|
|
|
/// <summary>
|
|
|
/// 密炼动作
|
|
|
/// </summary>
|
|
|
private enum MixingAction
|
|
|
{
|
|
|
加胶料 = 1,
|
|
|
加炭黑 = 2,
|
|
|
加油1 = 3,
|
|
|
开卸料门 = 4,
|
|
|
关卸料门 = 5,
|
|
|
升上顶栓上到位 = 6,
|
|
|
上顶栓清扫 = 7,
|
|
|
压上顶栓 = 8,
|
|
|
配方结束 = 9,
|
|
|
保持 = 10,
|
|
|
开加料门 = 11,
|
|
|
关加料门 = 12,
|
|
|
加小药 = 13,
|
|
|
上顶栓浮动 = 14,
|
|
|
加油2 = 15,
|
|
|
加粉料 = 16
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 称量动作
|
|
|
/// </summary>
|
|
|
private enum WeightAction
|
|
|
{
|
|
|
称量 = 0,
|
|
|
称到 = 1,
|
|
|
卸料 = 2,
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 称量类型
|
|
|
/// </summary>
|
|
|
private enum WeightType
|
|
|
{
|
|
|
炭黑称量信息 = 0,
|
|
|
油1称量信息 = 1,
|
|
|
胶料称量信息 = 2,
|
|
|
粉料称量信息 = 3,
|
|
|
小料称量信息 = 4,
|
|
|
油2称量信息 = 5
|
|
|
//小料称量信息 = 9,
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 验证配方
|
|
|
/// </summary>
|
|
|
/// <param name="recipe"></param>
|
|
|
/// <param name="isXiaoLiao"></param>
|
|
|
/// <returns></returns>
|
|
|
private string ValidityRecipe(RecipeInfo recipe, bool isXiaoLiao)
|
|
|
{
|
|
|
string Result = string.Empty;
|
|
|
if (recipe.IsUseAreaTemp == 1)
|
|
|
{
|
|
|
if ((recipe.SideTemp == null) || ((int)recipe.SideTemp) <= 0)
|
|
|
{
|
|
|
return Language(231); //侧壁温度不能为空且必须大于0
|
|
|
}
|
|
|
if ((recipe.RollTemp == null) || ((int)recipe.RollTemp) <= 0)
|
|
|
{
|
|
|
return Language(232); //卸料门温度不能为空且必须大于0
|
|
|
}
|
|
|
if ((recipe.DdoorTemp == null) || ((int)recipe.DdoorTemp) <= 0)
|
|
|
{
|
|
|
return Language(233); //卸料门温度不能为空且必须大于0
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(recipe.RecipeMaterialCode))
|
|
|
{
|
|
|
return Language(234); //物料信息不能为空
|
|
|
}
|
|
|
if (string.IsNullOrWhiteSpace(recipe.RecipeEquipCode))
|
|
|
{
|
|
|
return Language(235); //机台信息不能为空
|
|
|
}
|
|
|
//if (string.IsNullOrWhiteSpace(recipe.RecipeType))
|
|
|
//{
|
|
|
// return Language(236); //配方类型不能为空
|
|
|
//}
|
|
|
if (string.IsNullOrWhiteSpace(recipe.RecipeState))
|
|
|
{
|
|
|
return Language(237); //配方状态不能为空
|
|
|
}
|
|
|
if ((recipe.OverTimeSetTime == null) || ((int)recipe.OverTimeSetTime) <= 0)
|
|
|
{
|
|
|
return Language(238); //超时排胶时间不能为空且必须大于0
|
|
|
}
|
|
|
if ((recipe.OverTempSetTemp == null) || ((int)recipe.OverTempSetTemp) <= 0)
|
|
|
{
|
|
|
return Language(239); //紧急排胶温度不能为空且必须大于0
|
|
|
}
|
|
|
if ((recipe.OverTempMinTime == null) || ((int)recipe.OverTempMinTime) <= 0)
|
|
|
{
|
|
|
return Language(240); //超温排胶最短时间不能为空且必须大于0
|
|
|
}
|
|
|
return Result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 验证密炼信息
|
|
|
/// </summary>
|
|
|
/// <param name="mixinglst"></param>
|
|
|
/// <param name="isXiaoLiao"></param>
|
|
|
/// <returns></returns>
|
|
|
private string ValidityRecipeMixing(List<RecipeMixing> mixinglst,bool isXiaoLiao)
|
|
|
{
|
|
|
if (isXiaoLiao)
|
|
|
{
|
|
|
return string.Empty;
|
|
|
}
|
|
|
bool isExistsMixingInfo = false;
|
|
|
string Result = string.Empty;
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(mixing.ActionCode) && (
|
|
|
((mixing.MixingTime != null) && ((int)mixing.MixingTime > 0))
|
|
|
|| ((mixing.MixingTemp != null) && ((int)mixing.MixingTemp > 0))
|
|
|
|| ((mixing.MixingEnergy != null) && ((int)mixing.MixingEnergy > 0))
|
|
|
|| ((mixing.MixingPower != null) && ((int)mixing.MixingPower > 0))
|
|
|
|| ((mixing.MixingPress != null) && ((int)mixing.MixingPress > 0))
|
|
|
|| ((mixing.MixingSpeed != null) && ((int)mixing.MixingSpeed > 0))
|
|
|
|| (!string.IsNullOrWhiteSpace(mixing.TermCode))
|
|
|
))
|
|
|
{
|
|
|
return string.Format(Language(241), mixing.Index.ToString());
|
|
|
}
|
|
|
}
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(mixing.ActionCode))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
isExistsMixingInfo = true;
|
|
|
if ((mixing.MixingSpeed == null) || (mixing.MixingSpeed == 0))
|
|
|
{
|
|
|
return Language(242);
|
|
|
}
|
|
|
if ((mixing.MixingPress == null) || (mixing.MixingPress == 0))
|
|
|
{
|
|
|
return Language(243);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
if (!isExistsMixingInfo)
|
|
|
{
|
|
|
return Language(244);
|
|
|
}
|
|
|
bool isExist加胶料 = false;
|
|
|
bool isExist开卸料门 = false;
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(mixing.ActionCode))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
if (mixing.ActionCode.Trim() == ((int)MixingAction.加胶料).ToString())
|
|
|
{
|
|
|
isExist加胶料 = true;
|
|
|
}
|
|
|
if (mixing.ActionCode.Trim() == ((int)MixingAction.开卸料门).ToString())
|
|
|
{
|
|
|
isExist开卸料门 = true;
|
|
|
}
|
|
|
if ((!string.IsNullOrWhiteSpace(mixing.TermName)) && (mixing.TermName.Contains("温度"))
|
|
|
&& ((mixing.MixingTemp == null) || (mixing.MixingTemp <= 0)))
|
|
|
{
|
|
|
return string.Format(Language(245), mixing.Index.ToString());
|
|
|
}
|
|
|
if ((!string.IsNullOrWhiteSpace(mixing.TermName)) && (mixing.TermName.Contains("温度"))
|
|
|
&& ((mixing.MixingTemp == null) || (mixing.MixingTemp > 200)))
|
|
|
{
|
|
|
return string.Format(Language(246), mixing.Index.ToString());
|
|
|
}
|
|
|
if ((mixing.MixingTemp != null) && (mixing.MixingTemp > 0)
|
|
|
&& ((string.IsNullOrWhiteSpace(mixing.TermName)) || (!mixing.TermName.Contains("温度"))))
|
|
|
{
|
|
|
return string.Format(Language(247), mixing.Index.ToString());
|
|
|
}
|
|
|
if ((!string.IsNullOrWhiteSpace(mixing.ActionCode)) && (mixing.ActionCode == ((int)MixingAction.保持).ToString())
|
|
|
&& ((mixing.MixingTime == null) || (mixing.MixingTime <= 0)))
|
|
|
{
|
|
|
return string.Format(Language(248), mixing.Index.ToString());
|
|
|
}
|
|
|
if ((!string.IsNullOrWhiteSpace(mixing.TermName)) && (mixing.TermName.Contains("功率"))
|
|
|
&& ((mixing.MixingPower == null) || (mixing.MixingPower <= 0)))
|
|
|
{
|
|
|
return string.Format(Language(249), mixing.Index.ToString());
|
|
|
}
|
|
|
if ((mixing.MixingPower != null) && (mixing.MixingPower > 0)
|
|
|
&& ((string.IsNullOrWhiteSpace(mixing.TermName)) || (!mixing.TermName.Contains("功率"))))
|
|
|
{
|
|
|
return string.Format(Language(250), mixing.Index.ToString());
|
|
|
}
|
|
|
if ((!string.IsNullOrWhiteSpace(mixing.TermName)) && (mixing.TermName.Contains("能量"))
|
|
|
&& ((mixing.MixingEnergy == null) || (mixing.MixingEnergy <= 0)))
|
|
|
{
|
|
|
return string.Format(Language(251), mixing.Index.ToString());
|
|
|
}
|
|
|
if ((mixing.MixingEnergy != null) && (mixing.MixingEnergy > 0)
|
|
|
&& ((string.IsNullOrWhiteSpace(mixing.TermName)) || (!mixing.TermName.Contains("能量"))))
|
|
|
{
|
|
|
return string.Format(Language(252), mixing.Index.ToString());
|
|
|
}
|
|
|
}
|
|
|
if (!isExist加胶料)
|
|
|
{
|
|
|
return Language(253);
|
|
|
}
|
|
|
if (!isExist开卸料门)
|
|
|
{
|
|
|
return Language(254);
|
|
|
}
|
|
|
return Result;
|
|
|
}
|
|
|
private bool WeightTypeNeed卸料(string weightType)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(weightType))
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
if (weightType.Trim() == ((int)WeightType.炭黑称量信息).ToString())
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
if (weightType.Trim() == ((int)WeightType.油1称量信息).ToString())
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
if (weightType.Trim() == ((int)WeightType.油2称量信息).ToString())
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
//增加粉料时必须有卸料
|
|
|
if (weightType.Trim() == ((int)WeightType.粉料称量信息).ToString())
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
private bool WeightActionIs卸料(string weightAction)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(weightAction))
|
|
|
{
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
if (weightAction.Trim() == ((int)WeightAction.卸料).ToString())
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 验证称量信息
|
|
|
/// </summary>
|
|
|
/// <param name="weightlst"></param>
|
|
|
/// <param name="isXiaoLiao"></param>
|
|
|
/// <returns></returns>
|
|
|
private string ValidityRecipeWeight(List<RecipeWeight> weightlst,bool isXiaoLiao)
|
|
|
{
|
|
|
string Result = string.Empty;
|
|
|
Dictionary<int, List<RecipeWeight>> weightTypelst = new Dictionary<int, List<RecipeWeight>>();
|
|
|
bool isExistsWeightInfo = false;
|
|
|
foreach (RecipeWeight weight in weightlst)
|
|
|
{
|
|
|
List<RecipeWeight> lst = null;
|
|
|
if (!weightTypelst.TryGetValue(weight.WeightType, out lst))
|
|
|
{
|
|
|
lst = new List<RecipeWeight>();
|
|
|
weightTypelst.Add(weight.WeightType, lst);
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
{
|
|
|
isExistsWeightInfo = true;
|
|
|
}
|
|
|
lst.Add(weight);
|
|
|
}
|
|
|
if (!isExistsWeightInfo)
|
|
|
{
|
|
|
return Language(255);
|
|
|
}
|
|
|
foreach (List<RecipeWeight> lst in weightTypelst.Values)
|
|
|
{
|
|
|
RecipeWeight weight_first = null;
|
|
|
RecipeWeight weight_last = null;
|
|
|
foreach (RecipeWeight weight in lst)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
{
|
|
|
if (weight_first == null)
|
|
|
{
|
|
|
weight_first = weight;
|
|
|
weight_last = weight;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
weight_last = weight;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (weight_first != null)
|
|
|
{
|
|
|
if (WeightTypeNeed卸料(weight_first.WeightType.ToString()) && WeightActionIs卸料(weight_first.ActCode))
|
|
|
{
|
|
|
return string.Format(Language(256), ((WeightType)(weight_first.WeightType)).ToString());
|
|
|
}
|
|
|
if (WeightTypeNeed卸料(weight_last.WeightType.ToString()) && !WeightActionIs卸料(weight_last.ActCode))
|
|
|
{
|
|
|
return string.Format(Language(257), ((WeightType)(weight_first.WeightType)).ToString());
|
|
|
}
|
|
|
}
|
|
|
foreach (RecipeWeight weight in lst)
|
|
|
{
|
|
|
if ((string.IsNullOrWhiteSpace(weight.ActCode)) || WeightActionIs卸料(weight.ActCode))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
#region 称量
|
|
|
if ((weight.SetWeight == null) ||
|
|
|
(weight.ErrorAllow == null) ||
|
|
|
(weight.SetWeight == 0) ||
|
|
|
(weight.ErrorAllow == 0))
|
|
|
{
|
|
|
return string.Format(Language(258), ((WeightType)(weight_first.WeightType)).ToString(), weight.MaterialName);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<RecipeMixing> mixinglst = getRecipeMixingInfo();
|
|
|
foreach (KeyValuePair<int, List<RecipeWeight>> weightType in weightTypelst)
|
|
|
{
|
|
|
bool isExists = false;
|
|
|
#region 炭黑称量信息
|
|
|
if (weightType.Key == (int)WeightType.炭黑称量信息)
|
|
|
{
|
|
|
foreach (RecipeWeight weight in weightType.Value)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
{
|
|
|
isExists = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isExists)
|
|
|
{
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(mixing.ActionCode)
|
|
|
&& mixing.ActionCode.Trim() == ((int)MixingAction.加炭黑).ToString())
|
|
|
{
|
|
|
isExists = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isExists)
|
|
|
{
|
|
|
return Language(259);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region 油1称量信息
|
|
|
if (weightType.Key == (int)WeightType.油1称量信息)
|
|
|
{
|
|
|
foreach (RecipeWeight weight in weightType.Value)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
{
|
|
|
isExists = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isExists)
|
|
|
{
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(mixing.ActionCode)
|
|
|
&& mixing.ActionCode.Trim() == ((int)MixingAction.加油1).ToString())
|
|
|
{
|
|
|
isExists = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isExists)
|
|
|
{
|
|
|
return Language(260);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region 油2称量信息
|
|
|
if (weightType.Key == (int)WeightType.油2称量信息)
|
|
|
{
|
|
|
foreach (RecipeWeight weight in weightType.Value)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
{
|
|
|
isExists = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isExists)
|
|
|
{
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(mixing.ActionCode)
|
|
|
&& mixing.ActionCode.Trim() == ((int)MixingAction.加油2).ToString())
|
|
|
{
|
|
|
isExists = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isExists)
|
|
|
{
|
|
|
return Language(261);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
#region 粉料称量信息
|
|
|
if (weightType.Key == (int)WeightType.粉料称量信息)
|
|
|
{
|
|
|
foreach (RecipeWeight weight in weightType.Value)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
{
|
|
|
isExists = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isExists)
|
|
|
{
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(mixing.ActionCode)
|
|
|
&& mixing.ActionCode.Trim() == ((int)MixingAction.加粉料).ToString())
|
|
|
{
|
|
|
isExists = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isExists)
|
|
|
{
|
|
|
return Language(274);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
int iCount = 0;
|
|
|
#region 加炭黑
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(mixing.ActionCode)
|
|
|
&& mixing.ActionCode.Trim() == ((int)MixingAction.加炭黑).ToString())
|
|
|
{
|
|
|
iCount++;
|
|
|
}
|
|
|
}
|
|
|
foreach (KeyValuePair<int, List<RecipeWeight>> weightType in weightTypelst)
|
|
|
{
|
|
|
if (weightType.Key == (int)WeightType.炭黑称量信息)
|
|
|
{
|
|
|
foreach (RecipeWeight weight in weightType.Value)
|
|
|
{
|
|
|
if ((!string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
&& weight.ActCode.Trim() == ((int)WeightAction.卸料).ToString())
|
|
|
{
|
|
|
iCount = 0; ;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (iCount != 0)
|
|
|
{
|
|
|
return Language(262);
|
|
|
}
|
|
|
#endregion
|
|
|
#region 加油1
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(mixing.ActionCode)
|
|
|
&& mixing.ActionCode.Trim() == ((int)MixingAction.加油1).ToString())
|
|
|
{
|
|
|
iCount++;
|
|
|
}
|
|
|
}
|
|
|
foreach (KeyValuePair<int, List<RecipeWeight>> weightType in weightTypelst)
|
|
|
{
|
|
|
if (weightType.Key == (int)WeightType.油1称量信息)
|
|
|
{
|
|
|
foreach (RecipeWeight weight in weightType.Value)
|
|
|
{
|
|
|
if ((!string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
&& weight.ActCode.Trim() == ((int)WeightAction.卸料).ToString())
|
|
|
{
|
|
|
iCount--;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (iCount != 0)
|
|
|
{
|
|
|
return Language(263);
|
|
|
}
|
|
|
#endregion
|
|
|
#region 加油2
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(mixing.ActionCode)
|
|
|
&& mixing.ActionCode.Trim() == ((int)MixingAction.加油2).ToString())
|
|
|
{
|
|
|
iCount++;
|
|
|
}
|
|
|
}
|
|
|
foreach (KeyValuePair<int, List<RecipeWeight>> weightType in weightTypelst)
|
|
|
{
|
|
|
if (weightType.Key == (int)WeightType.油2称量信息)
|
|
|
{
|
|
|
foreach (RecipeWeight weight in weightType.Value)
|
|
|
{
|
|
|
if ((!string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
&& weight.ActCode.Trim() == ((int)WeightAction.卸料).ToString())
|
|
|
{
|
|
|
iCount--;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (iCount != 0)
|
|
|
{
|
|
|
return Language(264);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 加粉料
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(mixing.ActionCode)
|
|
|
&& mixing.ActionCode.Trim() == ((int)MixingAction.加粉料).ToString())
|
|
|
{
|
|
|
iCount++;
|
|
|
}
|
|
|
}
|
|
|
foreach (KeyValuePair<int, List<RecipeWeight>> weightType in weightTypelst)
|
|
|
{
|
|
|
if (weightType.Key == (int)WeightType.粉料称量信息)
|
|
|
{
|
|
|
foreach (RecipeWeight weight in weightType.Value)
|
|
|
{
|
|
|
if ((!string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
&& weight.ActCode.Trim() == ((int)WeightAction.卸料).ToString())
|
|
|
{
|
|
|
iCount--;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (iCount != 0)
|
|
|
{
|
|
|
return Language(275);
|
|
|
}
|
|
|
#endregion
|
|
|
return Result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 业务保存
|
|
|
|
|
|
/// <summary>
|
|
|
/// 新增配方时,获取配方编码
|
|
|
/// </summary>
|
|
|
/// <param name="recipe"></param>
|
|
|
/// <returns></returns>
|
|
|
private string GetRecipeCode(RecipeInfo recipe)
|
|
|
{
|
|
|
string recipeType = "正常";
|
|
|
//IBaseControl recipeTypeControl = base.GetMCControlByKey("RecipeType").FirstOrDefault(); //查找配方类型控件
|
|
|
//if (recipeTypeControl != null)
|
|
|
//{
|
|
|
// recipeType = recipeTypeControl.MCValue.ToString().Trim();
|
|
|
//}
|
|
|
string recipeTypeId = getRecipeInfoValueString("RecipeType");
|
|
|
recipeType = PlanCommon.GetSysCodeItemName(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "PmtType", Convert.ToInt32(recipeTypeId));
|
|
|
string result = String.Format("{0:yyMMdd}{1}{2:D3}", DateTime.Now, recipeType, recipe.RecipeVersionID);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#region 保存配方主信息
|
|
|
/// <summary>
|
|
|
/// 保存配方主信息
|
|
|
/// </summary>
|
|
|
/// <param name="dbHelper">数据访问辅助对象</param>
|
|
|
/// <param name="recipe">配方主信息实体</param>
|
|
|
/// <returns></returns>
|
|
|
private string SaveRecipeInfo(DbHelper dbHelper, RecipeInfo recipe)
|
|
|
{
|
|
|
string Result = string.Empty;
|
|
|
StringBuilder sqlfied = new StringBuilder();
|
|
|
StringBuilder sqlvalue = new StringBuilder();
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
if (string.IsNullOrWhiteSpace(recipe.ObjID))
|
|
|
{
|
|
|
sqlfied.AppendLine("INSERT INTO pmt_recipe(");
|
|
|
sqlfied.Append("equip_code").Append(","); //必须保存机台
|
|
|
sqlfied.Append("recipe_code").Append(","); //配方编码
|
|
|
|
|
|
sqlvalue.Append("'").Append(recipe.RecipeEquipCode.Substring(3)).Append("',"); //设置机台值,取后2位
|
|
|
sqlvalue.Append("'").Append(GetRecipeCode(recipe)).Append("',"); //设置配方编码
|
|
|
foreach (DbMCControl control in GetAllDbMCControls())
|
|
|
{
|
|
|
if (control.DataTable.Equals("pmt_recipe", StringComparison.CurrentCultureIgnoreCase)
|
|
|
&& !string.IsNullOrWhiteSpace(control.DataField)
|
|
|
&& !control.DataField.Equals("ObjID", StringComparison.CurrentCultureIgnoreCase)
|
|
|
&& (control.BaseControl.DbOptionType == DbOptionTypes.Modify || control.BaseControl.DbOptionType == DbOptionTypes.QueryAndModify)
|
|
|
&& control.BaseControl.MCValue != null)
|
|
|
{
|
|
|
sqlfied.Append(control.DataField).Append(",");
|
|
|
string key = "@" + control.DataField;
|
|
|
sqlvalue.Append(key).Append(",");
|
|
|
dbHelper.AddParameter(key, control.BaseControl.MCValue.ToString() == "" ? "0" : control.BaseControl.MCValue);
|
|
|
}
|
|
|
}
|
|
|
sqlfied.Remove(sqlfied.Length - 1, 1).AppendLine(") VALUES (");
|
|
|
sqlfied.Append(sqlvalue.Remove(sqlvalue.Length - 1, 1)).AppendLine(");SELECT SCOPE_IDENTITY();");
|
|
|
dbHelper.CommandText = sqlfied.ToString();
|
|
|
return dbHelper.ToScalar().ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
RecipeLogHelper.Instance.ClearStringBuilder(); //工艺日志处理
|
|
|
RecipeLogHelper.Instance.PmtRecipeOld.Append(String.Format("Equip_Code:{0},", recipe.RecipeEquipCode));
|
|
|
RecipeLogHelper.Instance.PmtRecipeNow.Append(String.Format("Equip_Code:{0},", recipe.RecipeEquipCode));
|
|
|
DataRow recipeDataRow = RecipeLogHelper.Instance.GetRecipeDataRow(recipe.RecipeMaterialCode, recipe.RecipeVersionID); //工艺日志处理
|
|
|
|
|
|
sqlfied.AppendLine("UPDATE pmt_recipe SET");
|
|
|
foreach (DbMCControl control in GetAllDbMCControls())
|
|
|
{
|
|
|
if (control.DataTable.Equals("pmt_recipe", StringComparison.CurrentCultureIgnoreCase)
|
|
|
&& (control.DataField != null && !control.DataField.Equals("ObjID", StringComparison.CurrentCultureIgnoreCase))
|
|
|
&& (control.BaseControl.DbOptionType == DbOptionTypes.Modify || control.BaseControl.DbOptionType == DbOptionTypes.QueryAndModify)
|
|
|
&& control.BaseControl.MCValue != null)
|
|
|
{
|
|
|
sqlfied.Append(control.DataField).Append("=");
|
|
|
string key = "@" + control.DataField;
|
|
|
sqlfied.Append(key).Append(",");
|
|
|
dbHelper.AddParameter(key, control.BaseControl.MCValue.ToString()== "" ? "0" : control.BaseControl.MCValue);
|
|
|
|
|
|
//工艺日志处理
|
|
|
try
|
|
|
{
|
|
|
if (recipeDataRow != null)
|
|
|
{
|
|
|
RecipeLogHelper.Instance.IsBegin = true; //开始处理工艺日志
|
|
|
RecipeLogHelper.Instance.PmtRecipeOld.Append(String.Format("{0}:{1}", control.DataField, Mesnac.Basic.DataProcessor.RowValue(recipeDataRow, control.DataField, "0")));
|
|
|
RecipeLogHelper.Instance.PmtRecipeOld.Append(",");
|
|
|
RecipeLogHelper.Instance.PmtRecipeNow.Append(String.Format("{0}:{1}", control.DataField, control.BaseControl.MCValue.ToString() == "" ? "0" : control.BaseControl.MCValue));
|
|
|
RecipeLogHelper.Instance.PmtRecipeNow.Append(",");
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error("工艺日志处理失败-配方主信息:" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
sqlfied.Remove(sqlfied.Length - 1, 1).AppendLine(" WHERE ObjID=").Append(recipe.ObjID.ToString());
|
|
|
dbHelper.CommandText = sqlfied.ToString();
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
return recipe.ObjID.ToString();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 保存配方密炼信息
|
|
|
/// <summary>
|
|
|
/// 保存配方密炼信息
|
|
|
/// </summary>
|
|
|
/// <param name="dbHelper">数据访问辅助对象</param>
|
|
|
/// <param name="recipe">配方主信息</param>
|
|
|
/// <param name="mixinglst">要保存的密炼信息列表</param>
|
|
|
/// <returns></returns>
|
|
|
private string SaveRecipeInfo(DbHelper dbHelper, RecipeInfo recipe, List<RecipeMixing> mixinglst)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (RecipeLogHelper.Instance.IsBegin)
|
|
|
{
|
|
|
RecipeLogHelper.Instance.GenerateRecipeMixOld(recipe.RecipeMaterialCode, recipe.RecipeVersionID);
|
|
|
}
|
|
|
|
|
|
string Result = string.Empty;
|
|
|
StringBuilder sqlstr = new StringBuilder();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandText = "DELETE FROM pmt_mix WHERE RecipeObjID=" + recipe.ObjID.ToString();
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
sqlstr.AppendLine(@"INSERT INTO pmt_mix(RecipeObjID, father_code, equip_code, edt_code, mix_id, act_code, term_code,
|
|
|
set_time, set_temp, set_power, set_ener, set_pres, set_rota)
|
|
|
values (@RecipeObjID, @father_code, @equip_code, @edt_code, @MixingStep, @ActionCode, @TermCode,
|
|
|
@MixingTime, @MixingTemp, @MixingPower, @MixingEnergy, @MixingPress, @MixingSpeed)");
|
|
|
int iMixingStep = 1;
|
|
|
foreach (RecipeMixing mixing in mixinglst)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(mixing.ActionCode))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@RecipeObjID", recipe.ObjID);
|
|
|
dbHelper.AddParameter("@father_code", recipe.RecipeMaterialCode);
|
|
|
dbHelper.AddParameter("@equip_code", recipe.RecipeEquipCode.Substring(3, 2));
|
|
|
dbHelper.AddParameter("@edt_code", recipe.RecipeVersionID);
|
|
|
dbHelper.AddParameter("@MixingStep", iMixingStep);
|
|
|
dbHelper.AddParameter("@ActionCode", mixing.ActionCode);
|
|
|
dbHelper.AddParameter("@TermCode", mixing.TermCode);
|
|
|
dbHelper.AddParameter("@MixingTime", mixing.MixingTime);
|
|
|
dbHelper.AddParameter("@MixingTemp", mixing.MixingTemp);
|
|
|
dbHelper.AddParameter("@MixingPower", mixing.MixingPower);
|
|
|
dbHelper.AddParameter("@MixingEnergy", mixing.MixingEnergy);
|
|
|
dbHelper.AddParameter("@MixingPress", mixing.MixingPress);
|
|
|
dbHelper.AddParameter("@MixingSpeed", mixing.MixingSpeed);
|
|
|
dbHelper.CommandText = sqlstr.ToString();
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
iMixingStep++;
|
|
|
}
|
|
|
|
|
|
if (RecipeLogHelper.Instance.IsBegin)
|
|
|
{
|
|
|
RecipeLogHelper.Instance.GenerateRecipeMixNow(recipe.RecipeMaterialCode, recipe.RecipeVersionID);
|
|
|
}
|
|
|
return Result;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error("保存配方-保存配方密炼信息失败:" + ex.Message);
|
|
|
return String.Empty;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 保存配方称量信息
|
|
|
/// <summary>
|
|
|
/// 保存配方称量信息
|
|
|
/// </summary>
|
|
|
/// <param name="dbHelper">数据访问辅助对象</param>
|
|
|
/// <param name="recipe">配方主信息</param>
|
|
|
/// <param name="weightlst">要保存的称量信息列表</param>
|
|
|
/// <returns></returns>
|
|
|
private string SaveRecipeInfo(DbHelper dbHelper, RecipeInfo recipe, List<RecipeWeight> weightlst)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (RecipeLogHelper.Instance.IsBegin)
|
|
|
{
|
|
|
RecipeLogHelper.Instance.GenerateRecipeWeighOld(recipe.RecipeMaterialCode, recipe.RecipeVersionID);
|
|
|
}
|
|
|
|
|
|
string Result = string.Empty;
|
|
|
StringBuilder sqlstr = new StringBuilder();
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandText = "DELETE FROM pmt_weigh WHERE RecipeObjID=" + recipe.ObjID.ToString();
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
sqlstr.AppendLine(@"INSERT INTO pmt_weigh(RecipeObjID,weigh_type,weight_id,father_code,equip_code,edt_code,act_code,child_name,child_code,set_weight,error_allow,Auto_ploy)
|
|
|
values (@RecipeObjID,@WeightType,@WeightID,@father_code,@equip_code,@edt_code,@ActCode,@MaterialName,@MaterialCode,@SetWeight,@ErrorAllow,@AutoPloy)");
|
|
|
|
|
|
Dictionary<int, List<RecipeWeight>> weightTypelst = new Dictionary<int, List<RecipeWeight>>();
|
|
|
foreach (RecipeWeight weight in weightlst)
|
|
|
{
|
|
|
List<RecipeWeight> lst = null;
|
|
|
if (!weightTypelst.TryGetValue(weight.WeightType, out lst))
|
|
|
{
|
|
|
lst = new List<RecipeWeight>();
|
|
|
weightTypelst.Add(weight.WeightType, lst);
|
|
|
}
|
|
|
lst.Add(weight);
|
|
|
}
|
|
|
|
|
|
foreach (List<RecipeWeight> lst in weightTypelst.Values)
|
|
|
{
|
|
|
int WeightID = 1;
|
|
|
foreach (RecipeWeight weight in lst)
|
|
|
{
|
|
|
if (string.IsNullOrWhiteSpace(weight.ActCode))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.AddParameter("@RecipeObjID", recipe.ObjID);
|
|
|
dbHelper.AddParameter("@WeightType", weight.WeightType);
|
|
|
dbHelper.AddParameter("@WeightID", WeightID);
|
|
|
dbHelper.AddParameter("@father_code", recipe.RecipeMaterialCode);
|
|
|
dbHelper.AddParameter("@equip_code", recipe.RecipeEquipCode.Substring(3, 2));
|
|
|
dbHelper.AddParameter("@edt_code", recipe.RecipeVersionID);
|
|
|
dbHelper.AddParameter("@ActCode", weight.ActCode);
|
|
|
dbHelper.AddParameter("@MaterialName", weight.MaterialName);
|
|
|
dbHelper.AddParameter("@MaterialCode", weight.MaterialCode);
|
|
|
dbHelper.AddParameter("@SetWeight", weight.SetWeight);
|
|
|
dbHelper.AddParameter("@ErrorAllow", weight.ErrorAllow);
|
|
|
dbHelper.AddParameter("@AutoPloy", weight.AutoPloy);
|
|
|
dbHelper.CommandText = sqlstr.ToString();
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
WeightID++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (RecipeLogHelper.Instance.IsBegin)
|
|
|
{
|
|
|
RecipeLogHelper.Instance.GenerateRecipeWeighNow(recipe.RecipeMaterialCode, recipe.RecipeVersionID);
|
|
|
}
|
|
|
|
|
|
return Result;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error("配方保存-保存配方称量信息失败:" + ex.Message);
|
|
|
return String.Empty;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 更新配方信息
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新配方信息
|
|
|
/// </summary>
|
|
|
/// <param name="dbHelper">数据访问辅助对象</param>
|
|
|
/// <param name="recipe">配方主信息</param>
|
|
|
/// <returns></returns>
|
|
|
private string RefreshRecipe(DbHelper dbHelper, RecipeInfo recipe)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string Result = string.Empty;
|
|
|
string sqlstr = string.Empty;
|
|
|
//更新机台号和每车重量
|
|
|
sqlstr = @"UPDATE [pmt_recipe] SET [define_date]=getdate(),[total_weight]=t.total FROM
|
|
|
(SELECT SUM(t.set_weight) as total FROM pmt_weigh t WHERE RecipeObjID=" + recipe.ObjID.ToString() + ") t WHERE ObjID=" + recipe.ObjID.ToString();
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
//更新物料名称
|
|
|
//sqlstr = @"UPDATE [pmt_recipe] SET [mater_name]=(select t.[mater_name] from [pmt_material] as t where t.[mater_code] = pmt_recipe.[mater_code]) WHERE ObjID=" + recipe.ObjID.ToString();
|
|
|
//dbHelper.ClearParameter();
|
|
|
//dbHelper.CommandText = sqlstr;
|
|
|
//dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
//更新配方名称
|
|
|
// sqlstr = @"UPDATE [pmt_recipe] SET [recipe_code]=t.showName FROM (
|
|
|
//SELECT t2.[mater_name]+t1.ItemName AS showName FROM [SysCode] t1,[pmt_material] t2 WHERE t1.TypeID='PmtType' AND t1.ItemCode='" + recipe.RecipeType + @"' AND t2.[mater_code]='" + recipe.RecipeMaterialCode + @"') t WHERE ObjID=" + recipe.ObjID.ToString();
|
|
|
// dbHelper.ClearParameter();
|
|
|
// dbHelper.CommandText = sqlstr;
|
|
|
// dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
//更新配方版本
|
|
|
// sqlstr = @"UPDATE [pmt_recipe] SET [edt_code]=ISNULL(t.RecipeVersionID,1) FROM (
|
|
|
//SELECT MAX([edt_code])+1 AS RecipeVersionID FROM [pmt_recipe] WHERE [mater_code]='" + recipe.RecipeMaterialCode + @"' AND ObjID<>" + recipe.ObjID.ToString() + ") t WHERE ObjID=" + recipe.ObjID.ToString();
|
|
|
// dbHelper.ClearParameter();
|
|
|
// dbHelper.CommandText = sqlstr;
|
|
|
// dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
//更新称量信息表中的物料编码和版本
|
|
|
//sqlstr = "UPDATE [pmt_weigh] SET [father_code]=t.[mater_code],[edt_code]=t.[edt_code] FROM [pmt_recipe] t WHERE RecipeObjID=t.ObjID AND RecipeObjID=" + recipe.ObjID.ToString();
|
|
|
//dbHelper.ClearParameter();
|
|
|
//dbHelper.CommandText = sqlstr;
|
|
|
//dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
//跟新密炼信息表中的物料编码和版本
|
|
|
//sqlstr = "UPDATE [pmt_mix] SET [father_code]=t.[mater_code],[edt_code]=t.[edt_code] FROM [pmt_recipe] t WHERE RecipeObjID=t.ObjID AND RecipeObjID=" + recipe.ObjID.ToString();
|
|
|
//dbHelper.ClearParameter();
|
|
|
//dbHelper.CommandText = sqlstr;
|
|
|
//dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
//更新配方状态
|
|
|
if (recipe.RecipeState.Trim() == "1")
|
|
|
{
|
|
|
sqlstr = @"UPDATE [pmt_recipe] SET [recipe_state]=0 WHERE [mater_code]='" + recipe.RecipeMaterialCode + @"' AND [recipe_state]=1 AND ObjID<>" + recipe.ObjID.ToString();
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandText = sqlstr;
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
|
|
|
return Result;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error("保存配方-更新配方信息失败:" + ex.Message);
|
|
|
return String.Empty;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 提示错误信息,并终止程序执行
|
|
|
/// <summary>
|
|
|
/// 提示错误信息,并终止程序执行
|
|
|
/// </summary>
|
|
|
/// <param name="msg">要提示的信息内容</param>
|
|
|
private void ReturnFromAciton(string msg)
|
|
|
{
|
|
|
base.ShowMsg(msg);
|
|
|
throw new Exception(msg);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 保存配方数据业务入口
|
|
|
/// <summary>
|
|
|
/// 保存配方数据业务入口
|
|
|
/// </summary>
|
|
|
/// <param name="runtime"></param>
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
{
|
|
|
base.RunIni(runtime);
|
|
|
|
|
|
///判断当前配方是否处于编辑状态
|
|
|
if (this.IsEditMode())
|
|
|
{
|
|
|
|
|
|
bool isXiaoLiao = false; //是否小料
|
|
|
|
|
|
RecipeInfo recipe = getRecipeInfo(); //从界面获取配方主信息
|
|
|
int recipeObjId = 0;
|
|
|
if (String.IsNullOrWhiteSpace(recipe.ObjID))
|
|
|
{
|
|
|
recipeObjId = 0;
|
|
|
}
|
|
|
int.TryParse(recipe.ObjID, out recipeObjId);
|
|
|
if (recipeObjId <= 0)
|
|
|
{
|
|
|
if (PlanCommon.IsExistsRecipeMaterCode(recipe.RecipeMaterialCode.Trim()))
|
|
|
{
|
|
|
//【配方编码】已存在,请输入一个不存在的配方编码!
|
|
|
MessageBox.Show(Language(283), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
runtime.IsReturn = true; //终止执行
|
|
|
return;
|
|
|
}
|
|
|
string materName = this.getRecipeInfoValueString("mater_name");
|
|
|
if (PlanCommon.IsExistsRecipeMaterName(materName.Trim()))
|
|
|
{
|
|
|
//【配方名称】已存在,请输入一个不存在的配方编码!
|
|
|
MessageBox.Show(Language(284), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
runtime.IsReturn = true; //终止执行
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
string msg = ValidityRecipe(recipe, isXiaoLiao); //验证配方是否符合验证规则
|
|
|
if (!string.IsNullOrWhiteSpace(msg))
|
|
|
{
|
|
|
ReturnFromAciton(msg);
|
|
|
}
|
|
|
List<RecipeMixing> mixinglst = getRecipeMixingInfo(); //从界面获取密炼信息
|
|
|
msg = ValidityRecipeMixing(mixinglst, isXiaoLiao); //验证密炼信息是否符合规则
|
|
|
if (!string.IsNullOrWhiteSpace(msg))
|
|
|
{
|
|
|
ReturnFromAciton(msg);
|
|
|
}
|
|
|
List<RecipeWeight> weightlst = getRecipeWeightInfo(); //从界面获取称量信息
|
|
|
msg = ValidityRecipeWeight(weightlst, isXiaoLiao); //验证称量信息是否符合规则
|
|
|
if (!string.IsNullOrWhiteSpace(msg))
|
|
|
{
|
|
|
ReturnFromAciton(msg);
|
|
|
}
|
|
|
DbMCSource dbsource = base.GetAllDbMCSources().FirstOrDefault();
|
|
|
DbHelper dbHelper = NewDbHelper(dbsource.DesignSource);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
ReturnFromAciton(Language(265));
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
//dbHelper.BeginTransaction(); //开启事务
|
|
|
msg = SaveRecipeInfo(dbHelper, recipe); //保存配方主信息
|
|
|
int ObjID = 0;
|
|
|
if (!int.TryParse(msg, out ObjID))
|
|
|
{
|
|
|
goto gotoReturn;
|
|
|
}
|
|
|
msg = string.Empty;
|
|
|
recipe.ObjID = ObjID.ToString();
|
|
|
msg = SaveRecipeInfo(dbHelper, recipe, mixinglst); //保存密炼信息
|
|
|
if (!string.IsNullOrWhiteSpace(msg))
|
|
|
{
|
|
|
goto gotoReturn;
|
|
|
}
|
|
|
msg = SaveRecipeInfo(dbHelper, recipe, weightlst); //保存称量信息
|
|
|
if (!string.IsNullOrWhiteSpace(msg))
|
|
|
{
|
|
|
goto gotoReturn;
|
|
|
}
|
|
|
msg = RefreshRecipe(dbHelper, recipe); //更新配方相关数据
|
|
|
RecipeLogHelper.Instance.SaveRecipeLog(recipe.RecipeMaterialCode, recipe.RecipeVersionID); //保存工艺日志
|
|
|
base.DBLog("配方管理", "保存配方", "配方保存成功,配方:" + recipe.RecipeMaterialName + "[" + recipe.RecipeMaterialCode + "]-版本:" + recipe.RecipeVersionID);
|
|
|
if (!string.IsNullOrWhiteSpace(msg))
|
|
|
{
|
|
|
goto gotoReturn;
|
|
|
}
|
|
|
//dbHelper.CommitTransaction(); //事务提交
|
|
|
msg = Language(266);
|
|
|
base.ShowMsg(msg);
|
|
|
return;
|
|
|
gotoReturn:
|
|
|
//dbHelper.RollbackTransaction(); //事务回滚
|
|
|
ReturnFromAciton(msg);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
base.LogError(ex);
|
|
|
//dbHelper.RollbackTransaction();
|
|
|
ReturnFromAciton(Language(267) + ":" + ex.Message);
|
|
|
runtime.IsReturn = true;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
//dbHelper.CloseConnection();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show(base.Language(277), base.Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
runtime.IsReturn = true; //终止执行
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 辅助方法 根据物料代码获取物料名称
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据物料代码获取物料名称
|
|
|
/// </summary>
|
|
|
/// <param name="mater_code">物料代码</param>
|
|
|
/// <returns>返回对应的物料名称</returns>
|
|
|
public string GetMaterName(string mater_code)
|
|
|
{
|
|
|
DbMCSource dbsource = base.GetAllDbMCSources().FirstOrDefault();
|
|
|
DbHelper dbHelper = NewDbHelper(dbsource.DesignSource);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
ReturnFromAciton(Language(265));
|
|
|
}
|
|
|
dbHelper.ClearParameter();
|
|
|
string strSql = "select top 1 mater_name from dbo.pmt_material where mater_code=@mater_code";
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@mater_code", mater_code.Trim());
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
{
|
|
|
return result.ToString().Trim();
|
|
|
}
|
|
|
return String.Empty;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据称量信息是否为只读,判断当前配方是否处于编辑状态
|
|
|
/// </summary>
|
|
|
/// <returns>编辑状态返回true,否则返回false</returns>
|
|
|
public bool IsEditMode()
|
|
|
{
|
|
|
bool flag = true;
|
|
|
List<MCDataGridView> gridList = GetTControls<MCDataGridView>();
|
|
|
foreach (MCDataGridView grid in gridList)
|
|
|
{
|
|
|
if (grid.ReadOnly == true)
|
|
|
{
|
|
|
flag = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
}
|