Esempio n. 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.hid_Page_Status.Value == "EDIT")
            {
                #region 檢查條件

                CAAModel.CAACommon CAAComm = new CAAModel.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_ErrorMsg, typeof(UpdatePanel), "CAA102", s_ScriptManager_Script, true);
                    }

                    #endregion

                    return;
                }

                #endregion

                #endregion

                if (this.slp_SAL_DATE.ReadOnly == false)
                {
                    //檢查該筆資料是否月結
                    if (CheckClose() == true)
                    {
                        this.ErrorMsgLabel.Text = "此營業日期已月結,故不允許修改!";
                        return;
                    }
                    //檢查該筆資料是否沖帳
                    if (CheckWASH_YN() == true) //"此代收已沖帳,不允許修改!"            
                    {
                        this.ErrorMsgLabel.Text = "此代收已沖帳,不允許修改!";
                        return;
                    }
                }

                CAAModel.MaintainCollRecord BCO = new CAAModel.MaintainCollRecord(ConntionDB);

                string strMsg = string.Empty;
                string strNowDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                string strID = dt.Rows[0]["ID"].ToString(); ;
                if (OnlyEditMemo() == false) //是否只更新MEMO欄位
                {
                    ParameterList.Clear();
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_COLL_NO.Text, "string", false)); //V_COLL_NO
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_SAL_DATE.Text, "date", false)); //D_NEW_SAL_DATE
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_COLL_DATE.Text, "date", false)); //D_NEW_COLL_DATE
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_COLL_TIME.Text.Replace(":", ""), "string", false)); //V_NEW_COLL_TIME
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_COLL_SEQNO.Text, "string", false)); //V_NEW_COLL_SEQNO
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CHARGE.Text, "int", false)); //手續費
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_STORE_ID.Text, "string", false)); //V_NEW_STORE_ID
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_PAY_CHKNO.Text, "string", false)); //V_NEW_PAY_CHKNO
                    ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false)); //V_NEW_UPDATEUID
                    ParameterList.Add(CAAComm.GetValueSetParameter(strNowDate, "datetime", false)); //D_NEW_UPDATEDATE
                    ParameterList.Add(CAAComm.GetValueSetParameter(dt.Rows[0]["CREATEUID"].ToString(), "string", false)); //V_OLD_CREATEUID
                    ParameterList.Add(CAAComm.GetValueSetParameter(dt.Rows[0]["CREATEDATE"].ToString(), "datetime", false)); //D_OLD_CREATEDATE
                    ParameterList.Add(CAAComm.GetValueSetParameter(dt.Rows[0]["UPDATEUID"].ToString(), "string", false)); //V_OLD_UPDATEUID
                    ParameterList.Add(CAAComm.GetValueSetParameter(dt.Rows[0]["UPDATEDATE"].ToString(), "datetime", false)); //D_OLD_UPDATEDATE
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_MEMO.Text, "string", false)); //V_MEMO

                    ArrayList aryUpd = BCO.UpdateCollRecord(ParameterList, null);

                    #region 組合跳轉頁面字串

                    string s_ADDLocation_Replace_String = string.Empty;

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

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

                    #endregion

                    if (aryUpd[1].ToString() == "1")
                    {
                        strMsg = "alert('儲存成功!');location.replace('CAA102.aspx?V_ID=" + strID + "&mode=VIEW&Code=CAA10" + s_ADDLocation_Replace_String + "');";
                    }
                    else
                    {
                        strMsg = "alert('" + aryUpd[0].ToString() + "');location.replace('CAA102.aspx?V_ID=" + strID + "&mode=VIEW&Code=CAA10" + s_ADDLocation_Replace_String + "');";
                    }
                    ScriptManager.RegisterStartupScript(this.btnSave, this.GetType(), "TO_CAA102.aspx", strMsg, true);

                }
                else
                {
                    ParameterList.Clear();
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_COLL_NO.Text, "string", false)); //V_COLL_NO                   
                    ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false)); //V_NEW_UPDATEUID
                    ParameterList.Add(CAAComm.GetValueSetParameter(strNowDate, "datetime", false)); //D_NEW_UPDATEDATE
                    ParameterList.Add(CAAComm.GetValueSetParameter(dt.Rows[0]["CREATEUID"].ToString(), "string", false)); //V_OLD_CREATEUID
                    ParameterList.Add(CAAComm.GetValueSetParameter(dt.Rows[0]["CREATEDATE"].ToString(), "datetime", false)); //D_OLD_CREATEDATE
                    ParameterList.Add(CAAComm.GetValueSetParameter(dt.Rows[0]["UPDATEUID"].ToString(), "string", false)); //V_OLD_UPDATEUID
                    ParameterList.Add(CAAComm.GetValueSetParameter(dt.Rows[0]["UPDATEDATE"].ToString(), "datetime", false)); //D_OLD_UPDATEDATE
                    ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_MEMO.Text, "string", false)); //V_MEMO

                    BCO.UpdateMemo(ParameterList, null);

                    #region 組合跳轉頁面字串

                    string s_ADDLocation_Replace_String = string.Empty;

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

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

                    #endregion

                    strMsg = "alert('儲存成功!');location.replace('CAA102.aspx?V_ID=" + strID + "&mode=VIEW&Code=CAA10" + s_ADDLocation_Replace_String + "');";

                    ScriptManager.RegisterStartupScript(this.btnSave, this.GetType(), "TO_CAA102.aspx", strMsg, true);
                }

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