示例#1
0
    /// <summary>
    /// BUTTON [儲存]鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_Save_Click(object sender, EventArgs e)
    {
        try
        {
            #region 新增模式

            if (this.hid_PageStatus.Value == "insert")
            {
                #region 檢查條件

                BCO.CAACommon CAAComm = new BCO.CAACommon();
                ArrayList arl_Check_Condition = Check_Condition("BUTTON [儲存]鈕,新增狀態");

                #region 如果檢查有誤,則Return

                if (arl_Check_Condition[1].ToString() != string.Empty)
                {
                    #region 錯誤訊息

                    this.ErrorMsgLabel.Text = arl_Check_Condition[1].ToString();

                    #endregion

                    #region Focus欄位

                    if (arl_Check_Condition[0].ToString() != string.Empty)
                    {
                        string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(arl_Check_Condition[0].ToString(), true);
                        ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true);
                    }

                    #endregion

                    return;
                }

                #endregion

                #endregion

                #region 至資料庫取得Table Schema

                ParameterList.Clear();
                ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID

                DataTable dt_Update_Inv = new DataTable();
                DataTable dt_New_Main = new DataTable();
                DataTable dt_New_Detl = new DataTable();

                BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);
                dt_Update_Inv = bco.GET_VDS_CAA_INV_MAIN_SCHEMA(ParameterList);
                dt_New_Main = bco.GET_VDS_CAA_DISC_MAIN_SCHEMA(ParameterList);
                dt_New_Detl = bco.GET_VDS_CAA_DISC_DETL_SCHEMA(ParameterList);

                #endregion

                #region 將資料寫入Temp Table

                string s_Now = DateTime.Now.ToString();
                string s_CLOSE_MONTH_ACCT = string.Empty;

                #region SLP轉型

                TextBox txt_DISC_AMT = (TextBox)this.slp_DISC_AMT.FindControl("TextBoxCode");//總金額

                #endregion

                #region VDS_CAA_DISC_MAIN

                DataRow dr_New_Main = dt_New_Main.NewRow();

                #region 設定欄位[結帳年月-財會]

                if (this.slp_DISC_SOURCE.Text == "1")//欄位[來源]=系統開立
                { s_CLOSE_MONTH_ACCT = this.slp_CLOSE_MONTH_ACCT.Text; }
                else if (this.slp_DISC_SOURCE.Text == "2")//欄位[來源]=人工開立
                { s_CLOSE_MONTH_ACCT = (this.slp_PROOF_DATE.Text == string.Empty) ? string.Empty : DateTime.Parse(this.slp_PROOF_DATE.Text).ToString("yyyyMM"); }

                #endregion

                dr_New_Main["DISC_FORM"] = CAAComm.GetValueSetParameter(this.slp_DISC_FORM.Text, "int", false);//格式代號
                dr_New_Main["DISC_SOURCE"] = CAAComm.GetValueSetParameter(this.slp_DISC_SOURCE.Text, "int", false);//來源
                dr_New_Main["STORE_ID"] = CAAComm.GetValueSetParameter(this.slp_STORE_ID.Text, "string", false);//店號
                dr_New_Main["DISC_TYPE"] = CAAComm.GetValueSetParameter(this.slp_DISC_TYPE.Text, "string", false);//形式
                dr_New_Main["ROOT_NO"] = CAAComm.GetValueSetParameter(this.slp_ROOT_NO.Text, "string", false);//商品群分類
                dr_New_Main["TAX_TYPE"] = CAAComm.GetValueSetParameter(this.slp_TAX_TYPE.Text, "string", false);//稅別
                dr_New_Main["DISC_DATE"] = CAAComm.GetValueSetParameter(this.slp_DISC_DATE.Text, "date", false);//折讓日期
                dr_New_Main["CHG_DISC_DATE"] = CAAComm.GetValueSetParameter(this.slp_CHG_DISC_DATE.Text, "date", false);//異動折讓日期
                dr_New_Main["ACT_DISC_NO"] = CAAComm.GetValueSetParameter(this.txt_ACT_DISC_NO.Text, "string", false);//財會折讓單號
                dr_New_Main["PROOF_FLG"] = CAAComm.GetValueSetParameter((this.chb_PROOF_FLG.Checked == true) ? "1" : "0", "int", false);//憑證已回
                dr_New_Main["PROOF_DATE"] = CAAComm.GetValueSetParameter(this.slp_PROOF_DATE.Text, "date", false);//憑證已回日期
                dr_New_Main["REPROOF_FLG"] = CAAComm.GetValueSetParameter((this.chb_REPROOF_FLG.Checked == true) ? "1" : "0", "int", false);//取具進項憑証
                dr_New_Main["REPROOF_NO"] = CAAComm.GetValueSetParameter(this.txt_REPROOF_NO.Text, "string", false);//發票號碼/收據
                dr_New_Main["CANCEL_FLG"] = CAAComm.GetValueSetParameter((this.chb_CANCEL_FLG.Checked == true) ? "1" : "0", "int", false);//作廢
                dr_New_Main["CANCEL_DATE"] = CAAComm.GetValueSetParameter(this.slp_CANCEL_DATE.Text, "date", false);//作廢日期
                dr_New_Main["PERIOD_FLG"] = CAAComm.GetValueSetParameter((this.chb_PERIOD_FLG.Checked == true) ? "1" : "0", "int", false);//申報
                dr_New_Main["PERIOD_DATE"] = CAAComm.GetValueSetParameter(this.slp_PERIOD_DATE.Text, "date", false);//申報日期
                dr_New_Main["TEMPORAL_FLG"] = CAAComm.GetValueSetParameter((this.chb_TEMPORAL_FLG.Checked == true) ? "1" : "0", "int", false);//轉暫收
                dr_New_Main["TEMPORAL_DATE"] = CAAComm.GetValueSetParameter(this.slp_TEMPORAL_DATE.Text, "date", false);//暫收日期
                dr_New_Main["RFNO"] = CAAComm.GetValueSetParameter(this.txt_RFNO.Text, "string", false);//統一編號
                dr_New_Main["DISC_UAMT"] = CAAComm.GetValueSetParameter(this.slp_DISC_UAMT.Text, "int", false);//折讓金額(未稅)
                dr_New_Main["DISC_TAX"] = CAAComm.GetValueSetParameter(this.slp_DISC_TAX.Text, "int", false);//折讓稅額
                dr_New_Main["DISC_AMT"] = CAAComm.GetValueSetParameter(Request[txt_DISC_AMT.UniqueID].ToString(), "int", false);//總金額
                dr_New_Main["CLOSE_MONTH"] = CAAComm.GetValueSetParameter(this.slp_CLOSE_MONTH.Text, "string", false);//結帳年月
                dr_New_Main["MEMO"] = CAAComm.GetValueSetParameter(this.txt_MEMO.Text, "string", false);//備註
                dr_New_Main["CREATEDATE"] = CAAComm.GetValueSetParameter(s_Now, "datetime", false);//建立日期
                dr_New_Main["CREATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//建立人員
                dr_New_Main["UPDATEDATE"] = CAAComm.GetValueSetParameter(s_Now, "datetime", false);//更新日期
                dr_New_Main["UPDATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//更新人員
                dr_New_Main["ENABLE"] = CAAComm.GetValueSetParameter("1", "int", false);//有效
                dr_New_Main["DETL_FLG"] = CAAComm.GetValueSetParameter((this.chb_REPROOF_FLG.Checked == true) ? "0" : "1", "int", false);//明細註記,0代表沒有明細,1代表有明細
                dr_New_Main["REMARK_FLG"] = CAAComm.GetValueSetParameter("0", "int", false);//標記註記(預設為0)
                dr_New_Main["CHECK_FLG"] = CAAComm.GetValueSetParameter("0", "int", false);//勾選註記(預設為0)
                dr_New_Main["DISC_REMAIN_AMT"] = CAAComm.GetValueSetParameter(Request[txt_DISC_AMT.UniqueID].ToString(), "int", false);//沖帳餘額(預設等於總金額[DISC_AMT])
                dr_New_Main["WASH_STATUS"] = CAAComm.GetValueSetParameter("0", "int", false);//沖帳狀態(預設為0)
                dr_New_Main["SOURCE_TYPE"] = CAAComm.GetValueSetParameter("1", "string", false);//區分資料來源(預設為1),1是代表營業系統,2是代表財會系統
                dr_New_Main["IS_SCHEDULE"] = CAAComm.GetValueSetParameter("0", "int", false);//檔期(預設為0),1代表有檔期,0代表沒有檔期
                dr_New_Main["CLOSE_MONTH_ACCT"] = CAAComm.GetValueSetParameter(s_CLOSE_MONTH_ACCT, "int", false);//結帳年月-財會
                dr_New_Main["RECEIPT_FLG"] = CAAComm.GetValueSetParameter((this.chb_RECEIPT_FLG.Checked == true) ? "1" : "0", "int", false);//取具收據

                dt_New_Main.Rows.Add(dr_New_Main);

                #endregion

                #region VDS_CAA_DISC_DETL

                //如果[取具進項憑証]和[取具收據]都沒有被勾選,才必須新增 Detl 資料
                if (this.chb_REPROOF_FLG.Checked == false &&
                    this.chb_RECEIPT_FLG.Checked == false)
                {
                    DataTable dt_NewItem_New = new DataTable();
                    DataTable dt_NewItem_Modify = new DataTable();

                    dt_NewItem_New = dt_NewItem.GetChanges(DataRowState.Added);
                    dt_NewItem_Modify = dt_NewItem.GetChanges(DataRowState.Modified);

                    if (dt_NewItem_New != null || dt_NewItem_Modify != null)
                    {
                        if (dt_NewItem_New != null)
                        {
                            foreach (DataRow dr_NewItem_New in dt_NewItem_New.Rows)
                            {
                                //新增模式,若[折讓金額(未稅)]為0且[折讓稅額]為0,則該筆資料不新增至資料庫
                                if (dr_NewItem_New["DISC_UAMT"].ToString() != "0" ||
                                    dr_NewItem_New["DISC_TAX"].ToString() != "0")
                                { Set_NewItem_To_Temp_For_Add(dr_NewItem_New, dt_New_Detl, s_Now); }
                            }
                        }
                        if (dt_NewItem_Modify != null)
                        {
                            foreach (DataRow dr_NewItem_Modify in dt_NewItem_Modify.Rows)
                            {
                                //新增模式,若[折讓金額(未稅)]為0且[折讓稅額]為0,則該筆資料不新增至資料庫
                                if (dr_NewItem_Modify["DISC_UAMT"].ToString() != "0" ||
                                    dr_NewItem_Modify["DISC_TAX"].ToString() != "0")
                                { Set_NewItem_To_Temp_For_Add(dr_NewItem_Modify, dt_New_Detl, s_Now); }
                            }
                        }
                    }

                    if (dt_New_Detl.Rows.Count == 0)
                    {
                        this.ErrorMsgLabel.Text = "無需要異動的資料";
                        return;
                    }
                }

                #endregion

                #region VDS_CAA_INV_MAIN

                //如果[取具進項憑証]和[取具收據]都沒有被勾選,才要做以下動作
                if (this.chb_REPROOF_FLG.Checked == false &&
                    this.chb_RECEIPT_FLG.Checked == false)
                {
                    foreach (DataRow dr_New_Detl in dt_New_Detl.Rows)
                    {
                        string s_FilterExpression = "INV_NO = '" + dr_New_Detl["INV_NO"].ToString() + "'";
                        DataRow[] dr_NewItem = dt_NewItem.Select(s_FilterExpression);

                        if (dr_NewItem.Length == 1)
                        { Set_NewItem_To_Temp_For_INV_MAIN(dr_NewItem[0], dt_Update_Inv, s_Now); }
                        else
                        { throw new Exception("按下銷貨折讓維護的[儲存]鈕,更改資料至發票主檔,發生頁面資料錯誤"); }
                    }
                }

                #endregion

                #endregion

                #region 連結資料庫

                string s_DISC_NO = bco.CreateDiscRecord(null, dt_New_Main, dt_New_Detl, dt_Update_Inv);

                #endregion

                #region 清空變數,跳轉頁面至檢視模式

                if (dt_NewItem != null)
                { dt_NewItem.Clear(); }
                ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CAA182", "alert('新增完成');location.replace('CAA182.aspx?Code=CAA18&CAA182_Mode=view&CAA182_DISC_NO=" + s_DISC_NO + "');", true);

                #endregion
            }

            #endregion

            #region 編輯模式

            else if (this.hid_PageStatus.Value == "edit")
            {
                #region 檢查條件

                BCO.CAACommon CAAComm = new BCO.CAACommon();
                ArrayList arl_Check_Condition = Check_Condition("BUTTON [儲存]鈕,編輯狀態");

                #region 如果檢查有誤,則Return

                if (arl_Check_Condition[1].ToString() != string.Empty)
                {
                    #region 錯誤訊息

                    this.ErrorMsgLabel.Text = arl_Check_Condition[1].ToString();

                    #endregion

                    #region Focus欄位

                    if (arl_Check_Condition[0].ToString() != string.Empty)
                    {
                        string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(arl_Check_Condition[0].ToString(), true);
                        ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true);
                    }

                    #endregion

                    return;
                }

                #endregion

                #endregion

                #region 判斷是做何種勾選動作

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

                Check_CheckStatus(out b_IsRight, out s_ReturnMsg);

                #endregion

                #region 20100310 秀玲新增規則,已沖帳時,檢查狀態

                #region 規則

                /* 因為在檢視頁進入編輯頁時有做限制,
                 * 所以在[總金額(DISC_AMT)][沖帳餘額(DISC_REMAIN_AMT)]不相同,代表已沖帳時,
                 * 按下[儲存]鈕時,會有6種情況(請看function Check_CheckStatus的邏輯)
                 * (1)都沒有勾
                 * (2)勾選欄位[取具進項憑証]
                 * (3)勾選欄位[取具收據]
                 * (4)勾選欄位[憑證已回]
                 * (5)勾選欄位[轉暫收]
                 * (6)原本就勾選欄位[申報]
                 * 如果不是這5種狀況,則提示錯誤訊息*/

                #endregion

                arl_Check_Condition.Clear();
                arl_Check_Condition = Check_Condition("BUTTON [儲存]鈕,編輯模式,判斷完狀態後的檢查", s_ReturnMsg);

                #region 如果檢查有誤,則Return

                if (arl_Check_Condition[1].ToString() != string.Empty)
                {
                    #region 錯誤訊息

                    this.ErrorMsgLabel.Text = arl_Check_Condition[1].ToString();

                    #endregion

                    return;
                }

                #endregion

                #endregion

                #region 依照勾選動作將資料寫入TempTable,並連結資料庫

                #region SLP轉型

                TextBox txt_TEMPORAL_DATE = (TextBox)this.slp_TEMPORAL_DATE.FindControl("TextBoxCode");//暫收日期
                TextBox txt_DISC_AMT = (TextBox)this.slp_DISC_AMT.FindControl("TextBoxCode");//總金額

                #endregion

                #region 宣告變數

                DataTable dt_Update_Inv = new DataTable();
                DataTable dt_Update_Disc_Main = new DataTable();
                DataTable dt_Add_Disc_Detl = new DataTable();
                DataTable dt_Update_Disc_Detl = new DataTable();
                DataTable dt_Delete_Disc_Detl = new DataTable();
                BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);
                string s_Now = DateTime.Now.ToString();
                string s_DISC_NO = string.Empty;
                string s_CLOSE_MONTH_ACCT = string.Empty;

                ParameterList.Clear();
                ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID

                #endregion

                #region 規則

                //只會有以下10種情況,不是這8種情況就是錯誤的
                //1.勾選欄位[憑證已回]
                //2.勾選欄位[取具進項憑証]
                //3.勾選欄位[取具收據]
                //4.勾選欄位[作廢]
                //5.勾選欄位[轉暫收]
                //6.取消勾選欄位[憑證已回]
                //7.取消勾選欄位[取具進項憑証]
                //8.取消勾選欄位[取具收據]
                //9.都沒有勾
                //10.原本就勾選欄位[申報]

                #endregion

                #region 勾選欄位[憑證已回] or 取消勾選欄位[憑證已回] or 取消勾選欄位[取具進項憑証] or 取消勾選欄位[取具收據] or 都沒有勾

                if (s_ReturnMsg == "勾選欄位[憑證已回]" ||
                    s_ReturnMsg == "取消勾選欄位[憑證已回]" ||
                    s_ReturnMsg == "取消勾選欄位[取具進項憑証]" ||
                    s_ReturnMsg == "取消勾選欄位[取具收據]" ||
                    s_ReturnMsg == "都沒有勾")
                {
                    #region [總金額(DISC_AMT)][沖帳餘額(DISC_REMAIN_AMT)]相同,尚未沖帳

                    if (dt_Main.Rows[0]["DISC_REMAIN_AMT"].ToString() == dt_Main.Rows[0]["DISC_AMT"].ToString())
                    {
                        #region 取得 TempTable 的 SCHEMA

                        dt_Update_Disc_Main = bco.GET_VDS_CAA_DISC_MAIN_SCHEMA(ParameterList);
                        dt_Add_Disc_Detl = bco.GET_VDS_CAA_DISC_DETL_SCHEMA(ParameterList);
                        dt_Update_Disc_Detl = dt_Add_Disc_Detl.Copy();
                        dt_Delete_Disc_Detl = dt_Add_Disc_Detl.Copy();
                        dt_Update_Inv = bco.GET_VDS_CAA_INV_MAIN_SCHEMA(ParameterList);

                        #endregion

                        #region 新增 VDS_CAA_DISC_MAIN 的異動欄位

                        dt_Update_Disc_Main.Columns.Add("NEW_UPDATEDATE", dt_Update_Disc_Main.Columns["UPDATEDATE"].DataType);
                        dt_Update_Disc_Main.Columns.Add("NEW_UPDATEUID", dt_Update_Disc_Main.Columns["UPDATEUID"].DataType);
                        dt_Update_Disc_Main.Columns.Add("NEW_DISC_TYPE", dt_Update_Disc_Main.Columns["DISC_TYPE"].DataType);//型式
                        dt_Update_Disc_Main.Columns.Add("NEW_ACT_DISC_NO", dt_Update_Disc_Main.Columns["ACT_DISC_NO"].DataType);//財會折讓單號
                        dt_Update_Disc_Main.Columns.Add("NEW_CHG_DISC_DATE", dt_Update_Disc_Main.Columns["CHG_DISC_DATE"].DataType);//異動折讓日期
                        dt_Update_Disc_Main.Columns.Add("NEW_PROOF_FLG", dt_Update_Disc_Main.Columns["PROOF_FLG"].DataType);//憑證已回
                        dt_Update_Disc_Main.Columns.Add("NEW_PROOF_DATE", dt_Update_Disc_Main.Columns["PROOF_DATE"].DataType);//憑證已回日期
                        dt_Update_Disc_Main.Columns.Add("NEW_REPROOF_FLG", dt_Update_Disc_Main.Columns["REPROOF_FLG"].DataType);//取具進項憑証
                        dt_Update_Disc_Main.Columns.Add("NEW_REPROOF_NO", dt_Update_Disc_Main.Columns["REPROOF_NO"].DataType);//發票號碼/收據
                        dt_Update_Disc_Main.Columns.Add("NEW_RECEIPT_FLG", dt_Update_Disc_Main.Columns["RECEIPT_FLG"].DataType);//取具收據
                        dt_Update_Disc_Main.Columns.Add("NEW_DISC_UAMT", dt_Update_Disc_Main.Columns["DISC_UAMT"].DataType);//折讓金額(未稅)
                        dt_Update_Disc_Main.Columns.Add("NEW_DISC_TAX", dt_Update_Disc_Main.Columns["DISC_TAX"].DataType);//折讓稅額
                        dt_Update_Disc_Main.Columns.Add("NEW_DISC_AMT", dt_Update_Disc_Main.Columns["DISC_AMT"].DataType);//總金額
                        dt_Update_Disc_Main.Columns.Add("NEW_MEMO", dt_Update_Disc_Main.Columns["MEMO"].DataType);//備註
                        dt_Update_Disc_Main.Columns.Add("NEW_CLOSE_MONTH_ACCT", dt_Update_Disc_Main.Columns["CLOSE_MONTH_ACCT"].DataType);//結帳年月-財會
                        dt_Update_Disc_Main.Columns.Add("NEW_DISC_REMAIN_AMT", dt_Update_Disc_Main.Columns["DISC_REMAIN_AMT"].DataType);//沖帳餘額
                        dt_Update_Disc_Main.Columns.Add("NEW_DETL_FLG", dt_Update_Disc_Main.Columns["DETL_FLG"].DataType);//明細註記(1是有明細0是沒明細)

                        #endregion

                        #region 新增 VDS_CAA_DISC_DETL 的異動欄位

                        dt_Update_Disc_Detl.Columns.Add("NEW_UPDATEDATE", dt_Update_Disc_Detl.Columns["UPDATEDATE"].DataType);
                        dt_Update_Disc_Detl.Columns.Add("NEW_UPDATEUID", dt_Update_Disc_Detl.Columns["UPDATEUID"].DataType);
                        dt_Update_Disc_Detl.Columns.Add("NEW_DISC_UAMT", dt_Update_Disc_Detl.Columns["DISC_UAMT"].DataType);
                        dt_Update_Disc_Detl.Columns.Add("NEW_DISC_TAX", dt_Update_Disc_Detl.Columns["DISC_TAX"].DataType);
                        dt_Update_Disc_Detl.Columns.Add("NEW_DISC_AMT", dt_Update_Disc_Detl.Columns["DISC_AMT"].DataType);

                        #endregion

                        #region 將資料寫入Temp Table

                        #region VDS_CAA_DISC_MAIN

                        foreach (DataRow dr_MainRow in dt_Main.Rows)
                        {
                            DataRow dr_Update_Disc_Main = dt_Update_Disc_Main.NewRow();

                            #region 設定欄位[結帳年月-財會]

                            if (this.slp_DISC_SOURCE.Text == "1")//欄位[來源]=系統開立
                            { s_CLOSE_MONTH_ACCT = this.slp_CLOSE_MONTH_ACCT.Text; }
                            else if (this.slp_DISC_SOURCE.Text == "2")//欄位[來源]=人工開立
                            { s_CLOSE_MONTH_ACCT = (this.slp_PROOF_DATE.Text == string.Empty) ? string.Empty : DateTime.Parse(this.slp_PROOF_DATE.Text).ToString("yyyyMM"); }

                            #endregion

                            dr_Update_Disc_Main["NEW_UPDATEDATE"] = CAAComm.GetValueSetParameter(s_Now, "datetime", false);//更新日期
                            dr_Update_Disc_Main["NEW_UPDATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//更新人員
                            dr_Update_Disc_Main["NEW_DISC_TYPE"] = CAAComm.GetValueSetParameter(this.slp_DISC_TYPE.Text, "string", false);//型式
                            dr_Update_Disc_Main["NEW_ACT_DISC_NO"] = CAAComm.GetValueSetParameter(this.txt_ACT_DISC_NO.Text, "string", false);//財會折讓單號
                            dr_Update_Disc_Main["NEW_CHG_DISC_DATE"] = CAAComm.GetValueSetParameter(this.slp_CHG_DISC_DATE.Text, "date", false);//異動折讓日期
                            dr_Update_Disc_Main["NEW_PROOF_FLG"] = CAAComm.GetValueSetParameter((this.chb_PROOF_FLG.Checked == true) ? "1" : "0", "int", false);//憑證已回
                            dr_Update_Disc_Main["NEW_PROOF_DATE"] = CAAComm.GetValueSetParameter(this.slp_PROOF_DATE.Text, "date", false);//憑證已回日期
                            dr_Update_Disc_Main["NEW_REPROOF_FLG"] = CAAComm.GetValueSetParameter((this.chb_REPROOF_FLG.Checked == true) ? "1" : "0", "int", false);//取具進項憑証
                            dr_Update_Disc_Main["NEW_REPROOF_NO"] = CAAComm.GetValueSetParameter(this.txt_REPROOF_NO.Text, "string", false);//發票號碼/收據
                            dr_Update_Disc_Main["NEW_RECEIPT_FLG"] = CAAComm.GetValueSetParameter((this.chb_RECEIPT_FLG.Checked == true) ? "1" : "0", "int", false);//取具收據
                            dr_Update_Disc_Main["NEW_DISC_UAMT"] = CAAComm.GetValueSetParameter(this.slp_DISC_UAMT.Text, "int", false);//折讓金額(未稅)
                            dr_Update_Disc_Main["NEW_DISC_TAX"] = CAAComm.GetValueSetParameter(this.slp_DISC_TAX.Text, "int", false);//折讓稅額
                            dr_Update_Disc_Main["NEW_DISC_AMT"] = CAAComm.GetValueSetParameter(Request[txt_DISC_AMT.UniqueID].ToString(), "int", false);//總金額
                            dr_Update_Disc_Main["NEW_MEMO"] = CAAComm.GetValueSetParameter(this.txt_MEMO.Text, "string", false);//備註
                            dr_Update_Disc_Main["NEW_CLOSE_MONTH_ACCT"] = CAAComm.GetValueSetParameter(s_CLOSE_MONTH_ACCT, "string", false);//結帳年月-財會
                            dr_Update_Disc_Main["NEW_DISC_REMAIN_AMT"] = CAAComm.GetValueSetParameter(Request[txt_DISC_AMT.UniqueID].ToString(), "int", false);//沖帳餘額
                            dr_Update_Disc_Main["NEW_DETL_FLG"] = CAAComm.GetValueSetParameter((this.chb_REPROOF_FLG.Checked == true) ? "0" : "1", "int", false);//明細註記(1是有明細0是沒明細)

                            foreach (DataColumn dtcolumn in dt_Update_Disc_Main.Columns)
                            {
                                if (dtcolumn.ColumnName.Length < 4 ||
                                    dtcolumn.ColumnName.Substring(0, 4) != "NEW_")
                                { dr_Update_Disc_Main[dtcolumn.ColumnName] = dr_MainRow[dtcolumn.ColumnName]; }
                            }

                            dt_Update_Disc_Main.Rows.Add(dr_Update_Disc_Main);
                        }

                        #endregion

                        #region VDS_CAA_DISC_DETL

                        //如果[取具進項憑証]和[取具收據]都沒有被勾選,才必須新增 Detl 資料
                        if (this.chb_REPROOF_FLG.Checked == false &&
                            this.chb_RECEIPT_FLG.Checked == false)
                        {
                            DataTable dt_NewItem_New = new DataTable();
                            DataTable dt_NewItem_Modify = new DataTable();

                            dt_NewItem_New = dt_NewItem.GetChanges(DataRowState.Added);
                            dt_NewItem_Modify = dt_NewItem.GetChanges(DataRowState.Modified);

                            if (dt_NewItem_New != null || dt_NewItem_Modify != null)
                            {
                                if (dt_NewItem_New != null)
                                {
                                    foreach (DataRow dr_NewItem_New in dt_NewItem_New.Rows)
                                    {
                                        //新增的資料,若[折讓金額(未稅)]為0且[折讓稅額]為0,則該筆資料不新增至資料庫
                                        if (dr_NewItem_New["DISC_UAMT"].ToString() != "0" ||
                                            dr_NewItem_New["DISC_TAX"].ToString() != "0")
                                        { Set_NewItem_To_Temp_For_Add(dr_NewItem_New, dt_Add_Disc_Detl, s_Now); }
                                    }
                                }
                                if (dt_NewItem_Modify != null)
                                {
                                    foreach (DataRow dr_NewItem_Modify in dt_NewItem_Modify.Rows)
                                    {
                                        //修改的資料,若[折讓金額(未稅)]為0且[折讓稅額]為0,則該筆資料將從資料庫中刪除
                                        if (dr_NewItem_Modify["DISC_UAMT"].ToString() == "0" &&
                                            dr_NewItem_Modify["DISC_TAX"].ToString() == "0")
                                        { Set_NewItem_To_Temp_For_Delete(dr_NewItem_Modify, dt_Delete_Disc_Detl, s_Now); }
                                        else
                                        { Set_NewItem_To_Temp_For_Modify(dr_NewItem_Modify, dt_Update_Disc_Detl, s_Now); }
                                    }
                                }
                            }
                        }

                        #endregion

                        #region VDS_CAA_INV_MAIN

                        //如果[取具進項憑証]和[取具收據]都沒有被勾選,才要做以下動作
                        if (this.chb_REPROOF_FLG.Checked == false &&
                            this.chb_RECEIPT_FLG.Checked == false)
                        {
                            foreach (DataRow dr_Add_Disc_Detl in dt_Add_Disc_Detl.Rows)
                            {
                                string s_FilterExpression = "INV_NO = '" + dr_Add_Disc_Detl["INV_NO"].ToString() + "'";
                                DataRow[] dr_Item = dt_NewItem.Select(s_FilterExpression);

                                if (dr_Item.Length == 1)
                                { Set_NewItem_To_Temp_For_INV_MAIN(dr_Item[0], dt_Update_Inv, s_Now); }
                                else
                                { throw new Exception("按下銷貨折讓維護的[儲存]鈕,更改資料至發票主檔,發生頁面資料錯誤"); }
                            }

                            foreach (DataRow dr_Update_Disc_Detl in dt_Update_Disc_Detl.Rows)
                            {
                                string s_FilterExpression = "INV_NO = '" + dr_Update_Disc_Detl["INV_NO"].ToString() + "'";
                                DataRow[] dr_Item = dt_NewItem.Select(s_FilterExpression);

                                if (dr_Item.Length == 1)
                                { Set_NewItem_To_Temp_For_INV_MAIN(dr_Item[0], dt_Update_Inv, s_Now); }
                                else
                                { throw new Exception("按下銷貨折讓維護的[儲存]鈕,更改資料至發票主檔,發生頁面資料錯誤"); }
                            }

                            foreach (DataRow dr_Delete_Disc_Detl in dt_Delete_Disc_Detl.Rows)
                            {
                                string s_FilterExpression = "INV_NO = '" + dr_Delete_Disc_Detl["INV_NO"].ToString() + "'";
                                DataRow[] dr_Item = dt_NewItem.Select(s_FilterExpression);

                                if (dr_Item.Length == 1)
                                { Set_NewItem_To_Temp_For_INV_MAIN(dr_Item[0], dt_Update_Inv, s_Now); }
                                else
                                { throw new Exception("按下銷貨折讓維護的[儲存]鈕,更改資料至發票主檔,發生頁面資料錯誤"); }
                            }
                        }

                        #endregion

                        #endregion

                        #region 連結資料庫

                        s_DISC_NO = bco.UpdateDiscRecord_OTHER_Checked(null,
                            dt_Update_Disc_Main,
                            dt_Add_Disc_Detl,
                            dt_Update_Disc_Detl,
                            dt_Delete_Disc_Detl,
                            dt_Update_Inv,
                            Session["UID"].ToString());

                        #endregion
                    }

                    #endregion

                    #region [總金額(DISC_AMT)][沖帳餘額(DISC_REMAIN_AMT)]不相同,已沖帳

                    else
                    {
                        if (s_ReturnMsg == "勾選欄位[憑證已回]" ||
                            s_ReturnMsg == "都沒有勾")
                        {
                            #region 取得 TempTable 的 SCHEMA

                            dt_Update_Disc_Main = bco.GET_VDS_CAA_DISC_MAIN_SCHEMA(ParameterList);

                            #endregion

                            #region 新增 VDS_CAA_DISC_MAIN 的異動欄位

                            dt_Update_Disc_Main.Columns.Add("NEW_UPDATEDATE", dt_Update_Disc_Main.Columns["UPDATEDATE"].DataType);
                            dt_Update_Disc_Main.Columns.Add("NEW_UPDATEUID", dt_Update_Disc_Main.Columns["UPDATEUID"].DataType);
                            dt_Update_Disc_Main.Columns.Add("NEW_MEMO", dt_Update_Disc_Main.Columns["MEMO"].DataType);//備註

                            #endregion

                            #region 將異動資料寫入 VDS_CAA_DISC_MAIN 的 TempTable

                            foreach (DataRow dr_MainRow in dt_Main.Rows)
                            {
                                DataRow dr_Update_Disc_Main = dt_Update_Disc_Main.NewRow();

                                dr_Update_Disc_Main["NEW_UPDATEDATE"] = CAAComm.GetValueSetParameter(s_Now, "datetime", false);//更新日期
                                dr_Update_Disc_Main["NEW_UPDATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//更新人員
                                dr_Update_Disc_Main["NEW_MEMO"] = CAAComm.GetValueSetParameter(this.txt_MEMO.Text, "string", false);//備註

                                foreach (DataColumn dtcolumn in dt_Update_Disc_Main.Columns)
                                {
                                    if (dtcolumn.ColumnName.Length < 4 ||
                                        dtcolumn.ColumnName.Substring(0, 4) != "NEW_")
                                    { dr_Update_Disc_Main[dtcolumn.ColumnName] = dr_MainRow[dtcolumn.ColumnName]; }
                                }

                                dt_Update_Disc_Main.Rows.Add(dr_Update_Disc_Main);
                            }

                            #endregion

                            #region 連結資料庫

                            s_DISC_NO = bco.UpdateDiscRecord_PERIOD_Checked(null, dt_Update_Disc_Main);

                            #endregion
                        }
                    }

                    #endregion
                }

                #endregion

                #region 勾選欄位[取具進項憑証] or 勾選欄位[取具收據]

                else if (s_ReturnMsg == "勾選欄位[取具進項憑証]" ||
                         s_ReturnMsg == "勾選欄位[取具收據]")
                {
                    #region [總金額(DISC_AMT)][沖帳餘額(DISC_REMAIN_AMT)]相同,尚未沖帳

                    if (dt_Main.Rows[0]["DISC_REMAIN_AMT"].ToString() == dt_Main.Rows[0]["DISC_AMT"].ToString())
                    {
                        #region 取得 TempTable 的 SCHEMA

                        dt_Update_Disc_Main = bco.GET_VDS_CAA_DISC_MAIN_SCHEMA(ParameterList);

                        #endregion

                        #region 新增 VDS_CAA_DISC_MAIN 的異動欄位

                        dt_Update_Disc_Main.Columns.Add("NEW_UPDATEDATE", dt_Update_Disc_Main.Columns["UPDATEDATE"].DataType);
                        dt_Update_Disc_Main.Columns.Add("NEW_UPDATEUID", dt_Update_Disc_Main.Columns["UPDATEUID"].DataType);
                        dt_Update_Disc_Main.Columns.Add("NEW_DISC_TYPE", dt_Update_Disc_Main.Columns["DISC_TYPE"].DataType);//型式
                        dt_Update_Disc_Main.Columns.Add("NEW_ACT_DISC_NO", dt_Update_Disc_Main.Columns["ACT_DISC_NO"].DataType);//財會折讓單號
                        dt_Update_Disc_Main.Columns.Add("NEW_CHG_DISC_DATE", dt_Update_Disc_Main.Columns["CHG_DISC_DATE"].DataType);//異動折讓日期
                        dt_Update_Disc_Main.Columns.Add("NEW_PROOF_DATE", dt_Update_Disc_Main.Columns["PROOF_DATE"].DataType);//憑證已回日期
                        dt_Update_Disc_Main.Columns.Add("NEW_REPROOF_FLG", dt_Update_Disc_Main.Columns["REPROOF_FLG"].DataType);//取具進項憑証
                        dt_Update_Disc_Main.Columns.Add("NEW_REPROOF_NO", dt_Update_Disc_Main.Columns["REPROOF_NO"].DataType);//發票號碼/收據
                        dt_Update_Disc_Main.Columns.Add("NEW_RECEIPT_FLG", dt_Update_Disc_Main.Columns["RECEIPT_FLG"].DataType);//取具收據
                        dt_Update_Disc_Main.Columns.Add("NEW_DISC_UAMT", dt_Update_Disc_Main.Columns["DISC_UAMT"].DataType);//折讓金額(未稅)
                        dt_Update_Disc_Main.Columns.Add("NEW_DISC_TAX", dt_Update_Disc_Main.Columns["DISC_TAX"].DataType);//折讓稅額
                        dt_Update_Disc_Main.Columns.Add("NEW_DISC_AMT", dt_Update_Disc_Main.Columns["DISC_AMT"].DataType);//總金額
                        dt_Update_Disc_Main.Columns.Add("NEW_MEMO", dt_Update_Disc_Main.Columns["MEMO"].DataType);//備註
                        dt_Update_Disc_Main.Columns.Add("NEW_CLOSE_MONTH_ACCT", dt_Update_Disc_Main.Columns["CLOSE_MONTH_ACCT"].DataType);//結帳年月-財會
                        dt_Update_Disc_Main.Columns.Add("NEW_DISC_REMAIN_AMT", dt_Update_Disc_Main.Columns["DISC_REMAIN_AMT"].DataType);//沖帳餘額
                        dt_Update_Disc_Main.Columns.Add("NEW_DETL_FLG", dt_Update_Disc_Main.Columns["DETL_FLG"].DataType);//明細註記(1是有明細0是沒明細)

                        #endregion

                        #region 將異動資料寫入 VDS_CAA_DISC_MAIN 的 TempTable

                        foreach (DataRow dr_MainRow in dt_Main.Rows)
                        {
                            DataRow dr_Update_Disc_Main = dt_Update_Disc_Main.NewRow();

                            #region 設定欄位[結帳年月-財會]

                            if (this.slp_DISC_SOURCE.Text == "1")//欄位[來源]=系統開立
                            { s_CLOSE_MONTH_ACCT = this.slp_CLOSE_MONTH_ACCT.Text; }
                            else if (this.slp_DISC_SOURCE.Text == "2")//欄位[來源]=人工開立
                            { s_CLOSE_MONTH_ACCT = (this.slp_PROOF_DATE.Text == string.Empty) ? string.Empty : DateTime.Parse(this.slp_PROOF_DATE.Text).ToString("yyyyMM"); }

                            #endregion

                            dr_Update_Disc_Main["NEW_UPDATEDATE"] = CAAComm.GetValueSetParameter(s_Now, "datetime", false);//更新日期
                            dr_Update_Disc_Main["NEW_UPDATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//更新人員
                            dr_Update_Disc_Main["NEW_DISC_TYPE"] = CAAComm.GetValueSetParameter(this.slp_DISC_TYPE.Text, "string", false);//型式
                            dr_Update_Disc_Main["NEW_ACT_DISC_NO"] = CAAComm.GetValueSetParameter(this.txt_ACT_DISC_NO.Text, "string", false);//財會折讓單號
                            dr_Update_Disc_Main["NEW_CHG_DISC_DATE"] = CAAComm.GetValueSetParameter(this.slp_CHG_DISC_DATE.Text, "date", false);//異動折讓日期
                            dr_Update_Disc_Main["NEW_PROOF_DATE"] = CAAComm.GetValueSetParameter(this.slp_PROOF_DATE.Text, "date", false);//憑證已回日期
                            dr_Update_Disc_Main["NEW_REPROOF_FLG"] = CAAComm.GetValueSetParameter((this.chb_REPROOF_FLG.Checked == true) ? "1" : "0", "int", false);//取具進項憑証
                            dr_Update_Disc_Main["NEW_REPROOF_NO"] = CAAComm.GetValueSetParameter(this.txt_REPROOF_NO.Text, "string", false);//發票號碼/收據
                            dr_Update_Disc_Main["NEW_RECEIPT_FLG"] = CAAComm.GetValueSetParameter((this.chb_RECEIPT_FLG.Checked == true) ? "1" : "0", "int", false);//取具收據
                            dr_Update_Disc_Main["NEW_DISC_UAMT"] = CAAComm.GetValueSetParameter(this.slp_DISC_UAMT.Text, "int", false);//折讓金額(未稅)
                            dr_Update_Disc_Main["NEW_DISC_TAX"] = CAAComm.GetValueSetParameter(this.slp_DISC_TAX.Text, "int", false);//折讓稅額
                            dr_Update_Disc_Main["NEW_DISC_AMT"] = CAAComm.GetValueSetParameter(Request[txt_DISC_AMT.UniqueID].ToString(), "int", false);//總金額
                            dr_Update_Disc_Main["NEW_MEMO"] = CAAComm.GetValueSetParameter(this.txt_MEMO.Text, "string", false);//備註
                            dr_Update_Disc_Main["NEW_CLOSE_MONTH_ACCT"] = CAAComm.GetValueSetParameter(s_CLOSE_MONTH_ACCT, "string", false);//結帳年月-財會
                            dr_Update_Disc_Main["NEW_DISC_REMAIN_AMT"] = CAAComm.GetValueSetParameter(Request[txt_DISC_AMT.UniqueID].ToString(), "int", false);//沖帳餘額
                            dr_Update_Disc_Main["NEW_DETL_FLG"] = CAAComm.GetValueSetParameter("0", "int", false);//明細註記(1是有明細0是沒明細)

                            foreach (DataColumn dtcolumn in dt_Update_Disc_Main.Columns)
                            {
                                if (dtcolumn.ColumnName.Length < 4 ||
                                    dtcolumn.ColumnName.Substring(0, 4) != "NEW_")
                                { dr_Update_Disc_Main[dtcolumn.ColumnName] = dr_MainRow[dtcolumn.ColumnName]; }
                            }

                            dt_Update_Disc_Main.Rows.Add(dr_Update_Disc_Main);
                        }

                        #endregion

                        #region 連結資料庫

                        ParameterList.Clear();
                        ParameterList.Add(CAAComm.GetValueSetParameter(s_Now, "datetime", false));//更新日期
                        ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//更新人員

                        s_DISC_NO = bco.UpdateDiscRecord_REPROOF_Checked(null, dt_Update_Disc_Main, ParameterList);

                        #endregion
                    }

                    #endregion

                    #region [總金額(DISC_AMT)][沖帳餘額(DISC_REMAIN_AMT)]不相同,已沖帳

                    else
                    {
                        #region 取得 TempTable 的 SCHEMA

                        dt_Update_Disc_Main = bco.GET_VDS_CAA_DISC_MAIN_SCHEMA(ParameterList);

                        #endregion

                        #region 新增 VDS_CAA_DISC_MAIN 的異動欄位

                        dt_Update_Disc_Main.Columns.Add("NEW_UPDATEDATE", dt_Update_Disc_Main.Columns["UPDATEDATE"].DataType);
                        dt_Update_Disc_Main.Columns.Add("NEW_UPDATEUID", dt_Update_Disc_Main.Columns["UPDATEUID"].DataType);
                        dt_Update_Disc_Main.Columns.Add("NEW_MEMO", dt_Update_Disc_Main.Columns["MEMO"].DataType);//備註

                        #endregion

                        #region 將異動資料寫入 VDS_CAA_DISC_MAIN 的 TempTable

                        foreach (DataRow dr_MainRow in dt_Main.Rows)
                        {
                            DataRow dr_Update_Disc_Main = dt_Update_Disc_Main.NewRow();

                            dr_Update_Disc_Main["NEW_UPDATEDATE"] = CAAComm.GetValueSetParameter(s_Now, "datetime", false);//更新日期
                            dr_Update_Disc_Main["NEW_UPDATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//更新人員
                            dr_Update_Disc_Main["NEW_MEMO"] = CAAComm.GetValueSetParameter(this.txt_MEMO.Text, "string", false);//備註

                            foreach (DataColumn dtcolumn in dt_Update_Disc_Main.Columns)
                            {
                                if (dtcolumn.ColumnName.Length < 4 ||
                                    dtcolumn.ColumnName.Substring(0, 4) != "NEW_")
                                { dr_Update_Disc_Main[dtcolumn.ColumnName] = dr_MainRow[dtcolumn.ColumnName]; }
                            }

                            dt_Update_Disc_Main.Rows.Add(dr_Update_Disc_Main);
                        }

                        #endregion

                        #region 連結資料庫

                        s_DISC_NO = bco.UpdateDiscRecord_PERIOD_Checked(null, dt_Update_Disc_Main);

                        #endregion
                    }

                    #endregion
                }

                #endregion

                #region 勾選欄位[作廢]

                else if (s_ReturnMsg == "勾選欄位[作廢]")
                {
                    #region 取得 TempTable 的 SCHEMA

                    dt_Update_Disc_Main = bco.GET_VDS_CAA_DISC_MAIN_SCHEMA(ParameterList);

                    #endregion

                    #region 新增 VDS_CAA_DISC_MAIN 的異動欄位

                    dt_Update_Disc_Main.Columns.Add("NEW_UPDATEDATE", dt_Update_Disc_Main.Columns["UPDATEDATE"].DataType);
                    dt_Update_Disc_Main.Columns.Add("NEW_UPDATEUID", dt_Update_Disc_Main.Columns["UPDATEUID"].DataType);
                    dt_Update_Disc_Main.Columns.Add("NEW_CANCEL_FLG", dt_Update_Disc_Main.Columns["CANCEL_FLG"].DataType);//作廢註記
                    dt_Update_Disc_Main.Columns.Add("NEW_CANCEL_DATE", dt_Update_Disc_Main.Columns["CANCEL_DATE"].DataType);//作廢日期
                    dt_Update_Disc_Main.Columns.Add("NEW_MEMO", dt_Update_Disc_Main.Columns["MEMO"].DataType);//備註

                    #endregion

                    #region 將異動資料寫入 VDS_CAA_DISC_MAIN 的 TempTable

                    foreach (DataRow dr_MainRow in dt_Main.Rows)
                    {
                        DataRow dr_Update_Disc_Main = dt_Update_Disc_Main.NewRow();

                        dr_Update_Disc_Main["NEW_UPDATEDATE"] = CAAComm.GetValueSetParameter(s_Now, "datetime", false);//更新日期
                        dr_Update_Disc_Main["NEW_UPDATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//更新人員
                        dr_Update_Disc_Main["NEW_CANCEL_FLG"] = CAAComm.GetValueSetParameter((this.chb_CANCEL_FLG.Checked == true) ? "1" : "0", "int", false);//作廢註記
                        dr_Update_Disc_Main["NEW_CANCEL_DATE"] = CAAComm.GetValueSetParameter(this.slp_CANCEL_DATE.Text, "date", false);//作廢日期
                        dr_Update_Disc_Main["NEW_MEMO"] = CAAComm.GetValueSetParameter(this.txt_MEMO.Text, "string", false);//備註

                        foreach (DataColumn dtcolumn in dt_Update_Disc_Main.Columns)
                        {
                            if (dtcolumn.ColumnName.Length < 4 ||
                                dtcolumn.ColumnName.Substring(0, 4) != "NEW_")
                            { dr_Update_Disc_Main[dtcolumn.ColumnName] = dr_MainRow[dtcolumn.ColumnName]; }
                        }

                        dt_Update_Disc_Main.Rows.Add(dr_Update_Disc_Main);
                    }

                    #endregion

                    #region 連結資料庫

                    ParameterList.Clear();
                    ParameterList.Add(CAAComm.GetValueSetParameter(s_Now, "datetime", false));//更新日期
                    ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//更新人員

                    s_DISC_NO = bco.UpdateDiscRecord_CANCEL_Checked(null, dt_Update_Disc_Main, ParameterList);

                    #endregion
                }

                #endregion

                #region 勾選欄位[轉暫收]

                else if (s_ReturnMsg == "勾選欄位[轉暫收]")
                {
                    #region 取得 TempTable 的 SCHEMA

                    dt_Update_Disc_Main = bco.GET_VDS_CAA_DISC_MAIN_SCHEMA(ParameterList);

                    #endregion

                    #region 新增 VDS_CAA_DISC_MAIN 的異動欄位

                    dt_Update_Disc_Main.Columns.Add("NEW_UPDATEDATE", dt_Update_Disc_Main.Columns["UPDATEDATE"].DataType);
                    dt_Update_Disc_Main.Columns.Add("NEW_UPDATEUID", dt_Update_Disc_Main.Columns["UPDATEUID"].DataType);
                    dt_Update_Disc_Main.Columns.Add("NEW_TEMPORAL_FLG", dt_Update_Disc_Main.Columns["TEMPORAL_FLG"].DataType);//轉暫收註記
                    dt_Update_Disc_Main.Columns.Add("NEW_TEMPORAL_DATE", dt_Update_Disc_Main.Columns["TEMPORAL_DATE"].DataType);//暫收日期
                    dt_Update_Disc_Main.Columns.Add("NEW_MEMO", dt_Update_Disc_Main.Columns["MEMO"].DataType);//備註
                    dt_Update_Disc_Main.Columns.Add("NEW_TARGET", typeof(string));//判斷資料原本是否為"轉暫收"

                    #endregion

                    #region 將異動資料寫入 VDS_CAA_DISC_MAIN 的 TempTable

                    foreach (DataRow dr_MainRow in dt_Main.Rows)
                    {
                        DataRow dr_Update_Disc_Main = dt_Update_Disc_Main.NewRow();

                        dr_Update_Disc_Main["NEW_UPDATEDATE"] = CAAComm.GetValueSetParameter(s_Now, "datetime", false);//更新日期
                        dr_Update_Disc_Main["NEW_UPDATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//更新人員
                        dr_Update_Disc_Main["NEW_TEMPORAL_FLG"] = CAAComm.GetValueSetParameter((this.chb_TEMPORAL_FLG.Checked == true) ? "1" : "0", "int", false);//轉暫收註記
                        dr_Update_Disc_Main["NEW_TEMPORAL_DATE"] = CAAComm.GetValueSetParameter(Request[txt_TEMPORAL_DATE.UniqueID].ToString(), "date", false);//暫收日期
                        dr_Update_Disc_Main["NEW_MEMO"] = CAAComm.GetValueSetParameter(this.txt_MEMO.Text, "string", false);//備註
                        dr_Update_Disc_Main["NEW_TARGET"] = (dr_MainRow["TEMPORAL_FLG"].ToString() == "1") ? "Original TEMPORAL" : "New TEMPORAL";//判斷資料原本是否為"轉暫收"

                        foreach (DataColumn dtcolumn in dt_Update_Disc_Main.Columns)
                        {
                            if (dtcolumn.ColumnName.Length < 4 ||
                                dtcolumn.ColumnName.Substring(0, 4) != "NEW_")
                            { dr_Update_Disc_Main[dtcolumn.ColumnName] = dr_MainRow[dtcolumn.ColumnName]; }
                        }

                        dt_Update_Disc_Main.Rows.Add(dr_Update_Disc_Main);
                    }

                    #endregion

                    #region 連結資料庫

                    s_DISC_NO = bco.UpdateDiscRecord_TEMPORAL_Checked(null, dt_Update_Disc_Main);

                    #endregion
                }

                #endregion

                #region 原本就勾選欄位[申報]

                else if (s_ReturnMsg == "原本就勾選欄位[申報]")
                {
                    #region 取得 TempTable 的 SCHEMA

                    dt_Update_Disc_Main = bco.GET_VDS_CAA_DISC_MAIN_SCHEMA(ParameterList);

                    #endregion

                    #region 新增 VDS_CAA_DISC_MAIN 的異動欄位

                    dt_Update_Disc_Main.Columns.Add("NEW_UPDATEDATE", dt_Update_Disc_Main.Columns["UPDATEDATE"].DataType);
                    dt_Update_Disc_Main.Columns.Add("NEW_UPDATEUID", dt_Update_Disc_Main.Columns["UPDATEUID"].DataType);
                    dt_Update_Disc_Main.Columns.Add("NEW_MEMO", dt_Update_Disc_Main.Columns["MEMO"].DataType);//備註

                    #endregion

                    #region 將異動資料寫入 VDS_CAA_DISC_MAIN 的 TempTable

                    foreach (DataRow dr_MainRow in dt_Main.Rows)
                    {
                        DataRow dr_Update_Disc_Main = dt_Update_Disc_Main.NewRow();

                        dr_Update_Disc_Main["NEW_UPDATEDATE"] = CAAComm.GetValueSetParameter(s_Now, "datetime", false);//更新日期
                        dr_Update_Disc_Main["NEW_UPDATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);//更新人員
                        dr_Update_Disc_Main["NEW_MEMO"] = CAAComm.GetValueSetParameter(this.txt_MEMO.Text, "string", false);//備註

                        foreach (DataColumn dtcolumn in dt_Update_Disc_Main.Columns)
                        {
                            if (dtcolumn.ColumnName.Length < 4 ||
                                dtcolumn.ColumnName.Substring(0, 4) != "NEW_")
                            { dr_Update_Disc_Main[dtcolumn.ColumnName] = dr_MainRow[dtcolumn.ColumnName]; }
                        }

                        dt_Update_Disc_Main.Rows.Add(dr_Update_Disc_Main);
                    }

                    #endregion

                    #region 連結資料庫

                    s_DISC_NO = bco.UpdateDiscRecord_PERIOD_Checked(null, dt_Update_Disc_Main);

                    #endregion
                }

                #endregion

                #endregion

                #region 清空變數,跳轉頁面至檢視模式

                if (dt_NewItem != null)
                { dt_NewItem.Clear(); }

                #region 組合跳轉頁面字串

                string s_ADDLocation_Replace_String = string.Empty;

                try
                {
                    int i_Count = int.Parse(Request.QueryString["CAA182_COUNT"]);
                    string s_Request_Key = Request.QueryString["CAA182_PageTimeStamp"];

                    s_ADDLocation_Replace_String = "&CAA182_COUNT=" + i_Count.ToString() + "&CAA182_PageTimeStamp=" + s_Request_Key;
                }
                catch { s_ADDLocation_Replace_String = string.Empty; }

                #endregion

                ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CAA182", "alert('更新成功');location.replace('CAA182.aspx?Code=CAA18&CAA182_Mode=view&CAA182_DISC_NO=" + s_DISC_NO + s_ADDLocation_Replace_String + "');", true);

                #endregion
            }

            #endregion

            #region 如果不符合以上條件,代表錯誤

            else { throw new Exception("頁面資料錯誤,只有在[新增模式][編輯模式]下,才可按[儲存]鈕"); }

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { Finally_Function(); }
    }
示例#2
0
    /// <summary>
    /// 離開[店號]時,帶出相關資料
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void txt_STORE_ID_Onblur()
    {
        try
        {
            #region 新增模式

            BCO.CAACommon CAAComm = new BCO.CAACommon();

            if (this.hid_PageStatus.Value == "insert")
            {
                #region 檢查傳入欄位[店號]的值

                if (this.slp_STORE_ID.Text.Trim() == string.Empty)
                {
                    Set_STORE_ID_Default();

                    #region Focus欄位

                    DropDownList drop_DISC_TYPE = (DropDownList)this.slp_DISC_TYPE.FindControl("D1");
                    string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(drop_DISC_TYPE.ClientID, false);
                    ScriptManager.RegisterStartupScript(this.up_Condition, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true);

                    #endregion

                    return;
                }

                #endregion

                #region 傳入參數

                //新增狀態下,必須使用sysdate,去查店號資料
                //資料必須是當時有效的店號
                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));//V_LOG_UPDATEUID

                #endregion

                #region 連結資料庫

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

                #endregion

                #region 將資料寫入相關欄位

                //重新將店號再寫入一次
                this.slp_STORE_ID.Text = this.slp_STORE_ID.Text;

                if (dr.Read())
                {
                    this.slp_GROUP_NO.Text = dr.IsDBNull(0) ? string.Empty : dr.GetString(0);//店群
                    this.slp_Z_O.Text = dr.IsDBNull(1) ? string.Empty : dr.GetString(1);//營業所
                    this.slp_SAL_ID.Text = dr.IsDBNull(2) ? string.Empty : dr.GetString(2);//營業人員
                    this.slp_AC_UID.Text = dr.IsDBNull(3) ? string.Empty : dr.GetString(3);//帳務人員
                    this.txt_PAY_RFNO.Text = dr.IsDBNull(4) ? string.Empty : dr.GetString(4);//結帳統編
                    this.txt_RFNO.Text = dr.IsDBNull(5) ? string.Empty : dr.GetString(5);//統一編號
                    this.txt_INV_ADDR.Text = dr.IsDBNull(6) ? string.Empty : dr.GetString(6);//地址
                    this.txt_TITLE.Text = dr.IsDBNull(7) ? string.Empty : dr.GetString(7);//發票抬頭

                    //Rika 20110413 修改 若統編開頭為A 則預設為2聯式折讓
                    if (this.txt_RFNO.Text.Substring(0, 1) == "A")
                    {
                        DropDownList drop_DISC_FORM = (DropDownList)this.slp_DISC_FORM.FindControl("D1");
                        drop_DISC_FORM.SelectedValue = "34";
                    }
                    else
                    {
                        DropDownList drop_DISC_FORM = (DropDownList)this.slp_DISC_FORM.FindControl("D1");
                        drop_DISC_FORM.SelectedValue = "33";
                    }

                    #region Focus欄位

                    DropDownList drop_DISC_TYPE = (DropDownList)this.slp_DISC_TYPE.FindControl("D1");
                    string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(drop_DISC_TYPE.ClientID, false);
                    ScriptManager.RegisterStartupScript(this.up_Condition, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true);

                    #endregion
                }

                #endregion

                #region 檢查回傳資料

                else
                {
                    Set_STORE_ID_Default();

                    #region 若發生錯誤則alert訊息(秀玲要alert訊息)

                    string s_ScriptManager_Script = "alert('無符合店號或己關店,請重新輸入')";
                    ScriptManager.RegisterStartupScript(this.up_Condition, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true);

                    #endregion
                }
                dr.Close();

                #endregion
            }

            #endregion

            #region 如果不符合以上條件,代表錯誤

            else { throw new Exception("頁面資料錯誤,只有在[新增模式]下,才有欄位[店號]Onblur事件"); }

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally
        { Finally_Function(); }
    }
示例#3
0
    /// <summary>
    /// 取得頁面上的資料
    /// </summary>
    /// <param name="s_DISC_NO">折讓單號</param>
    private void Get_PageDataMainAndDetl(string s_DISC_NO)
    {
        #region 傳入參數

        BCO.CAACommon CAAComm = new BCO.CAACommon();

        ParameterList.Clear();
        ParameterList.Add(CAAComm.GetValueSetParameter(s_DISC_NO, "string", false));//[折讓單號]
        ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID

        #endregion

        #region 連結資料庫

        BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);
        DataSet ds_Return = bco.QueryDataByView(ParameterList);

        #endregion

        #region 將資料寫入相關欄位 MAIN

        string s_RequestString = Request.QueryString["CAA182_Type"];

        if (ds_Return.Tables["MAIN"].Rows.Count != 1 && s_RequestString != "ToolBar")
        { throw new Exception("查無折讓單號:" + s_DISC_NO + "的相關資料"); }
        else if (ds_Return.Tables["MAIN"].Rows.Count != 1 && s_RequestString == "ToolBar")
        { throw new Exception("查無此筆資料或已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!"); }

        DataRow dr_Return_Main = ds_Return.Tables["MAIN"].Rows[0];

        this.txt_DISC_NO.Text = dr_Return_Main["DISC_NO"].ToString();//折讓單號
        this.slp_DISC_FORM.Text = dr_Return_Main["DISC_FORM"].ToString();//格式代號
        this.slp_DISC_SOURCE.Text = dr_Return_Main["DISC_SOURCE"].ToString();//來源
        this.slp_GROUP_NO.Text = dr_Return_Main["GROUP_NO"].ToString();//店群
        this.slp_STORE_ID.Text = dr_Return_Main["STORE_ID"].ToString();//店號
        this.slp_Z_O.Text = dr_Return_Main["Z_O"].ToString();//營業所
        this.slp_DISC_TYPE.Text = dr_Return_Main["DISC_TYPE"].ToString();//型式
        this.slp_ROOT_NO.Text = dr_Return_Main["ROOT_NO"].ToString();//商品群分類
        this.slp_TAX_TYPE.Text = dr_Return_Main["TAX_TYPE"].ToString();//稅別
        this.slp_SAL_ID.Text = dr_Return_Main["SAL_ID"].ToString();//營業人員
        this.slp_AC_UID.Text = dr_Return_Main["AC_UID"].ToString();//帳務人員
        this.slp_DISC_DATE.Text = dr_Return_Main["DISC_DATE"].ToString();//折讓日期
        this.txt_ACT_DISC_NO.Text = dr_Return_Main["ACT_DISC_NO"].ToString();//財會折讓單號
        this.slp_CHG_DISC_DATE.Text = dr_Return_Main["CHG_DISC_DATE"].ToString();//異動折讓日期
        if (dr_Return_Main["PROOF_FLG"].ToString() != "0" && dr_Return_Main["PROOF_FLG"].ToString() != "1")
        { throw new Exception("折讓單號:" + dr_Return_Main["DISC_NO"].ToString() + ",資料庫欄位[PROOF_FLG]資料錯誤"); }
        else
        { this.chb_PROOF_FLG.Checked = dr_Return_Main["PROOF_FLG"].ToString() == "0" ? false : true; }//憑證已回
        this.slp_PROOF_DATE.Text = dr_Return_Main["PROOF_DATE"].ToString();//憑證已回日期
        if (dr_Return_Main["REPROOF_FLG"].ToString() != "0" && dr_Return_Main["REPROOF_FLG"].ToString() != "1")
        { throw new Exception("折讓單號:" + dr_Return_Main["DISC_NO"].ToString() + ",資料庫欄位[REPROOF_FLG]資料錯誤"); }
        else
        { this.chb_REPROOF_FLG.Checked = dr_Return_Main["REPROOF_FLG"].ToString() == "0" ? false : true; }//取具進項憑証
        this.txt_REPROOF_NO.Text = dr_Return_Main["REPROOF_NO"].ToString();//發票號碼/收據

        if (dr_Return_Main["RECEIPT_FLG"].ToString() != "0" && dr_Return_Main["RECEIPT_FLG"].ToString() != "1")
        { throw new Exception("折讓單號:" + dr_Return_Main["DISC_NO"].ToString() + ",資料庫欄位[RECEIPT_FLG]資料錯誤"); }
        else
        { this.chb_RECEIPT_FLG.Checked = dr_Return_Main["RECEIPT_FLG"].ToString() == "0" ? false : true; }//憑證收據
        if (dr_Return_Main["CANCEL_FLG"].ToString() != "0" && dr_Return_Main["CANCEL_FLG"].ToString() != "1")
        { throw new Exception("折讓單號:" + dr_Return_Main["DISC_NO"].ToString() + ",資料庫欄位[CANCEL_FLG]資料錯誤"); }
        else
        { this.chb_CANCEL_FLG.Checked = dr_Return_Main["CANCEL_FLG"].ToString() == "0" ? false : true; }//作廢
        this.slp_CANCEL_DATE.Text = dr_Return_Main["CANCEL_DATE"].ToString();//作廢日期
        if (dr_Return_Main["PERIOD_FLG"].ToString() != "0" && dr_Return_Main["PERIOD_FLG"].ToString() != "1")
        { throw new Exception("折讓單號:" + dr_Return_Main["DISC_NO"].ToString() + ",資料庫欄位[PERIOD_FLG]資料錯誤"); }
        else
        { this.chb_PERIOD_FLG.Checked = dr_Return_Main["PERIOD_FLG"].ToString() == "0" ? false : true; }//申報
        this.slp_PERIOD_DATE.Text = dr_Return_Main["PERIOD_DATE"].ToString();//申報日期
        if (dr_Return_Main["TEMPORAL_FLG"].ToString() != "0" && dr_Return_Main["TEMPORAL_FLG"].ToString() != "1")
        { throw new Exception("折讓單號:" + dr_Return_Main["DISC_NO"].ToString() + ",資料庫欄位[TEMPORAL_FLG]資料錯誤"); }
        else
        { this.chb_TEMPORAL_FLG.Checked = dr_Return_Main["TEMPORAL_FLG"].ToString() == "0" ? false : true; }//轉暫收
        this.slp_TEMPORAL_DATE.Text = dr_Return_Main["TEMPORAL_DATE"].ToString();//暫收日期
        this.txt_PAY_RFNO.Text = dr_Return_Main["PAY_RFNO"].ToString();//結帳統編
        this.txt_RFNO.Text = dr_Return_Main["RFNO"].ToString();//統一編號
        this.txt_TITLE.Text = dr_Return_Main["TITLE"].ToString();//發票抬頭
        this.txt_INV_ADDR.Text = dr_Return_Main["INV_ADDR"].ToString();//地址
        this.slp_DISC_UAMT.Text = dr_Return_Main["DISC_UAMT"].ToString();//折讓金額(未稅)
        this.slp_DISC_TAX.Text = dr_Return_Main["DISC_TAX"].ToString();//折讓稅額
        this.slp_DISC_AMT.Text = dr_Return_Main["DISC_AMT"].ToString();//總金額
        this.slp_CLOSE_MONTH.Text = dr_Return_Main["CLOSE_MONTH"].ToString();//結帳年月
        this.txt_MEMO.Text = dr_Return_Main["MEMO"].ToString();//備註
        this.slp_CLOSE_MONTH_ACCT.Text = dr_Return_Main["CLOSE_MONTH_ACCT"].ToString();//結帳年月-財會
        this.hid_Record_Date.Value = dr_Return_Main["CREATEDATE"].ToString();//建立時間

        //20110512 rika insert
        this.slp_PERIOD_MONTH.Text = dr_Return_Main["PERIOD_MONTH"].ToString();//申報期別
        this.slp_DISC_REMAIN_AMT.Text = dr_Return_Main["DISC_REMAIN_AMT"].ToString();//折讓餘額
        this.slp_DISC_WASH_AMT.Text = (Convert.ToInt32(dr_Return_Main["DISC_AMT"])-Convert.ToInt32(dr_Return_Main["DISC_REMAIN_AMT"])).ToString();//累積沖帳金額

        #endregion

        #region 編輯狀態,紀錄CheckBox的勾選狀態

        if (this.hid_PageStatus.Value == "edit")
        {
            if (arl_Chk_Status != null)
            { arl_Chk_Status.Clear(); }
            else
            { arl_Chk_Status = new ArrayList(); }

            //20100715 秀玲新增[取具收據]狀態
            arl_Chk_Status.Add(this.chb_PROOF_FLG.Checked);//憑證已回
            arl_Chk_Status.Add(this.chb_REPROOF_FLG.Checked);//取具進項憑証
            arl_Chk_Status.Add(this.chb_RECEIPT_FLG.Checked);//取具收據
            arl_Chk_Status.Add(this.chb_CANCEL_FLG.Checked);//作廢
            arl_Chk_Status.Add(this.chb_PERIOD_FLG.Checked);//申報
            arl_Chk_Status.Add(this.chb_TEMPORAL_FLG.Checked);//轉暫收

            this.hid_CheckBox_Status.Value = string.Empty;
            for (int i = 0; i < arl_Chk_Status.Count; i++)
            {
                if ((bool)arl_Chk_Status[i] == true)
                { hid_CheckBox_Status.Value += "1,"; }
                else
                { hid_CheckBox_Status.Value += "0,"; }
            }

            //將最後一個"逗號"去除
            hid_CheckBox_Status.Value = hid_CheckBox_Status.Value.Remove(hid_CheckBox_Status.Value.Length - 1, 1);
        }

        #endregion

        #region 編輯狀態,依照CheckBox的勾選狀態來設定GirdView的Enable

        if (this.hid_PageStatus.Value == "edit")
        {
            bool b_IsRight = false;
            string s_ReturnMsg = string.Empty;

            Check_CheckStatus(out b_IsRight, out s_ReturnMsg);

            if (b_IsRight == false)
            {
                if (s_ReturnMsg == "勾選欄位[憑證已回]" ||
                    s_ReturnMsg == "取消勾選欄位[憑證已回]" ||
                    s_ReturnMsg == "勾選欄位[取具進項憑証]" ||
                    s_ReturnMsg == "取消勾選欄位[取具進項憑証]" ||
                    s_ReturnMsg == "勾選欄位[取具收據]" ||
                    s_ReturnMsg == "取消勾選欄位[取具收據]" ||
                    s_ReturnMsg == "都沒有勾")
                { b_GirdView_Enable = true; }
            }
        }

        #endregion

        #region 資料與GridView繫結 DETL

        //抓取本頁初次登記的時間
        string SessionIDName = "CAA182_" + PageTimeStamp.Value;

        Session["SessionID"] = SessionIDName;
        Session[SessionIDName] = ds_Return.Tables["DETL"];

        this.gv_DiscInv.DataSource = ds_Return.Tables["DETL"];
        this.gv_DiscInv.PageSize = 10;
        this.gv_DiscInv.PageIndex = 0;
        this.gv_DiscInv.DataBind();

        #endregion

        #region 如果是編輯模式,則將資料放入TempTable

        if (this.hid_PageStatus.Value == "edit")
        {
            dt_Main = ds_Return.Tables["MAIN"].Copy();
            dt_NewItem = ds_Return.Tables["DETL"].Copy();
        }

        #endregion
    }
示例#4
0
    /// <summary>
    /// 折讓項目,欄位[發票號碼]TextChanged事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void txt_Disc_INV_NO_TextChanged(object sender, EventArgs e)
    {
        try
        {
            #region 新增模式 & 檢視模式

            if (this.hid_PageStatus.Value == "insert" ||
                this.hid_PageStatus.Value == "edit")
            {
                #region 設定變數

                BCO.CAACommon CAAComm = new BCO.CAACommon();

                #endregion

                #region 檢查傳入欄位[發票號碼]的值

                if (this.txt_Disc_INV_NO.Text.Trim() == string.Empty)
                {
                    Set_Disc_NewItem_Default();
                    return;
                }

                #endregion

                #region 若輸入的發票號碼存在於按折讓開立查出的資料

                bool b_IsExist_GetDiscInv = Set_Disc_NewItem_Value(this.txt_Disc_INV_NO.Text, dt_NewItem);

                #endregion

                #region 若輸入的發票號碼不存在於按折讓開立查出的資料

                if (b_IsExist_GetDiscInv == false)
                {
                    #region 傳入參數

                    ParameterList.Clear();
                    ParameterList.Add(CAAComm.GetValueSetParameter("TEXT", "string", false));//[查詢型態]
                    if (this.hid_PageStatus.Value == "insert")
                    { ParameterList.Add(CAAComm.GetValueSetParameter(DateTime.Now.ToString(), "date", false)); }
                    else if (this.hid_PageStatus.Value == "edit")
                    { ParameterList.Add(CAAComm.GetValueSetParameter(this.hid_Record_Date.Value, "date", false)); }//[履歷時間]
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_STORE_ID.Text, "string", false));//[店號]
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_RFNO.Text, "string", false));//[統一編號]
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_ROOT_NO.Text, "string", false));//[商品群分類]
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_TAX_TYPE.Text, "int", false));//[稅別]
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_Disc_INV_NO.Text, "string", false));//[發票號碼]
                    ParameterList.Add(CAAComm.GetValueSetParameter("1", "int", false));//只取第1筆
                    ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID

                    #endregion

                    #region 連結資料庫

                    BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);
                    DataTable dt_Return = bco.GetDetailRecord(ParameterList);

                    #endregion

                    #region 檢查回傳資料

                    #region 如果沒資料

                    if (dt_Return.Rows.Count == 0)
                    {
                        this.ErrorMsgLabel2.Text = "查無發票號碼:" + this.txt_Disc_INV_NO.Text + "的相關資料";
                        Set_Disc_NewItem_Default();
                    }

                    #endregion

                    #region 如果有資料

                    else
                    {
                        Set_Disc_NewItem_Value(this.txt_Disc_INV_NO.Text, dt_Return);

                        #region 使用XML,將資料放置到前端

                        xml_VDS_CAA_INV_MAIN_Data.InnerHtml = dt_Return.DataSet.GetXml();

                        #endregion

                        #region Focus欄位

                        string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(slp_Disc_DISC_UAMT.TextBox_Code.ClientID, true);
                        ScriptManager.RegisterStartupScript(this.up_DiscItem, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true);

                        #endregion
                    }

                    #endregion

                    #endregion
                }
                else
                {
                    #region Focus欄位

                    string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(slp_Disc_DISC_UAMT.TextBox_Code.ClientID, true);
                    ScriptManager.RegisterStartupScript(this.up_DiscItem, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true);

                    #endregion
                }

                #endregion
            }

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel2.Text = ex.Message;
        }
        finally { Finally_Function(); }
    }
示例#5
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;
    }
示例#6
0
    protected void but_TAB3_Export_Click(object sender, EventArgs e)
    {
        try
        {
            ArrayList arl_Check_Condition = Check_Condition("TAB 報表");

            #region 如果檢查有誤,則Return

            if (arl_Check_Condition[1].ToString() != string.Empty)
            {
                #region 錯誤訊息

                this.ErrorMsgLabel.Text = arl_Check_Condition[1].ToString();

                #endregion

                #region Focus欄位

                if (arl_Check_Condition[0].ToString() != string.Empty)
                {
                    BCO.CAACommon CAAComm = new BCO.CAACommon();
                    string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(arl_Check_Condition[0].ToString(), true);
                    ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CAA181", s_ScriptManager_Script, true);
                }

                #endregion

                return;
            }

            #endregion


            #region 傳入參數

            BCO.CAACommon CAACommon = new BCO.CAACommon();

            ParameterList.Clear();
            ParameterList.Add(this.slp_3_CLOSE_MONTH_B.Text);//結帳年月起  
            ParameterList.Add(this.slp_3_CLOSE_MONTH_E.Text);//結帳年月迄
            ParameterList.Add(this.slp_3_CLOSE_MONTH_ACCT_B.Text);//結帳年月-財會起
            ParameterList.Add(this.slp_3_CLOSE_MONTH_ACCT_E.Text);//結帳年月-財會迄
            ParameterList.Add(this.slp_3_PROFIT_NO_B.Text);//利潤中心起
            ParameterList.Add(this.slp_3_PROFIT_NO_E.Text);//利潤中心迄
            ParameterList.Add(this.slp_3_Z_O_B.Text);//營業所起
            ParameterList.Add(this.slp_3_Z_O_E.Text);//營業所迄
            ParameterList.Add(this.slp_3_AC_UID_B.Text);//帳務人員起
            ParameterList.Add(this.slp_3_AC_UID_E.Text);//帳務人員迄
            ParameterList.Add(this.chb_3_Status.Items[0].Selected ? 1 : 0);//狀態:憑證己回
            ParameterList.Add(this.chb_3_Status.Items[1].Selected ? 1 : 0);//狀態:憑證未回
            ParameterList.Add(this.chb_3_Status.Items[2].Selected ? 1 : 0);//狀態:取具進項憑證
            ParameterList.Add(this.chb_3_Status.Items[3].Selected ? 1 : 0);//狀態:取具收據
            ParameterList.Add(this.chb_3_Status.Items[4].Selected ? 1 : 0);//狀態:作廢
            ParameterList.Add(this.slp_3_DISC_SOURCE.Text);//來源
            ParameterList.Add(this.slp_3_DISC_TYPE.Text);//型式
            ParameterList.Add(this.slp_3_PERIOD_DATE.StartDate);//申報日期起
            ParameterList.Add(this.slp_3_PERIOD_DATE.EndDate);//申報日期迄
            ParameterList.Add(this.slp_3_PERIOD_MONTH_B.Text);//申報期別起
            ParameterList.Add(this.slp_3_PERIOD_MONTH_E.Text);//申報期別迄 

            #endregion

            #region 連結資料庫

            DataTable dt = new DataTable();

            BCO.MaintainDiscRecord BCO = new BCO.MaintainDiscRecord(ConntionDB);
            dt = BCO.QueryData_ACCT(ParameterList);

            #endregion

            #region 檢查回傳資料

            if (dt.Rows.Count == 0)
            { this.ErrorMsgLabel.Text = "查無資料"; }

            #endregion
            else
            {
                DataRow dr = dt.NewRow();

                dr["PROFIT_NO"] = "未稅合計";
                dr["W_AMT"]	= dt.Compute("Sum(W_AMT)", string.Empty);
                dr["Z_AMT"] = dt.Compute("Sum(Z_AMT)", string.Empty);
                dr["Z_AMT_1"] = dt.Compute("Sum(Z_AMT_1)", string.Empty);
                dr["Z_AMT_2"] = dt.Compute("Sum(Z_AMT_2)", string.Empty);
                dr["Z_AMT_3"] = dt.Compute("Sum(Z_AMT_3)", string.Empty);
                dr["Z_AMT_4"] = dt.Compute("Sum(Z_AMT_4)", string.Empty);
                dr["Z_AMT_5"] = dt.Compute("Sum(Z_AMT_5)", string.Empty);
                dr["Z_AMT_6"] = dt.Compute("Sum(Z_AMT_6)", string.Empty);
                dr["Z_AMT_7"] = dt.Compute("Sum(Z_AMT_7)", string.Empty);
                dr["AMT"] = dt.Compute("Sum(AMT)", string.Empty);
                dr["PSS_AMT"] = dt.Compute("Sum(PSS_AMT)", string.Empty);
                dr["OTHER_AMT"] = dt.Compute("Sum(OTHER_AMT)", string.Empty);

                dt.Rows.Add(dr);

                Export_Excel(dt);
            }
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }

    }
