}//btn_Save_Click protected void btn_Delete_Click(object sender, EventArgs e) { #region try { #region if (SLP_StoreChain1.Text != "" && SLP_Store1.Text != "") { MKTModel.VDS_MKT21_BCO BCO = new MKTModel.VDS_MKT21_BCO(ConnectionDB); BCO.DEL_UN_TAG_STORE(GetQueryParams(), null); ErrorMsgLabel.Text = "刪除成功"; SLP_StoreChain1.Text = ""; SLP_Store1.Text = ""; string strJS = string.Format("alert('刪除成功');location.replace('MKT211.aspx?Code=MKT21&PageTimeStamp={0}');", PageTimeStamp.Value); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "DELETE_OK", strJS, true); } else { ErrorMsgLabel.Text = "請輸入通路、門市"; } #endregion } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }//btn_Delete_Click
/// <summary> /// 繫結資料到控制項 /// </summary> /// <param name="vdb"></param> private void QueryData() { #region string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); MKTModel.VDS_MKT21_BCO BCO = new MKTModel.VDS_MKT21_BCO(ConnectionDB); DataTable dt = null; dt = BCO.QUERY_UN_TAG_STORE(GetQueryParams()); Session[SessionIDName] = dt; Int32 iRowCount = 0; aryParamsPKey.Clear(); GridView1.DataSource = dt; GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); if (dt != null && dt.Rows.Count > 0) { iRowCount = dt.Rows.Count; foreach (DataRow dr in dt.Rows) { #region aryParamsPKey.Add(dr["ID"].ToString()); #endregion } } else { ErrorMsgLabel.Text = "查無資料"; } Session[string.Format("{0}_{1}", strPreFixed, PageTimeStamp.Value)] = aryParamsPKey; LabelQueryRecordCount.Text = string.Format(" {0} Rows ", iRowCount); #endregion }
protected void btn_Save_Click(object sender, EventArgs e) { #region try { #region if (SLP_StoreChain1.Text != "" && SLP_Store1.Text != "") { MKTModel.VDS_MKT21_BCO BCO = new MKTModel.VDS_MKT21_BCO(ConnectionDB); string strID = "", strErrMsg = ""; bool bResult = false; bResult = BCO.ADD_UN_TAG_STORE(GetQueryParams(), null, out strID, out strErrMsg); if (bResult && strErrMsg == "") { ArrayList aryTmp = new ArrayList(); aryTmp.Clear(); aryTmp.Add(strID); aryParamsPKey = aryTmp; CurrentPageMode = PageCurrentMode.Readonly; SetControlsByCurrentPageMode(); ErrorMsgLabel.Text = "新增成功"; //string strJS = string.Format("alert('新增成功');location.replace('MKT212.aspx?Code=MKT21&Mode=Readonly&ID={0}&PageTimeStamp={1}');", strID, PageTimeStamp.Value); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ADD_OK", strJS, true); } else { ErrorMsgLabel.Text = strErrMsg; } } else { ErrorMsgLabel.Text = "請輸入通路、門市"; } #endregion } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; UpdatePanel1.Update(); } #endregion }//btn_Save_Click
/// <summary> /// 繫結資料到控制項 /// </summary> /// <param name="vdb"></param> private void QueryData() { #region try { SLP_StoreChain1.Text = ""; SLP_Store1.Text = ""; MKTModel.VDS_MKT21_BCO BCO = new MKTModel.VDS_MKT21_BCO(ConnectionDB); DataTable dt = null; ArrayList ParameterList = new ArrayList(); ParameterList.Add(s_ID); dt = BCO.QUERY_UN_TAG_STORE_BY_ID(ParameterList); if (dt != null && dt.Rows.Count > 0) { SLP_StoreChain1.Text = dt.Rows[0]["CHAN_NO"].ToString().Trim(); SLP_Store1.Text = dt.Rows[0]["STORE"].ToString().Trim(); } else { ErrorMsgLabel.Text = "查無資料或原始資料已被刪除"; } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
protected void btn_StoreSelect_Click(object sender, EventArgs e) { #region try { dtMultiSaveMKT21 = dtMKT21_POP_SelectStore; //(加入之前尚未存檔的選擇項目) if (dtMKT21_POP_SelectStore_old != null && dtMKT21_POP_SelectStore == null) { dtMultiSaveMKT21 = dtMKT21_POP_SelectStore_old; } if (dtMultiSaveMKT21.Rows.Count > 0) { //STEP 1.扣除已存在前次新增之資料 #region if (dtMKT21_POP_SelectStore_old != null && dtMKT21_POP_SelectStore_old.Rows.Count > 0) { for (Int32 i = dtMultiSaveMKT21.Rows.Count - 1; i >= 0; i--) { for (Int32 k = 0; k <= dtMKT21_POP_SelectStore_old.Rows.Count - 1; k++) { if (dtMultiSaveMKT21.Rows[i]["code"].ToString().Trim() == dtMKT21_POP_SelectStore_old.Rows[k]["code"].ToString().Trim()) { dtMultiSaveMKT21.Rows.RemoveAt(i); break; } } } } #endregion //STEP 2.與前次新增之DATATABLE合併 #region if (dtMKT21_POP_SelectStore_old != null && dtMKT21_POP_SelectStore_old.Rows.Count > 0) { dtMultiSaveMKT21.Merge(dtMKT21_POP_SelectStore_old); } #endregion //STEP 3.扣除已存在DB之資料 #region MKTModel.VDS_MKT21_BCO BCO = new MKTModel.VDS_MKT21_BCO(ConnectionDB); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(null); ParameterList.Add(null); ParameterList.Add(null); ParameterList.Add(null); ParameterList.Add(null); ParameterList.Add(null); ParameterList.Add(9999); DataTable Dt = BCO.QUERY_UN_TAG_STORE(ParameterList); if (Dt.Rows.Count > 0) { for (Int32 i = dtMultiSaveMKT21.Rows.Count - 1; i >= 0; i--) { for (Int32 k = 0; k <= Dt.Rows.Count - 1; k++) { if (dtMultiSaveMKT21.Rows[i]["code"].ToString().Trim() == Dt.Rows[k]["code"].ToString().Trim()) { dtMultiSaveMKT21.Rows.RemoveAt(i); break; } } } } #endregion } //將舊資料存到old dtMKT21_POP_SelectStore_old = dtMultiSaveMKT21; //Binding 到GridView GridView1.DataSource = dtMultiSaveMKT21; GridView1.DataBind(); UpdatePanel1.Update(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
protected void btn_Save_Click(object sender, EventArgs e) { #region try { if (dtMultiSaveMKT21 != null && dtMultiSaveMKT21.Rows.Count > 0) { bool bResult = false; string strID = "", strErrMsg = ""; ArrayList ParameterList = new ArrayList(); //------------------------- ALOModel.ALOCommon BCOCommon = new ALOModel.ALOCommon(); System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction(); MKTModel.VDS_MKT21_BCO BCO = new MKTModel.VDS_MKT21_BCO(ConnectionDB); try { for (Int32 i = 0; i <= dtMultiSaveMKT21.Rows.Count - 1; i++) { ParameterList.Clear(); ParameterList.Add(dtMultiSaveMKT21.Rows[i]["CHAN_NO"].ToString().Trim()); ParameterList.Add(dtMultiSaveMKT21.Rows[i]["STORE"].ToString().Trim()); ParameterList.Add(Session["UID"].ToString()); bResult = BCO.ADD_UN_TAG_STORE(ParameterList, DBT, out strID, out strErrMsg); if (!bResult || strErrMsg != "") { throw new Exception(strErrMsg); } } DBT.Commit();//交易成功 ErrorMsgLabel.Text = "新增完成"; btn_StoreSelect.Enabled = false; btn_Save.Enabled = false; btn_InsertAgain.Visible = true; btn_InsertAgain.Attributes.Add("onclick", "ReloadMKT213();return false;"); GridView1.Columns[6].Visible = false; } catch (Exception ex) { DBT.Rollback();//交易失敗 throw ex; } //------------------------- } else { ErrorMsgLabel.Text = "請先加入門市"; } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { UpdatePanel1.Update(); UpdatePanel2.Update(); } #endregion }
private void QueryData() { #region string SessionIDName = string.Format("{0}_{1}", strPrefixed, PageTimeStamp.Value); DataTable dt = new DataTable(); MKTModel.VDS_MKT21_BCO BCO = new MKTModel.VDS_MKT21_BCO(ConnectionDB); dt = BCO.QUERY_UN_TAG_STORE_POP(GetQueryParams()); bAfterQueryDataBinding = true; if (!dt.Columns.Contains("CHECKED"))//增加欄位以方便判別是否可 dt.Columns.Add("CHECKED"); if (!dt.Columns.Contains("ROWID"))//增加欄位以判別勾選與否 dt.Columns.Add("ROWID"); if (!dt.Columns.Contains("CODE"))//增加欄位以判別勾選與否 dt.Columns.Add("CODE"); if (!dt.Columns.Contains("ROWNUM"))//增加欄位以判別勾選與否 dt.Columns.Add("ROWNUM"); hidden_RowID_MaxID.Value = dt == null ? "-1" : (dt.Rows.Count - 1).ToString();//記錄最大ROWID hidden_RowID_Selected.Value = "";//清空已選ROWID Session[SessionIDName] = dt; SetRowIDToDataTable(true);//設定ROWID GridView1.DataSource = dt; GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); GridView1.SelectedIndex = -1; bAfterQueryDataBinding = false; if (dt == null || (dt != null && dt.Rows.Count <= 0)) { ResultMsgLabel.Text = "查無資料"; ButtonConfirm.Enabled = false; UpdatePanel2.Update(); } else { ButtonConfirm.Enabled = true; UpdatePanel2.Update(); } #endregion }