public int DeleteDemandOrder(DemandOrderDTO dto) { int iResult = -1; Database db = null; try { CheckBeforeDelete(dto); db = Common.CurrentDatabase; db.KeepConnection = true; db.BeginTransaction(IsolationLevel.Serializable); DemandOrderDAO daoOrder = new DemandOrderDAO(db); iResult = daoOrder.DeleteOrder(null, dto); db.Commit(); } catch (Exception) { db.Rollback(); throw; } finally { if (db.DBConnectionState == ConnectionState.Open) { db.Close(); } } return(iResult); }
public void SaveData(DemandOrderDTO dtoOrder, List <TmpDemandOrderDTO> dtoItems) { Database db = null; try { db = Common.CurrentDatabase; db.KeepConnection = true; db.BeginTransaction(IsolationLevel.Serializable); TmpDemandOrderDAO daoTmpOrder = new TmpDemandOrderDAO(db); DemandOrderDAO daoOrder = new DemandOrderDAO(db); //add all record to temp table daoTmpOrder.DeleteTempDemandOrder(null, dtoOrder); foreach (TmpDemandOrderDTO dto in dtoItems) { daoTmpOrder.InsertTempDemandOrder(null, dto); } //set all record to in-active and update data for item in table daoOrder.DeleteOrder(null, dtoOrder); daoOrder.UpdateOrder(null, dtoOrder); //delete data in tmp daoTmpOrder.DeleteTempDemandOrder(null, dtoOrder); db.Commit(); } catch (Exception) { db.Rollback(); throw; } finally { if (db.DBConnectionState == ConnectionState.Open) { db.Close(); } } }