Example #1
0
        public void DeletePOItems(POInfo masterInfo, string itemProductSysNos)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

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

                //�����dz�ʼ
                if (getCurrentStatus(masterInfo.SysNo) != (int)AppEnum.POStatus.Origin)
                    throw new BizException("status is not origin now,  delete item failed");

                //����item
                if (0 >=new PODac().DeleteItems(masterInfo.SysNo, itemProductSysNos))
                    throw new BizException("expected one-row update failed, delete item failed");

                //���� itemInfo �� masterInfo
                string[] _sysnos=itemProductSysNos.Split(',');
                //masterInfo.itemHash.Remove(itemProductSysNo);
                foreach (string item in _sysnos)
                {
                    if(Util.IsInteger(item))
                        masterInfo.itemHash.Remove(Convert.ToInt32(item));
                }

                //����master total amt
                masterInfo.TotalAmt = masterInfo.GetTotalAmt();
                Hashtable ht = new Hashtable(2);
                ht.Add("SysNo", masterInfo.SysNo);
                ht.Add("TotalAmt", masterInfo.TotalAmt);
                if (1 != new PODac().UpdateMaster(ht))
                    throw new BizException("expected one-row update failed, delete item failed");

                scope.Complete();
            }
        }
Example #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();
            }
        }
Example #3
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();
            }
        }
Example #4
0
        public void UpdatePOItem(POInfo masterInfo, POItemInfo itemInfo)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

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

                //�����dz�ʼ
                if ( getCurrentStatus(masterInfo.SysNo) != (int)AppEnum.POStatus.Origin )
                    throw new BizException("status is not origin now,  update item failed");

                //����item
                if ( 1 != new PODac().UpdateItem(itemInfo))
                    throw new BizException("expected one-row update failed, update item failed");

                //���� itemInfo �� masterInfo
                masterInfo.itemHash.Remove(itemInfo.ProductSysNo);
                masterInfo.itemHash.Add(itemInfo.ProductSysNo, itemInfo);

                //����master total amt
                masterInfo.TotalAmt = masterInfo.GetTotalAmt();
                Hashtable ht = new Hashtable(2);
                ht.Add("SysNo", masterInfo.SysNo);
                ht.Add("TotalAmt", masterInfo.TotalAmt);
                if ( 1 != new PODac().UpdateMaster(ht))
                    throw new BizException("expected one-row update failed, update item failed");

                scope.Complete();
            }
        }