protected void Btn_Query_Click(object sender, EventArgs e) { try { DataTable Dt = new DataTable(); #region 處理查詢 BCO.MaintainStoreGift bco = new MaintainStoreGift(ConnectionDB); Dt = bco.QueryStoreGift(this.getParameterList()); #endregion if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { ErrorMsgLabel.Text = "查無資料"; } else { Session["MKT141_" + PageTimeStamp.Value] = Dt.Copy(); } #region 將Key值存到Session中 ArrayList arl_Key = new ArrayList(); foreach (DataRow drRow in Dt.Rows) { arl_Key.Add(drRow["ID"].ToString()); } Session["MKT142_SortKey" + this.PageTimeStamp.Value] = arl_Key; #endregion #region 設定查詢結果 this.GridView1.DataSource = Dt; //設定分頁大小不得為0,如為0預設為1 if (TextBoxPagesize.Text == "0") { GridView1.PageSize = 1; } else { GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); } this.GridView1.PageIndex = 0; this.GridView1.DataBind(); Btn_PurchaseCard.Enabled = true; #endregion } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.ToString(); } finally { } }
private void LoadData(int intID, string strItem, string strPeriod) { try { #region Bind gvGift MaintainGift bcoGift = new MaintainGift(ConntionDB); ParameterList.Clear(); ParameterList.Add(strItem); ParameterList.Add(strPeriod); ParameterList.Add(999); DataTable Dt_Gift = bcoGift.QueryGift(ParameterList); Session["MKT05_POP_Gift" + PageTimeStamp.Value] = Dt_Gift; if (Dt_Gift != null && Dt_Gift.Rows.Count != 0) { gvGift.PageSize = 20; gvGift.PageIndex = 0; gvGift.DataSource = Dt_Gift; gvGift.DataBind(); NoData_1.Visible = false; } else { NoData_1.Visible = true; } #endregion #region Bind gvGiftChan MaintainPurchaseCard bco = new MaintainPurchaseCard(ConntionDB); ParameterList.Clear(); ParameterList.Add(intID); ParameterList.Add(strItem); ParameterList.Add(strPeriod); DataTable Dt_GiftChan = bco.MTK05_POP_GiftChan(ParameterList); Session["MKT05_POP_GiftChan" + PageTimeStamp.Value] = Dt_GiftChan; if (Dt_GiftChan != null && Dt_GiftChan.Rows.Count != 0) { gvGiftChan.PageSize = 20; gvGiftChan.PageIndex = 0; gvGiftChan.DataSource = Dt_GiftChan; gvGiftChan.DataBind(); NoData_2.Visible = false; } else { NoData_2.Visible = true; } #endregion #region Bind 通路門市贈品 MaintainStoreGift BCO = new MaintainStoreGift(ConntionDB); ParameterList.Clear(); ParameterList.Add(strItem); ParameterList.Add(strPeriod); ParameterList.Add("99999999"); DataTable Dt_GiftStore = BCO.QueryStoreGift(ParameterList); Session["MKT05_POP_GiftStore" + PageTimeStamp.Value] = Dt_GiftStore; if (Dt_GiftStore != null && Dt_GiftStore.Rows.Count != 0) { GridView1.PageSize = 20; GridView1.PageIndex = 0; GridView1.DataSource = Dt_GiftStore; GridView1.DataBind(); NoData_3.Visible = false; } else { NoData_3.Visible = true; } #endregion } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } }