}//databind_Mst /// <summary> /// 繫結資料 DTL /// </summary> private void databind_Dtl() { #region try { ErrorMsgLabel.Text = ""; BCO.MaintainChainGiftDtl bco = new BCO.MaintainChainGiftDtl(ConnectionDB); ParameterList.Clear(); ParameterList.Add(this.hiddenID.Value); DataTable dt = bco.QueryChainGiftDetlByPID(ParameterList); #region 將明細資料放至Session["MKT153_DTL_" + PageTimeStamp.Value]中 Session["MKT153_DTL_" + PageTimeStamp.Value] = dt; #endregion #region 保存 舊明細資料至 Session["MKT153_OLDDTL_" + PageTimeStamp.Value]中 Session["MKT153_OLDDTL_" + PageTimeStamp.Value] = dt.Copy(); #endregion this.GridView1.DataSource = dt; this.GridView1.PageIndex = 0; this.GridView1.DataBind(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }//databind_Dtl
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 #endregion #region 已於通路贈品設定中使用此贈品,不可刪除 BCO.MaintainChainGiftDtl bcoChainGiftDtl = new BCO.MaintainChainGiftDtl(ConnectionDB); DataTable dt = new DataTable(); dt = bcoChainGiftDtl.QueryByGiftData(this.getParameterList()); //已於通路贈品設定中使用此贈品,不可刪除 if (dt.Rows.Count > 0) { ErrorMsgLabel.Text = "已於通路贈品設定中使用此贈品,不可刪除"; return; } #endregion #region 已於門市贈品設定中使用此贈品,不可刪除 BCO.MaintainStoreGift bcoStoreGift = new BCO.MaintainStoreGift(ConnectionDB); dt = bcoStoreGift.QueryByGiftData(this.getParameterList()); //已於門市贈品設定中使用此贈品,不可刪除 if (dt.Rows.Count > 0) { ErrorMsgLabel.Text = "已於門市贈品設定中使用此贈品,不可刪除"; return; } #endregion #region 處理刪除作業 #region 組合刪除條件至ArrayList ArrayList returnList = new ArrayList(); returnList.Clear(); returnList.Add(Session["UID"].ToString()); #endregion try { BCO.MaintainGift bco = new BCO.MaintainGift(ConnectionDB); bco.DeleteGift(returnList, 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 } }