Пример #1
0
    protected void Btn_Delete_Click(object sender, EventArgs e)
    {
        ErrorMsgLabel.Text = "";
        if (this.hid_PageStatus.Value == "VIEW")
        {
            ErrorMsgLabel.Text = "";

            #region 取得更新前舊值


            #region 使用XML轉回DataSet

            DataSet DsMaster = new DataSet();
            System.IO.StringReader srM = new System.IO.StringReader(MasterOLDData.InnerHtml);
            DsMaster.ReadXml(srM);
            DataTable dtMasterOLD = DsMaster.Tables[0];

            #endregion

            //if (dtDetailOLD.Rows.Count == 0)
            //{
            //    throw new Exception("抓取不到舊值,更新失敗!");
            //}

            #endregion

            #region  處理刪除作業

            try
            {

                BCO.MaintainChainGift bco = new BCO.MaintainChainGift(ConnectionDB);

                bco.DeleteMasterAndDetail(getParameterList(), dtMasterOLD.Rows[0], null);

                ScriptManager.RegisterStartupScript(Page, this.GetType(), "ClientScript", "alert('刪除完成');location.replace('MKT151.aspx?Code=MKT15');", true);

            }
            catch (Exception ex)
            {
                this.Btn_Save.Visible = false;//存檔

                ErrorMsgLabel.Text = ex.Message;
            }
            #endregion

        }
    }