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
{
///
/// 获取干混机物料
///
///
public static List GetDryerMaterrial()
{
var list = GetStockMaterrial(1);
list.RemoveAll(x => x.CmbValue == 5);
list.RemoveAll(x => x.CmbValue == 6);
return list;
}
///
/// 获取糊化机物料
///
///
public static List GetSiloMaterrial()
{
var list1 = GetStockMaterrial(1);
list1 = list1.Where(x => x.CmbValue == 5 || x.CmbValue == 6).ToList();
return list1;
}
///
/// 根据物料获取罐号
///
///
///
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 GetStockMaterrial(int mtypId)
{
string sql = "select Id, Code, StockName, MTypeId, MTypeName, MId, MName, Remark from lj_stock_material";
var dataTable = DBHelp.GetTable(sql);
List ls = new List();
ls.Add(new MyMCCombobox()
{
CmbValue = -1,
CmbDisplay = "请选择"
});
foreach (DataRow o in dataTable.Rows)
{
int tableMTypeId = Convert.ToInt32(o["MTypeId"]);
if (mtypId != 0)
{
if (tableMTypeId == mtypId)
{
ls.Add(new MyMCCombobox()
{
CmbValue = (int)o["Id"],
CmbDisplay = o["StockName"].ToString() + $"({o["MName"]})"
});
}
}
}
return ls;
}
}
}