using Common; using Model; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BLL.DAL { public class DALPltOutDetail { public bool Add(List EMats) { bool result = false; try { //IList ls = new List(); List para = new List(); StringBuilder strSql = new StringBuilder(); strSql.Append(" Insert into ErpOutDetail (OrdNo,Palno,Addre,CurQuant,Demo,Lever) values "); for (int i = 0; i < EMats.Count; i++) { strSql.Append("(@OrdNo" + i + ","); para.Add(new SqlParam("@OrdNO" + i, EMats[i].OrdNo)); strSql.Append("@Palno" + i + ","); para.Add(new SqlParam("@Palno" + i, EMats[i].Palno)); strSql.Append("@Addre" + i + ","); para.Add(new SqlParam("@Addre" + i, EMats[i].Addre)); //lijiangang新增:更改货位状态为待出库 StringBuilder Sql = new StringBuilder(); Sql.Append("update DepotsLocation set TurnoverDemand='04' where LocationCode='" + EMats[i].Addre + "'"); DataFactory.SqlDataBase().ExecuteBySql(Sql); strSql.Append("@CurQuant" + i + ","); para.Add(new SqlParam("@CurQuant" + i, EMats[i].CurQuant)); strSql.Append("@Demo" + i + ","); para.Add(new SqlParam("@Demo" + i, EMats[i].Demo)); strSql.Append("@Lever" + i + "),"); para.Add(new SqlParam("@Lever" + i, EMats[i].Lever)); } SqlParam[] param = null; if (para != null) { strSql.Remove(strSql.Length - 1, 1); param = para.ToArray(); } int dt = DataFactory.SqlDataBase().ExecuteBySql(strSql, param); if (EMats.Count == dt) result = true; return result; } catch { return result; } } public bool Update(List model) { bool result = false; try { if (!this.Delete(model)) return false; if (!this.Add(model)) return false; return true; } catch { return result; } } public bool Delete(List EMats) { bool result = false; try { List para = new List(); StringBuilder strSql = new StringBuilder(); StringBuilder sp1 = new StringBuilder(); StringBuilder sp2 = new StringBuilder(); strSql.Append(" DELETE FROM ErpOutDetail where "); int i; sp1.Append(" OrdNo = "); //sp2.Append(" Palno in ( "); for (i = 0; i < EMats.Count; i++) { if (i == 0) { sp1.Append(" @OrdNo "); para.Add(new SqlParam("@OrdNO", EMats[i].OrdNo)); } //sp2.Append("@Palno" + i + ","); //para.Add(new SqlParam("@Palno" + i, EMats[i].Palno)); } if (i > 0) { //sp1.Append(" and "); //sp2.Append(" )"); strSql.Append(sp1); //strSql.Append(sp2.Remove(sp2.Length - 3, 1)); SqlParam[] param = null; param = para.ToArray(); int dt = DataFactory.SqlDataBase().ExecuteBySql(strSql, param); if (EMats.Count == dt) result = true; } return true; } catch { return result; } } } }