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/AutoControl/DB/StockMaterrialDBHelp.cs

83 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
namespace Mesnac.Action.ChemicalWeighing.AutoControl.DB
{
public class StockMaterrialDbHelp
{
/// <summary>
/// 获取干混机物料
/// </summary>
/// <returns></returns>
public static List<MyNameValue> GetDryerMaterrial()
{
var list = GetStockMaterrial(1);
list.RemoveAll(x => x.Id == 5);
list.RemoveAll(x => x.Id == 6);
return list;
}
/// <summary>
/// 获取糊化机物料
/// </summary>
/// <returns></returns>
public static List<MyNameValue> GetSiloMaterrial()
{
var list1 = GetStockMaterrial(1);
list1 = list1.Where(x => x.Id == 5 || x.Id == 6).ToList();
return list1;
}
/// <summary>
/// 根据物料获取罐号
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static int GetCodeById(int id)
{
string sql = $"select Code from lj_stock_material where Id={id}";
var dataTable = DBHelp.GetTable(sql);
return Convert.ToInt16(dataTable.Rows[0][0]);
}
private static List<MyNameValue> GetStockMaterrial(int mtypId)
{
string sql = "select Id, Code, StockName, MTypeId, MTypeName, MId, MName, Remark from lj_stock_material";
var dataTable = DBHelp.GetTable(sql);
List<MyNameValue> ls = new List<MyNameValue>();
ls.Add(new MyNameValue()
{
Id = -1,
Name = "请选择"
});
foreach (DataRow o in dataTable.Rows)
{
int tableMTypeId = Convert.ToInt32(o["MTypeId"]);
if (mtypId != 0)
{
if (tableMTypeId == mtypId)
{
ls.Add(new MyNameValue()
{
Id = (int)o["Id"],
Name = o["StockName"].ToString() + $"({o["MName"]})"
});
}
}
}
return ls;
}
}
}