using System; using System.Data; using System.Runtime.CompilerServices; using Mesnac.Action.ChemicalWeighing.LjMaterial; namespace Mesnac.Action.ChemicalWeighing.LjProdcutLine { public class ProductLineDb:DBHelp { public static void Add(ProductLineView view) { string sql = $"insert lj_product_line values ('{view.Name}',getdate(),'{view.DryId}','{view.DryName}')"; ExecuteNonQuery(sql); } /// /// 根据Id去查询设备返回实体 /// /// /// public static ProductLineView GetById(int id) { ProductLineView view = new ProductLineView(); string sql = $"select Id, Name, CreateTime, DryId, DryName from lj_product_line where Id={id}"; DataTable dt = GetTable(sql); if (dt.Rows.Count == 1) { var datarow = dt.Rows[0]; view.Id = Convert.ToInt32(datarow["Id"]); view.Name = datarow["Name"].ToString(); view.CreateTime = Convert.ToDateTime(datarow["CreateTime"]); view.DryId = datarow["DryId"].ToString(); view.DryName = datarow["DryName"].ToString(); } return view; } /// /// 通过Id去更新设备 /// /// public static void Update(ProductLineView view) { string sql = $"update lj_product_line set Name='{view.Name}',DryId='{view.DryId}',DryName='{view.DryName}' from lj_product_line where Id={view.Id}"; ExecuteNonQuery(sql); } public static void Del(int id) { string sql = string.Format($"delete from lj_product_line where id={id}"); ExecuteNonQuery(sql); } } }