using System; using System.Data; 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()); } } }