Exemple #1
0
    /// <summary>
    /// BUTTON [儲存]鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_Save_Click(object sender, EventArgs e)
    {
        try
        {
            #region 先判斷GridView有無資料

            if (this.gv_Result.Rows.Count == 0)
            {
                this.ErrorMsgLabel.Text = "請先按[查詢]鈕";
                return;
            }

            #endregion

            #region 將GridView的資訊寫入TempTable

            bool b_IsRightExecute = false;
            Set_PageValue_To_TempTable("Modify" ,out b_IsRightExecute);

            #endregion

            #region 如果將GridView的資訊寫入TempTable有誤,則 return

            if (b_IsRightExecute == false)
            { return; }

            #endregion

            #region 整理要異動資料庫的資料

            #region 至資料庫取得Table Schema

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

            BCO.ProcessDiscRecord bco = new BCO.ProcessDiscRecord(ConntionDB);
            DataTable dt_Update_Disc = bco.GET_VDS_CAA_DISC_MAIN_SCHEMA_3(ParameterList);

            #endregion

            #region 整理需要異動資料庫的資料

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

            string s_Now = DateTime.Now.ToString();

            foreach (DataRow drRow in dt_Result.Rows)
            {
                #region 先判斷該筆資料是否需要異動資料庫

                bool b_IsModify = false;

                if (drRow["CHECK_FLG"].ToString() != drRow["CHECK_FLG", DataRowVersion.Original].ToString())
                { b_IsModify = true; }
                if (drRow["PERIOD_MONTH"].ToString() != drRow["PERIOD_MONTH", DataRowVersion.Original].ToString())
                { b_IsModify = true; }

                #endregion

                #region 將需要異動資料庫的資料寫入TempTable

                if (b_IsModify == true)
                {
                    DataRow dr_Update_Disc = dt_Update_Disc.NewRow();

                    //New Data
                    dr_Update_Disc["NEW_UPDATEDATE"] = CAAComm.GetValueSetParameter(s_Now, "datetime", false);
                    dr_Update_Disc["NEW_UPDATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);
                    dr_Update_Disc["NEW_CHECK_FLG"] = drRow["CHECK_FLG"];
                    dr_Update_Disc["NEW_PERIOD_MONTH"] = drRow["PERIOD_MONTH"];

                    //Old Data
                    dr_Update_Disc["ID"] = drRow["ID", DataRowVersion.Original];
                    dr_Update_Disc["CODE"] = drRow["CODE", DataRowVersion.Original];
                    dr_Update_Disc["DISC_NO"] = drRow["DISC_NO", DataRowVersion.Original];
                    dr_Update_Disc["DISC_DATE"] = drRow["DISC_DATE", DataRowVersion.Original];
                    dr_Update_Disc["CHG_DISC_DATE"] = drRow["CHG_DISC_DATE", DataRowVersion.Original];
                    dr_Update_Disc["ACT_DISC_NO"] = drRow["ACT_DISC_NO", DataRowVersion.Original];
                    dr_Update_Disc["DISC_FORM"] = drRow["DISC_FORM", DataRowVersion.Original];
                    dr_Update_Disc["DISC_SOURCE"] = drRow["DISC_SOURCE", DataRowVersion.Original];
                    dr_Update_Disc["STORE_ID"] = drRow["STORE_ID", DataRowVersion.Original];
                    dr_Update_Disc["DISC_TYPE"] = drRow["DISC_TYPE", DataRowVersion.Original];
                    dr_Update_Disc["ROOT_NO"] = drRow["ROOT_NO", DataRowVersion.Original];
                    dr_Update_Disc["TAX_TYPE"] = drRow["TAX_TYPE", DataRowVersion.Original];
                    dr_Update_Disc["PROOF_FLG"] = drRow["PROOF_FLG", DataRowVersion.Original];
                    dr_Update_Disc["PROOF_DATE"] = drRow["PROOF_DATE", DataRowVersion.Original];
                    dr_Update_Disc["REPROOF_FLG"] = drRow["REPROOF_FLG", DataRowVersion.Original];
                    dr_Update_Disc["REPROOF_NO"] = drRow["REPROOF_NO", DataRowVersion.Original];
                    dr_Update_Disc["CANCEL_FLG"] = drRow["CANCEL_FLG", DataRowVersion.Original];
                    dr_Update_Disc["CANCEL_DATE"] = drRow["CANCEL_DATE", DataRowVersion.Original];
                    dr_Update_Disc["REMARK_FLG"] = drRow["REMARK_FLG", DataRowVersion.Original];
                    dr_Update_Disc["PERIOD_FLG"] = drRow["PERIOD_FLG", DataRowVersion.Original];
                    dr_Update_Disc["PERIOD_DATE"] = drRow["PERIOD_DATE", DataRowVersion.Original];
                    dr_Update_Disc["CHECK_FLG"] = drRow["CHECK_FLG", DataRowVersion.Original];
                    dr_Update_Disc["TEMPORAL_FLG"] = drRow["TEMPORAL_FLG", DataRowVersion.Original];
                    dr_Update_Disc["TEMPORAL_DATE"] = drRow["TEMPORAL_DATE", DataRowVersion.Original];
                    dr_Update_Disc["DISC_UAMT"] = drRow["DISC_UAMT", DataRowVersion.Original];
                    dr_Update_Disc["DISC_TAX"] = drRow["DISC_TAX", DataRowVersion.Original];
                    dr_Update_Disc["DISC_AMT"] = drRow["DISC_AMT", DataRowVersion.Original];
                    dr_Update_Disc["CLOSE_MONTH"] = drRow["CLOSE_MONTH", DataRowVersion.Original];
                    dr_Update_Disc["PERIOD_MONTH"] = drRow["PERIOD_MONTH", DataRowVersion.Original];
                    dr_Update_Disc["MEMO"] = drRow["MEMO", DataRowVersion.Original];
                    dr_Update_Disc["CREATEDATE"] = drRow["CREATEDATE", DataRowVersion.Original];
                    dr_Update_Disc["CREATEUID"] = drRow["CREATEUID", DataRowVersion.Original];
                    dr_Update_Disc["UPDATEDATE"] = drRow["UPDATEDATE", DataRowVersion.Original];
                    dr_Update_Disc["UPDATEUID"] = drRow["UPDATEUID", DataRowVersion.Original];
                    dr_Update_Disc["DISC_REMAIN_AMT"] = drRow["DISC_REMAIN_AMT", DataRowVersion.Original];
                    dr_Update_Disc["ENABLE"] = drRow["ENABLE", DataRowVersion.Original];
                    dr_Update_Disc["WASH_STATUS"] = drRow["WASH_STATUS", DataRowVersion.Original];
                    dr_Update_Disc["RFNO"] = drRow["RFNO", DataRowVersion.Original];
                    dr_Update_Disc["DETL_FLG"] = drRow["DETL_FLG", DataRowVersion.Original];
                    dr_Update_Disc["VOUCH_DOC"] = drRow["VOUCH_DOC", DataRowVersion.Original];

                    dt_Update_Disc.Rows.Add(dr_Update_Disc);
                }

                #endregion
            }

            #endregion

            #endregion

            #region 連結資料庫

            if (dt_Update_Disc.Rows.Count > 0)
            {
                bco.SavePeriodRecord(null, dt_Update_Disc);
                this.dt_Result = null;
                this.gv_Result.DataSource = dt_Result;
                this.gv_Result.DataBind();
                this.ErrorMsgLabel.Text = "[儲存]成功";

                this.panSTORE_GROUP.Visible = false;
                this.slp_PERIOD_MONTH_BATCH.Text = "";
            }
            else
            { this.ErrorMsgLabel.Text = "無[儲存]的資料"; }

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
    }
Exemple #2
0
    /// <summary>
    /// 取得 GridView 的資料
    /// </summary>
    private void Get_GridView_Data(string btnType)
    {
        #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), "CAA031", s_ScriptManager_Script, true);
            }

            #endregion

            return;
        }

        #endregion

        #endregion

        try
        {

            #region 傳入參數

            ParameterList.Clear();
            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_STORE_ID.Text, "string", false));//[店號]
            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.txt_VOUCH_RFNO.Text, "string", false));//[統一編號] 20110321 Rika Insert
            ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_PAY_RFNO.Text, "string", false));//[結帳統編]
            ParameterList.Add(CAAComm.GetValueSetParameter((this.rad_CHECK_FLG.SelectedValue == "ALL") ? string.Empty : this.rad_CHECK_FLG.SelectedValue, "int", false));//[勾選狀態]
            ParameterList.Add(CAAComm.GetValueSetParameter((this.rad_PERIOD_FLG.SelectedValue == "ALL") ? string.Empty : this.rad_PERIOD_FLG.SelectedValue, "int", false));//[申報狀態]
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_AC_UID.Text, "string", false));//[帳務人員]
            ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_SAL_ID.Text, "string", false));//[營業人員]
            ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID

            #endregion

            #region 連結資料庫

            BCO.ProcessDiscRecord bco = new BCO.ProcessDiscRecord(ConntionDB);
            dt_Result = bco.QueryPeriodByFind(ParameterList);

            #endregion

            #region 檢查回傳資料

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

            #endregion

            if (btnType == "Query")
            {
                #region 資料與GridView繫結

                this.gv_Result.DataSource = dt_Result;
                this.gv_Result.PageSize = 20;//設定一頁20筆資料
                this.gv_Result.PageIndex = 0;
                this.gv_Result.DataBind();

                #endregion

                this.panSTORE_GROUP.Visible = true;
                this.slp_PERIOD_MONTH_BATCH.Text = "";
            }
            else if (btnType == "Export")
            {
                #region 匯出EXCEL表

                Export_Excel(dt_Result);
                
                #endregion
            }
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }         
    }