Esempio n. 1
0
        //停止往來
        public void StopCloseMonth(ArrayList ParameterList, DbTransaction RootDBT, out string V_MSG, out string V_STATUS_CREATEUID, out DateTime D_STATUS_CREATEDATE)
        {
            bool IsRootTranscation = false;

            try
            {
                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;

                #region 啟動交易或指定RootTranscation

                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
                dbo.StopCloseMonthSKU(ParameterList, DBT, out V_MSG, out V_STATUS_CREATEUID, out D_STATUS_CREATEDATE);//停止往來.商品交易
                if (V_MSG == "")
                {
                    dbo.StopCloseMonthContract(ParameterList, DBT, out V_MSG, out V_STATUS_CREATEUID, out D_STATUS_CREATEDATE);//停止往來.合約交易
                    if (V_MSG == "")
                    {
                        dbo.UpdateStopCalculate(ParameterList, DBT);//停止計算完後異動合約主檔的停止往來日
                    }
                }

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }

                #endregion

            }
            catch (Exception ex)
            {
                #region 交易失敗

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }

                #endregion

                throw ex;
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }

                #endregion

            }
        }