|
|
|
|
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 DataTable GetDryerMaterrial()
|
|
|
|
|
{
|
|
|
|
|
var list = GetStockMaterrial(1);
|
|
|
|
|
list.RemoveAll(x => x.CmbValue == 5);
|
|
|
|
|
list.RemoveAll(x => x.CmbValue == 6);
|
|
|
|
|
var dt = GetMcBox();
|
|
|
|
|
foreach (var entity in list)
|
|
|
|
|
{
|
|
|
|
|
var dr = dt.NewRow();
|
|
|
|
|
dr[0] = entity.CmbValue.ToString();
|
|
|
|
|
dr[1] = entity.CmbDisplay;
|
|
|
|
|
dt.Rows.Add(dr);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static DataTable GetMcBox()
|
|
|
|
|
{
|
|
|
|
|
DataTable dataTable = new DataTable();
|
|
|
|
|
dataTable.Columns.Add("CmbValue", typeof(string));
|
|
|
|
|
dataTable.Columns.Add("CmbDisplay", typeof(string));
|
|
|
|
|
|
|
|
|
|
DataRow dr = dataTable.NewRow();
|
|
|
|
|
dr[0] = "-1";
|
|
|
|
|
dr[1] = "请选择";
|
|
|
|
|
dataTable.Rows.Add(dr);
|
|
|
|
|
return dataTable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取糊化机物料
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static DataTable GetSiloMaterrial()
|
|
|
|
|
{
|
|
|
|
|
var list1 = GetStockMaterrial(1);
|
|
|
|
|
list1 = list1.Where(x => x.CmbValue == 5 || x.CmbValue == 6).ToList();
|
|
|
|
|
var dt = GetMcBox();
|
|
|
|
|
foreach (var entity in list1)
|
|
|
|
|
{
|
|
|
|
|
var dr = dt.NewRow();
|
|
|
|
|
dr[0] = entity.CmbValue.ToString();
|
|
|
|
|
dr[1] = entity.CmbDisplay;
|
|
|
|
|
dt.Rows.Add(dr);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据物料获取罐号
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
|
|
public static int GetCodeById(int id)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (id > 0)
|
|
|
|
|
{
|
|
|
|
|
string sql = $"select Code from lj_stock_material where Id={id}";
|
|
|
|
|
var dataTable = DBHelp.GetTable(sql);
|
|
|
|
|
if (dataTable.Rows.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
return Convert.ToInt16(dataTable.Rows[0][0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<MyMCCombobox> GetStockMaterrial(int mtypId)
|
|
|
|
|
{
|
|
|
|
|
string sql = "select Id, Code, StockName, MTypeId, MTypeName, MId, MName, Remark from lj_stock_material";
|
|
|
|
|
|
|
|
|
|
var dataTable = DBHelp.GetTable(sql);
|
|
|
|
|
List<MyMCCombobox> ls = new List<MyMCCombobox>();
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|