Esempio n. 1
0
    /// <summary>
    /// 檢查條件
    /// </summary>
    /// <param name="s_Type"></param>
    /// <returns></returns>
    private ArrayList Check_Condition(string s_Type)
    {
        #region 宣告

        CAAModel.CAACommon CAAComm = new CAAModel.CAACommon();
        ArrayList arl_Return = new ArrayList();
        arl_Return.Add(string.Empty);//該欄位放Focus欄位之ClientID
        arl_Return.Add(string.Empty);//該欄位放錯誤訊息

        #endregion

        #region BUTTON [儲存]鈕,編輯狀態

        if (s_Type == "BUTTON [儲存]鈕,編輯狀態")
        {
            #region 檢查日期格式

            arl_Return = CAAComm.Check_Format_Date(this.slp_SAL_DATE.Text, "欄位[營業日期]日期格式錯誤", "1", this.slp_SAL_DATE.DateTextBox.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.txt_COLL_DATE.Text, "欄位[交易日期]日期格式錯誤", "1", this.txt_COLL_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.txt_COLL_TIME.Text, "欄位[交易時間]時間格式錯誤", "1", this.txt_COLL_TIME.ClientID, arl_Return);

            #endregion

            #region 檢查數字格式

            arl_Return = CAAComm.Check_Format_Int(this.txt_COLL_SEQNO.Text, "欄位[交易序號]數字格式錯誤", "64", "1", this.txt_COLL_SEQNO.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Int(this.txt_PAY_CHKNO.Text, "欄位[繳款識別碼]數字格式錯誤", "32", "1", this.txt_PAY_CHKNO.ClientID, arl_Return);

            #endregion

            #region 檢查欄位的Byte長度

            if (CAAComm.Get_Byte_Length(this.txt_COLL_SEQNO.Text) > 10)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[交易序號]長度不可大於 10 Byte", "1", this.txt_COLL_SEQNO.ClientID); }

            if (CAAComm.Get_Byte_Length(this.txt_PAY_CHKNO.Text) > 9)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[繳款識別碼]長度不可大於 9 Byte", "1", this.txt_PAY_CHKNO.ClientID); }

            if (CAAComm.Get_Byte_Length(this.txt_MEMO.Text) > 200)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[原因說明]長度不可大於 200 Byte", "1", this.txt_MEMO.ClientID); }
            #endregion

            #region 檢查必填欄位

            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_CHARGE.Text, "text", "欄位[手續費]為必填欄位", "1", this.slp_CHARGE.TextBox_Code.ClientID, arl_Return);

            #endregion
        }

        #endregion

        #region BUTTON [編輯]鈕,檢視狀態

        else if (s_Type == "BUTTON [編輯]鈕,檢視狀態")
        {

        }

        #endregion

        return arl_Return;
    }
