Ejemplo n.º 1
0
        //��Ӳɹ���Ʒ��Ϣ
        public void CreatePOItem(POInfo oParam)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                //if (oParam.SysNo == AppConst.IntNull)
                //{
                //    oParam.SysNo = SequenceDac.GetInstance().Create("PO_Sequence");
                //    oParam.POID = getPOID(oParam.SysNo);
                //}

                oParam.TotalAmt = oParam.GetTotalAmt();

                //���������¼
                //int rowsAffected = new PODac().InsertMaster(oParam);
                //if (rowsAffected != 1)
                //    throw new BizException("insert po master error");
                foreach (POItemInfo item in oParam.itemHash.Values)
                {
                    item.POSysNo = oParam.SysNo;
                    item.UnitCost = Decimal.Round(item.OrderPrice * oParam.ExchangeRate + item.ApportionAddOn, 2);

                    int rowsAffected = new PODac().InsertItem(item);
                    if (rowsAffected != 1)
                        throw new BizException("insert po item error");

                    //����master total amt

                    oParam.TotalAmt = oParam.GetTotalAmt();
                    Hashtable ht = new Hashtable(2);
                    ht.Add("SysNo", oParam.SysNo);
                    ht.Add("TotalAmt", oParam.TotalAmt);
                    if (1 != new PODac().UpdateMaster(ht))
                        throw new BizException("expected one-row update failed, add item failed");
                }

                scope.Complete();
            }
        }
Ejemplo n.º 2
0
        public void CreatePO(POInfo oParam)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                if ( oParam.SysNo == AppConst.IntNull)
                {
                    oParam.SysNo = SequenceDac.GetInstance().Create("PO_Sequence");
                    oParam.POID = getPOID(oParam.SysNo);
                }

                oParam.TotalAmt = oParam.GetTotalAmt();

                //���������¼
                int rowsAffected = new PODac().InsertMaster(oParam);
                if(rowsAffected != 1)
                    throw new BizException("insert po master error");
                foreach( POItemInfo item in oParam.itemHash.Values)
                {
                    item.POSysNo = oParam.SysNo;
                    item.UnitCost = Decimal.Round(item.OrderPrice * oParam.ExchangeRate + item.ApportionAddOn, 2);

                    rowsAffected = new PODac().InsertItem(item);
                    if ( rowsAffected != 1)
                        throw new BizException("insert po item error");
                }

                scope.Complete();
            }
        }