Beispiel #1
0
 public DataTable QueryDiffData(ArrayList ParameterList)
 {
     try
     {
         VDS_IVM33_DBO dbo = new VDS_IVM33_DBO(ref USEDB);
         return dbo.QueryDiffData(ParameterList);
     }
     catch (Exception ex)
     { throw ex; }
 }
Beispiel #2
0
        public string[] UpdateDiffReason(string strUID, DataTable DiffData, DbTransaction RootDBT)
        {
            bool IsRootTranscation = false;
            string[] strReturn = new string[2];
            strReturn[0] = "";
            strReturn[1] = "";

            try
            {
                DBO.VDS_IVM33_DBO DBO = new VDS_IVM33_DBO(ref USEDB);

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

                #region 啟動交易或指定RootTranscation

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

                #endregion

                ArrayList ParameterList = new ArrayList();

                for (Int32 i = 0; i <= DiffData.Rows.Count - 1; i++)
                {
                    if (DiffData.Rows[i]["OLD_DIFF_REASON"].ToString() != DiffData.Rows[i]["DIFF_REASON"].ToString())//要更新
                    {
                        ParameterList.Clear();
                        ParameterList.Add(DiffData.Rows[i]["QC_DETL_ID"]);
                        ParameterList.Add(DiffData.Rows[i]["DIFF_REASON"]);
                        ParameterList.Add(strUID);

                        strReturn = DBO.UpdateDiffReason(ParameterList, DBT);
                        if (strReturn[0] != "1")
                        {
                            return strReturn;
                        }
                    }
                }

                #region 交易成功

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

                #endregion

                return strReturn;
            }
            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
            }
        }