public DataTable QueryRegularReturnItem(ArrayList ParameterList)
 {
     try
     {
         DBO.ITM_ITM11_DBO dbo = new ITM_ITM11_DBO(ref USEDB);
         return dbo.doQueryRegularReturnItem(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// 基本表單新增BCO
        /// </summary>
        /// <param name="ParameterList">輸入變數</param>
        /// <param name="RootDBT">是否有主交易,無主交易輸入null</param>
        /// <returns>回傳影響筆數</returns>
        public void InsertITM112(DataTable DetailData, DbTransaction RootDBT)
        {
            bool IsRootTranscation = false;
            try
            {
                DBO.ITM_ITM11_DBO dbo = new ITM_ITM11_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
                int N_ID, N_ID2;
                ArrayList ParameterList = new ArrayList();
                ArrayList ParameterList1 = new ArrayList();
                ArrayList ParameterList2 = new ArrayList();
                ArrayList ParameterList3 = new ArrayList();
                string sIsAddStore = "N";
                string sCHAN_NO = "";
                int iPID = 0;
                for (int i = 0; i < DetailData.Rows.Count; i++)
                {
                    if (DetailData.Rows[i]["SEL_FLAG"].ToString() == "1")
                    {
                        sIsAddStore = "N";
                        if (DetailData.Rows[i]["CHAN_NO"].ToString() != sCHAN_NO)
                        {
                            //InsertTemplateMain
                            ParameterList.Clear();
                            ParameterList.Add(DetailData.Rows[i]["CHAN_NO"].ToString() + Convert.ToDateTime(DetailData.Rows[i]["T_DATE"].ToString()).ToShortDateString());
                            ParameterList.Add(DetailData.Rows[i]["CHAN_NO"]);
                            ParameterList.Add(DetailData.Rows[i]["T_DATE"]);
                            ParameterList.Add(DetailData.Rows[i]["REMARK_CONTENT"]);
                            ParameterList.Add(DetailData.Rows[i]["CREATEDATE"]);
                            ParameterList.Add(DetailData.Rows[i]["CREATEUID"]);
                            ParameterList.Add(DetailData.Rows[i]["UPDATEDATE"]);
                            ParameterList.Add(DetailData.Rows[i]["UPDATEUID"]);
                            dbo.InsertTemplateMain(ParameterList, DBT, out N_ID);
                            sCHAN_NO = DetailData.Rows[i]["CHAN_NO"].ToString();
                            iPID = N_ID;
                            sIsAddStore = "Y";
                        }

                        //InsertTemplateItem
                        ParameterList2.Clear();
                        ParameterList2.Add(iPID);
                        ParameterList2.Add(DetailData.Rows[i]["CHAN_NO"]);
                        ParameterList2.Add(DetailData.Rows[i]["T_DATE"]);
                        ParameterList2.Add(DetailData.Rows[i]["ITEM"]);
                        ParameterList2.Add(DetailData.Rows[i]["PERIOD"]);
                        ParameterList2.Add(DetailData.Rows[i]["CREATEDATE"]);
                        ParameterList2.Add(DetailData.Rows[i]["CREATEUID"]);
                        ParameterList2.Add(DetailData.Rows[i]["UPDATEDATE"]);
                        ParameterList2.Add(DetailData.Rows[i]["UPDATEUID"]);
                        ParameterList2.Add(DetailData.Rows[i]["SEL_FLAG"]);

                        dbo.InsertTemplateItem(ParameterList2, DBT, out N_ID2);

                        //if (sIsAddStore == "Y")
                        //{
                        //    //InsertTemplateStore
                        //    ParameterList1.Clear();

                        //    ParameterList1.Add(DetailData.Rows[i]["CHAN_NO"]);
                        //    ParameterList1.Add(DetailData.Rows[i]["T_DATE"]);
                        //    ParameterList1.Add(DetailData.Rows[i]["CREATEUID"]);
                        //    ParameterList1.Add(DetailData.Rows[i]["CREATEDATE"]);
                        //    ParameterList1.Add(DetailData.Rows[i]["UPDATEUID"]);
                        //    ParameterList1.Add(DetailData.Rows[i]["UPDATEDATE"]);

                        //    dbo.InsertTemplateStore(ParameterList1, DBT);

                        //}

                        ////ResortTemplateItem
                        //ParameterList3.Clear();

                        //ParameterList3.Add(DetailData.Rows[i]["CHAN_NO"]);
                        //ParameterList3.Add(DetailData.Rows[i]["T_DATE"]);

                        //dbo.ResortTemplateItem(ParameterList3, DBT);
                    }
                    else
                    {
                        //InsertTemplateItem
                        ParameterList2.Clear();
                        ParameterList2.Add(iPID);
                        ParameterList2.Add(DetailData.Rows[i]["CHAN_NO"]);
                        ParameterList2.Add(DetailData.Rows[i]["T_DATE"]);
                        ParameterList2.Add(DetailData.Rows[i]["ITEM"]);
                        ParameterList2.Add(DetailData.Rows[i]["PERIOD"]);
                        ParameterList2.Add(DetailData.Rows[i]["CREATEDATE"]);
                        ParameterList2.Add(DetailData.Rows[i]["CREATEUID"]);
                        ParameterList2.Add(DetailData.Rows[i]["UPDATEDATE"]);
                        ParameterList2.Add(DetailData.Rows[i]["UPDATEUID"]);
                        ParameterList2.Add(DetailData.Rows[i]["SEL_FLAG"]);
                        dbo.InsertTemplateItem(ParameterList2, DBT, out N_ID2);
                    }

                }
                sCHAN_NO = "";
                for (int i = 0; i < DetailData.Rows.Count; i++)
                {
                    if (DetailData.Rows[i]["CHAN_NO"].ToString() != sCHAN_NO)
                    {
                        //InsertTemplateStore
                        ParameterList1.Clear();

                        ParameterList1.Add(DetailData.Rows[i]["CHAN_NO"]);
                        ParameterList1.Add(DetailData.Rows[i]["T_DATE"]);
                        ParameterList1.Add(DetailData.Rows[i]["CREATEUID"]);
                        ParameterList1.Add(DetailData.Rows[i]["CREATEDATE"]);
                        ParameterList1.Add(DetailData.Rows[i]["UPDATEUID"]);
                        ParameterList1.Add(DetailData.Rows[i]["UPDATEDATE"]);

                        dbo.InsertTemplateStore(ParameterList1, DBT);


                        //ResortTemplateItem
                        ParameterList3.Clear();
                        ParameterList3.Add(DetailData.Rows[i]["CHAN_NO"]);
                        ParameterList3.Add(DetailData.Rows[i]["T_DATE"]);

                        dbo.ResortTemplateItem(ParameterList3, DBT);
                    }
                    sCHAN_NO = DetailData.Rows[i]["CHAN_NO"].ToString();
                }


                #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

            }
        }
 /// <summary>
 /// ITM111按下Button[查詢]鈕
 /// </summary>
 /// <param name="ParameterList"></param>
 /// <returns></returns>
 public DataTable QUERYSETTEMPLATEDATA(ArrayList ParameterList)
 {
     try
     {
         ITM_ITM11_DBO ITM11 = new ITM_ITM11_DBO(ref USEDB);
         return ITM11.QUERYSETTEMPLATEDATA(ParameterList);
     }
     catch (Exception ex)
     { throw ex; }
 }
 /// <summary>
 /// 刪除VDS_PUR_PICK_CONTROL_CHK,取消鎖定編輯
 /// </summary>
 public int DeleteControlChk(ArrayList ParameterList)
 {
     try
     {
         DBO.ITM_ITM11_DBO dbo = new ITM_ITM11_DBO(ref USEDB);
         return dbo.DeleteControlChk(ParameterList, null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// 新增VDS_PUR_PICK_CONTROL_CHK,鎖定編輯
        /// </summary>
        public int InsertControlChk(ArrayList ParameterList, DbTransaction RootDBT)
        {
            #region
            bool IsRootTranscation = false;
            int bResult;
            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.ITM_ITM11_DBO dbo = new ITM_ITM11_DBO(ref USEDB);
                bResult = dbo.InsertControlChk(ParameterList, DBT);

                #region 交易成功

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

                #endregion

                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
            }
            #endregion
        }
 /// <summary>
 /// 取得該日期、批號是否有人在編輯
 /// </summary>
 public DataTable QueryControlChk()
 {
     try
     {
         DBO.ITM_ITM11_DBO dbo = new ITM_ITM11_DBO(ref USEDB);
         return dbo.QueryControlChk();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }