一厂MES,含注塑,喷涂,冲孔
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

76 lines
2.2 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.Weight
{
public class WeightRecordDAL
{
public static string TableName = "tb_weightRecord";
/// <summary>
/// 查找注塑机的最大ID
/// </summary>
/// <param name="Device"></param>
/// <returns></returns>
public DataTable SearchMaxIDByDevice(string Device)
{
try
{
string sql = @"select top 1 * from "+ TableName +" order by CreateTime desc";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool AddInfo(WeightRecordModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (GID,ID,DeviceNo";
sql += ") VALUES (";
sql += "@GID,";
sql += "@ID,";
sql += "@DeviceNo)";
#region 添加参数
param = new SqlParameter[3];
param[0] = new SqlParameter("@GID", SqlDbType.VarChar);
param[0].Value = md.GID;
param[1] = new SqlParameter("@ID", SqlDbType.Int);
param[1].Value = md.ID;
param[2] = new SqlParameter("@DeviceNo", SqlDbType.VarChar);
param[2].Value = md.DeviceNo;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}