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"; /// /// 查找注塑机的最大ID /// /// /// 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; } } } }