using MESClassLibrary.BLL.Log; using MESClassLibrary.EFModel; using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Data; using System.Linq; using System.Reflection; using System.Text; namespace MESClassLibrary.DAL.TruckBox { public class BoxDAL { public bool AddInfo(tb_Box_tx md) { try { string sql = @"insert into tb_Box_tx(BoxNo) values(@BoxNo)"; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@BoxNo", SqlDbType.VarChar); param[0].Value = md.BoxNo; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param); return true; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); return false; } } public string OldNo(string box) { try { string res = ""; string sql= @"select top 1 BoxNo from tb_Box_tx where BoxNo like '"+ box + @"%' order by Id desc"; DataTable dt= SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0]; if (dt!=null && dt.Rows.Count>0) { res = dt.Rows[0]["BoxNo"].ToString(); } return res; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); return ""; } } } }