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.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjProdcutLine/ProductLineDb.cs

59 lines
1.9 KiB
C#

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);
}
/// <summary>
/// 根据Id去查询设备返回实体
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
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;
}
/// <summary>
/// 通过Id去更新设备
/// </summary>
/// <param name="view"></param>
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);
}
}
}