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.

106 lines
4.6 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mesnac.Codd.Session;
using System.Data;
using Mesnac.Action.Feeding.BasicInfo;
namespace Mesnac.Action.Feeding.FinishBatch
{
/// <summary>
/// 密炼曲线存盘辅助类
/// </summary>
public class MixingCurveSaveHelper
{
private LotBarcode lotBarcode = null;
private RecipeData.PptPlanInfo planInfo = null;
/// <summary>
/// 构造方法
/// </summary>
/// <param name="_lotBarcode">车报表数据</param>
/// <param name="_planInfo">计划信息</param>
public MixingCurveSaveHelper(LotBarcode _lotBarcode, RecipeData.PptPlanInfo _planInfo)
{
this.lotBarcode = _lotBarcode;
this.planInfo = _planInfo;
}
#region SaveMixingCurve - 保存当前车密炼曲线信息
/// <summary>
/// 保存当前车密炼曲线信息
/// </summary>
/// <param name="dbHelper">数据访问对象</param>
/// <returns>保存成功返回true保存失败返回false</returns>
public bool SaveMixingCurve(DbHelper localHelper, DbHelper curveHelper)
{
try
{
string sqlstr = "SELECT * FROM PptLotData WHERE Barcode=@Barcode";
localHelper.CommandType = CommandType.Text;
localHelper.CommandText = sqlstr;
localHelper.ClearParameter();
localHelper.AddParameter("@Barcode", lotBarcode.Barcode);
DataRow rowLotData = localHelper.ToDataTable().Rows[0];
string dateYear = DateTime.Now.Year.ToString();
dateYear = string.Empty; //先不用年份
sqlstr = @"INSERT INTO Ppt_curvedata" + dateYear + @"(
Barcode,Plan_date,Plan_id,Serial_id,Start_datetime,Mixing_Time,Mixing_Temp,
Mixing_Power,Mixing_Energy,Mixing_Press,Mixing_Speed,If_Subed
) VALUES (
@Barcode,@Plan_date,@Plan_id,@Serial_id,@Start_datetime,@Mixing_Time,@Mixing_Temp,
@Mixing_Power,@Mixing_Energy,@Mixing_Press,@Mixing_Speed,@If_Subed)";
curveHelper.CommandType = CommandType.Text;
curveHelper.CommandText = sqlstr;
curveHelper.ClearParameter();
curveHelper.AddParameter("@Barcode", this.lotBarcode.Barcode);
curveHelper.AddParameter("@Plan_date", this.planInfo.PlanDate.Substring(0, 10));
curveHelper.AddParameter("@Plan_id", this.planInfo.PlanID);
curveHelper.AddParameter("@Serial_id", this.lotBarcode.SerialId);
curveHelper.AddParameter("@Start_datetime", rowLotData["StartDatetime"].ToString());
curveHelper.AddParameter("@Mixing_Time", CurveInfo.Instance.MixTimeStr.ToString());
curveHelper.AddParameter("@Mixing_Temp", CurveInfo.Instance.MixTempStr.ToString());
curveHelper.AddParameter("@Mixing_Power", CurveInfo.Instance.MixPowerStr.ToString());
curveHelper.AddParameter("@Mixing_Energy", CurveInfo.Instance.MixEnerStr.ToString());
curveHelper.AddParameter("@Mixing_Press", CurveInfo.Instance.MixPressStr.ToString());
curveHelper.AddParameter("@Mixing_Speed", CurveInfo.Instance.MixSpeedStr.ToString());
curveHelper.AddParameter("@If_Subed", string.Empty);
curveHelper.ExecuteNonQuery();
return true;
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService.Error("保存密炼曲线失败:" + ex.Message);
return false;
}
}
#endregion
#region 更新本地曲线库曲线数据的上传标志
/// <summary>
/// 更新本地曲线库曲线数据的上传标志
/// </summary>
/// <param name="curveHelper">本地曲线库数据连接对象</param>
public void UpdateIsUpFlag(DbHelper curveHelper)
{
try
{
string strSql = "update Ppt_CurveData set Up_IsNew = 1 where Barcode = @Barcode";
curveHelper.ClearParameter();
curveHelper.CommandText = strSql;
curveHelper.AddParameter("@Barcode", this.lotBarcode.Barcode.Trim());
curveHelper.ExecuteNonQuery();
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService.Error(String.Format("更新本地曲线库曲线数据[{0}]上传标志失败:{1}", this.lotBarcode.Barcode, ex.Message));
}
}
#endregion
}
}