public void DeletePOApportionMaster(POInfo oMaster, int apportionMasterSysNo) { if ( oMaster.Status != (int)AppEnum.POStatus.WaitingApportion ) throw new BizException("the status is not waiting apportion, insert failed"); TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { string sql = "select top 1 sysno from po_apportion_item where apportionsysno = " + apportionMasterSysNo; DataSet ds = SqlHelper.ExecuteDataSet(sql); if ( Util.HasMoreRow(ds)) throw new BizException("please delete apportion item first"); int rowsAffected = new POApportionDac().DeleteMaster(apportionMasterSysNo); if ( rowsAffected != 1) throw new BizException("d po apportion master error"); POApportionInfo oApportionMaster = null; foreach(POApportionInfo appMaster in oMaster.apportionHash.Keys) { if ( appMaster.SysNo == apportionMasterSysNo) oApportionMaster = appMaster; } oMaster.apportionHash.Remove(oApportionMaster); scope.Complete(); } }
public void CreatePOApportion(Hashtable htParam) { if ( htParam.Count == 0 ) return; TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { foreach(POApportionInfo masterInfo in htParam.Keys) { masterInfo.SysNo = SequenceDac.GetInstance().Create("PO_Apportion_Sequence"); int rowsAffected = new POApportionDac().Insert(masterInfo); if ( rowsAffected != 1) throw new BizException("insert po apportion master error"); foreach(POApportionItemInfo itemInfo in masterInfo.itemHash.Values) { itemInfo.ApportionSysNo = masterInfo.SysNo; rowsAffected = new POApportionDac().InsertItem(itemInfo); if ( rowsAffected != 1) throw new BizException("insert po apportion item error"); } } scope.Complete(); } }
public void DeletePOApportionItem(POInfo oPO, POApportionInfo oApportion, int productSysNo) { if ( oPO.Status != (int)AppEnum.POStatus.WaitingApportion ) throw new BizException("the status is not waiting apportion, insert failed"); TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { int rowsAffected = new POApportionDac().DeleteItem(oApportion.SysNo, productSysNo); if ( rowsAffected != 1) throw new BizException("insert po apportion master error"); oApportion.itemHash.Remove(productSysNo); scope.Complete(); } }
public void InsertPOApportionMaster(POInfo oMaster, POApportionInfo oApportionMaster) { foreach(POApportionInfo appMaster in oMaster.apportionHash.Keys) { if ( appMaster.ApportionSubjectSysNo == oApportionMaster.ApportionSubjectSysNo) throw new BizException("the same subject already exists"); } if ( oMaster.Status != (int)AppEnum.POStatus.WaitingApportion ) throw new BizException("the status is not waiting apportion, insert failed"); TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { oApportionMaster.SysNo = SequenceDac.GetInstance().Create("PO_Apportion_Sequence"); int rowsAffected = new POApportionDac().Insert(oApportionMaster); if ( rowsAffected != 1) throw new BizException("insert po apportion master error"); oMaster.apportionHash.Add(oApportionMaster, null); scope.Complete(); } }