示例#7
0
    /// <summary>
    /// BUTTON [折讓開立]鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_GetDiscInv_Click(object sender, EventArgs e)
    {
        try
        {
            #region 新增狀態

            if (this.hid_PageStatus.Value == "insert")
            {
                #region 檢查條件

                BCO.CAACommon CAAComm = new BCO.CAACommon();
                ArrayList arl_Check_Condition = Check_Condition("BUTTON [折讓開立]鈕");

                #region 如果檢查有誤,則Return

                if (arl_Check_Condition[1].ToString() != string.Empty)
                {
                    #region 錯誤訊息

                    this.ErrorMsgLabel.Text = arl_Check_Condition[1].ToString();

                    #endregion

                    #region Focus欄位

                    if (arl_Check_Condition[0].ToString() != string.Empty)
                    {
                        string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(arl_Check_Condition[0].ToString(), true);
                        ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true);
                    }

                    #endregion

                    return;
                }

                #endregion

                #endregion

                #region 清空變數

                if (dt_NewItem != null)
                { dt_NewItem.Clear(); }

                #endregion

                #region 清空新增項目

                #region 將新增項目的Panel關閉

                this.panel_Disc_NewItem.Visible = false;

                #endregion

                #region 設定新增項目的初始狀態

                Set_Disc_NewItem_Default();

                #endregion

                #endregion

                #region 傳入參數

                ParameterList.Clear();
                ParameterList.Add(CAAComm.GetValueSetParameter("BUTTON", "string", false));//[查詢型態]
                ParameterList.Add(CAAComm.GetValueSetParameter(DateTime.Now.ToString(), "date", false));//[履歷時間]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_STORE_ID.Text, "string", false));//[店號]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_RFNO.Text, "string", false));//[統一編號]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_ROOT_NO.Text, "string", false));//[商品群分類]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_TAX_TYPE.Text, "int", false));//[稅別]
                ParameterList.Add(CAAComm.GetValueSetParameter(string.Empty, "string", false));//[發票號碼]
                ParameterList.Add(CAAComm.GetValueSetParameter("100", "int", false));//只取前100筆
                ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID

                #endregion

                #region 連結資料庫

                BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);
                dt_NewItem = bco.GetDetailRecord(ParameterList);

                #endregion

                #region 資料與GridView繫結

                this.gv_DiscInv.DataSource = dt_NewItem;
                this.gv_DiscInv.PageSize = 10;//設定一頁10筆資料
                this.gv_DiscInv.PageIndex = 0;
                this.gv_DiscInv.DataBind();

                #endregion

                #region 檢查回傳資料

                #region 不管有沒有資料,[新增項目]鈕都要可以按

                this.but_Disc_NewItem.Enabled = true;

                #endregion

                #region 計算欄位[折讓金額(未稅)][折讓稅額][總金額]

                int i_txt_DISC_UAMT = 0;//折讓金額(未稅)
                int i_txt_DISC_TAX = 0;//折讓稅額
                int i_txt_DISC_AMT = 0;//含稅金額

                foreach (DataRow dr_Count in dt_NewItem.Rows)
                {
                    i_txt_DISC_UAMT += int.Parse(dr_Count["DISC_UAMT"].ToString());//折讓金額(未稅)
                    i_txt_DISC_TAX += int.Parse(dr_Count["DISC_TAX"].ToString());//折讓稅額
                    i_txt_DISC_AMT += int.Parse(dr_Count["DISC_AMT"].ToString());//含稅金額
                }

                this.slp_DISC_UAMT.Text = i_txt_DISC_UAMT.ToString();//折讓金額(未稅)
                this.slp_DISC_TAX.Text = i_txt_DISC_TAX.ToString();//折讓稅額
                this.slp_DISC_AMT.Text = i_txt_DISC_AMT.ToString();//總金額

                #endregion

                #region 將畫面鎖起來

                this.slp_DISC_FORM.ReadOnly = true;//格式代號
                this.slp_STORE_ID.ReadOnly = true;//店號
                this.slp_DISC_TYPE.ReadOnly = true;//型式
                this.slp_ROOT_NO.ReadOnly = true;//商品群分類
                this.slp_TAX_TYPE.ReadOnly = true;//稅別
                this.txt_ACT_DISC_NO.ReadOnly = true;//財會折讓單號
                this.txt_ACT_DISC_NO.CssClass = "readtxtbox";
                this.slp_CHG_DISC_DATE.ReadOnly = true;//異動折讓日期
                this.chb_PROOF_FLG.Enabled = false;//憑證已回
                this.slp_PROOF_DATE.ReadOnly = true;//憑證已回日期
                this.chb_REPROOF_FLG.Enabled = false;//取具進項憑証
                this.txt_REPROOF_NO.ReadOnly = true;//發票號碼/收據
                this.txt_REPROOF_NO.CssClass = "readtxtbox";
                this.chb_RECEIPT_FLG.Enabled = false;//取具收據
                this.slp_CLOSE_MONTH.ReadOnly = true;//結帳年月
                this.txt_MEMO.ReadOnly = true;//備註
                this.txt_MEMO.CssClass = "readtxtbox";

                #endregion

                #endregion
            }

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally
        { Finally_Function(); }
    }
示例#8
0
    /// <summary>
    /// BUTTON [查詢]鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_Query_Click(object sender, EventArgs e)
    {
        try
        {
            #region 檢查條件

            BCO.CAACommon CAAComm = new BCO.CAACommon();

            string s_Type = string.Empty;
            if (this.TabContainer1.ActiveTabIndex == 0)
            { s_Type = "BUTTON [查詢]鈕 TAB 銷貨折讓維護"; }
            else if (this.TabContainer1.ActiveTabIndex == 1)
            { s_Type = "BUTTON [查詢]鈕 TAB 發票折抵明細查詢"; }
            else
            { throw new Exception("頁面資訊錯誤,[查詢]鈕,只有在頁籤為[銷貨折讓維護][發票折抵明細查詢]時才可以使用"); }

            ArrayList arl_Check_Condition = Check_Condition(s_Type);

            #region 如果檢查有誤,則Return

            if (arl_Check_Condition[1].ToString() != string.Empty)
            {
                #region 錯誤訊息

                this.ErrorMsgLabel.Text = arl_Check_Condition[1].ToString();

                #endregion

                #region Focus欄位

                if (arl_Check_Condition[0].ToString() != string.Empty)
                {
                    string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(arl_Check_Condition[0].ToString(), true);
                    ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CAA181", s_ScriptManager_Script, true);
                }

                #endregion

                return;
            }

            #endregion

            #endregion

            #region 傳入參數

            #region TabContainer 銷貨折讓維護

            if (this.TabContainer1.ActiveTabIndex == 0)
            {
                ParameterList.Clear();
                ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_DISC_NO.Text, "string", this.chb_LikeSearch.Checked));//[折讓單號]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_FORM.Text, "int", false));//[格式代號]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_SOURCE.Text, "int", false));//[來源]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_GROUP_NO.Text, "string", this.chb_LikeSearch.Checked));//[店群]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_STORE_ID.Text, "string", this.chb_LikeSearch.Checked));//[店號]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_Z_O.Text, "string", false));//[營業所]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_TYPE.Text, "string", false));//[型式]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_ROOT_NO.Text, "string", this.chb_LikeSearch.Checked));//[商品群分類]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_TAX_TYPE.Text, "string", false));//[稅別]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_SAL_ID.Text, "string", this.chb_LikeSearch.Checked));//[營業人員]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_AC_UID.Text, "string", this.chb_LikeSearch.Checked));//[帳務人員]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_DATE.StartDate, "date", false));//[折讓日期]起
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_DATE.EndDate, "date", false));//[折讓日期]迄
                ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_ACT_DISC_NO.Text, "string", this.chb_LikeSearch.Checked));//[財會折讓單號]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CHG_DISC_DATE.StartDate, "date", false));//[異動折讓日期]起
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CHG_DISC_DATE.EndDate, "date", false));//[異動折讓日期]迄
                ParameterList.Add(CAAComm.GetValueSetParameter((this.radl_PROOF_TYPE.Text == "2") ? string.Empty : this.radl_PROOF_TYPE.Text, "int", false));//[憑證已回]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_PROOF_DATE.StartDate, "date", false));//[憑換已回日期]起
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_PROOF_DATE.EndDate, "date", false));//[憑換已回日期]迄
                ParameterList.Add(CAAComm.GetValueSetParameter((this.radl_REPROOF_TYPE.Text == "2") ? string.Empty : this.radl_REPROOF_TYPE.Text, "int", false));//[取具進項憑証]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_REPROOF_NO.Text, "string", this.chb_LikeSearch.Checked));//[發票號碼/收據]
                ParameterList.Add(CAAComm.GetValueSetParameter((this.radl_RECEIPT_TYPE.Text == "2") ? string.Empty : this.radl_RECEIPT_TYPE.Text, "int", false));//[取具收據]
                ParameterList.Add(CAAComm.GetValueSetParameter((this.radl_CANCEL_TYPE.Text == "2") ? string.Empty : this.radl_CANCEL_TYPE.Text, "int", false));//[作廢]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CANCEL_DATE.StartDate, "date", false));//[作廢日期]起
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CANCEL_DATE.EndDate, "date", false));//[作廢日期]迄
                ParameterList.Add(CAAComm.GetValueSetParameter((this.radl_PERIOD_TYPE.Text == "2") ? string.Empty : this.radl_PERIOD_TYPE.Text, "int", false));//[申報]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_PERIOD_DATE.StartDate, "date", false));//[申報日期]起
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_PERIOD_DATE.EndDate, "date", false));//[申報日期]迄
                ParameterList.Add(CAAComm.GetValueSetParameter((this.radl_TEMPORAL_TYPE.Text == "2") ? string.Empty : this.radl_TEMPORAL_TYPE.Text, "int", false));//[轉暫收]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_TEMPORAL_DATE.StartDate, "date", false));//[暫收日期]起
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_TEMPORAL_DATE.EndDate, "date", false));//[暫收日期]迄
                ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_PAY_RFNO.Text, "string", this.chb_LikeSearch.Checked));//[結帳統編]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_RFNO.Text, "string", this.chb_LikeSearch.Checked));//[統一編號]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_INV_NO.Text, "string", this.chb_LikeSearch.Checked));//[地址]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_UAMT.Text, "int", false));//[折讓金額(未稅)]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_UAMT.Operator, "int", false));//[折讓金額(未稅)]Operator
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_TAX.Text, "int", false));//[折讓稅額]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_TAX.Operator, "int", false));//[折讓稅額]Operator
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_AMT.Text, "int", false));//[總金額]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_AMT.Operator, "int", false));//[總金額]Operator
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CLOSE_MONTH_B.Text, "string", false));//[結帳年月]起
                
                //20110505 rika insert
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CLOSE_MONTH_E.Text, "string", false));//[結帳年月]迄 
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CLOSE_MONTH_ACCT_B.Text, "string", false));//[結帳年月-財會]起
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CLOSE_MONTH_ACCT_E.Text, "string", false));//[結帳年月-財會]迄  
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_PERIOD_MONTH_B.Text, "string", false));//[申報期別]起
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_PERIOD_MONTH_E.Text, "string", false));//[申報期別]迄  
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_WASH_AMT.Text, "int", false));//[累積沖帳金額]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_WASH_AMT.Operator, "int", false));//[累積沖帳金額]Operator
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_REMAIN_AMT.Text, "int", false));//[折讓餘額]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_DISC_REMAIN_AMT.Operator, "int", false));//[折讓餘額]Operator

                ParameterList.Add(CAAComm.GetValueSetParameter((this.txt_RowCountLimit.Text == string.Empty) ? "100" : (int.Parse(this.txt_RowCountLimit.Text) < 0) ? "100" : this.txt_RowCountLimit.Text, "int", false));//[筆數]

                ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID
            }

            #endregion

            #region TabContainer 發票折抵明細查詢

            else if (this.TabContainer1.ActiveTabIndex == 1)
            {
                ParameterList.Clear();
                ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_2_INV_NO.Text, "string", this.chb_LikeSearch.Checked));//[發票號碼]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_2_INV_DATE.StartDate, "date", false));//[發票日期]起
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_2_INV_DATE.EndDate, "date", false));//[發票日期]迄
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_2_TAX_TYPE.Text, "int", false));//[發票稅別]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_2_ROOT_NO.Text, "string", this.chb_LikeSearch.Checked));//[商品群分類]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_2_ITEM_NAME.Text, "string", this.chb_LikeSearch.Checked));//[品名]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_2_INV_UAMT.Text, "int", false));//[發票金額(未稅)]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_2_INV_UAMT.Operator, "int", false));//[發票金額(未稅)]Operator
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_2_INV_TAX.Text, "int", false));//[發票稅額]
                ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_2_INV_TAX.Operator, "int", false));//[發票稅額]Operator
                ParameterList.Add(CAAComm.GetValueSetParameter((this.txt_RowCountLimit.Text == string.Empty) ? "100" : (int.Parse(this.txt_RowCountLimit.Text) < 0) ? "100" : this.txt_RowCountLimit.Text, "int", false));//[筆數]
                ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID
            }

            #endregion

            #region 其他狀況就是錯誤

            else
            { throw new Exception("頁面資訊錯誤,[查詢]鈕,只有在頁籤為[銷貨折讓維護][發票折抵明細查詢]時才可以使用"); }

            #endregion

            #endregion

            #region 連結資料庫

            DataTable dt_Return = new DataTable();
            BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);

            #region TabContainer 銷貨折讓維護

            if (this.TabContainer1.ActiveTabIndex == 0)
            { dt_Return = bco.QueryDiscRecordByFind(ParameterList); }

            #endregion

            #region TabContainer 發票折抵明細查詢

            else if (this.TabContainer1.ActiveTabIndex == 1)
            { dt_Return = bco.QueryInvDiscByFind(ParameterList); }

            #endregion

            #region 其他狀況就是錯誤

            else
            { throw new Exception("頁面資訊錯誤,[查詢]鈕,只有在頁籤為[銷貨折讓維護][發票折抵明細查詢]時才可以使用"); }

            #endregion

            #endregion

            #region 資料與GridView繫結

            //抓取本頁初次登記的時間
            string SessionIDName = "CAA181_" + PageTimeStamp.Value;

            Session["SessionID"] = SessionIDName;
            Session[SessionIDName] = dt_Return;

            this.gv_QueryResult.DataSource = dt_Return;
            this.gv_QueryResult.PageSize = (this.txt_Pagesize.Text == string.Empty) ? 20 : (int.Parse(this.txt_Pagesize.Text) < 0) ? 20 : int.Parse(this.txt_Pagesize.Text);
            this.gv_QueryResult.PageIndex = 0;
            this.gv_QueryResult.DataBind();

            #endregion

            #region 將Key值存到Session中

            ArrayList arl_Key = new ArrayList();
            foreach (DataRow drRow in dt_Return.Rows)
            { arl_Key.Add(drRow["DISC_NO"].ToString()); }

            Session["CAA182_SortKey" + this.PageTimeStamp.Value] = arl_Key;

            #endregion

            #region 檢查回傳資料

            if (dt_Return.Rows.Count == 0)
            { this.ErrorMsgLabel.Text = "查無資料"; }

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { Finally_Function(); }
    }
示例#9
0
    /// <summary>
    /// 頁籤=[報表] 欄位[報表類型]=彙總,按下Button[匯出]鈕
    /// </summary>
    private void but_TAB3_Print_Total()
    {
        try
        {
            #region 檢查條件

            BCO.CAACommon CAAComm = new BCO.CAACommon();

            ArrayList arl_Check_Condition = Check_Condition("TAB 報表");

            #region 如果檢查有誤,則Return

            if (arl_Check_Condition[1].ToString() != string.Empty)
            {
                #region 錯誤訊息

                this.ErrorMsgLabel.Text = arl_Check_Condition[1].ToString();

                #endregion

                #region Focus欄位

                if (arl_Check_Condition[0].ToString() != string.Empty)
                {
                    string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(arl_Check_Condition[0].ToString(), true);
                    ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "CAA181", s_ScriptManager_Script, true);
                }

                #endregion

                return;
            }

            #endregion

            #endregion

            #region 傳入參數

            ParameterList.Clear();
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_3_CLOSE_MONTH_B.Text, "string", false));//[結帳年月]起 20110520修改為起迄
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_3_CLOSE_MONTH_E.Text, "string", false));//[結帳年月]迄
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_3_CLOSE_MONTH_ACCT_B.Text, "string", false));//[結帳年月-財會]起 20110520修改為起迄
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_3_CLOSE_MONTH_ACCT_E.Text, "string", false));//[結帳年月-財會]迄           
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_3_PROFIT_NO_B.Text, "string", false));//[利潤中心]起
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_3_PROFIT_NO_E.Text, "string", false));//[利潤中心]迄
            ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UID

            #endregion

            #region 連接資料庫

            DataSet ds_Return = new DataSet();
            BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);
            ds_Return = bco.QUERY_CAA18_REPORT_SUMMARY(ParameterList);

            #endregion

            #region 檢查回傳資料

            if (ds_Return.Tables["SUMMARY"].Rows.Count == 0)
            {
                this.ErrorMsgLabel.Text = "查無資料";
                return;
            }

            #endregion

            #region 組合匯出的Excel

            #region 設定變數

            ExcelXmlWorkbook exl_WorkSheet = new ExcelXmlWorkbook();
            Worksheet sheet = exl_WorkSheet[0];
            sheet.Name = "折讓入帳彙總表";

            #region 設定長和寬

            int i_Vertical = 0;//直的有幾個欄位(依據資料庫[利潤中心])
            int i_Horizontal = 0;//橫的有幾個欄位(依據資料庫[型式])

            int i_Vertical_Fix = 3;//直的固定欄位[型式、稅別、合計]
            int i_Horizontal_Fix = 4;//橫的固定欄位[標題抬頭、利潤中心抬頭、合計上方要空一行、合計]

            i_Vertical = ds_Return.Tables["PROFIT"].Rows.Count + i_Vertical_Fix;
            i_Horizontal = (ds_Return.Tables["DISC_TYPE"].Rows.Count * 3) + i_Horizontal_Fix;

            #endregion

            #endregion

            #region 設定格式

            #region 設定欄位寬度

            for (int i_Style = 0; i_Style < i_Vertical; i_Style++)
            { sheet.Columns(i_Style).Width = 100; }

            #endregion

            #region 設定合併儲存格

            Range rang_1 = new Range(sheet[0, 0], sheet[i_Vertical - 1, 0]);
            rang_1.Merge();

            #endregion

            #region 設定Style

            XmlStyle style_1 = new XmlStyle();
            style_1.Alignment.Vertical = VerticalAlignment.Center;
            style_1.Border.LineStyle = Borderline.Continuous;
            style_1.Border.Color = System.Drawing.Color.Black;
            style_1.Border.Sides = BorderSides.All;
            style_1.Border.Weight = 1;
            style_1.Font.Size = 10;
            style_1.Font.Name = "新細明體";

            XmlStyle style_2 = new XmlStyle();
            style_2.Alignment.Vertical = VerticalAlignment.Center;
            style_2.Alignment.Horizontal = HorizontalAlignment.Center;
            style_2.Border.LineStyle = Borderline.Continuous;
            style_2.Border.Color = System.Drawing.Color.Black;
            style_2.Border.Sides = BorderSides.All;
            style_2.Border.Weight = 1;
            style_2.Font.Size = 10;
            style_2.Font.Name = "新細明體";

            for (int x = 0; x < i_Vertical; x++)
            {
                for (int y = 0; y < i_Horizontal; y++)
                {
                    if (y != 0)
                    { sheet[x, y].Style = style_1; }
                }
            }

            #endregion

            #endregion

            #region 組合匯出資料

            for (int i = 0; i < i_Horizontal; i++)
            {
                switch (i)
                {
                    #region 橫的第一行

                    case 0:
                        sheet[0, 0].Value = this.slp_3_CLOSE_MONTH_ACCT_B.Text == string.Empty ? "折讓入帳彙總表" : this.slp_3_CLOSE_MONTH_ACCT_B.Text + "-" + this.slp_3_CLOSE_MONTH_ACCT_E.Text + "月折讓入帳彙總表";
                        sheet[0, 0].Style = style_2;
                        break;

                    #endregion

                    #region 橫的第二行

                    case 1:
                        sheet[0, 1].Value = string.Empty;
                        sheet[1, 1].Value = string.Empty;
                        for (int i_case_1 = 0; i_case_1 < ds_Return.Tables["PROFIT"].Rows.Count; i_case_1++)
                        { sheet[i_case_1 + 2, 1].Value = ds_Return.Tables["PROFIT"].Rows[i_case_1]["PROFIT_NAME"].ToString(); }
                        sheet[i_Vertical - 1, 1].Value = "合計";
                        break;

                    #endregion

                    #region 其它行

                    default:
                        switch (i_Horizontal - i)
                        {
                            #region 橫的倒數第二行(合計上面一行要空白)

                            case 2:
                                sheet[0, i].Value = string.Empty;
                                break;

                            #endregion

                            #region 橫的最後一行(合計那一行)

                            case 1:
                                sheet[0, i].Value = "合計";
                                for (int i_case_last = 0; i_case_last < ds_Return.Tables["PROFIT"].Rows.Count; i_case_last++)
                                { sheet[i_case_last + 2, i_Horizontal - 1].Value = FormulaHelper.Formula("SUM", new Range(sheet[i_case_last + 2, 0], sheet[i_case_last + 2, i_Horizontal - 2])); }
                                sheet[i_Vertical - 1, i_Horizontal - 1].Value = FormulaHelper.Formula("SUM", new Range(sheet[i_Vertical - 1, 0], sheet[i_Vertical - 1, i_Horizontal - 2]));
                                break;

                            #endregion

                            #region 橫的其他行

                            default:

                                #region 設定變數

                                int i_Get_Disc_Type = (i - 2) / 3;
                                int i_Get_Tax_Type = (i - 2) % 3;
                                string s_FilterExpression = string.Empty;//篩選條件
                                string s_DISC_SOURCE = string.Empty;//來源(1=系統、2=人工)
                                string s_DISC_TYPE = string.Empty;//型式
                                string s_TAX_TYPE = string.Empty;//稅別
                                string s_PROFIT_NO = string.Empty;//利潤中心

                                #endregion

                                #region 第1欄(型式)

                                sheet[0, i].Value = ds_Return.Tables["DISC_TYPE"].Rows[i_Get_Disc_Type]["DISC_TYPE_NAME"].ToString();

                                #endregion

                                #region 第2欄(稅別)

                                switch (i_Get_Tax_Type)
                                {
                                    case 0:
                                        sheet[1, i].Value = "應稅";
                                        break;
                                    case 1:
                                        sheet[1, i].Value = "稅額";
                                        break;
                                    case 2:
                                        sheet[1, i].Value = "免稅";
                                        break;
                                }

                                #endregion

                                #region 其他資料欄

                                for (int i_case_default = 0; i_case_default < ds_Return.Tables["PROFIT"].Rows.Count; i_case_default++)
                                {
                                    #region 設定[來源][型式][稅別][利潤中心]參數

                                    //[來源][型式]
                                    switch (i_Get_Disc_Type)
                                    {
                                        case 0://第1個一定是系統-一般
                                            s_DISC_SOURCE = "1";//來源(1=系統、2=人工)
                                            s_DISC_TYPE = "1";//型式=1=一般
                                            break;
                                        case 1://第2個一定是人工-一般
                                            s_DISC_SOURCE = "2";//來源(1=系統、2=人工)
                                            s_DISC_TYPE = "1";//型式=1=一般
                                            break;
                                        default:
                                            s_DISC_SOURCE = "2";//來源(1=系統、2=人工)
                                            s_DISC_TYPE = ds_Return.Tables["DISC_TYPE"].Rows[i_Get_Disc_Type]["DISC_TYPE_NAME"].ToString();
                                            break;
                                    }

                                    //[稅別]
                                    switch (i_Get_Tax_Type)
                                    {
                                        case 0:
                                            s_TAX_TYPE = "0";//稅別=0=應稅,稅別=1=免稅
                                            break;
                                        case 1:
                                            s_TAX_TYPE = "0";//稅別=0=應稅,稅別=1=免稅
                                            break;
                                        case 2:
                                            s_TAX_TYPE = "1";//稅別=0=應稅,稅別=1=免稅
                                            break;
                                    }

                                    //[利潤中心]
                                    s_PROFIT_NO = ds_Return.Tables["PROFIT"].Rows[i_case_default]["CODE"].ToString();

                                    #endregion

                                    #region 組合查詢條件,查詢資料

                                    s_FilterExpression = "DISC_SOURCE='" + s_DISC_SOURCE + "' and DISC_TYPE='" + s_DISC_TYPE + "' and TAX_TYPE='" + s_TAX_TYPE + "' and PROFIT_NO='" + s_PROFIT_NO + "'";
                                    DataRow[] dr = ds_Return.Tables["SUMMARY"].Select(s_FilterExpression);

                                    #endregion

                                    #region 將資料寫入欄位

                                    switch (dr.Length)
                                    {
                                        case 1:
                                            if (i_Get_Tax_Type != 1)
                                            { sheet[i_case_default + 2, i].Value = int.Parse(dr[0]["DISC_UAMT"].ToString()); }
                                            else
                                            { sheet[i_case_default + 2, i].Value = int.Parse(dr[0]["DISC_TAX"].ToString()); }
                                            break;
                                        default:
                                            sheet[i_case_default + 2, i].Value = 0;
                                            break;
                                    }

                                    #endregion
                                }

                                #endregion

                                #region 合計欄(Excel右邊的[合計]欄)

                                sheet[i_Vertical - 1, i].Value = FormulaHelper.Formula("SUM", new Range(sheet[0, i], sheet[i_Vertical - 2, i]));

                                #endregion

                                break;

                            #endregion
                        }
                        break;

                    #endregion
                }
            }

            #endregion

            #region 匯出Excel

            string s_FileName = HttpUtility.UrlEncode("折讓入帳彙總表.XLS", System.Text.Encoding.UTF8);//設定輸出檔名
            Response.Charset = "big5";
            Response.ContentType = "application/x-excel;charset='utf-8'";
            Response.AddHeader("content-disposition", "attachment; filename=" + s_FileName);//excel檔名
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            exl_WorkSheet.Export(stream);
            if (stream == null ||
                stream.Length == 0)
            { return; }
            stream.Flush();
            stream.Position = 0;
            System.IO.StreamReader sr = new System.IO.StreamReader(stream);
            string producedExcel = sr.ReadToEnd();
            stream.Close();
            Response.Write(producedExcel);
            Response.Flush();
            Response.End();

            #endregion

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
    }
示例#10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            #region Attributes

            this.but_Close.Attributes["onclick"] += "window.close();";

            #endregion

            #region 取得發票號碼

            string s_INV_NO = string.Empty;
            s_INV_NO = Request["INV_NO"].ToString();

            #endregion

            #region 傳入參數

            BCO.CAACommon CAAComm = new BCO.CAACommon();

            ParameterList.Clear();
            ParameterList.Add(CAAComm.GetValueSetParameter(s_INV_NO, "string", false));//[發票號碼]
            ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID

            #endregion

            #region 連結資料庫

            BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);
            DataTable dt_Return = bco.QueryDataByReView(ParameterList);

            #endregion

            #region 檢查回傳資料

            if (dt_Return.Rows.Count == 0)
            {
                this.ErrorMsgLabel.Text = "查無發票號碼:[" + s_INV_NO + "]的資料";
                return;
            }
            else if (dt_Return.Rows.Count != 1)
            {
                this.ErrorMsgLabel.Text = "發票號碼:[" + s_INV_NO + "]的資料錯誤";
                return;
            }

            #endregion

            #region 將資料寫入控制項

            DataRow dr_Return = dt_Return.Rows[0];

            this.slp_INV_DATE.Text = dr_Return["INV_DATE"].ToString();//發票日
            this.txt_INV_FORM.Text = dr_Return["INV_FORM"].ToString();//發票別
            this.txt_INV_NO.Text = dr_Return["INV_NO"].ToString();//發票號碼
            this.slp_TAX_TYPE.Text = dr_Return["TAX_TYPE"].ToString();//稅別
            this.txt_INV_CHKNO.Text = dr_Return["INV_CHKNO"].ToString();//檢查號
            this.slp_STORE_ID.Text = dr_Return["STORE_ID"].ToString();//店號
            this.txt_ITEM_NAME.Text = dr_Return["ITEM_NAME"].ToString();//品名
            this.txt_INV_VERSION.Text = dr_Return["INV_VERSION"].ToString();//版本
            this.txt_PAY_RFNO.Text = dr_Return["PAY_RFNO"].ToString();//結帳統編
            this.txt_VOUCH_RFNO.Text = dr_Return["VOUCH_RFNO"].ToString();//統一編號
            this.txt_INV_ADDR.Text = dr_Return["INV_ADDR"].ToString();//地址
            this.slp_INV_UAMT.Text = dr_Return["INV_UAMT"].ToString();//發票金額(未稅)
            this.slp_INV_TAX.Text = dr_Return["INV_TAX"].ToString();//發票稅額
            this.slp_INV_AMT.Text = dr_Return["INV_AMT"].ToString();//總金額

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { Set_PageStatus(); }
    }
示例#11
0
        /// <summary>
        /// CAA18 頁籤=銷貨折讓維護
        /// </summary>
        /// <param name="ParameterList"></param>
        /// <returns></returns>
        public DataTable CAA18_1(ArrayList ParameterList)
        {
            #region 宣告變數

            BCO.CAACommon CAAComm = new BCO.CAACommon();
            ArrayList arl_ReportService = new ArrayList();
            DataTable dt_Return = new DataTable();
            bool b_LikeSearch;

            #endregion

            #region 傳入參數

            b_LikeSearch = (ParameterList[52].ToString() == "true") ? true : false;

            arl_ReportService.Clear();
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[0].ToString(), "string", b_LikeSearch));//[折讓單號](0)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[1].ToString(), "int", false));//[格式代號](1)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[2].ToString(), "int", false));//[來源](2)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[3].ToString(), "string", b_LikeSearch));//[店群](3)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[4].ToString(), "string", b_LikeSearch));//[店號](4)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[5].ToString(), "string", false));//[營業所](5)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[6].ToString(), "string", false));//[型式](6)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[7].ToString(), "string", b_LikeSearch));//[商品群分類](7)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[8].ToString(), "string", false));//[稅別](8)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[9].ToString(), "string", b_LikeSearch));//[營業人員](9)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[10].ToString(), "string", b_LikeSearch));//[帳務人員](10)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[11].ToString(), "date", false));//[折讓日期]起(11)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[12].ToString(), "date", false));//[折讓日期]迄(12)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[13].ToString(), "string", b_LikeSearch));//[財會折讓單號](13)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[14].ToString(), "date", false));//[異動折讓日期]起(14)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[15].ToString(), "date", false));//[異動折讓日期]迄(15)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[16].ToString(), "int", false));//[憑證已回](16)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[17].ToString(), "date", false));//[憑換已回日期]起(17)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[18].ToString(), "date", false));//[憑換已回日期]迄(18)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[19].ToString(), "int", false));//[取具進項憑証](19)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[20].ToString(), "string", b_LikeSearch));//[發票號碼/收據](20)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[21].ToString(), "int", false));//[取具收據](21)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[22].ToString(), "int", false));//[作廢](22)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[23].ToString(), "date", false));//[作廢日期]起(23)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[24].ToString(), "date", false));//[作廢日期]迄(24)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[25].ToString(), "int", false));//[申報](25)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[26].ToString(), "date", false));//[申報日期]起(26)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[27].ToString(), "date", false));//[申報日期]迄(27)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[28].ToString(), "int", false));//[轉暫收](28)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[29].ToString(), "date", false));//[暫收日期]起(29)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[30].ToString(), "date", false));//[暫收日期]迄(30)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[31].ToString(), "string", b_LikeSearch));//[結帳統編](31)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[32].ToString(), "string", b_LikeSearch));//[統一編號](32)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[33].ToString(), "string", b_LikeSearch));//[地址](33)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[34].ToString(), "int", false));//[折讓金額(未稅)](34)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[35].ToString(), "int", false));//[折讓金額(未稅)]Operator(35)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[36].ToString(), "int", false));//[折讓稅額](36)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[37].ToString(), "int", false));//[折讓稅額]Operator(37)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[38].ToString(), "int", false));//[總金額](38)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[39].ToString(), "int", false));//[總金額]Operator(39)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[40].ToString(), "string", b_LikeSearch));//[結帳年月]起(40)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[41].ToString(), "string", b_LikeSearch));//[結帳年月]迄(41)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[42].ToString(), "string", b_LikeSearch));//[結帳年月-財會]起(42)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[43].ToString(), "string", b_LikeSearch));//[結帳年月-財會]迄(43)

            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[44].ToString(), "string", false));//[申報年月]起(44)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[45].ToString(), "string", false));//[申報年月]迄(45)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[46].ToString(), "int", false));//[累積沖帳金額](46)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[47].ToString(), "int", false));//[累積沖帳金額]Operator(47)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[48].ToString(), "int", false));//[折讓餘額](48)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[49].ToString(), "int", false));//[折讓餘額]Operator(49)

            arl_ReportService.Add(CAAComm.GetValueSetParameter((ParameterList[50].ToString() == string.Empty) ? "100" : (int.Parse(ParameterList[50].ToString()) < 0) ? "100" : ParameterList[50].ToString(), "int", false));//[筆數](50)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[51].ToString(), "string", false));//V_LOG_UID(51)

            #endregion

            #region 連結資料庫

            BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);
            dt_Return = bco.QueryDiscRecordByFind(arl_ReportService);

            #endregion

            #region 檢查回傳資料

            if (dt_Return.Rows.Count == 0)
            { throw new Exception("查無資料"); }

            #endregion

            return dt_Return;
        }
示例#12
0
        /// <summary>
        /// CAA18 頁籤=發票資料查詢
        /// </summary>
        /// <param name="ParameterList"></param>
        /// <returns></returns>
        public DataTable CAA18_2(ArrayList ParameterList)
        {
            #region 宣告變數

            BCO.CAACommon CAAComm = new BCO.CAACommon();
            ArrayList arl_ReportService = new ArrayList();
            DataTable dt_Return = new DataTable();
            bool b_LikeSearch;

            #endregion

            #region 傳入參數

            b_LikeSearch = (ParameterList[12].ToString() == "true") ? true : false;

            arl_ReportService.Clear();
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[0].ToString(), "string", b_LikeSearch));//[發票號碼](0)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[1].ToString(), "date", false));//[發票日期]起(1)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[2].ToString(), "date", false));//[發票日期]迄(2)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[3].ToString(), "int", false));//[發票稅別](3)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[4].ToString(), "string", b_LikeSearch));//[商品群分類](4)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[5].ToString(), "string", b_LikeSearch));//[品名](5)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[6].ToString(), "int", false));//[發票金額(未稅)](6)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[7].ToString(), "int", false));//[發票金額(未稅)]Operator(7)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[8].ToString(), "int", false));//[發票稅額](8)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[9].ToString(), "int", false));//[發票稅額]Operator(9)
            arl_ReportService.Add(CAAComm.GetValueSetParameter((ParameterList[10].ToString() == string.Empty) ? "100" : (int.Parse(ParameterList[10].ToString()) < 0) ? "100" : ParameterList[10].ToString(), "int", false));//[筆數](10)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[11].ToString(), "string", false));//V_LOG_UPDATEUID(11)

            #endregion

            #region 連結資料庫

            BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB);
            dt_Return = bco.QueryInvDiscByFind(arl_ReportService);

            #endregion

            #region 檢查回傳資料

            if (dt_Return.Rows.Count == 0)
            { throw new Exception("查無資料"); }

            #endregion

            return dt_Return;
        }