/// <summary>
        /// 呼叫VDS_ACM_VAM07.SP_DELETEDISCOUNTINVOICE
        /// 
        /// 傳入參數:
        /// 〔@折讓號碼〕
        /// 
        /// 傳回訊息:
        /// 〔@刪除是否成功〕
        /// 
        /// MAIN TABLE:
        /// VDS_VAM_DISCOUNT_MAIN(進項折讓主檔)
        /// VDS_VAM_DISCOUNT_DETL(進項折讓明細檔)
        /// VDS_VAM_DIFF_INVOICE(物料差主檔)
        /// VDS_VAM_DISCOUNT_INV(折讓發票檔)
        /// 
        /// REFERENCE TABLE:
        /// 1.VDS_VGI_ACCEPT_MAIN (驗收主檔)
        /// 2.VDS_VGR_RETURN_MAIN (廠退主檔)
        /// 
        /// 參考附件說明:Package_SP_VDS_ACM_VAM07.doc
        /// </summary>
        public void DeleteDiscountInvoice(ArrayList ParameterList1, DbTransaction RootDBT)
        {
            bool IsRootTranscation = false;

            try
            {
                DBO.VAM071_DBO dbo = new VAM071_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
                
                //先刪除原發票資料
                dbo.doDeleteDiscountInvoice(ParameterList1, DBT);
                
                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }
                
            }
            catch (Exception ex)
            {
                #region 交易失敗

                DBT.Rollback();
                #endregion

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

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

                #endregion

            }
        }
        /// <summary>
        /// 傳入值:
        /// 〔@要修改資料列PK〕
        /// 
        /// 回傳值:
        /// 〔@更新是否成功〕
        /// 
        /// 說明:
        /// 呼叫VDS_ACM_VAM07.
        /// SP_UPDATEDISCOUNTINVOICE,先將資料還原後在進行新增,所以先呼叫SP_DELETEDISCOUNTINVOICE刪除新增發票收據資料後在呼
        /// 叫SP名稱:SP_CREATEDISCOUNTINVOICE設定新增發票收據資料。
        /// 
        /// 參考附件說明:Package_SP_VDS_ACM_VAM07.doc
        /// </summary>
        public void UpdateDiscountInvoice(ArrayList ParameterList1,ArrayList ParameterList, DataTable dtA, DataTable dtB, DbTransaction RootDBT, string V_DISC_NO,int N_ID)
        {
            bool IsRootTranscation = false;

            try
            {
                DBO.VAM071_DBO dbo = new VAM071_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
                
                //先刪除原發票資料
                dbo.doDeleteDiscountInvoice(ParameterList1, DBT);

                //做折讓主檔新增
                dbo.doUpdateDiscountMain(ParameterList, N_ID, V_DISC_NO, DBT);


                //做折讓明細檔新增
                ArrayList Parameter_Det = new ArrayList();

                if (dtA != null)
                {
                    for (int i = 0; i < dtA.Rows.Count; i++)
                    {
                        Parameter_Det.Clear();
                        //N_PID
                        Parameter_Det.Add(N_ID);
                        //V_DISC_NO
                        Parameter_Det.Add(V_DISC_NO);
                        //V_TAX_TYPE
                        Parameter_Det.Add(ParameterList[1]);
                        //V_SOURCE_TYPE
                        Parameter_Det.Add(GetValueSetParameter(dtA.Rows[i]["SOURCE_TYPE"].ToString(), "string", false));
                        //V_SOURCE_NO
                        Parameter_Det.Add(GetValueSetParameter(dtA.Rows[i]["SOURCE_NO"].ToString(), "string", false));
                        //N_REMAIN_AMT目前沒用到該欄位所以填NULL
                        Parameter_Det.Add(GetValueSetParameter("", "float", false));
                        //N_AMT
                        Parameter_Det.Add(GetValueSetParameter(dtA.Rows[i]["AMT"].ToString(), "float", false));
                        //D_UPDATEDATE
                        Parameter_Det.Add(ParameterList[6]);
                        //V_UPDATEUID
                        Parameter_Det.Add(ParameterList[7]);
                        //D_CREATEDATE
                        Parameter_Det.Add(ParameterList[8]);
                        //V_CREATEUID
                        Parameter_Det.Add(ParameterList[9]);

                        dbo.doInsertDiscountDetl(Parameter_Det,DBT);
                    }
                }


                //做發票折讓明細檔新增
                
                if (dtB != null)
                {
                    for (int i = 0; i < dtB.Rows.Count; i++)
                    {
                        Parameter_Det.Clear();
                        
                        //V_DISC_NO
                        Parameter_Det.Add(V_DISC_NO);
                        //V_INV_NO
                        Parameter_Det.Add(GetValueSetParameter(dtB.Rows[i]["INV_NO"].ToString(), "string", false));
                        //N_DISC_AMT
                        Parameter_Det.Add(GetValueSetParameter(dtB.Rows[i]["DISC_AMT"].ToString(), "float", false));
                        //V_UPDATEUID
                        Parameter_Det.Add(ParameterList[7]);
                        //D_UPDATEDATE
                        Parameter_Det.Add(ParameterList[6]);
                        //V_CREATEUID
                        Parameter_Det.Add(ParameterList[9]);
                        //D_CREATEDATE
                        Parameter_Det.Add(ParameterList[8]);
                        
                        dbo.doInsertDiscountInvoice(Parameter_Det, DBT);
                    }
                }

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }
                else
                {
                    DBT.Rollback();
                }
                
            }
            catch (Exception ex)
            {
                #region 交易失敗

                DBT.Rollback();
                #endregion

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

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

                #endregion

            }
        }