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/LjMixManager/LjMixManagerDb.cs

260 lines
8.1 KiB
C#

1 year ago
using System;
1 year ago
using System.Collections.Generic;
1 year ago
using System.Data;
1 year ago
using System.Runtime.CompilerServices;
1 year ago
using System.Text;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
using Mesnac.Action.ChemicalWeighing.LjPlanning;
namespace Mesnac.Action.ChemicalWeighing.LjMixManager
{
public class LjMixManagerDb:DBHelp
{
public static LjMixManagerView GetById(int id)
{
var sql =
" select Id, CreateTime, UpdateTime, MetageAId, MetageAName, MixAId, MixAName, MetageB1Id, MetageB1Name," +
" MetageB2Id, MetageB2Name, MixBId, MixBName, MixCId, MixCName, RecipeType, Remark, DryId, DryName from lj_mix_manager where id=" +
id;
DataTable dt = GetTable(sql);
LjMixManagerView view = new LjMixManagerView();
if (dt.Rows.Count == 1)
{
DataRow dr = dt.Rows[0];
if (dr["CreateTime"] != null)
{
view.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
}
if (dr["UpdateTime"] != null)
{
view.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]);
}
if (dr["MetageAId"] != null)
{
view.MetageAId = dr["MetageAId"].ToString();
}
if (dr["MetageAName"] != null)
{
view.MetageAName = dr["MetageAName"].ToString();
}
if (dr["MixAId"] != null)
{
view.MixAId = dr["MetageAId"].ToString();
}
if (dr["MixAName"] != null)
{
view.MixAName = dr["MixAName"].ToString();
}
if (dr["MetageB1Id"] != null)
{
view.MetageB1Id = dr["MetageB1Id"].ToString();
}
if (dr["MetageB1Name"] != null)
{
view.MetageB1Name = dr["MetageB1Name"].ToString();
}
if (dr["MetageB2Id"] != null)
{
view.MetageB2Id = dr["MetageB2Id"].ToString();
}
if (dr["MetageB2Name"] != null)
{
view.MetageB2Name = dr["MetageB2Name"].ToString();
}
if (dr["MixBId"] != null)
{
view.MixBId = dr["MixBId"].ToString();
}
if (dr["MixBName"] != null)
{
view.MixBName = dr["MixBName"].ToString();
}
if (dr["MixBId"] != null)
{
view.MixBId = dr["MixBId"].ToString();
}
if (dr["MixBName"] != null)
{
view.MixBName = dr["MixBName"].ToString();
}
if (dr["MixCId"] != null)
{
view.MixCId = dr["MixCId"].ToString();
}
if (dr["MixCName"] != null)
{
view.MixCName = dr["MixCName"].ToString();
}
// if (dr["RecipeType"] != null)
// {
// view.RecipeType = Convert.ToInt32(dr["RecipeType"]);
// }
if (dr["Remark"] != null)
{
view.Remark = dr["Remark"].ToString();
}
view.DryId = Convert.ToInt32(dr["DryId"]);
view.DryName = dr["DryName"].ToString();
view.Id = id;
}
return view;
}
public static void Update(LjMixManagerView view)
{
StringBuilder sb = new StringBuilder();
sb.Append(" update lj_planning ");
//sb.Append($" CreateTime='{view.CreateTime}', ");
sb.Append($" UpdateTime='{view.UpdateTime}', ");
sb.Append($" MetageAId='{view.MetageAId}', ");
sb.Append($" MetageAName='{view.MetageAName}', ");
sb.Append($" MixAId='{view.MixAId}', ");
sb.Append($" MixAName='{view.MixAName}', ");
sb.Append($" MetageB1Id='{view.MetageB1Id}', ");
sb.Append($" MetageB1Name='{view.MetageB1Name}', ");
sb.Append($" MetageB2Id='{view.MetageB2Id}', ");
sb.Append($" MetageB2Name='{view.MetageB2Name}', ");
sb.Append($" MixBId='{view.MixBId}', ");
sb.Append($" MixBName='{view.MixBName}', ");
sb.Append($" MixCId='{view.MixCId}', ");
sb.Append($" MixCName='{view.MixCName}', ");
sb.Append($" RecipeType='{view.RecipeType}', ");
sb.Append($" Remark='{view.Remark}', ");
sb.Append($" DryId={view.DryId}, ");
sb.Append($" DryName='{view.DryName}' ");
sb.Append($" where id={view.Id}");
ExecuteNonQuery(sb.ToString());
}
public static void UpdateMixA(LjMixManagerView view)
{
StringBuilder sb = new StringBuilder();
sb.Append(" update lj_mix_manager ");
sb.Append($" set UpdateTime='{view.UpdateTime}', ");
sb.Append($" MetageAId='{view.MetageAId}', ");
sb.Append($" MetageAName='{view.MetageAName}', ");
sb.Append($" MixAId='{view.MixAId}', ");
sb.Append($" MixAName='{view.MixAName}' ");
sb.Append($" where id={view.Id}");
ExecuteNonQuery(sb.ToString());
}
public static void UpdateMixB(LjMixManagerView view)
{
StringBuilder sb = new StringBuilder();
sb.Append(" update lj_mix_manager ");
sb.Append($" set UpdateTime='{view.UpdateTime}', ");
sb.Append($" MetageB1Id='{view.MetageB1Id}', ");
sb.Append($" MetageB1Name='{view.MetageB1Name}', ");
sb.Append($" MetageB2Id='{view.MetageB2Id}', ");
sb.Append($" MetageB2Name='{view.MetageB2Name}', ");
sb.Append($" MixBId='{view.MixBId}', ");
sb.Append($" MixBName='{view.MixBName}' ");
sb.Append($" where id={view.Id}");
ExecuteNonQuery(sb.ToString());
}
public static void UpdateMixC(LjMixManagerView view)
{
StringBuilder sb = new StringBuilder();
sb.Append(" update lj_mix_manager ");
sb.Append($" set UpdateTime='{view.UpdateTime}', ");
sb.Append($" MixCId='{view.MixCId}', ");
sb.Append($" MixCName='{view.MixCName}' ");
sb.Append($" where id={view.Id}");
ExecuteNonQuery(sb.ToString());
}
1 year ago
public static List<RecipePlcView> GetListRecipePlcView(string metageAId)
{
//MtypeId
List<RecipePlcView> ls = new List<RecipePlcView>();
string sql =
$"select Id, MetageId, MTypeId, MId, MName, Weight, Difference, DeviceId, DeviceName from lj_metage_detail where MetageId='{metageAId}'";
var dataTable = GetTable(sql);
foreach (DataRow dr in dataTable.Rows)
{
var meId = Convert.ToInt32(dr["MTypeId"]);
//大仓物料
if (meId == 1)
{
}
var view = new RecipePlcView();
// view.TolErance=
}
return ls;
}
1 year ago
}
}