|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using Mesnac.Action.Base;
|
|
|
using Mesnac.Codd.Session;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace Mesnac.Action.Feeding.Verification
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 称量物料参数验证处理类
|
|
|
/// </summary>
|
|
|
public class WeightParamValidateAction : FeedingAction, IAction
|
|
|
{
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
{
|
|
|
base.RunIni(runtime);
|
|
|
DbMCControl jarTypeControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[SytJar].[JarType]").FirstOrDefault();
|
|
|
DbMCControl jarSerialControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[SytJar].[JarSerial]").FirstOrDefault();
|
|
|
if (jarTypeControl == null)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Warn("缺少罐类型输入控件!");
|
|
|
MessageBox.Show("缺少罐类型输入控件!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
runtime.IsReturn = true;
|
|
|
return;
|
|
|
}
|
|
|
if (jarSerialControl == null)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Warn("缺少罐号输入控件!");
|
|
|
MessageBox.Show("缺少罐号输入控件!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
runtime.IsReturn = true;
|
|
|
return;
|
|
|
}
|
|
|
string jarType = String.Empty;
|
|
|
string jarSerial = String.Empty;
|
|
|
if (jarTypeControl.BaseControl.MCValue != null)
|
|
|
{
|
|
|
jarType = jarTypeControl.BaseControl.MCValue.ToString();
|
|
|
}
|
|
|
if (jarSerialControl.BaseControl.MCValue != null)
|
|
|
{
|
|
|
jarSerial = jarSerialControl.BaseControl.MCValue.ToString();
|
|
|
}
|
|
|
DbHelper dbHelper = base.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (dbHelper == null)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Warn("获取本地数据连接失败!");
|
|
|
MessageBox.Show("获取本地数据连接失败!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
runtime.IsReturn = true;
|
|
|
return;
|
|
|
}
|
|
|
if (this.IsExists(dbHelper, jarType.Trim(), jarSerial.Trim()))
|
|
|
{
|
|
|
MessageBox.Show("添加失败:已存在此罐号的称量参数!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
runtime.IsReturn = true;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断是否称量物料参数表中是否已存在此参数
|
|
|
/// </summary>
|
|
|
/// <param name="jarType">罐的类型</param>
|
|
|
/// <param name="jarSerial">罐号</param>
|
|
|
/// <returns>存在返回true,不存在返回false</returns>
|
|
|
public bool IsExists(DbHelper dbHelper, string jarType, string jarSerial)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
//string strSql = "select COUNT(*) from SytPar where parType = @parType and parNumber = @parNumber";
|
|
|
string strSql = "select COUNT(*) from SytJar where JarType = @JarType and JarSerial = @JarSerial";
|
|
|
dbHelper.CommandType = System.Data.CommandType.Text;
|
|
|
dbHelper.ClearParameter();
|
|
|
dbHelper.CommandText = strSql;
|
|
|
dbHelper.AddParameter("@JarType", jarType);
|
|
|
dbHelper.AddParameter("@JarSerial", jarSerial);
|
|
|
object result = dbHelper.ToScalar();
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
{
|
|
|
int intResult = 0;
|
|
|
if (int.TryParse(result.ToString(), out intResult))
|
|
|
{
|
|
|
if (intResult > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error("判断称量物料参数是否存在出错:" + ex.Message);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|