public int UpdateMaterialOutDtlList(SqlTransaction Transaction, List <MaterialOutDtlModel> mObjs, int MaterialOutCode) { try { MaterialOutDtlDAL ldal = new MaterialOutDtlDAL(Transaction); Hashtable hashtable = new Hashtable(); foreach (MaterialOutDtlModel model in ldal.GetMaterialOutDtlListByMaterialOutCode(MaterialOutCode)) { if (!hashtable.Contains(model.MaterialInDtlCode)) { hashtable.Add(model.MaterialInDtlCode, model.MaterialInDtlCode); } if (FindModel(mObjs, model.MaterialOutDtlCode.ToString()) == null) { ldal.Delete(model.MaterialOutDtlCode); } } foreach (MaterialOutDtlModel model2 in mObjs) { if (!hashtable.Contains(model2.MaterialInDtlCode)) { hashtable.Add(model2.MaterialInDtlCode, model2.MaterialInDtlCode); } if (model2.MaterialOutDtlCode <= 0) { model2.MaterialOutDtlCode = int.Parse(SystemManageDAO.GetNewSysCode("MaterialOutDtlCode")); model2.MaterialOutCode = MaterialOutCode; ldal.Insert(model2); continue; } ldal.Update(model2); } IEnumerator enumerator = hashtable.Keys.GetEnumerator(); try { while (enumerator.MoveNext()) { int current = (int)enumerator.Current; string commandText = "update MaterialInDtl set OutQty = (select sum(isnull(OutQty, 0)) from MaterialOutDtl where MaterialInDtlCode = MaterialInDtl.MaterialInDtlCode)"; ldal._DataProcess.RunSql(commandText); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } } catch (Exception exception) { throw exception; } return(1); }
public int Delete(int Code, SqlTransaction Transaction) { int num; try { MaterialOutDAL tdal = new MaterialOutDAL(Transaction); MaterialOutDtlDAL ldal = new MaterialOutDtlDAL(Transaction); MaterialOutDtlQueryModel qmObj = new MaterialOutDtlQueryModel(); qmObj.MaterialOutCodeEqual = Code.ToString(); foreach (MaterialOutDtlModel model2 in ldal.Select(qmObj)) { ldal.Delete(model2.MaterialOutDtlCode); } num = tdal.Delete(Code); } catch (Exception exception) { throw exception; } return(num); }