/// <summary>
 /// 判斷
 /// </summary>
 public string CheckStAcceptData(ArrayList ParameterList)
 {
     try
     {
         DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
         return dbo.CheckStAcceptData(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public DataTable QuerySwitch(QueryType QT,
                                     ArrayList ParameterList
                                     )
        {
            DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
            DataTable Dt;

            try
            {
                switch (QT)
                {
                    case QueryType.ALL:
                        Dt = dbo.doQueryAll();
                        break;
                    case QueryType.CODE:
                        Dt = dbo.doQueryByCode(ParameterList);
                        break;
                    case QueryType.PK:
                        Dt = dbo.GetMasterByPK(ParameterList);
                        break;
                    case QueryType.Where1:
                        Dt = dbo.GetMainByWhere1(ParameterList);
                        break;
                    case QueryType.QueryByFIND:
                        Dt = dbo.doQueryByFind(ParameterList);
                        break;
                    case QueryType.QueryByLOAD:
                        Dt = dbo.doQueryByLoad(ParameterList);
                        break;
                    case QueryType.QueryByExport:
                        Dt = dbo.doQueryByExprot(ParameterList);
                        break;
                    case QueryType.QueryByPrint:
                        Dt = dbo.doQueryByPrint(ParameterList);
                        break;
                    default:
                        Dt = new DataTable();
                        break;
                }

                return Dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 基本表單新增BCO
        /// </summary>
        /// <param name="ParameterList">輸入變數</param>
        /// <param name="RootDBT">是否有主交易,無主交易輸入null</param>
        /// <returns>回傳影響筆數</returns>
        public int CreatePurchaseOrder(ArrayList ParameterList, DbTransaction RootDBT)
        {
            int PID = 0;
            bool IsRootTranscation = false;

            try
            {
                DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(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

                //      PID = dbo.doCreate(ParameterList, DBT);

                #region 交易成功

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

                #endregion

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

            }
        }
 public DataTable GetItemsByPurchase_No(ArrayList ParameterList)
 {
     try
     {
         DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
         return dbo.GetItemsByPUR_No(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public int DeleteAll(ArrayList ParameterList, DbTransaction RootDBT)
        {
            bool IsRootTranscation = false;
            Int32 iResult = 0;
            DateTime d_Now;
            try
            {
                DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(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

                d_Now = DateTime.Now;

                iResult = dbo.doDeleteAll(ParameterList, DBT, d_Now);

                #region 交易成功

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

                #endregion

                return iResult;

            }
            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

            }
        }
        /// <summary>
        /// 基本表單更新BCO
        /// </summary>
        /// <param name="DetailData">更新變數</param>
        /// <param name="RootDBT">是否有主交易,無主交易輸入null</param>
        /// <returns>回傳成功與否</returns>
        ///  
        public bool UpdateDetail(ArrayList ParameterList, DataRow dRow, DataRow dRow_Oringinal, DbTransaction RootDBT)
        {
            bool IsRootTranscation = false;
            bool bResult = false;
            string s_Log_User = string.Empty;
            DateTime d_Now;

            try
            {
                DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(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

                d_Now = DateTime.Now;
                s_Log_User = ParameterList[2].ToString();

                dbo.doUpdate(ParameterList, dRow, dRow_Oringinal, DBT, s_Log_User, d_Now);

                #region 交易成功

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

                #endregion

                bResult = true;

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

            }
        }
 public void CheckItemData(ArrayList ParameterList, out string Msg)
 {
     try
     {
         DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
         dbo.CheckItemData(ParameterList, out Msg);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public DataTable QueryPrintPurchaseOrderDetail(ArrayList ParameterList)
 {
     try
     {
         DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
         return dbo.PrintPurchaseOrderDetail(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public DataTable QueryPurchaseOrderByFind_1(ArrayList ParameterList)
 {
     try
     {
         DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
         return dbo.doQueryByFind_1(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public DataTable GetDetail_Data(ArrayList ParameterList)
 {
     try
     {
         DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
         return dbo.Check_DC_DateAndGetDetailData(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public DataTable QueryPurchaseOrderByALL()
 {
     try
     {
         DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
         return dbo.doQueryAll();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public DataTable GetTempErrorDataByfind(ArrayList ParameterList)
 {
     try
     {
         DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
         return dbo.GetTempErrorDataByFind(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// 對Detail table 做結案動作
        /// </summary>
        /// <param name="ParMasterList">更新變數</param>
        /// <param name="RootDBT">是否有主交易,無主交易輸入null</param>
        /// <returns>回傳影響筆數</returns>
        public void ClosePurchaseOrderDetail(ArrayList ParDetailList,
                                             DataRow OldDetailRow,
                                             DbTransaction RootDBT
                                            )
        {
            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.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
                dbo.doClosePurchaseOrderDetail(ParDetailList, OldDetailRow, 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
            }
        }
 public string GetOrderDocumentIDAndCode()
 {
     try
     {
         DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
         return dbo.GetOrderDocumentIDAndCode();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// Master 表單更新BCO
        /// </summary>
        /// <param name="ParameterList">更新變數</param>
        /// <param name="RootDBT">是否有主交易,無主交易輸入null</param>
        /// <returns>回傳成功與否</returns>
        public bool UpdatePUR_Master(ArrayList ParameterList,
                                     DbTransaction RootDBT,
                                     DataTable oldMaster)
        {
            bool IsRootTranscation = false;
            bool bResult = 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.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
                dbo.doUpdateMaster(ParameterList, oldMaster.Rows[0], DBT);

                #region 交易成功

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

                #endregion

                bResult = true;
                return bResult;
            }
            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

            }
        }
 public DataTable QueryGiftSchema()
 {
     try
     {
         DBO.PUR_PurchaseDayGoodDBO dbo = new PUR_PurchaseDayGoodDBO(ref USEDB);
         return dbo.doQueryGiftSchema();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }