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.

115 lines
4.4 KiB
C#

1 year ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Mesnac.Basic;
using Mesnac.Codd.Session;
using System.Configuration;
namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
{
/// <summary>
/// 数据存盘辅助类
/// </summary>
public class LotSaveHelper
{
#region 数据验证方法
/// <summary>
/// 判断车条码对应的数据是否存在
/// </summary>
/// <param name="barcode">车条码</param>
/// <returns>存在返回true否则返回false</returns>
public static bool Exists(string barcode)
{
try
{
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
if (dbHelper == null)
{
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
}
dbHelper.CommandType = CommandType.Text;
string sqlstr = "select COUNT(Barcode) from PptLotData where Barcode=@Barcode";
dbHelper.CommandText = sqlstr;
dbHelper.ClearParameter();
dbHelper.AddParameter("@Barcode", barcode);
object result = dbHelper.ToScalar();
if (result != null && result != System.DBNull.Value)
{
int intResult = 0;
int.TryParse(result.ToString(), out intResult);
if (intResult > 0)
{
return true;
}
}
return false;
}
catch(Exception ex)
{
ICSharpCode.Core.LoggingService<LotSaveHelper>.Error(ex.Message, ex);
return false;
}
}
#endregion
#region 数据查询
#endregion
#region 报表存盘基础信息数据追加
/// <summary>
/// 追加报表存盘基础信息数据至数据库
/// </summary>
/// <param name="lotData">报表头数据对象</param>
public static void InsertLRLotData(Entity.LR_lot lotData)
{
try
{
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
if (dbHelper == null)
{
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
}
dbHelper.CommandType = CommandType.Text;
string sqlstr = @"insert into LR_lot(Dosing_id,Plan_id,Equip_code,Serial_Num,Prd_date,Real_weight,Real_Error,Waste_Time,Warning_sgn,Net_Weight,Ng_sgn,ResetFlag,ResetStationNo,Lot_Barcode)
values(@Dosing_id,@Plan_id,@Equip_code,@Serial_Num,@Prd_date,@Real_weight,@Real_Error,@Waste_Time,@Warning_sgn,@Net_Weight,@Ng_sgn,@ResetFlag,@ResetStationNo,@Lot_Barcode)";
dbHelper.CommandText = sqlstr;
dbHelper.ClearParameter();
dbHelper.AddParameter("@Dosing_id", 0);
dbHelper.AddParameter("@Plan_id", lotData.Plan_id);
dbHelper.AddParameter("@Equip_code", ConfigurationManager.AppSettings["EquipCode"]);
dbHelper.AddParameter("@Serial_Num", lotData.Serial_Num);
dbHelper.AddParameter("@Prd_date", lotData.Prd_date);
dbHelper.AddParameter("@Real_weight", lotData.Real_weight / 1000);
dbHelper.AddParameter("@Real_Error", lotData.Real_Error / 1000);
dbHelper.AddParameter("@Waste_Time", lotData.Waste_Time);
dbHelper.AddParameter("@Warning_sgn", lotData.Warning_sgn);
dbHelper.AddParameter("@Net_Weight", lotData.Net_Weight / 1000);
dbHelper.AddParameter("@Ng_sgn", lotData.Ng_sgn);
dbHelper.AddParameter("@ResetFlag", 0);
dbHelper.AddParameter("@ResetStationNo", 0);
dbHelper.AddParameter("@Lot_Barcode", null);
dbHelper.ExecuteNonQuery();
}
catch(Exception ex)
{
ICSharpCode.Core.LoggingService<LotSaveHelper>.Error("车报表数据保存异常:" + ex.Message, ex);
}
}
#endregion
#region 数据更新
#endregion
}
}