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.
114 lines
4.2 KiB
C#
114 lines
4.2 KiB
C#
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
using Mesnac.Codd.Session;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.BinManage
|
|
{
|
|
class BinHelper
|
|
{
|
|
#region 查询料仓信息
|
|
|
|
/// <summary>
|
|
/// 查询料仓信息
|
|
/// </summary>
|
|
/// <returns>料仓信息表</returns>
|
|
public static DataTable getBin()
|
|
{
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
if (dbHelper == null)
|
|
{
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
}
|
|
dbHelper.ClearParameter();
|
|
dbHelper.CommandType = CommandType.Text;
|
|
string strSql = "SELECT Bin_Serial, Material_ID, Material_name FROM Pmt_Bin LEFT JOIN Pmt_material ON Pmt_Bin.Material_ID=Pmt_material.ID ORDER BY Bin_Serial";
|
|
dbHelper.CommandText = strSql;
|
|
DataTable table = dbHelper.ToDataTable();
|
|
return table;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获取物料名与ID对象集合
|
|
/// <summary>
|
|
/// 获取所有物料对象集合
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<Pmt_material> GetMaterialList()
|
|
{
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
if (dbHelper == null)
|
|
{
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
}
|
|
dbHelper.ClearParameter();
|
|
dbHelper.CommandType = CommandType.Text;
|
|
string sqlstr = "SELECT ID, Material_name FROM Pmt_material";
|
|
dbHelper.CommandText = sqlstr;
|
|
DataTable table = dbHelper.ToDataTable();
|
|
List<Pmt_material> lst = new List<Pmt_material>();
|
|
Pmt_material material = null;
|
|
foreach (DataRow row in table.Rows)
|
|
{
|
|
material = new Pmt_material();
|
|
material.ID = Mesnac.Basic.DataProcessor.RowValue(row, "ID", String.Empty);
|
|
material.Material_name = Mesnac.Basic.DataProcessor.RowValue(row, "Material_name", String.Empty);
|
|
lst.Add(material);
|
|
}
|
|
return lst;
|
|
}
|
|
#endregion
|
|
|
|
#region 根据料仓号修改对应物料
|
|
public static void updateBin(Pmt_Bin bin)
|
|
{
|
|
try
|
|
{
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
if (dbHelper == null)
|
|
{
|
|
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
|
|
}
|
|
dbHelper.ClearParameter();
|
|
dbHelper.CommandType = CommandType.Text;
|
|
string strSql = "UPDATE Pmt_Bin SET Material_ID=@MaterialId, IF_FLAG=@IfFlag WHERE Bin_Serial=@BinSerial";
|
|
dbHelper.CommandText = strSql;
|
|
dbHelper.AddParameter("@MaterialId", bin.Material_ID);
|
|
dbHelper.AddParameter("@BinSerial", bin.Bin_Serial);
|
|
dbHelper.AddParameter("@IfFlag", 1);
|
|
dbHelper.ExecuteNonQuery();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSharpCode.Core.LoggingService<BinHelper>.Error("修改料仓信息异常:" + ex.Message, ex);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取bin对象集合
|
|
public static List<Pmt_Bin> getBinList()
|
|
{
|
|
DataTable userTable = getBin();
|
|
List<Pmt_Bin> lst = new List<Pmt_Bin>();
|
|
|
|
foreach (DataRow row in userTable.Rows)
|
|
{
|
|
Pmt_Bin bin = new Pmt_Bin
|
|
{
|
|
Bin_Serial = Mesnac.Basic.DataProcessor.RowValue(row, "Bin_Serial", 0),
|
|
Material_ID = Mesnac.Basic.DataProcessor.RowValue(row, "Material_ID", String.Empty)
|
|
};
|
|
lst.Add(bin);
|
|
}
|
|
return lst;
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|