public DataTable QueryByID(ArrayList ParameterList)
 {
     try
     {
         DBO.MaintainChanReturnDataDBO db = new MaintainChanReturnDataDBO(ref USEDB);
         return db.QueryByID(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public DataTable DoImportCheck(ArrayList ParameterList)
 {
     try
     {
         DBO.MaintainChanReturnDataDBO db = new MaintainChanReturnDataDBO(ref USEDB);
         return db.DoImportCheck(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void DoImportFile(string DataLine)
 {
     try
     {
         DBO.MaintainChanReturnDataDBO db = new MaintainChanReturnDataDBO(ref USEDB);
         db.DoImportFile(DataLine);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void GetItemByBarCode(ArrayList ParameterList, out string strItem, out string strPeriod, out decimal iPrice, out DateTime DChanEndDate, out string strMSG, out string strRESULT)
 {
     try
     {
         DBO.MaintainChanReturnDataDBO db = new MaintainChanReturnDataDBO(ref USEDB);
         db.GetItemByBarCode(ParameterList, out strItem, out strPeriod, out iPrice,out DChanEndDate, out strMSG, out strRESULT);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void DoDelImportFile()
 {
     DBO.MaintainChanReturnDataDBO db = new MaintainChanReturnDataDBO(ref USEDB);
  
     try
     {
         db.DoDelImportFile();               
     }
     catch (Exception ex)
     {               
         throw ex;
     }
     finally
     {
        
     }
 }
        public bool DoInsertDetl(ArrayList ParameterList, DbTransaction RootDBT)
        {           
            DBO.MaintainChanReturnDataDBO db = new MaintainChanReturnDataDBO(ref USEDB);
            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

                db.DoInsertDetl(ParameterList, DBT);
                   
                #region 交易成功

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

                return true;
                #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 bool CreateChanReturnData(ArrayList ParameterList, DataTable dtDetail, DbTransaction RootDBT,string strID,DateTime dUpdate,
                                     out string BatchNo, out int PID)
        {
            string strBatchNo = "";
            int iPID = 0;

            ArrayList ErrorList = new ArrayList();

            DBO.MaintainChanReturnDataDBO db = new MaintainChanReturnDataDBO(ref USEDB);
            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

                db.CreateChanReturnData(ParameterList, DBT, out iPID, out strBatchNo);

                BatchNo = strBatchNo;
                PID = iPID;

                //建立Detail資料

                ArrayList DetailList = new ArrayList();

                for (int i = 0; i < dtDetail.Rows.Count; i++)
                {
                    DetailList.Clear();
                    DetailList.Add(iPID);                    
                    //DetailList.Add(dtDetail.Rows[i][1].ToString()); //item
                    //DetailList.Add(dtDetail.Rows[i][3].ToString()); //Period
                    //DetailList.Add(decimal.Parse(dtDetail.Rows[i][4].ToString())); //N_CHAN_PRICE
                    //DetailList.Add(DateTime.Parse(dtDetail.Rows[i][5].ToString())); //D_CHAN_END_DATE
                    //DetailList.Add(Int32.Parse(dtDetail.Rows[i][6].ToString())); //N_BACKWARD_QTY
                    DetailList.Add(dtDetail.Rows[i]["item"].ToString()); //item
                    DetailList.Add(dtDetail.Rows[i]["period"].ToString()); //Period
                    DetailList.Add(decimal.Parse(dtDetail.Rows[i]["Chan_Price"].ToString())); //N_CHAN_PRICE
                    DetailList.Add(DateTime.Parse(dtDetail.Rows[i]["Chan_End_Date"].ToString())); //D_CHAN_END_DATE
                    DetailList.Add(Int32.Parse(dtDetail.Rows[i]["BackWard_Qty"].ToString())); //N_BACKWARD_QTY
                    DetailList.Add(strID); //V_CREATEUID
                    DetailList.Add(strID); //V_UPDATEUID
                    DetailList.Add(dUpdate);//D_UPDATEDATE
                    DetailList.Add(dUpdate);//D_CREATEDATE
                    db.DoInsertDetl(DetailList, DBT);
                }

                #region 交易成功

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

                return true;
                #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 DataTable GetImpErrData(ArrayList ParameterList)
 {
     try
     {
         DBO.MaintainChanReturnDataDBO db = new MaintainChanReturnDataDBO(ref USEDB);
         return db.GetImpErrData(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 //查詢匯入資料
 public DataTable GetImpData(string V_USER_ID)
 {
     try
     {
         DBO.MaintainChanReturnDataDBO db = new MaintainChanReturnDataDBO(ref USEDB);
         return db.GetImpData(V_USER_ID);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public string GetOrderDocumentIDAndCode()
 {
     try
     {
         DBO.MaintainChanReturnDataDBO db = new MaintainChanReturnDataDBO(ref USEDB);
         return db.GetOrderDocumentIDAndCode();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }