|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Controls.Base;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.Intake.Qingquan.MaterialManager
|
|
|
|
|
{
|
|
|
|
|
public class Material
|
|
|
|
|
{
|
|
|
|
|
#region 在本地数据库,判断某个物料编码是否存在
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 在本地数据库,判断某个物料编码是否存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materCode">要判断的物料编码</param>
|
|
|
|
|
/// <returns>物料编码存在返回true,否则返回false</returns>
|
|
|
|
|
public static bool IsExistsMaterCode(string materCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IntakeAction action = new IntakeAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
string strSql = @"select COUNT(*) from pmt_material where mater_code=@materCode";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@materCode", materCode.Trim());
|
|
|
|
|
object result = localHelper.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("获取mater_code失败:" + ex.Message, ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region 在本地数据库,判断某个物料名称是否存在
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 在本地数据库,判断某个物料名称是否存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materName">要判断的物料名称</param>
|
|
|
|
|
/// <returns>物料名称存在返回true,否则返回false</returns>
|
|
|
|
|
public static bool IsExistsMaterName(string materName)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IntakeAction action = new IntakeAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
string strSql = @"select COUNT(*) from pmt_material where mater_name=@materName";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@materName", materName.Trim());
|
|
|
|
|
object result = localHelper.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("获取Recipe_Name失败:" + ex.Message, ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
#region 在本地数据库,判断某个物料别名是否存在
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 在本地数据库,判断某个物料别名是否存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materByCode">要判断的物料别名</param>
|
|
|
|
|
/// <returns>物料别名存在返回true,否则返回false</returns>
|
|
|
|
|
public static bool IsExistsMaterByCode(string materByCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IntakeAction action = new IntakeAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
string strSql = @"select COUNT(*) from pmt_material where Mater_Bycode=@materByCode";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@materByCode", materByCode.Trim());
|
|
|
|
|
object result = localHelper.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("获取Mater_Bycode失败:" + ex.Message, ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region 在本地数据库,修改某个物料进行验证
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 在本地数据库,判断某个物料信息是否存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materName">要判断的物料名称 1物料编码有重复,2物料名称有重复,3物料别名有重复 0没有重复,4 异常</param>
|
|
|
|
|
/// <returns>1物料编码有重复,2物料名称有重复,3物料别名有重复 0没有重复,4 异常</returns>
|
|
|
|
|
public static int IsUpdateMaterByObjId(string objid, string materCode, string materByCode, string materName)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IntakeAction action = new IntakeAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
string strSql = @"select COUNT(*) from pmt_material where Mater_Bycode=@materByCode and ObjID!=@objid";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@materByCode", materByCode.Trim());
|
|
|
|
|
localHelper.AddParameter("objid", objid);
|
|
|
|
|
object result = localHelper.ToScalar();
|
|
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
int intResult = 0;
|
|
|
|
|
if (int.TryParse(result.ToString(), out intResult))
|
|
|
|
|
{
|
|
|
|
|
if (intResult > 0)
|
|
|
|
|
{
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
localHelper.CommandText = @"select COUNT(*) from pmt_material where mater_code=@materCode and ObjID!=@objid";
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.AddParameter("@materCode", materCode.Trim());
|
|
|
|
|
localHelper.AddParameter("objid", objid);
|
|
|
|
|
result = localHelper.ToScalar();
|
|
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
int intResult = 0;
|
|
|
|
|
if (int.TryParse(result.ToString(), out intResult))
|
|
|
|
|
{
|
|
|
|
|
if (intResult > 0)
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
localHelper.CommandText = @"select COUNT(*) from pmt_material where mater_name=@materName and ObjID!=@objid";
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.AddParameter("@materName", materName.Trim());
|
|
|
|
|
localHelper.AddParameter("objid", objid);
|
|
|
|
|
result = localHelper.ToScalar();
|
|
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
int intResult = 0;
|
|
|
|
|
if (int.TryParse(result.ToString(), out intResult))
|
|
|
|
|
{
|
|
|
|
|
if (intResult > 0)
|
|
|
|
|
{
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("获取Mater失败:" + ex.Message, ex);
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 在本地数据库,判断某个大罐编号是否存在
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 在本地数据库,判断某个大罐编号是否存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="num">要判断的大罐编号</param>
|
|
|
|
|
/// <returns>大罐编号存在返回true,否则返回false</returns>
|
|
|
|
|
public static bool IsExistsDayBin(string num)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IntakeAction action = new IntakeAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
string strSql = @"select COUNT(*) from pst_DayBin where Bin_Type=2 AND Bin_Num =@num";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@num", num.Trim());
|
|
|
|
|
object result = localHelper.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, ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 检测某个类型的罐编号是否存在
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检测某个类型的罐编号是否存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">Objid</param>
|
|
|
|
|
/// <param name="type">罐类型1 日罐,2大罐</param>
|
|
|
|
|
/// <param name="num">灌号</param>
|
|
|
|
|
/// <returns>存在返回true,否则返回false</returns>
|
|
|
|
|
public static bool IsEXistsDayBinNumByID(string id, string type,string num)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IntakeAction action = new IntakeAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
string strSql = @"select COUNT(*) from pst_DayBin where Bin_Type=@type AND Objid !=@id and Bin_Num=@num";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@id", id.Trim());
|
|
|
|
|
localHelper.AddParameter("@type",type.Trim());
|
|
|
|
|
localHelper.AddParameter("@num",num);
|
|
|
|
|
object result = localHelper.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, ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 检测某个类型的罐编号是否存在
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检测某个类型的罐编号是否存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">Objid</param>
|
|
|
|
|
/// <param name="type">罐类型1 日罐,2大罐</param>
|
|
|
|
|
/// <param name="num">灌号</param>
|
|
|
|
|
/// <returns>存在返回true,否则返回false</returns>
|
|
|
|
|
public static bool IsEXistsSmallDayBinNumByID(string id, string type, string num,string equipcode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IntakeAction action = new IntakeAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
string strSql = @"select COUNT(*) from pst_DayBin where Bin_Type=@type AND Objid !=@id and Bin_Num=@num and Equip_Code=@equipcode";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@id", id.Trim());
|
|
|
|
|
localHelper.AddParameter("@type", type.Trim());
|
|
|
|
|
localHelper.AddParameter("@equipcode",equipcode.Trim());
|
|
|
|
|
localHelper.AddParameter("@num", num);
|
|
|
|
|
object result = localHelper.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, ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 在本地数据库,判断某个机台的灌号物料是否存在
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 在本地数据库,判断某个机台的灌号物料是否存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="equipcode">机台编号</param>
|
|
|
|
|
/// <param name="binnum">灌号</param>
|
|
|
|
|
/// <returns>存在返回true,否则返回false</returns>
|
|
|
|
|
public static bool IsExistsSmallDayBin(string equipcode,string binnum)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IntakeAction action = new IntakeAction();
|
|
|
|
|
DbHelper localHelper = action.NewDbHelper(Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
localHelper.CommandType = CommandType.Text;
|
|
|
|
|
localHelper.ClearParameter();
|
|
|
|
|
string strSql = @"select COUNT(*) from pst_DayBin where Bin_Type=1 AND Bin_Num =@binnum and Equip_Code=@equipcode";
|
|
|
|
|
localHelper.CommandText = strSql;
|
|
|
|
|
localHelper.AddParameter("@binnum", binnum.Trim());
|
|
|
|
|
localHelper.AddParameter("@equipcode",equipcode.Trim());
|
|
|
|
|
object result = localHelper.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, ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|