protected void Btn_Query_Click(object sender, EventArgs e) { try { ErrorMsgLabel.Text = ""; ResultMsgLabel.Text = ""; gvMsgLabel.Text = ""; #region 勾選[門市主檔檢核] if (CheckBox1.Checked) { DataTable Dt = new DataTable(); Dt = this.searchData(); if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { ResultMsgLabel.Text = "門市主檔檢核成功"; } else { dt_Detail = Dt; #region 設定查詢結果 gvMsgLabel.Text = "門市主檔檢核未成功"; this.gv_Detail.DataSource = Dt; // this.gv_Detail.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); this.gv_Detail.PageIndex = 0; this.gv_Detail.DataBind(); #endregion } } #endregion #region 勾選[產生唯一檔] else if (CheckBox2.Checked) { DataTable Dt = new DataTable(); Dt = this.searchData(); if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { //ResultMsgLabel.Text = "查無資料"; BCO.CreateStoreUniqueFile bco = new CreateStoreUniqueFile(ConntionDB); int[] vCount = bco.CreateMutiStoreData(null); ScriptManager.RegisterStartupScript(this.up_ErrorMsg, typeof(UpdatePanel), "STM031", "alert('成功轉入門市唯一檔共" + Convert.ToString(vCount[0]) + "筆,目前可配送店數" + Convert.ToString(vCount[1]) + "筆');", true); } else { dt_Detail = Dt; #region 設定查詢結果 gvMsgLabel.Text = "門市主檔審核未成功"; this.gv_Detail.DataSource = Dt; // this.gv_Detail.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); this.gv_Detail.PageIndex = 0; this.gv_Detail.DataBind(); #endregion } } #endregion } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.ToString(); } finally { } }
public DataTable searchData() { #region 前置檢查與參數過濾 #endregion #region 清空靜態變數 dt_Detail = null; #endregion #region 處理查詢 BCO.CreateStoreUniqueFile bco = new CreateStoreUniqueFile(ConntionDB); DataTable Dt = bco.GetCheckStore(); #endregion return Dt; }
/// <summary> /// Page_Load事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { try { ErrorMsgLabel.Text = ""; ResultMsgLabel.Text = ""; gvMsgLabel.Text = ""; AuthorityControls(this); if (!IsPostBack) { //寫入首次載入Page TimeStamp PageTimeStamp.Value = string.Format("{0}{1}{2}{3}{4}{5}", DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString().PadLeft(2, '0'), DateTime.Now.Day.ToString().PadLeft(2, '0'), DateTime.Now.Hour.ToString().PadLeft(2, '0'), DateTime.Now.Minute.ToString().PadLeft(2, '0'), DateTime.Now.Second.ToString().PadLeft(2, '0') ); //設定最後一次產生時間 BCO.CreateStoreUniqueFile bco = new CreateStoreUniqueFile(ConntionDB); string workDate = bco.GetLastWorkTime(); Lab_Date.Text = workDate; //設定GridView預設的狀態 Initialization_Component(); //設定ToolBar預設狀態 ToolBarInit(); //該頁面共有4種狀態 //查詢 QUERY //檢視 VIEW //新增 INSERT //編輯 EDIT this.hid_PageStatus.Value = "QUERY"; this.txt_PageStatus.Text = "QUERY"; #region 預設系統功能鍵及Focus欄位 this.Form.Attributes["onkeypress"] += "return STMCommon_WebForm_FireDefaultButton(event,'" + this.Btn_Query.ClientID + "');"; BCO.STMCommon STMComm = new BCO.STMCommon(); string s_ScriptManager_Script = STMComm.ToMakeUp_SetFocus_Script(CheckBox1.ClientID, false); ScriptManager.RegisterStartupScript(this.up_ErrorMsg, typeof(UpdatePanel), "STM031", s_ScriptManager_Script, true); #endregion } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0]; //直接取第一個 } finally { Finally_Function(); } }