Esempio n. 2
0
    /// <summary>
    /// 檢查條件
    /// </summary>
    /// <param name="s_Type"></param>
    /// <returns></returns>
    private ArrayList Check_Condition(string s_Type)
    {
        #region 宣告

        BCO.CAACommon CAAComm = new BCO.CAACommon();
        ArrayList arl_Return = new ArrayList();
        arl_Return.Add(string.Empty);//該欄位放Focus欄位之ClientID
        arl_Return.Add(string.Empty);//該欄位放錯誤訊息

        #endregion

        #region SLP轉型

        #region 銷或折讓維護區

        TextBox txt_STORE_ID = (TextBox)this.slp_STORE_ID.FindControl("TextBoxCode");//店號
        TextBox txt_ROOT_NO = (TextBox)this.slp_ROOT_NO.FindControl("TextBoxCode");//商品群分類
        TextBox txt_DISC_DATE = (TextBox)this.slp_DISC_DATE.FindControl("TextBoxCode");//折讓日期
        TextBox txt_CHG_DISC_DATE = (TextBox)this.slp_CHG_DISC_DATE.FindControl("TextBoxCode");//異動折讓日期
        TextBox txt_PROOF_DATE = (TextBox)this.slp_PROOF_DATE.FindControl("TextBoxCode");//憑證已回日期
        TextBox txt_CANCEL_DATE = (TextBox)this.slp_CANCEL_DATE.FindControl("TextBoxCode");//作廢日期
        TextBox txt_PERIOD_DATE = (TextBox)this.slp_PERIOD_DATE.FindControl("TextBoxCode");//申報日期
        TextBox txt_TEMPORAL_DATE = (TextBox)this.slp_TEMPORAL_DATE.FindControl("TextBoxCode");//暫收日期
        TextBox txt_DISC_UAMT = (TextBox)this.slp_DISC_UAMT.FindControl("TextBoxCode");//折讓金額(未稅)
        TextBox txt_DISC_TAX = (TextBox)this.slp_DISC_TAX.FindControl("TextBoxCode");//折讓稅額
        TextBox txt_DISC_AMT = (TextBox)this.slp_DISC_AMT.FindControl("TextBoxCode");//總金額
        TextBox txt_CLOSE_MONTH = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)this.slp_CLOSE_MONTH.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");//結帳年月

        DropDownList drop_DISC_SOURCE = (DropDownList)this.slp_DISC_SOURCE.FindControl("D1");//來源
        DropDownList drop_DISC_TYPE = (DropDownList)this.slp_DISC_TYPE.FindControl("D1");//型式
        DropDownList drop_TAX_TYPE = (DropDownList)this.slp_TAX_TYPE.FindControl("D1");//稅別

        #endregion

        #region 折讓項目區

        TextBox txt_Disc_INV_DATE = (TextBox)this.slp_Disc_INV_DATE.FindControl("TextBoxCode");//發票日期
        TextBox txt_Disc_DISC_UAMT = (TextBox)this.slp_Disc_DISC_UAMT.FindControl("TextBoxCode");//折讓金額(未稅)
        TextBox txt_Disc_DISC_TAX = (TextBox)this.slp_Disc_DISC_TAX.FindControl("TextBoxCode");//折讓稅額
        TextBox txt_Disc_NON_INV_UAMT = (TextBox)this.slp_Disc_NON_INV_UAMT.FindControl("TextBoxCode");//發票餘額(未稅)
        TextBox txt_Disc_NON_INV_TAX = (TextBox)this.slp_Disc_NON_INV_TAX.FindControl("TextBoxCode");//發票稅額

        #endregion

        #endregion

        #region BUTTON [儲存]鈕

        #region 新增狀態

        if (s_Type == "BUTTON [儲存]鈕,新增狀態")
        {
            #region 檢查欄位的Byte長度

            if (CAAComm.Get_Byte_Length(this.txt_ACT_DISC_NO.Text) > 13)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[財會折讓單號]長度不可大於 13 Byte", "1", this.txt_ACT_DISC_NO.ClientID); }
            if (CAAComm.Get_Byte_Length(this.txt_REPROOF_NO.Text) > 12)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[發票號碼/收據]長度不可大於 12 Byte", "1", this.txt_REPROOF_NO.ClientID); }
            if (CAAComm.Get_Byte_Length(this.txt_RFNO.Text) > 10)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[統一編號]長度不可大於 10 Byte", "1", this.txt_RFNO.ClientID); }
            if (CAAComm.Get_Byte_Length(this.txt_MEMO.Text) > 200)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[備註]長度不可大於 200 Byte", "1", this.txt_MEMO.ClientID); }

            #endregion

            #region 檢查SLP日期格式

            arl_Return = CAAComm.Check_Format_Date(this.slp_DISC_DATE.Text, "欄位[折讓日期]日期格式錯誤", "1", txt_DISC_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_CHG_DISC_DATE.Text, "欄位[異動折讓日期]日期格式錯誤", "1", txt_DISC_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_PROOF_DATE.Text, "欄位[憑證已回日期]日期格式錯誤", "1", txt_PROOF_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_CANCEL_DATE.Text, "欄位[作廢日期]日期格式錯誤", "1", txt_CANCEL_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_PERIOD_DATE.Text, "欄位[申報日期]日期格式錯誤", "1", txt_PERIOD_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_TEMPORAL_DATE.Text, "欄位[暫收日期]日期格式錯誤", "1", txt_TEMPORAL_DATE.ClientID, arl_Return);

            #endregion

            #region 檢查SLP數字格式

            arl_Return = CAAComm.Check_Format_Int(this.slp_DISC_UAMT.Text, "欄位[折讓金額(未稅)]數字格式錯誤", "32", "1", txt_DISC_UAMT.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Int(this.slp_DISC_TAX.Text, "欄位[折讓稅額]數字格式錯誤", "32", "1", txt_DISC_TAX.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Int(Request[txt_DISC_AMT.UniqueID].ToString(), "欄位[總金額]數字格式錯誤", "32", "1", txt_DISC_AMT.ClientID, arl_Return);

            #endregion

            #region 檢查SLP年月格式

            arl_Return = CAAComm.Check_Format_YearMonth(this.slp_CLOSE_MONTH.Text, "欄位[結帳年月]年月格式錯誤", "1", txt_CLOSE_MONTH.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_YearMonth(this.slp_CLOSE_MONTH_ACCT.Text, "欄位[結帳年月-財會]年月格式錯誤", "1", this.slp_CLOSE_MONTH_ACCT.TextBoxCode_Object.ClientID, arl_Return);

            #endregion

            #region 檢查必填欄位

            arl_Return = CAAComm.Check_MustFillin_Column(drop_DISC_SOURCE.SelectedIndex.ToString(), "drop", "欄位[來源]為必填欄位", "1", string.Empty, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_STORE_ID.Text, "text", "欄位[店號]為必填欄位", "1", txt_STORE_ID.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(drop_DISC_TYPE.SelectedIndex.ToString(), "drop", "欄位[型式]為必填欄位", "1", string.Empty, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(drop_TAX_TYPE.SelectedIndex.ToString(), "drop", "欄位[稅別]為必填欄位", "1", string.Empty, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_ROOT_NO.Text, "text", "欄位[商品群分類]為必填欄位", "1", txt_ROOT_NO.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_CLOSE_MONTH.Text, "text", "欄位[結帳年月]為必填欄位", "1", txt_CLOSE_MONTH.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_DISC_UAMT.Text, "text", "欄位[折讓金額(未稅)]為必填欄位", "1", txt_DISC_UAMT.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_DISC_TAX.Text, "text", "欄位[折讓稅額]為必填欄位", "1", txt_DISC_TAX.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(Request[txt_DISC_AMT.UniqueID].ToString(), "text", "欄位[總金額]為必填欄位", "1", txt_DISC_AMT.ClientID, arl_Return);

            #endregion

            #region 如果基本檢查有誤,則Return

            if (arl_Return[1].ToString() != string.Empty)
            { return arl_Return; }

            #endregion

            #region 自訂檢查

            #region 檢查欄位[折讓金額(未稅)][折讓稅額][總金額]

            int i_DISC_UAMT = int.Parse(this.slp_DISC_UAMT.Text);//折讓金額(未稅)
            int i_DISC_TAX = int.Parse(this.slp_DISC_TAX.Text);//折讓稅額
            int i_DISC_AMT = int.Parse(Request[txt_DISC_AMT.UniqueID].ToString());//總金額

            if (i_DISC_UAMT < 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓金額(未稅)]不可小於0", "1", txt_DISC_UAMT.ClientID); }
            if (i_DISC_TAX < 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓稅額]不可小於0", "1", txt_DISC_TAX.ClientID); }
            if (i_DISC_AMT <= 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[總金額]不可小於或等於0", "1", txt_DISC_AMT.ClientID); }
            if (i_DISC_UAMT == 0 && i_DISC_TAX != 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓金額(未稅)]為0時,欄位[折讓稅額]也必須為0", "1", txt_DISC_TAX.ClientID); }
            if (i_DISC_UAMT + i_DISC_TAX != i_DISC_AMT)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓金額(未稅)]加上欄位[折讓稅額]必須等於欄位[總金額]", "1", txt_DISC_AMT.ClientID); }
            if (this.slp_TAX_TYPE.Text == "1" ||//[稅別]=免稅
                this.slp_TAX_TYPE.Text == "2")//[稅別]=零稅
            {
                if (i_DISC_TAX != 0)
                { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[稅別]是免稅或零稅時,欄位[折讓稅額]必須為0", "1", txt_DISC_TAX.ClientID); }
            }

            #endregion

            #region 新增模式下欄位[來源]必須是選擇人工開立

            if (this.slp_DISC_SOURCE.Text != "2")//2代表是人工開立
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[來源]必須是選擇人工開立", "1", drop_DISC_SOURCE.ClientID); }

            #endregion

            #region 檢查欄位[店號]是否為有效店號

            #region 傳入參數

            ParameterList.Clear();
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_STORE_ID.Text, "string", false));//店號
            ParameterList.Add(CAAComm.GetValueSetParameter(DateTime.Now.ToString(), "datetime", false));//系統時間
            ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//登入人員

            #endregion

            #region 連結資料庫

            BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);
            IDataReader dr = bco.QUERY_CAA18_DATA_BY_STORE_ID(ParameterList);

            #endregion

            if (dr.Read() == false)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[店號]查無符合店號或己關店,請重新輸入", "1", this.slp_STORE_ID.TextBox_Code.ClientID); }
            dr.Close();

            #endregion

            #region 新增模式下欄位[作廢]不能勾選

            if (this.chb_CANCEL_FLG.Checked == true)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[作廢]不能勾選", "1", chb_CANCEL_FLG.ClientID); }

            #endregion

            #region 新增模式下欄位[作廢日期]必須為空白

            if (this.slp_CANCEL_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[作廢日期]必須為空白", "1", txt_CANCEL_DATE.ClientID); }

            #endregion

            #region 新增模式下欄位[申報]不能勾選

            if (this.chb_PERIOD_FLG.Checked == true)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[申報]不能勾選", "1", chb_PERIOD_FLG.ClientID); }

            #endregion

            #region 新增模式下欄位[申報日期]必須為空白

            if (this.slp_PERIOD_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[申報日期]必須為空白", "1", txt_PERIOD_DATE.ClientID); }

            #endregion

            #region 新增模式下欄位[轉暫收]不能勾選

            if (this.chb_TEMPORAL_FLG.Checked == true)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[轉暫收]不能勾選", "1", chb_TEMPORAL_FLG.ClientID); }

            #endregion

            #region 新增模式下欄位[暫收日期]必須為空白

            if (this.slp_TEMPORAL_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[暫收日期]必須為空白", "1", txt_TEMPORAL_DATE.ClientID); }

            #endregion

            #region 檢查若己月結則不允許新增

            #region 傳入參數

            ParameterList.Clear();
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CLOSE_MONTH.Text, "string", false));//[結帳年月]
            ParameterList.Add(CAAComm.GetValueSetParameter("CAA18", "string", false)); //V_FUNC_NO

            #endregion

            #region 連結資料庫

            BCO.ChanMonthCloseYN bco_Is_Close = new BCO.ChanMonthCloseYN(ConntionDB);

            #endregion

            #region 檢查回傳資料

            //回傳結果=Y,該月份已月結
            //回傳結果=N,該月份尚未月結
            if (((ArrayList)bco_Is_Close.GetChanMonthCloseStatus(ParameterList, null))[0].ToString() == "Y")
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[結帳年月]該月份已月結", "1", txt_CLOSE_MONTH.ClientID); }

            #endregion

            #endregion

            #region 檢查欄位[憑證已回]若已勾選,則欄位[憑證已回日期]為必填欄位

            if (this.chb_PROOF_FLG.Checked == true && this.slp_PROOF_DATE.Text.Trim() == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[憑證已回]若有勾選,則欄位[憑證已回日期]為必填欄位", "1", txt_PROOF_DATE.ClientID); }

            #endregion

            #region 檢查欄位[憑證已回日期]若有值,則欄位[憑證已回]或[取具進項憑証]或[取具收據]必須勾選

            if ((this.chb_PROOF_FLG.Checked == false && this.chb_REPROOF_FLG.Checked == false && this.chb_RECEIPT_FLG.Checked == false) == true &&
                this.slp_PROOF_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[憑證已回日期]若有值,則欄位[憑證已回]或[取具進項憑証]或[取具收據]必須勾選", "1", string.Empty); }

            #endregion

            #region 檢查欄位[取具進項憑証]若已勾選,則欄位[憑證已回日期]為必填欄位

            if (this.chb_REPROOF_FLG.Checked == true && this.slp_PROOF_DATE.Text == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[取具進項憑証]若已勾選,則欄位[憑證已回日期]為必填欄位", "1", txt_PROOF_DATE.ClientID); }

            #endregion

            #region 檢查欄位[取具進項憑証]若已勾選,則欄位[發票號碼/收據]為必填欄位

            if (this.chb_REPROOF_FLG.Checked == true && this.txt_REPROOF_NO.Text == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[取具進項憑証]若已勾選,則欄位[發票號碼/收據]為必填欄位", "1", this.txt_REPROOF_NO.ClientID); }

            #endregion

            #region 檢查欄位[發票號碼/收據]若有值,則欄位[取具進項憑証]必須勾選

            if (this.chb_REPROOF_FLG.Checked == false && this.txt_REPROOF_NO.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[發票號碼/收據]若有值,則欄位[取具進項憑証]必須勾選", "1", string.Empty); }

            #endregion

            #region 檢查欄位[取具收據]若已勾選,則欄位[憑證已回日期]為必填欄位

            if (this.chb_RECEIPT_FLG.Checked == true && this.slp_PROOF_DATE.Text == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[取具收據]若已勾選,則欄位[憑證已回日期]為必填欄位", "1", txt_PROOF_DATE.ClientID); }

            #endregion

            #endregion
        }

        #endregion

        #region 編輯狀態

        else if (s_Type == "BUTTON [儲存]鈕,編輯狀態")
        {
            #region 檢查欄位的Byte長度

            if (CAAComm.Get_Byte_Length(this.txt_ACT_DISC_NO.Text) > 13)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[財會折讓單號]長度不可大於 13 Byte", "1", this.txt_ACT_DISC_NO.ClientID); }
            if (CAAComm.Get_Byte_Length(this.txt_REPROOF_NO.Text) > 12)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[發票號碼/收據]長度不可大於 12 Byte", "1", this.txt_REPROOF_NO.ClientID); }
            if (CAAComm.Get_Byte_Length(this.txt_RFNO.Text) > 10)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[統一編號]長度不可大於 10 Byte", "1", this.txt_RFNO.ClientID); }
            if (CAAComm.Get_Byte_Length(this.txt_MEMO.Text) > 200)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[備註]長度不可大於 200 Byte", "1", this.txt_MEMO.ClientID); }

            #endregion

            #region 檢查SLP日期格式

            arl_Return = CAAComm.Check_Format_Date(this.slp_DISC_DATE.Text, "欄位[折讓日期]日期格式錯誤", "1", txt_DISC_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_CHG_DISC_DATE.Text, "欄位[異動折讓日期]日期格式錯誤", "1", txt_DISC_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_PROOF_DATE.Text, "欄位[憑證已回日期]日期格式錯誤", "1", txt_PROOF_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_CANCEL_DATE.Text, "欄位[作廢日期]日期格式錯誤", "1", txt_CANCEL_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_PERIOD_DATE.Text, "欄位[申報日期]日期格式錯誤", "1", txt_PERIOD_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_TEMPORAL_DATE.Text, "欄位[暫收日期]日期格式錯誤", "1", txt_TEMPORAL_DATE.ClientID, arl_Return);

            #endregion

            #region 檢查SLP數字格式

            arl_Return = CAAComm.Check_Format_Int(this.slp_DISC_UAMT.Text, "欄位[折讓金額(未稅)]數字格式錯誤", "32", "1", txt_DISC_UAMT.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Int(this.slp_DISC_TAX.Text, "欄位[折讓稅額]數字格式錯誤", "32", "1", txt_DISC_TAX.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Int(Request[txt_DISC_AMT.UniqueID].ToString(), "欄位[總金額]數字格式錯誤", "32", "1", txt_DISC_AMT.ClientID, arl_Return);

            #endregion

            #region 檢查SLP年月格式

            arl_Return = CAAComm.Check_Format_YearMonth(this.slp_CLOSE_MONTH.Text, "欄位[結帳年月]年月格式錯誤", "1", txt_CLOSE_MONTH.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_YearMonth(this.slp_CLOSE_MONTH_ACCT.Text, "欄位[結帳年月-財會]年月格式錯誤", "1", this.slp_CLOSE_MONTH_ACCT.TextBoxCode_Object.ClientID, arl_Return);

            #endregion

            #region 檢查不可同時進行多個勾選作業

            bool b_IsRight = false;
            string s_ReturnMsg = string.Empty;

            Check_CheckStatus(out b_IsRight, out s_ReturnMsg);

            if (b_IsRight == true)//代表進行1個以上勾選作業
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "不可同時進行多個勾選作業", "1", string.Empty); }

            #endregion

            #region 檢查月結是否與頁面LOAD進來時相同,如有異動,請使用者重新LOAD頁面

            #region 傳入參數

            ParameterList.Clear();
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CLOSE_MONTH.Text, "string", false));//[結帳年月]
            ParameterList.Add(CAAComm.GetValueSetParameter("CAA18", "string", false)); //V_FUNC_NO

            #endregion

            #region 連結資料庫

            BCO.ChanMonthCloseYN bco_Is_Close = new BCO.ChanMonthCloseYN(ConntionDB);

            #endregion

            #region 檢查回傳資料

            //回傳結果=Y,該月份已月結
            //回傳結果=N,該月份尚未月結
            bool b_IsClose_Now = false;
            if (((ArrayList)bco_Is_Close.GetChanMonthCloseStatus(ParameterList, null))[0].ToString() == "Y")
            { b_IsClose_Now = true; }
            else
            { b_IsClose_Now = false; }

            if (b_IsClose != b_IsClose_Now)//代表月結已被更動
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "月結已被更動,請重新載入編輯頁面", "1", string.Empty); }

            #endregion

            #endregion

            #region 如果基本檢查有誤,則Return

            if (arl_Return[1].ToString() != string.Empty)
            { return arl_Return; }

            #endregion

            #region 自訂檢查

            #region 檢查欄位[折讓金額(未稅)][折讓稅額][總金額]

            int i_DISC_UAMT = int.Parse(this.slp_DISC_UAMT.Text);//折讓金額(未稅)
            int i_DISC_TAX = int.Parse(this.slp_DISC_TAX.Text);//折讓稅額
            int i_DISC_AMT = int.Parse(Request[txt_DISC_AMT.UniqueID].ToString());//總金額

            if (i_DISC_UAMT < 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓金額(未稅)]不可小於0", "1", txt_DISC_UAMT.ClientID); }
            if (i_DISC_TAX < 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓稅額]不可小於0", "1", txt_DISC_TAX.ClientID); }
            if (i_DISC_AMT <= 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[總金額]不可小於或等於0", "1", txt_DISC_AMT.ClientID); }
            if (i_DISC_UAMT == 0 && i_DISC_TAX != 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓金額(未稅)]為0時,欄位[折讓稅額]也必須為0", "1", txt_DISC_TAX.ClientID); }
            if (i_DISC_UAMT + i_DISC_TAX != i_DISC_AMT)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓金額(未稅)]加上欄位[折讓稅額]必須等於欄位[總金額]", "1", txt_DISC_AMT.ClientID); }
            if (this.slp_TAX_TYPE.Text == "1" ||//[稅別]=免稅
                this.slp_TAX_TYPE.Text == "2")//[稅別]=零稅
            {
                if (i_DISC_TAX != 0)
                { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[稅別]是免稅或零稅時,欄位[折讓稅額]必須為0", "1", txt_DISC_TAX.ClientID); }
            }

            #endregion

            #region 檢查如果己月結則[折讓金額(未稅)][折讓稅額][總金額]要與原始金額相同

            if (b_IsClose == true)//該月份已月結
            {
                if (this.hid_Original_DISC_UAMT.Value.Trim() != this.slp_DISC_UAMT.Text.Trim())
                { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[結帳年月]" + this.slp_CLOSE_MONTH.Text + "該月份己月結,欄位[折讓金額(未稅)]的金額必須等於原始折讓金額(未稅)" + this.hid_Original_DISC_UAMT.Value.Trim() + "元", "1", txt_DISC_UAMT.ClientID); }
                if (this.hid_Original_DISC_TAX.Value.Trim() != this.slp_DISC_TAX.Text.Trim())
                { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[結帳年月]" + this.slp_CLOSE_MONTH.Text + "該月份己月結,欄位[折讓稅額]的金額必須等於原始折讓稅額" + this.hid_Original_DISC_TAX.Value.Trim() + "元", "1", txt_DISC_TAX.ClientID); }
                if (this.hid_Original_DISC_AMT.Value.Trim() != Request[txt_DISC_AMT.UniqueID].ToString().Trim())
                { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[結帳年月]" + this.slp_CLOSE_MONTH.Text + "該月份己月結,欄位[總金額]的金額必須等於原始折讓稅額" + this.hid_Original_DISC_AMT.Value.Trim() + "元", "1", txt_DISC_AMT.ClientID); }
            }

            #endregion

            #region 檢查下列情況如果已月結則修改後的金額必須等於原始金額

            if (b_IsClose == true)//該月份已月結
            {
                if (s_ReturnMsg == "勾選欄位[憑證已回]" ||
                    s_ReturnMsg == "取消勾選欄位[憑證已回]" ||
                    s_ReturnMsg == "取消勾選欄位[取具進項憑証]" ||
                    s_ReturnMsg == "都沒有勾")
                {
                    int i_IsClose_DISC_UAMT = 0;
                    int i_IsClose_DISC_TAX = 0;
                    int i_IsClose_DISC_AMT = 0;

                    foreach (DataRow drRow in dt_NewItem.Rows)
                    {
                        i_IsClose_DISC_UAMT += int.Parse(drRow["DISC_UAMT"].ToString());//折讓金額(未稅)
                        i_IsClose_DISC_TAX += int.Parse(drRow["DISC_TAX"].ToString());//折讓稅額
                        i_IsClose_DISC_AMT += int.Parse(drRow["DISC_AMT"].ToString());//總金額
                    }

                    if (this.hid_Original_DISC_UAMT.Value.Trim() != i_IsClose_DISC_UAMT.ToString())
                    { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[結帳年月]" + this.slp_CLOSE_MONTH.Text + "已月結,折讓項目的折讓金額(未稅):" + i_IsClose_DISC_UAMT.ToString() + "元,不等於原始折讓金額(未稅):" + this.hid_Original_DISC_UAMT.Value + "元", "1", string.Empty); }
                    if (this.hid_Original_DISC_TAX.Value.Trim() != i_IsClose_DISC_TAX.ToString())
                    { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[結帳年月]" + this.slp_CLOSE_MONTH.Text + "已月結,折讓項目的折讓稅額:" + i_IsClose_DISC_TAX.ToString() + "元,不等於原始折讓稅額:" + this.hid_Original_DISC_TAX.Value + "元", "1", string.Empty); }
                    if (this.hid_Original_DISC_AMT.Value.Trim() != i_IsClose_DISC_AMT.ToString())
                    { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[結帳年月]" + this.slp_CLOSE_MONTH.Text + "已月結,折讓項目的總金額:" + i_IsClose_DISC_AMT.ToString() + "元,不等於原始總金額:" + this.hid_Original_DISC_AMT.Value + "元", "1", string.Empty); }
                }
            }

            #endregion

            #region 檢查欄位[憑證已回]若已勾選,則欄位[憑證已回日期]為必填欄位

            if (this.chb_PROOF_FLG.Checked == true && this.slp_PROOF_DATE.Text.Trim() == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[憑證已回]若有勾選,則欄位[憑證已回日期]為必填欄位", "1", txt_PROOF_DATE.ClientID); }

            #endregion

            #region 檢查欄位[憑證已回日期]若有值,則欄位[憑證已回]或[取具進項憑証]或[取具收據]必須勾選

            if ((this.chb_PROOF_FLG.Checked == false && this.chb_REPROOF_FLG.Checked == false && this.chb_RECEIPT_FLG.Checked == false) == true &&
                this.slp_PROOF_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[憑證已回日期]若有值,則欄位[憑證已回]或[取具進項憑証]或[取具收據]必須勾選", "1", string.Empty); }

            #endregion

            #region 檢查欄位[取具進項憑証]若已勾選,則欄位[憑證已回日期]為必填欄位

            if (this.chb_REPROOF_FLG.Checked == true && this.slp_PROOF_DATE.Text == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[取具進項憑証]若已勾選,則欄位[憑證已回日期]為必填欄位", "1", txt_PROOF_DATE.ClientID); }

            #endregion

            #region 檢查欄位[取具進項憑証]若已勾選,則欄位[發票號碼/收據]為必填欄位

            if (this.chb_REPROOF_FLG.Checked == true && this.txt_REPROOF_NO.Text == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[取具進項憑証]若已勾選,則欄位[發票號碼/收據]為必填欄位", "1", this.txt_REPROOF_NO.ClientID); }

            #endregion

            #region 檢查欄位[發票號碼/收據]若有值,則欄位[取具進項憑証]必須勾選

            if (this.chb_REPROOF_FLG.Checked == false && this.txt_REPROOF_NO.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[發票號碼/收據]若有值,則欄位[取具進項憑証]必須勾選", "1", string.Empty); }

            #endregion

            #region 檢查欄位[取具收據]若已勾選,則欄位[憑證已回日期]為必填欄位

            if (this.chb_RECEIPT_FLG.Checked == true && this.slp_PROOF_DATE.Text == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[取具收據]若已勾選,則欄位[憑證已回日期]為必填欄位", "1", txt_PROOF_DATE.ClientID); }

            #endregion

            #region 檢查欄位[作廢]若已勾選,則欄位[作廢日期]為必填欄位

            if (this.chb_CANCEL_FLG.Checked == true && this.slp_CANCEL_DATE.Text.Trim() == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[作廢]若有勾選,則欄位[作廢日期]為必填欄位", "1", txt_CANCEL_DATE.ClientID); }

            #endregion

            #region 檢查[總金額][沖帳餘額],若有沖帳過,則不允許作廢

            #region 規則

            /* 20100325秀玲新增此判斷需求
             * 如果該張折讓單的[DISC_REMAIN_AMT](沖帳金額) & [DISC_AMT](總金額)金額不相符
             * 代表該張折讓單已經沖帳過,不允許作廢。*/

            #endregion

            if (this.chb_CANCEL_FLG.Checked == true || this.slp_CANCEL_DATE.Text.Trim() != string.Empty)
            {
                if (dt_Main.Rows[0]["DISC_REMAIN_AMT"].ToString() != dt_Main.Rows[0]["DISC_AMT"].ToString())
                { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "折讓單已沖帳,不允許作廢", "1", string.Empty); }
            }

            #endregion

            #region 檢查欄位[作廢日期]若有值,則欄位[作廢]必須勾選

            if (this.chb_CANCEL_FLG.Checked == false && this.slp_CANCEL_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[作廢日期]若有值,則欄位[作廢]必須勾選", "1", string.Empty); }

            #endregion

            #region 檢查欄位[轉暫收]若已勾選,則欄位[暫收日期]為必填欄位

            if (this.chb_TEMPORAL_FLG.Checked == true && this.slp_TEMPORAL_DATE.Text.Trim() == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[轉暫收]若有勾選,則欄位[暫收日期]為必填欄位", "1", txt_TEMPORAL_DATE.ClientID); }

            #endregion

            #region 檢查欄位[暫收日期]若有值,則欄位[轉暫收]必須勾選

            if (this.chb_TEMPORAL_FLG.Checked == false && this.slp_TEMPORAL_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[暫收日期]若有值,則欄位[轉暫收]必須勾選", "1", string.Empty); }

            #endregion

            #region 檢查欄位[憑證已回][取具進項憑証][取具收據]三個欄位只能擇一勾選

            int i_Check_Count = 0;

            i_Check_Count += this.chb_PROOF_FLG.Checked == true ? 1 : 0;//憑證已回
            i_Check_Count += this.chb_REPROOF_FLG.Checked == true ? 1 : 0;//取具進項憑証
            i_Check_Count += this.chb_RECEIPT_FLG.Checked == true ? 1 : 0;//取具收據

            if (i_Check_Count > 1)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[憑證已回][取具進項憑証][取具收據]三個欄位只能擇一勾選", "1", string.Empty); }

            #endregion

            #region 檢查欄位[取具收據]如果有勾選,則欄位[折讓稅額]必須為0

            if (this.chb_RECEIPT_FLG.Checked == true &&
                this.slp_DISC_TAX.Text != "0")
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[取具收據]如果有勾選,則欄位[折讓稅額]必須為0", "1", this.slp_DISC_TAX.TextBox_Code.ClientID); }

            #endregion

            #endregion
        }

        #endregion

        #endregion

        #region BUTTON [折讓開立]鈕

        else if (s_Type == "BUTTON [折讓開立]鈕")
        {
            #region 檢查欄位的Byte長度

            if (CAAComm.Get_Byte_Length(this.txt_ACT_DISC_NO.Text) > 13)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[財會折讓單號]長度不可大於 13 Byte", "1", this.txt_ACT_DISC_NO.ClientID); }
            if (CAAComm.Get_Byte_Length(this.txt_REPROOF_NO.Text) > 12)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[發票號碼/收據]長度不可大於 12 Byte", "1", this.txt_REPROOF_NO.ClientID); }
            if (CAAComm.Get_Byte_Length(this.txt_RFNO.Text) > 10)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[統一編號]長度不可大於 10 Byte", "1", this.txt_RFNO.ClientID); }
            if (CAAComm.Get_Byte_Length(this.txt_MEMO.Text) > 200)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[備註]長度不可大於 200 Byte", "1", this.txt_MEMO.ClientID); }

            #endregion

            #region 檢查SLP日期格式

            arl_Return = CAAComm.Check_Format_Date(this.slp_DISC_DATE.Text, "欄位[折讓日期]日期格式錯誤", "1", txt_DISC_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_CHG_DISC_DATE.Text, "欄位[異動折讓日期]日期格式錯誤", "1", txt_DISC_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_PROOF_DATE.Text, "欄位[憑證已回日期]日期格式錯誤", "1", txt_PROOF_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_CANCEL_DATE.Text, "欄位[作廢日期]日期格式錯誤", "1", txt_CANCEL_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_PERIOD_DATE.Text, "欄位[申報日期]日期格式錯誤", "1", txt_PERIOD_DATE.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Date(this.slp_TEMPORAL_DATE.Text, "欄位[暫收日期]日期格式錯誤", "1", txt_TEMPORAL_DATE.ClientID, arl_Return);

            #endregion

            #region 檢查SLP數字格式

            arl_Return = CAAComm.Check_Format_Int(this.slp_DISC_UAMT.Text, "欄位[折讓金額(未稅)]數字格式錯誤", "32", "1", txt_DISC_UAMT.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Int(this.slp_DISC_TAX.Text, "欄位[折讓稅額]數字格式錯誤", "32", "1", txt_DISC_TAX.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Int(Request[txt_DISC_AMT.UniqueID].ToString(), "欄位[總金額]數字格式錯誤", "32", "1", txt_DISC_AMT.ClientID, arl_Return);

            #endregion

            #region 檢查SLP年月格式

            arl_Return = CAAComm.Check_Format_YearMonth(this.slp_CLOSE_MONTH.Text, "欄位[結帳年月]年月格式錯誤", "1", txt_CLOSE_MONTH.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_YearMonth(this.slp_CLOSE_MONTH_ACCT.Text, "欄位[結帳年月-財會]年月格式錯誤", "1", this.slp_CLOSE_MONTH_ACCT.TextBoxCode_Object.ClientID, arl_Return);

            #endregion

            #region 檢查必填欄位

            arl_Return = CAAComm.Check_MustFillin_Column(drop_DISC_SOURCE.SelectedIndex.ToString(), "drop", "欄位[來源]為必填欄位", "1", string.Empty, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_STORE_ID.Text, "text", "欄位[店號]為必填欄位", "1", txt_STORE_ID.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(drop_DISC_TYPE.SelectedIndex.ToString(), "drop", "欄位[型式]為必填欄位", "1", string.Empty, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(drop_TAX_TYPE.SelectedIndex.ToString(), "drop", "欄位[稅別]為必填欄位", "1", string.Empty, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_ROOT_NO.Text, "text", "欄位[商品群分類]為必填欄位", "1", txt_ROOT_NO.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_CLOSE_MONTH.Text, "text", "欄位[結帳年月]為必填欄位", "1", txt_CLOSE_MONTH.ClientID, arl_Return);

            #endregion

            #region 如果基本檢查有誤,則Return

            if (arl_Return[1].ToString() != string.Empty)
            { return arl_Return; }

            #endregion

            #region 自訂檢查

            #region 新增模式下欄位[來源]必須是選擇人工開立

            if (this.slp_DISC_SOURCE.Text != "2")//2代表是人工開立
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[來源]必須是選擇人工開立", "1", drop_DISC_SOURCE.ClientID); }

            #endregion

            #region 新增模式下欄位[作廢]不能勾選

            if (this.chb_CANCEL_FLG.Checked == true)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[作廢]不能勾選", "1", chb_CANCEL_FLG.ClientID); }

            #endregion

            #region 新增模式下欄位[作廢日期]必須為空白

            if (this.slp_CANCEL_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[作廢日期]必須為空白", "1", txt_CANCEL_DATE.ClientID); }

            #endregion

            #region 新增模式下欄位[申報]不能勾選

            if (this.chb_PERIOD_FLG.Checked == true)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[申報]不能勾選", "1", chb_PERIOD_FLG.ClientID); }

            #endregion

            #region 新增模式下欄位[申報日期]必須為空白

            if (this.slp_PERIOD_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[申報日期]必須為空白", "1", txt_PERIOD_DATE.ClientID); }

            #endregion

            #region 新增模式下欄位[轉暫收]不能勾選

            if (this.chb_TEMPORAL_FLG.Checked == true)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[轉暫收]不能勾選", "1", chb_TEMPORAL_FLG.ClientID); }

            #endregion

            #region 新增模式下欄位[暫收日期]必須為空白

            if (this.slp_TEMPORAL_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "新增模式下欄位[暫收日期]必須為空白", "1", txt_TEMPORAL_DATE.ClientID); }

            #endregion

            #region 檢查若己月結則不允許新增

            #region 傳入參數

            ParameterList.Clear();
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CLOSE_MONTH.Text, "string", false));//[結帳年月]
            ParameterList.Add(CAAComm.GetValueSetParameter("CAA18", "string", false)); //V_FUNC_NO

            #endregion

            #region 連結資料庫

            BCO.ChanMonthCloseYN bco_Is_Close = new BCO.ChanMonthCloseYN(ConntionDB);

            #endregion

            #region 檢查回傳資料

            //回傳結果=Y,該月份已月結
            //回傳結果=N,該月份尚未月結
            if (((ArrayList)bco_Is_Close.GetChanMonthCloseStatus(ParameterList, null))[0].ToString() == "Y")
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[結帳年月]該月份已月結", "1", txt_CLOSE_MONTH.ClientID); }

            #endregion

            #endregion

            #region 檢查欄位[憑證已回]若已勾選,則欄位[憑證已回日期]為必填欄位

            if (this.chb_PROOF_FLG.Checked == true && this.slp_PROOF_DATE.Text.Trim() == string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[憑證已回]若有勾選,則欄位[憑證已回日期]為必填欄位", "1", txt_PROOF_DATE.ClientID); }

            #endregion

            #region 檢查欄位[憑證已回日期]若有值,則欄位[憑證已回]或[取具進項憑証]必須勾選

            if ((this.chb_PROOF_FLG.Checked == false && this.chb_REPROOF_FLG.Checked == false) == true
                && this.slp_PROOF_DATE.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[憑證已回日期]若有值,則欄位[憑證已回]或[取具進項憑証]必須勾選", "1", string.Empty); }

            #endregion

            #region 檢查欄位[取具進項憑証]若已勾選,則不允許按[折讓開立]鈕

            if (this.chb_REPROOF_FLG.Checked == true)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[取具進項憑証]若已勾選,則不允許按[折讓開立]鈕", "1", string.Empty); }

            #endregion

            #region 檢查欄位[發票號碼/收據]若有值,則欄位[取具進項憑証]必須勾選

            if (this.chb_REPROOF_FLG.Checked == false && this.txt_REPROOF_NO.Text.Trim() != string.Empty)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[發票號碼/收據]若有值,則欄位[取具進項憑証]必須勾選", "1", string.Empty); }

            #endregion

            #endregion
        }

        #endregion

        #region 折讓項目 BUTTON [確認]鈕

        else if (s_Type == "折讓項目 BUTTON [確認]鈕")
        {
            #region 檢查SLP日期格式

            arl_Return = CAAComm.Check_Format_Date(this.slp_Disc_INV_DATE.Text, "欄位[發票日期]日期格式錯誤", "1", txt_Disc_INV_DATE.ClientID, arl_Return);

            #endregion

            #region 檢查SLP數字格式

            arl_Return = CAAComm.Check_Format_Int(this.slp_Disc_DISC_UAMT.Text, "欄位[折讓金額(未稅)]數字格式錯誤", "32", "1", txt_Disc_DISC_UAMT.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Int(Request[txt_Disc_DISC_TAX.UniqueID].ToString(), "欄位[折讓稅額]數字格式錯誤", "32", "1", txt_Disc_DISC_TAX.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Int(this.slp_Disc_NON_INV_UAMT.Text, "欄位[發票餘額(未稅)]數字格式錯誤", "32", "1", txt_Disc_NON_INV_UAMT.ClientID, arl_Return);
            arl_Return = CAAComm.Check_Format_Int(this.slp_Disc_NON_INV_TAX.Text, "欄位[發票稅額]數字格式錯誤", "32", "1", txt_Disc_NON_INV_TAX.ClientID, arl_Return);

            #endregion

            #region 檢查必填欄位

            arl_Return = CAAComm.Check_MustFillin_Column(this.txt_Disc_INV_NO.Text, "text", "欄位[發票號碼]為必填欄位", "1", this.txt_Disc_INV_NO.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_Disc_DISC_UAMT.Text, "text", "欄位[折讓金額(未稅)]為必填欄位", "1", txt_Disc_DISC_UAMT.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(Request[txt_Disc_DISC_TAX.UniqueID].ToString(), "text", "欄位[折讓稅額]為必填欄位", "1", txt_Disc_DISC_TAX.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_Disc_NON_INV_UAMT.Text, "text", "欄位[發票餘額(未稅)]為必填欄位", "1", txt_Disc_NON_INV_UAMT.ClientID, arl_Return);
            arl_Return = CAAComm.Check_MustFillin_Column(this.slp_Disc_NON_INV_TAX.Text, "text", "欄位[發票稅額]為必填欄位", "1", txt_Disc_NON_INV_TAX.ClientID, arl_Return);

            #endregion

            #region 如果基本檢查有誤,則Return

            if (arl_Return[1].ToString() != string.Empty)
            { return arl_Return; }

            #endregion

            #region 自訂檢查

            int i_Disc_DISC_UAMT = int.Parse(this.slp_Disc_DISC_UAMT.Text);//折讓金額(未稅)
            int i_Disc_DISC_TAX = int.Parse(Request[txt_Disc_DISC_TAX.UniqueID].ToString());//折讓稅額
            int i_Total_NON_INV_UAMT = int.Parse(this.hid_Disc_Total_NON_INV_UAMT.Value);//發票餘額(未稅)+折讓金額(未稅)
            int i_Total_NON_INV_TAX = int.Parse(this.hid_Disc_Total_NON_INV_TAX.Value);//發票稅額+折讓稅額

            if (i_Disc_DISC_UAMT < 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓金額(未稅)]不可小於0", "1", txt_Disc_DISC_UAMT.ClientID); }
            if (i_Disc_DISC_TAX < 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓稅額]不可小於0", "1", txt_Disc_DISC_TAX.ClientID); }
            if (i_Disc_DISC_UAMT == 0 && i_Disc_DISC_TAX != 0)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓金額(未稅)]為0時,欄位[折讓稅額]也必須為0", "1", txt_Disc_DISC_TAX.ClientID); }
            if (i_Disc_DISC_UAMT > i_Total_NON_INV_UAMT)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓金額(未稅)]不得大於[發票餘額(未稅)]", "1", txt_Disc_DISC_UAMT.ClientID); }
            if (i_Disc_DISC_TAX > i_Total_NON_INV_TAX)
            { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[折讓稅額]不得大於[發票稅額]", "1", txt_Disc_DISC_TAX.ClientID); }
            if (this.slp_TAX_TYPE.Text == "1" ||//[稅別]=免稅
                this.slp_TAX_TYPE.Text == "2")//[稅別]=零稅
            {
                if (i_Disc_DISC_TAX != 0)
                { arl_Return = CAAComm.ToMakeUp_Err_ArrayList(arl_Return, "欄位[稅別]是免稅或零稅時,欄位[折讓稅額]必須為0", "1", txt_Disc_DISC_TAX.ClientID); }
            }

            #endregion
        }

        #endregion

        return arl_Return;
    }
Esempio n. 3
0
        /// <summary>
        /// 設定折讓對帳單列印資料
        /// </summary>
        /// <param name="dt_Temp_Result">折讓對帳單列印資料 Temp Table</param>
        /// <param name="d_Now">列印日期時間</param>
        /// <param name="dr_Temp_Main1">折讓對帳單左邊主檔資料區</param>
        /// <param name="dr_Temp_Main2">折讓對帳單右邊發票資料區</param>
        /// <param name="dr_Temp_Detl_Purchase">折讓對帳單進貨明細資料區</param>
        /// <param name="dr_Temp_Detl_Return">折讓對帳單退貨明細資料區</param>
        /// <param name="dr_Temp_Store">折讓對帳單店號相關資料</param>
        /// <param name="s_TAB_Index">2=折讓對帳單,4=單店未開發票對帳單</param>
        /// <returns></returns>
        private DataTable Collate_Information_Disc(DataTable dt_Temp_Result,
                                                   DateTime d_Now,
                                                   DataRow[] dr_Temp_Main1,
                                                   DataRow[] dr_Temp_Main2,
                                                   DataRow[] dr_Temp_Detl_Purchase,
                                                   DataRow[] dr_Temp_Detl_Return,
                                                   DataRow[] dr_Temp_Store,
                                                   string s_TAB_Index,
                                                   string strPROMTE)
        {
            #region 錯誤資料

            //沒有明細資料 OR 沒有店號的資料皆屬於錯誤資料
            if ((dr_Temp_Detl_Purchase == null && dr_Temp_Detl_Return == null) ||
                (dr_Temp_Store == null))
            {
                DataRow dr_Temp_Result = dt_Temp_Result.NewRow();
                string s_Err_Disc_No = string.Empty;

                foreach (DataRow dr_Main1 in dr_Temp_Main1)
                {
                    if (s_Err_Disc_No == string.Empty)
                    { s_Err_Disc_No += dr_Main1["DISC_NO"].ToString(); }
                    else
                    { s_Err_Disc_No += "," + dr_Main1["DISC_NO"].ToString(); }
                }

                dr_Temp_Result["MAIN_LEFT_14"] = "資料異常,無法正確列印對帳單,折讓單號碼:" + s_Err_Disc_No;

                dt_Temp_Result.Rows.Add(dr_Temp_Result);
            }

            #endregion

            #region 正確資料

            else
            {
                #region 設定變數

                #region 列印日期 and 時間

                string s_Print_Date = d_Now.ToString("yyyy/MM/dd");//列印日期
                string s_Print_Time = d_Now.ToString("HH:mm:ss");//列印時間

                #endregion

                #region 設定行數

                int i_Detl_Count = 50;//設定Detl明細資料總共有幾行(包含[頁首][內容]頁尾[小計][單店小計][總計])
                int i_Detl_Title = 4;//設定Detl頁首有幾行
                int i_Detl_Total = 10;//設定Detl頁尾[小計][單店小計]&[總計]共有幾行
                int i_Detl_Content = i_Detl_Count - i_Detl_Title;//設定Detl內容行數
                bool b_IsFinally = false;//設定明細資料是否為最後一筆
                int i_Actual_Total = 0;//設定Detl頁尾單店小計&總計執行到第幾筆

                #endregion

                #region 設定折讓單號碼

                string s_DISC_NO_Able = string.Empty;//應稅發票號碼
                string s_DISC_NO_Free = string.Empty;//免稅發票號碼
                string s_DISC_NO_Zero = string.Empty;//零稅率發票號碼

                #endregion

                #region 計算[小計]金額

                decimal dec_Subtotal_TOT_AMT_Purchase = 0;//[小計]-進貨未稅金額
                decimal dec_Subtotal_TOT_AMT_AND_TAX_Purchase = 0;//[小計]-進貨含稅金額
                decimal dec_Subtotal_TOT_AMT_Return = 0;//[小計]-退貨未稅金額
                decimal dec_Subtotal_TOT_AMT_AND_TAX_Return = 0;//[小計]-退貨含稅金額

                #endregion

                #region 計算[單店小計]金額

                decimal dec_Single_Amount_Able = 0;//單店小計-[應稅]的[合計]
                decimal dec_Single_Amount_Free = 0;//單店小計-[免稅]的[合計]
                decimal dec_Single_Amount_Zero = 0;//單店小計-[零稅]的[合計]
                decimal dec_Single_Tax_Able = 0;//單店小計-[應稅]的[稅額]
                decimal dec_Single_Tax_Zero = 0;//單店小計-[零稅]的[稅額]

                #endregion

                #region 計算[總計]金額

                int i_Total_Amount_Able = 0;//總計-[應稅]的[未稅金額]
                int i_Total_Amount_Free = 0;//總計-[免稅]的[未稅金額]
                int i_Total_Amount_Zero = 0;//總計-[零稅]的[未稅金額]
                int i_Total_Tax_Able = 0;//總計-[應稅]的[稅額]
                int i_Total_Tax_Zero = 0;//總計-[零稅]的[稅額]
                int i_Total_Disc_Able = 0;//總計-[應稅]的[折讓總額]
                int i_Total_Disc_Free = 0;//總計-[免稅]的[折讓總額]
                int i_Total_Disc_Zero = 0;//總計-[零稅]的[折讓總額]

                #endregion

                #endregion

                #region 計算需要幾頁來印這一筆資料

                #region 設定變數

                int i_dt_Temp_Result_Count_Inv = 0;//計算右邊主檔發票資料需要幾頁來列印
                int i_dt_Temp_Result_Count_Purchase = 0;//計算進貨的DETL資料需要幾頁來列印
                int i_dt_Temp_Result_Count_Return = 0;//計算退貨的DETL資料需要幾頁來列印
                int i_dt_Temp_Result_Count = 0;//最後需要幾頁來列印
                ArrayList arl_Inv_Statistics = new ArrayList();
                ArrayList arl_Disc_Statistics = new ArrayList();

                #endregion

                #region 計算右邊主檔發票資料需要幾頁來列印

                if (s_TAB_Index == "2")//折讓對帳單
                {
                    DataTable dt_Temp_Right = new DataTable();

                    for (int i_Main1 = 0; i_Main1 < dr_Temp_Main1.Length; i_Main1++)
                    {
                        #region 設定變數

                        int i_Main2_Statistics = 0;//計算該張折讓單對應到的發票張數

                        #endregion

                        #region 計算每一張折讓單需要幾頁來列印

                        //算出該張折讓單對應到幾筆發票資料
                        for (int i_Main2 = 0; i_Main2 < dr_Temp_Main2.Length; i_Main2++)
                        {
                            if (dr_Temp_Main1[i_Main1]["DISC_NO"].ToString() == dr_Temp_Main2[i_Main2]["DISC_NO"].ToString())
                            {
                                i_Main2_Statistics += 1;

                                //將資料存入ArrayList中
                                //文字陣列有2個參數
                                //(1)折讓單號在dr_Temp_Main1陣列中是第幾筆資料
                                //(2)發票號碼在dr_Temp_Main2陣列中是第幾筆資料
                                arl_Inv_Statistics.Add(new string[] { i_Main1.ToString(), i_Main2.ToString() });
                            }
                        }

                        //計算該張折讓單需要幾頁列印
                        if (i_Main2_Statistics % 5 > 0)
                        { i_Main2_Statistics = (i_Main2_Statistics / 5) + 1; }
                        else
                        { i_Main2_Statistics = i_Main2_Statistics / 5; }

                        //將資料存入ArrayList中
                        //文字陣列有2個參數
                        //(1)折讓單號
                        //(2)該張折讓單需要幾頁來顯示
                        //(3)該張折讓單已經顯示幾頁
                        arl_Disc_Statistics.Add(new string[] { dr_Temp_Main1[i_Main1]["DISC_NO"].ToString(), i_Main2_Statistics.ToString(), "0" });

                        #endregion

                        #region 不滿五筆資料中間補空白

                        for (int q = 0; q < arl_Inv_Statistics.Count % 5; q++)
                        { arl_Inv_Statistics.Add("空白"); }

                        #endregion

                        i_dt_Temp_Result_Count_Inv += i_Main2_Statistics;
                    }
                }

                #endregion

                #region 計算進貨的DETL資料需要幾頁來列印

                i_dt_Temp_Result_Count_Purchase = (dr_Temp_Detl_Purchase.Length + i_Detl_Total) / i_Detl_Content;
                if ((dr_Temp_Detl_Purchase.Length + i_Detl_Total) % i_Detl_Content > 0)
                { i_dt_Temp_Result_Count_Purchase += 1; }

                #endregion

                #region 計算退貨的DETL資料需要幾頁來列印

                i_dt_Temp_Result_Count_Return = (dr_Temp_Detl_Return.Length + i_Detl_Total) / i_Detl_Content;
                if ((dr_Temp_Detl_Return.Length + i_Detl_Total) % i_Detl_Content > 0)
                { i_dt_Temp_Result_Count_Return += 1; }

                #endregion

                //取最大值
                i_dt_Temp_Result_Count = Math.Max(i_dt_Temp_Result_Count_Inv, Math.Max(i_dt_Temp_Result_Count_Purchase, i_dt_Temp_Result_Count_Return));

                #region 把紀錄發票的變數的筆數補滿最大的頁數

                //折讓對帳單,有可能左邊明細資料需要5頁來印,但右邊發票只要1頁來印就可以
                //這時紀錄發票的變數(arl_Inv_Statistics)只有紀錄第一頁的五筆資料,2,3,4,5頁都沒紀錄,
                //所以要在這邊補滿"空白"這個字串,不然後面程式判斷會有誤

                if (i_dt_Temp_Result_Count * 5 > arl_Inv_Statistics.Count)
                {
                    int i_fill = i_dt_Temp_Result_Count * 5 - arl_Inv_Statistics.Count;

                    for (int i_fill_variable = 0; i_fill_variable < i_fill; i_fill_variable++)
                    { arl_Inv_Statistics.Add("空白"); }
                }

                #endregion

                #endregion

                #region 計算總計金額 & 紀錄折讓單號

                foreach (DataRow dr_Main1 in dr_Temp_Main1)
                {
                    #region 應稅

                    if (dr_Main1["TAX_TYPE"].ToString() == "0")
                    {
                        i_Total_Amount_Able += int.Parse(dr_Main1["DISC_UAMT"].ToString());//總計-[應稅]的[未稅金額]
                        i_Total_Tax_Able += int.Parse(dr_Main1["DISC_TAX"].ToString());//總計-[應稅]的[稅額]
                        i_Total_Disc_Able += int.Parse(dr_Main1["DISC_AMT"].ToString());//總計-[應稅]的[折讓總額]

                        s_DISC_NO_Able += (s_DISC_NO_Able == string.Empty) ? dr_Main1["DISC_NO"].ToString() : "," + dr_Main1["DISC_NO"].ToString();
                    }

                    #endregion

                    #region 免稅

                    else if (dr_Main1["TAX_TYPE"].ToString() == "1")
                    {
                        i_Total_Amount_Free += int.Parse(dr_Main1["DISC_UAMT"].ToString());//總計-[免稅]的[未稅金額]
                        i_Total_Disc_Free += int.Parse(dr_Main1["DISC_AMT"].ToString());//總計-[免稅]的[折讓總額]

                        s_DISC_NO_Free += (s_DISC_NO_Free == string.Empty) ? dr_Main1["DISC_NO"].ToString() : "," + dr_Main1["DISC_NO"].ToString();
                    }

                    #endregion

                    #region 零稅

                    else if (dr_Main1["TAX_TYPE"].ToString() == "2")
                    {
                        i_Total_Amount_Zero += int.Parse(dr_Main1["DISC_UAMT"].ToString());//總計-[零稅]的[未稅金額]
                        i_Total_Tax_Zero += int.Parse(dr_Main1["DISC_TAX"].ToString());//總計-[零稅]的[稅額]
                        i_Total_Disc_Zero += int.Parse(dr_Main1["DISC_AMT"].ToString());//總計-[零稅]的[折讓總額]

                        s_DISC_NO_Zero += (s_DISC_NO_Zero == string.Empty) ? dr_Main1["DISC_NO"].ToString() : "," + dr_Main1["DISC_NO"].ToString();
                    }

                    #endregion
                }

                #endregion

                #region 將資料寫入TempTable

                for (int a = 0; a < i_dt_Temp_Result_Count; a++)
                {
                    DataRow dr_Temp_Result = dt_Temp_Result.NewRow();

                    #region 左邊主檔資料區

                    dr_Temp_Result["MAIN_LEFT_0"] = "列印日期:" + s_Print_Date;//列印日期
                    dr_Temp_Result["MAIN_LEFT_1"] = "列印時間:" + s_Print_Time;//列印時間
                    dr_Temp_Result["MAIN_LEFT_2"] = Convert.ToString(a + 1) + "/" + i_dt_Temp_Result_Count.ToString();//頁次
                    dr_Temp_Result["MAIN_LEFT_3"] = dr_Temp_Store[0]["Z_O"].ToString();//營業所
                    dr_Temp_Result["MAIN_LEFT_4"] = dr_Temp_Store[0]["ROUTE"].ToString();//路線
                    dr_Temp_Result["MAIN_LEFT_5"] = dr_Temp_Store[0]["STEP"].ToString();//路順
                    dr_Temp_Result["MAIN_LEFT_6"] = dr_Temp_Store[0]["D_SIR_NAME"].ToString();//物流士
                    dr_Temp_Result["MAIN_LEFT_7"] = dr_Temp_Store[0]["CLOSE_MONTH"].ToString();//結帳年月
                    dr_Temp_Result["MAIN_LEFT_8"] = dr_Temp_Store[0]["GROUP_NO"].ToString();//店群
                    dr_Temp_Result["MAIN_LEFT_9"] = dr_Temp_Store[0]["STORE"].ToString();//店號
                    dr_Temp_Result["MAIN_LEFT_10"] = dr_Temp_Store[0]["STORE_NAME"].ToString();//店名
                    dr_Temp_Result["MAIN_LEFT_11"] = dr_Temp_Store[0]["STORE_TEL"].ToString();//電話
                    dr_Temp_Result["MAIN_LEFT_12"] = dr_Temp_Store[0]["AC_UID"].ToString();//帳務人員
                    dr_Temp_Result["MAIN_LEFT_13"] = dr_Temp_Store[0]["INV_ADDR"].ToString();//地址
                    dr_Temp_Result["MAIN_LEFT_15"] = dr_Temp_Store[0]["SAL_ID"].ToString();//帳務人員
                    #endregion

                    #region 訊息告知欄位區

                    dr_Temp_Result["MAIN_LEFT_14"] = strPROMTE;//檔期編號 20110427 rika insert

                    #endregion

                    #region 右邊主檔資料區(印發票的地方)

                    //頁籤=[折讓對帳單]時,才有右邊主檔資料區
                    if (s_TAB_Index == "2")//折讓對帳單
                    {
                        #region 設定變數

                        #region 規則

                        /*
                         * 折讓對帳單右邊列印發票部份為一式四份,每一式可列印五張發票
                         * 折讓單必須分別列印
                         * EX:
                         * 假設STORE1在同一天有A,B兩張折讓單
                         * A折讓單對應6張發票,B折讓單對應3張發票
                         * 則該份折讓對帳單應該列印出三張
                         * 第一張:A折讓單 & 對應的前5張發票
                         * 第二張:A折讓單 & 對應的最後一張發票
                         * 第三張:B折讓單 & 對應的三張發票
                         */

                        #endregion

                        #region 將折讓日期由西元年轉為民國年

                        DateTime d_DISC_DATE = DateTime.Parse(dr_Temp_Main1[0]["DISC_DATE"].ToString());
                        System.Globalization.TaiwanCalendar g_TaiwanCalendar = new System.Globalization.TaiwanCalendar();

                        string s_DISC_Year = g_TaiwanCalendar.GetYear(d_DISC_DATE).ToString(); //折讓日期(年)
                        string s_DISC_Month = g_TaiwanCalendar.GetMonth(d_DISC_DATE).ToString(); //折讓日期(月)
                        string s_DISC_Date = g_TaiwanCalendar.GetDayOfMonth(d_DISC_DATE).ToString(); //折讓日期(日)

                        #endregion

                        string s_VOUCH_RFNO = string.Empty;
                        bool b_Is_Bearing_Page = false;//折讓單[合計]是否顯示"續下頁"
                        string s_Disc_Total_String = string.Empty;

                        #endregion

                        //一張折讓對帳單是[一式四份]
                        for (int b = 0; b < 4; b++)
                        {
                            #region 將發票資料寫入TempTable

                            //一式包含[五張發票]
                            for (int c = 0; c < 5; c++)
                            {
                                if (arl_Inv_Statistics.Count > 0 &&
                                    arl_Inv_Statistics[a * 5 + c].ToString() != "空白")
                                {
                                    int i_dr_Temp_Main2_Count = int.Parse(((string[])(arl_Inv_Statistics[a * 5 + c]))[1].ToString());

                                    #region 將發票日期由西元年轉換成民國年

                                    DateTime d_INV_DATE = DateTime.Parse(dr_Temp_Main2[i_dr_Temp_Main2_Count]["INV_DATE"].ToString());
                                    string s_INV_Year = g_TaiwanCalendar.GetYear(d_INV_DATE).ToString(); //發票日期(年)
                                    string s_INV_Month = g_TaiwanCalendar.GetMonth(d_INV_DATE).ToString(); //發票日期(月)
                                    string s_INV_Date = g_TaiwanCalendar.GetDayOfMonth(d_INV_DATE).ToString(); //發票日期(日)

                                    #endregion

                                    #region 設定[字軌號碼][品名][數量]

                                    BCO.CAACommon CAAComm = new BCO.CAACommon();
                                    string s_Item_Name = string.Empty;
                                    int i_Item_Name_Length = 0;

                                    s_Item_Name = dr_Temp_Main2[i_dr_Temp_Main2_Count]["ITEM_NAME"].ToString().Trim();
                                    i_Item_Name_Length = CAAComm.Get_Byte_Length(s_Item_Name);

                                    //如果[品名]的byte長度超過16,則一次減掉一個字
                                    //減到[品名]的byte長度小於或等於16,則跳出迴圈

                                    if (i_Item_Name_Length > 16)
                                    {
                                        for (int i_Length = 0; i_Length < s_Item_Name.Length; i_Length++)
                                        {
                                            if (CAAComm.Get_Byte_Length(s_Item_Name.Substring(0, s_Item_Name.Length - i_Length)) <= 16)
                                            {
                                                s_Item_Name = s_Item_Name.Substring(0, s_Item_Name.Length - i_Length) + string.Empty.PadRight(16 - CAAComm.Get_Byte_Length(s_Item_Name.Substring(0, s_Item_Name.Length - i_Length)), ' ');
                                                break;
                                            }
                                        }
                                    }
                                    else
                                    { s_Item_Name = s_Item_Name + string.Empty.PadRight(16 - CAAComm.Get_Byte_Length(s_Item_Name), ' '); }

                                    #endregion

                                    #region 將資料寫入Temp Table

                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_0"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["INV_FORM"].ToString();//聯式
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_1"] = s_INV_Year;//年
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_2"] = s_INV_Month;//月
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_3"] = s_INV_Date;//日
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_4"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["INV_NO"].ToString().Trim();//字軌號碼
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_4"] += string.Empty.PadLeft(1, ' ');//字軌號碼與品名之間的空白(全形空白)
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_4"] += s_Item_Name;//品名
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_4"] += string.Empty.PadLeft(1, ' ');//品名與數量之間的空白(全形空白)
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_4"] += "1";//數量
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_5"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["DISC_UAMT"].ToString();//末稅金額
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_6"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["DISC_TAX"].ToString();//稅額
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_7"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["TAX_TYPE"].ToString() == "0" ? "V" : string.Empty;//應稅
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_8"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["TAX_TYPE"].ToString() == "2" ? "V" : string.Empty;//零稅
                                    dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_9"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["TAX_TYPE"].ToString() == "1" ? "V" : string.Empty;//免稅

                                    #endregion
                                }
                            }

                            #endregion

                            #region 如果發票明細有資料,才將折讓單資訊寫入表頭

                            if (dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_0_0"].ToString() != string.Empty)
                            {
                                if (arl_Inv_Statistics.Count > 0 &&
                                    arl_Inv_Statistics[a * 5 + 0].ToString() != "空白")
                                {
                                    /*
                                     * 右邊發票資料是一式四份
                                     * 每一式上方和下方是折讓單資料,中間是發票資料
                                     * 每一張折讓對帳單中的發票資料會對應到同一張折讓單,不會對應到多筆折讓單
                                     * 所以折讓單資料就抓每一式的第一張發票所對應的折讓單
                                     */

                                    int i_dr_Temp_Main1_Count = int.Parse(((string[])(arl_Inv_Statistics[a * 5 + 0]))[0].ToString());

                                    #region 設定欄位[統一編號]

                                    s_VOUCH_RFNO = Get_VOUCH_RFNO(dr_Temp_Main1[i_dr_Temp_Main1_Count]["RFNO"].ToString());

                                    #endregion

                                    #region 設定欄位[合計]的顯示方式

                                    if (b == 0)
                                    {
                                        for (int i_Show_All = 0; i_Show_All < arl_Disc_Statistics.Count; i_Show_All++)
                                        {
                                            string[] s_Disc_Array = (string[])arl_Disc_Statistics[i_Show_All];

                                            if (s_Disc_Array[0].ToString() == dr_Temp_Main1[i_dr_Temp_Main1_Count]["DISC_NO"].ToString())
                                            {
                                                s_Disc_Array[2] = Convert.ToString(Convert.ToInt32(s_Disc_Array[2]) + 1);

                                                if (s_Disc_Array[1] != s_Disc_Array[2])
                                                { b_Is_Bearing_Page = true; }

                                                s_Disc_Total_String = s_Disc_Array[2] + "/" + s_Disc_Array[1];
                                            }
                                        }
                                    }

                                    #endregion

                                    #region 將折讓資料寫入TempTable

                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_0"] = s_DISC_Year;//年
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_1"] = s_DISC_Month;//月
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_2"] = s_DISC_Date;//日
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_3"] = dr_Temp_Main1[i_dr_Temp_Main1_Count]["DISC_NO"].ToString();//折讓單號
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_4"] = dr_Temp_Main1[i_dr_Temp_Main1_Count]["Z_O"].ToString();//營業所
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_5"] = dr_Temp_Main1[i_dr_Temp_Main1_Count]["AC_UID"].ToString();//帳務人員
                                    decimal decDISC_UAMT = decimal.Parse(dr_Temp_Main1[i_dr_Temp_Main1_Count]["DISC_UAMT"].ToString());
                                    decimal decDISC_TAX = decimal.Parse(dr_Temp_Main1[i_dr_Temp_Main1_Count]["DISC_TAX"].ToString());
                                    //if (dr_Temp_Main1[i_dr_Temp_Main1_Count]["DISC_FORM"].ToString().Trim() == "34")
                                    //{
                                    //    decDISC_UAMT = decDISC_UAMT + decDISC_TAX;
                                    //    decDISC_TAX = 0;
                                    //}
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_6"] = (b_Is_Bearing_Page == true) ? "續下頁" : decDISC_UAMT.ToString();//金額(不含稅之進貨額)
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_7"] = (b_Is_Bearing_Page == true) ? string.Empty : decDISC_TAX.ToString();//營業稅額
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_8"] = (b_Is_Bearing_Page == true) ? string.Empty : ((dr_Temp_Main1[i_dr_Temp_Main1_Count]["TAX_TYPE"].ToString() == "0") ? "V" : string.Empty);//應稅
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_9"] = (b_Is_Bearing_Page == true) ? string.Empty : ((dr_Temp_Main1[i_dr_Temp_Main1_Count]["TAX_TYPE"].ToString() == "2") ? "V" : string.Empty);//零稅率
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_10"] = (b_Is_Bearing_Page == true) ? string.Empty : ((dr_Temp_Main1[i_dr_Temp_Main1_Count]["TAX_TYPE"].ToString() == "1") ? "V" : string.Empty);//免稅
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_11"] = dr_Temp_Main1[i_dr_Temp_Main1_Count]["STORE_ID"].ToString() + " " + dr_Temp_Main1[i_dr_Temp_Main1_Count]["TITLE"].ToString();//原進貨營業人(或原買受人)名稱
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_12"] = s_VOUCH_RFNO;//營業事業統一編號
                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_13"] = s_Disc_Total_String;//幾分之幾(1/3,2/3...)

                                    dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_14"] = dr_Temp_Main1[i_dr_Temp_Main1_Count]["PROFIT_NO"].ToString();//利潤中心
                                    #endregion
                                }
                            }
                            else
                            { dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_0_6"] = "空白"; }//品名

                            #endregion
                        }
                    }

                    #endregion

                    #region 明細資料區

                    #region 設定Detl頁首

                    if (b_IsFinally == false)
                    {
                        #region [群分類][書展]

                        dr_Temp_Result["DETL_0_0"] += dr_Temp_Main1[0]["ROOT_NO"].ToString().PadRight(10, ' ');//群分類
                        dr_Temp_Result["DETL_0_0"] += dr_Temp_Main1[0]["IS_SCHEDULE"].ToString().PadRight(10, ' ');//書展
                        dr_Temp_Result["DETL_0_0"] += "可扣款日:";
                        dr_Temp_Result["DETL_0_0"] += (dr_Temp_Main1[0]["DUE_DATE"].ToString() == string.Empty) ? "          " : DateTime.Parse(dr_Temp_Main1[0]["DUE_DATE"].ToString()).ToString("yyyy/MM/dd");
                        dr_Temp_Result["DETL_0_0"] += "     ";
                        dr_Temp_Result["DETL_0_0"] += "可扣款總額:";
                        dr_Temp_Result["DETL_0_0"] += string.Format("{0:#,0}", i_Total_Disc_Able + i_Total_Disc_Free + i_Total_Disc_Zero).PadLeft(10);//總計-[應稅]的[折讓總額]

                        #endregion

                        #region 頁首上面[橫線]

                        dr_Temp_Result["DETL_1_0"] = "-----------";
                        dr_Temp_Result["DETL_1_1"] = "----------------------";
                        dr_Temp_Result["DETL_1_2"] = "----------------------";
                        dr_Temp_Result["DETL_1_3"] = "----------------------";
                        dr_Temp_Result["DETL_1_4"] = "----------------------";
                        dr_Temp_Result["DETL_1_5"] = "----------------------";
                        dr_Temp_Result["DETL_1_6"] = "----------------------";
                        dr_Temp_Result["DETL_1_7"] = "-----|-----";
                        dr_Temp_Result["DETL_1_8"] = "--------------";
                        dr_Temp_Result["DETL_1_9"] = "----------------------";
                        dr_Temp_Result["DETL_1_10"] = "----------------------";
                        dr_Temp_Result["DETL_1_11"] = "----------------------";
                        dr_Temp_Result["DETL_1_12"] = "----------------------";
                        dr_Temp_Result["DETL_1_13"] = "----------------------";
                        dr_Temp_Result["DETL_1_14"] = "----------------------";

                        #endregion

                        #region 頁首[標題]

                        dr_Temp_Result["DETL_2_0"] = "日期";
                        dr_Temp_Result["DETL_2_1"] = "屬性";
                        dr_Temp_Result["DETL_2_2"] = "稅別";
                        dr_Temp_Result["DETL_2_3"] = "高見單號";
                        dr_Temp_Result["DETL_2_4"] = "通路單號";
                        dr_Temp_Result["DETL_2_5"] = "未稅金額";
                        dr_Temp_Result["DETL_2_6"] = "含稅金額";
                        dr_Temp_Result["DETL_2_7"] = "|";
                        dr_Temp_Result["DETL_2_8"] = "日期";
                        dr_Temp_Result["DETL_2_9"] = "屬性";
                        dr_Temp_Result["DETL_2_10"] = "稅別";
                        dr_Temp_Result["DETL_2_11"] = "高見單號";
                        dr_Temp_Result["DETL_2_12"] = "通路單號";
                        dr_Temp_Result["DETL_2_13"] = "未稅金額";
                        dr_Temp_Result["DETL_2_14"] = "含稅金額";

                        #endregion

                        #region 頁首下面[橫線]

                        dr_Temp_Result["DETL_3_0"] = "-----------";
                        dr_Temp_Result["DETL_3_1"] = "----------------------";
                        dr_Temp_Result["DETL_3_2"] = "----------------------";
                        dr_Temp_Result["DETL_3_3"] = "----------------------";
                        dr_Temp_Result["DETL_3_4"] = "----------------------";
                        dr_Temp_Result["DETL_3_5"] = "----------------------";
                        dr_Temp_Result["DETL_3_6"] = "----------------------";
                        dr_Temp_Result["DETL_3_7"] = "-----|-----";
                        dr_Temp_Result["DETL_3_8"] = "--------------";
                        dr_Temp_Result["DETL_3_9"] = "----------------------";
                        dr_Temp_Result["DETL_3_10"] = "----------------------";
                        dr_Temp_Result["DETL_3_11"] = "----------------------";
                        dr_Temp_Result["DETL_3_12"] = "----------------------";
                        dr_Temp_Result["DETL_3_13"] = "----------------------";
                        dr_Temp_Result["DETL_3_14"] = "----------------------";

                        #endregion
                    }

                    #endregion

                    #region 設定Detl內容

                    int i_Actual_Purchase = 0;//進貨實際寫入筆數
                    int i_Actual_Return = 0;//退貨實際寫入筆數
                    decimal dec_TOT_AMT_AND_TAX = 0;//計算含稅金額

                    //i_Detl_Content = Detl內容行數
                    for (int d = 0; d < i_Detl_Content; d++)
                    {
                        int i_dr_Temp_Detl_Count = a * i_Detl_Content + d;

                        #region 進貨部分

                        if (dr_Temp_Detl_Purchase.Length > i_dr_Temp_Detl_Count)
                        {
                            #region 計算含稅金額

                            #region 規則

                            /*
                             * 原本的規則:
                             * 如果稅別 = 應稅&零稅,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX
                             * 如果稅別 = 免稅,含稅金額直接放0
                             * 20091005 秀玲修改規則
                             * 不管它的稅別,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX
                             */

                            #endregion

                            dec_TOT_AMT_AND_TAX = decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()) + decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString());

                            #endregion

                            #region 寫入資料

                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_0"] = DateTime.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["ACCT_DATE"].ToString()).ToString("yyyy/MM/dd");//日期
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_1"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["ACCT_KD"];//屬性
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_2"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"];//稅別
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_3"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["EA_NO"];//高見單號
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_4"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["CHAN_SOURCE_NO"];//通路單號
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_5"] = (Math.Abs(decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString())) > 1000000) ? "******" : string.Format("{0:N}", dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"]);//未稅金額
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_6"] = (Math.Abs(dec_TOT_AMT_AND_TAX) > 1000000) ? "******" : string.Format("{0:N}", dec_TOT_AMT_AND_TAX);//含稅金額
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_7"] = "|";

                            #endregion

                            #region 計算[進貨]的明細最後是寫到哪一行

                            i_Actual_Purchase = i_Detl_Title + d;

                            #endregion

                            #region 計算[小計]金額

                            dec_Subtotal_TOT_AMT_Purchase += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//[小計]-進貨未稅金額
                            dec_Subtotal_TOT_AMT_AND_TAX_Purchase += dec_TOT_AMT_AND_TAX;//[小計]-進貨含稅金額

                            #endregion

                            #region 計算[單店小計]金額

                            if (dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "應稅")
                            {
                                dec_Single_Amount_Able += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[應稅]的[合計]
                                dec_Single_Tax_Able += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString());//單店小計-[應稅]的[稅額]
                            }
                            else if (dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "免稅")
                            { dec_Single_Amount_Free += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()); }//單店小計-[免稅]的[合計]
                            else if (dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "零稅")
                            {
                                dec_Single_Amount_Zero += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[零稅]的[合計]
                                dec_Single_Tax_Zero += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString()); //單店小計-[零稅]的[稅額]
                            }

                            #endregion
                        }

                        #endregion

                        #region 退貨部分

                        if (dr_Temp_Detl_Return.Length > i_dr_Temp_Detl_Count)
                        {
                            #region 計算含稅金額

                            #region 規則

                            /*
                             * 原本的規則:
                             * 如果稅別 = 應稅&零稅,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX
                             * 如果稅別 = 免稅,含稅金額直接放0
                             * 20091005 秀玲修改規則
                             * 不管它的稅別,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX
                             */

                            #endregion

                            dec_TOT_AMT_AND_TAX = decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()) + decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString());

                            #endregion

                            #region 寫入資料

                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_7"] = "|";
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_8"] = DateTime.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["ACCT_DATE"].ToString()).ToString("yyyy/MM/dd");//日期
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_9"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["ACCT_KD"];//屬性
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_10"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"];//稅別
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_11"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["EA_NO"];//高見單號
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_12"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["CHAN_SOURCE_NO"];//通路單號
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_13"] = (Math.Abs(decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString())) > 1000000) ? "******" : string.Format("{0:N}", dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"]);//未稅金額
                            dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_14"] = (Math.Abs(dec_TOT_AMT_AND_TAX) > 1000000) ? "******" : string.Format("{0:N}", dec_TOT_AMT_AND_TAX);//含稅金額

                            #endregion

                            #region 計算[退貨]的明細最後是寫到哪一行

                            i_Actual_Return = i_Detl_Title + d;

                            #endregion

                            #region 計算[小計]金額

                            dec_Subtotal_TOT_AMT_Return += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//[小計]-退貨未稅金額
                            dec_Subtotal_TOT_AMT_AND_TAX_Return += dec_TOT_AMT_AND_TAX;//[小計]-退貨含稅金額

                            #endregion

                            #region 計算[單店小計]金額

                            if (dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "應稅")
                            {
                                dec_Single_Amount_Able += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[應稅]的[合計]
                                dec_Single_Tax_Able += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString());//單店小計-[應稅]的[稅額]
                            }
                            else if (dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "免稅")
                            { dec_Single_Amount_Free += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()); }//單店小計-[免稅]的[合計]
                            else if (dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "零稅")
                            {
                                dec_Single_Amount_Zero += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[零稅]的[合計]
                                dec_Single_Tax_Zero += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString()); //單店小計-[零稅]的[稅額]
                            }

                            #endregion
                        }

                        #endregion
                    }

                    #endregion

                    #region 設定Detl頁尾[小計]&[單店小計]&[總計]

                    //取得Detl頁尾小計從哪一行開始
                    int i_Detl_Subtotal_Begin = ((i_Actual_Purchase > i_Actual_Return) ? i_Actual_Purchase : i_Actual_Return) + 1;

                    //判斷是否為最後一筆
                    if ((i_Detl_Content * a + i_Detl_Subtotal_Begin - i_Detl_Title ==
                        ((dr_Temp_Detl_Purchase.Length > dr_Temp_Detl_Return.Length)
                        ? dr_Temp_Detl_Purchase.Length : dr_Temp_Detl_Return.Length)) ||
                        (b_IsFinally == true))
                    {
                        //i_Detl_Count = Detl明細資料總共有幾行(包含[頁首][內容][頁尾小計][頁尾總計])
                        //i_Detl_Subtotal = Detl頁尾小計有幾行

                        int i_Detl_Total_Begin = 0;//紀錄Detl頁尾單店小計&總計從哪一行開始
                        int i_Actual_Detl_Total_Begin = 0;//設定小計總計是要在哪一行
                        int i_Original_i_Actual_Total = 0;//若是這一頁是只印小計總計部分,這個變數紀錄上一頁是印到第幾筆

                        if (b_IsFinally == true)
                        { i_Original_i_Actual_Total = i_Actual_Total; }
                        else
                        { i_Detl_Total_Begin = i_Detl_Subtotal_Begin; }

                        #region 小計

                        #region [小計]上方那一條線

                        if ((i_Detl_Total_Begin + 0 < i_Detl_Count) &&
                            (i_Actual_Total < 1))
                        {
                            if (b_IsFinally == true)
                            { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; }
                            else
                            { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 0; }

                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = "--------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_1"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_2"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_3"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_4"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_5"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_6"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_7"] = "-----|-----";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_8"] = "--------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_9"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_10"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_11"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_12"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_13"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_14"] = "----------------------";

                            i_Actual_Total = 1;
                        }

                        #endregion

                        #region [小計]資料

                        if ((i_Detl_Total_Begin + 1 < i_Detl_Count) &&
                            (i_Actual_Total < 2))
                        {
                            if (b_IsFinally == true)
                            { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; }
                            else
                            { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 1; }

                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = "小計";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_5"] = (Math.Abs(dec_Subtotal_TOT_AMT_Purchase) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_Purchase);//進貨[未稅金額]小計
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_6"] = (Math.Abs(dec_Subtotal_TOT_AMT_AND_TAX_Purchase) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_AND_TAX_Purchase);//進貨[含稅金額]小計
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_7"] = "|";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_13"] = (Math.Abs(dec_Subtotal_TOT_AMT_Return) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_Return);//退貨[未稅金額]小計
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_14"] = (Math.Abs(dec_Subtotal_TOT_AMT_AND_TAX_Return) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_AND_TAX_Return);//退貨[含稅金額]小計

                            i_Actual_Total = 2;
                        }

                        #endregion

                        #region [小計]下方那一條線

                        if ((i_Detl_Total_Begin + 2 < i_Detl_Count) &&
                            (i_Actual_Total < 3))
                        {
                            if (b_IsFinally == true)
                            { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; }
                            else
                            { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 2; }

                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = "--------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_1"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_2"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_3"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_4"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_5"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_6"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_7"] = "-----|-----";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_8"] = "--------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_9"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_10"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_11"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_12"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_13"] = "----------------------";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_14"] = "----------------------";

                            i_Actual_Total = 3;
                        }

                        #endregion

                        #endregion

                        #region 單店小計

                        if ((i_Detl_Total_Begin + 3 < i_Detl_Count) &&
                            (i_Actual_Total < 4))
                        {
                            if (b_IsFinally == true)
                            { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; }
                            else
                            { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 3; }

                            //注意:[應稅 合計:$]中間的空白,是[全型]的空白
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "單店小計".PadRight(4, ' ');
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(45);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "應稅 :未稅金額";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Able, MidpointRounding.AwayFromZero)).PadLeft(10);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Tax_Able, MidpointRounding.AwayFromZero)).PadLeft(10);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            if (dec_Single_Amount_Able < 0)
                            { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; }
                            else
                            { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; }
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Able, MidpointRounding.AwayFromZero) + System.Math.Round(dec_Single_Tax_Able, MidpointRounding.AwayFromZero)).PadLeft(10);

                            i_Actual_Total = 4;
                        }

                        if ((i_Detl_Total_Begin + 4 < i_Detl_Count) &&
                            (i_Actual_Total < 5))
                        {
                            if (b_IsFinally == true)
                            { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; }
                            else
                            { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 4; }

                            //注意:[免稅 合計:$]中間的空白,是[全型]的空白
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' ');
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(45);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "免稅 :未稅金額";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Free, MidpointRounding.AwayFromZero)).PadLeft(10);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(8);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(10);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            if (dec_Single_Amount_Free < 0)
                            { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; }
                            else
                            { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; }
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Free, MidpointRounding.AwayFromZero)).PadLeft(10);

                            i_Actual_Total = 5;
                        }

                        if ((i_Detl_Total_Begin + 5 < i_Detl_Count) &&
                            (i_Actual_Total < 6))
                        {
                            if (b_IsFinally == true)
                            { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; }
                            else
                            { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 5; }

                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' ');
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(45);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "零稅率:未稅金額";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Zero, MidpointRounding.AwayFromZero)).PadLeft(10);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Tax_Zero, MidpointRounding.AwayFromZero)).PadLeft(10);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            if (dec_Single_Amount_Zero < 0)
                            { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; }
                            else
                            { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; }
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Zero, MidpointRounding.AwayFromZero) + System.Math.Round(dec_Single_Tax_Zero, MidpointRounding.AwayFromZero)).PadLeft(10);

                            i_Actual_Total = 6;
                        }

                        #endregion

                        #region 中間空一行

                        if ((i_Detl_Total_Begin + 6 < i_Detl_Count) &&
                            (i_Actual_Total < 7))
                        {
                            if (b_IsFinally == true)
                            { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; }
                            else
                            { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 6; }

                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = string.Empty;

                            i_Actual_Total = 7;
                        }

                        #endregion

                        #region 總計

                        if ((i_Detl_Total_Begin + 7 < i_Detl_Count) &&
                                (i_Actual_Total < 8))
                        {
                            if (b_IsFinally == true)
                            { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; }
                            else
                            { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 7; }

                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總計".PadRight(4, ' ');
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "應稅折讓號碼 :";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += (s_DISC_NO_Able.Length > 28) ? s_DISC_NO_Able.Substring(0, 27) : s_DISC_NO_Able.PadRight(27);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(2);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "應稅 :未稅金額";
                            i_Total_Amount_Able = i_Total_Amount_Able * -1;
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Amount_Able).PadLeft(10);//總計-[應稅]的[未稅金額]
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$";
                            i_Total_Tax_Able = i_Total_Tax_Able * -1;
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Tax_Able).PadLeft(10);//總計-[應稅]的[稅額]
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "折讓總額:$";//折讓總額
                            i_Total_Disc_Able = i_Total_Disc_Able * -1;
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Disc_Able).PadLeft(10);//總計-[應稅]的[折讓總額]                            

                            i_Actual_Total = 8;
                        }

                        if ((i_Detl_Total_Begin + 8 < i_Detl_Count) &&
                            (i_Actual_Total < 9))
                        {
                            if (b_IsFinally == true)
                            { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; }
                            else
                            { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 8; }

                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' ');
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "免稅折讓號碼 :";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += (s_DISC_NO_Free.Length > 28) ? s_DISC_NO_Free.Substring(0, 27) : s_DISC_NO_Free.PadRight(27);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(2);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "免稅 :未稅金額";
                            i_Total_Amount_Free = i_Total_Amount_Free * -1;
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Amount_Free).PadLeft(10);//總計-[免稅]的[未稅金額]
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(8);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(10);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "折讓總額:$";//折讓總額
                            i_Total_Disc_Free = i_Total_Disc_Free * -1;
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Disc_Free).PadLeft(10);//總計-[免稅]的[折讓總額]

                            i_Actual_Total = 9;
                        }

                        if ((i_Detl_Total_Begin + 9 < i_Detl_Count) &&
                            (i_Actual_Total < 10))
                        {
                            if (b_IsFinally == true)
                            { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; }
                            else
                            { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 9; }

                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' ');
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "零稅率折讓號碼:";
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += (s_DISC_NO_Zero.Length > 28) ? s_DISC_NO_Zero.Substring(0, 27) : s_DISC_NO_Zero.PadRight(27);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(2);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "零稅率:未稅金額";
                            i_Total_Amount_Zero = i_Total_Amount_Zero * -1;
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Amount_Zero).PadLeft(10);//總計-[零稅]的[未稅金額]
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$";
                            i_Total_Tax_Zero = i_Total_Tax_Zero * -1;
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Tax_Zero).PadLeft(10);//總計-[零稅]的[稅額]
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5);
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "折讓總額:$";
                            i_Total_Disc_Zero = i_Total_Disc_Zero * -1;
                            dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Disc_Zero).PadLeft(10);//總計-[零稅]的[折讓總額]                          

                            i_Actual_Total = 10;
                        }

                        #endregion

                        //設定明細資料是否為最後一筆
                        b_IsFinally = true;
                    }

                    #endregion

                    #endregion

                    dt_Temp_Result.Rows.Add(dr_Temp_Result);
                }

                #endregion
            }

            #endregion

            return dt_Temp_Result;
        }