// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); DateTime cktime; int ckint; if (! DateTime.TryParse(tb_btime.Text, out cktime)) tb_btime.Text = ""; ods_Mg_Log.SelectParameters["btime"].DefaultValue = tb_btime.Text; if (! DateTime.TryParse(tb_etime.Text, out cktime)) tb_etime.Text = ""; ods_Mg_Log.SelectParameters["etime"].DefaultValue = tb_etime.Text; if (! int.TryParse(tb_mg_sid.Text,out ckint)) tb_mg_sid.Text = ""; ods_Mg_Log.SelectParameters["mg_sid"].DefaultValue = tb_mg_sid.Text; tb_mg_name.Text = cfc.CleanSQL(tb_mg_name.Text); ods_Mg_Log.SelectParameters["mg_name"].DefaultValue = tb_mg_name.Text; tb_fi_name1.Text = cfc.CleanSQL(tb_fi_name1.Text); ods_Mg_Log.SelectParameters["fi_name1"].DefaultValue = tb_fi_name1.Text; tb_fi_name2.Text = cfc.CleanSQL(tb_fi_name2.Text); ods_Mg_Log.SelectParameters["fi_name2"].DefaultValue = tb_fi_name2.Text; tb_lg_ip.Text = cfc.CleanSQL(tb_lg_ip.Text); ods_Mg_Log.SelectParameters["lg_ip"].DefaultValue = tb_lg_ip.Text; gv_Mg_Log.DataBind(); if (gv_Mg_Log.PageCount - 1 < gv_Mg_Log.PageIndex) { gv_Mg_Log.PageIndex = gv_Mg_Log.PageCount; gv_Mg_Log.DataBind(); } }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); string tmpstr = ""; // 有輸入 ab_name 設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_ab_name.Text.Trim()); if (tmpstr != "") ods_As_Book.SelectParameters["ab_name"].DefaultValue = tmpstr; else { tb_ab_name.Text = ""; ods_As_Book.SelectParameters["ab_name"].DefaultValue = ""; } // 有輸入 ab_nike 設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_ab_nike.Text.Trim()); if (tmpstr != "") ods_As_Book.SelectParameters["ab_nike"].DefaultValue = tmpstr; else { tb_ab_nike.Text = ""; ods_As_Book.SelectParameters["ab_nike"].DefaultValue = ""; } // 有輸入 ab_company 設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_ab_company.Text.Trim()); if (tmpstr != "") ods_As_Book.SelectParameters["ab_company"].DefaultValue = tmpstr; else { tb_ab_company.Text = ""; ods_As_Book.SelectParameters["ab_company"].DefaultValue = ""; } // 有輸入 ag_name 設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_ag_name.Text.Trim()); if (tmpstr != "") ods_As_Book.SelectParameters["ag_name"].DefaultValue = tmpstr; else { tb_ag_name.Text = ""; ods_As_Book.SelectParameters["ag_name"].DefaultValue = ""; } // 有輸入 ag_attrib 設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_ag_attrib.Text.Trim()); if (tmpstr != "") ods_As_Book.SelectParameters["ag_attrib"].DefaultValue = tmpstr; else { tb_ag_attrib.Text = ""; ods_As_Book.SelectParameters["ag_attrib"].DefaultValue = ""; } gv_As_Book.DataBind(); if (gv_As_Book.PageCount - 1 < gv_As_Book.PageIndex) { gv_As_Book.PageIndex = gv_As_Book.PageCount; gv_As_Book.DataBind(); } }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); int ckint = 0; string tmpstr = ""; // 有輸入編號,則設定條件 if (int.TryParse(tb_tp_sid.Text.Trim(), out ckint)) ods_Ts_Paper.SelectParameters["tp_sid"].DefaultValue = ckint.ToString(); else { tb_tp_sid.Text = ""; ods_Ts_Paper.SelectParameters["tp_sid"].DefaultValue = ""; } // 有輸入 tp_title,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_tp_title.Text.Trim()); if (tmpstr != "") ods_Ts_Paper.SelectParameters["tp_title"].DefaultValue = tmpstr; else { tb_tp_title.Text = ""; ods_Ts_Paper.SelectParameters["tp_title"].DefaultValue = ""; } gv_Ts_Paper.DataBind(); if (gv_Ts_Paper.PageCount - 1 < gv_Ts_Paper.PageIndex) { gv_Ts_Paper.PageIndex = gv_Ts_Paper.PageCount; gv_Ts_Paper.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { int ckint = 0; Common_Func cfc = new Common_Func(); DateTime ckbtime, cketime; string tmpstr = ""; if (!IsPostBack) { // 檢查使用者權限並存入登入紀錄 //Check_Power("A003", true); #region 接受下一頁返回時的舊查詢條件 if (Request["pageid"] != null) { if (int.TryParse(Request["pageid"], out ckint)) { if (ckint > gv_Bt_Head.PageCount) ckint = gv_Bt_Head.PageCount; gv_Bt_Head.PageIndex = ckint; } else lb_pageid.Text = "0"; } if (Request["bh_sid"] != null) { if (int.TryParse(Request["bh_sid"], out ckint)) { tb_bh_sid.Text = ckint.ToString(); ods_Bt_Head.SelectParameters["bh_sid"].DefaultValue = ckint.ToString(); } } if (Request["bh_title"] != null) { tmpstr = cfc.CleanSQL(Request["bh_title"].Trim()); if (tmpstr != "") { tb_bh_title.Text = tmpstr; ods_Bt_Head.SelectParameters["bh_title"].DefaultValue = tmpstr; } else { tb_bh_title.Text = ""; ods_Bt_Head.SelectParameters["bh_title"].DefaultValue = ""; } } if (Request["is_check"] != null) { if (Request["is_check"] == "0") { rb_is_check0.Checked = true; rb_is_check1.Checked = false; rb_is_check_all.Checked = false; } else if (Request["is_check"] == "1") { rb_is_check0.Checked = false; rb_is_check1.Checked = true; rb_is_check_all.Checked = false; } else { rb_is_check0.Checked = false; rb_is_check1.Checked = false; rb_is_check_all.Checked = true; } } else { rb_is_check0.Checked = false; rb_is_check1.Checked = false; rb_is_check_all.Checked = true; } if (Request["btime"] != null) { if (DateTime.TryParse(Request["btime"], out ckbtime)) { tb_btime.Text = Request["btime"]; ods_Bt_Head.SelectParameters["btime"].DefaultValue = ckbtime.ToString("yyyy/MM/dd HH:mm:ss"); } } if (Request["etime"] != null) { if (DateTime.TryParse(Request["etime"], out cketime)) { tb_btime.Text = Request["etime"]; ods_Bt_Head.SelectParameters["etime"].DefaultValue = cketime.ToString("yyyy/MM/dd HH:mm:ss"); } } #endregion } #region 檢查頁數是否超過 ods_Bt_Head.DataBind(); gv_Bt_Head.DataBind(); if (gv_Bt_Head.PageCount < gv_Bt_Head.PageIndex) { gv_Bt_Head.PageIndex = gv_Bt_Head.PageCount; gv_Bt_Head.DataBind(); } lb_pageid.Text = gv_Bt_Head.PageIndex.ToString(); #endregion }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int ckint = 0; Common_Func cfc = new Common_Func(); DateTime ckbtime, cketime; // 檢查使用者權限並存入登入紀錄 //Check_Power("D001", true); ods_Fm_Forum.SelectParameters["is_close"].DefaultValue = "1"; #region 接受下一頁返回時的舊查詢條件 if (Request["pageid"] != null) { if (int.TryParse(Request["pageid"], out ckint)) gv_Fm_Forum.PageIndex = ckint; else lb_pageid.Text = "0"; } if (Request["ff_topic"] != null) { tb_ff_topic.Text = cfc.CleanSQL(Request["ff_topic"]); ods_Fm_Forum.SelectParameters["ff_topic"].DefaultValue = tb_ff_topic.Text; } if (Request["ff_desc"] != null) { tb_ff_desc.Text = cfc.CleanSQL(Request["ff_desc"]); ods_Fm_Forum.SelectParameters["ff_desc"].DefaultValue = tb_ff_desc.Text; } if (Request["ff_name"] != null) { tb_ff_name.Text = cfc.CleanSQL(Request["ff_name"]); ods_Fm_Forum.SelectParameters["ff_name"].DefaultValue = tb_ff_name.Text; } if (Request["btime"] != null) { if (DateTime.TryParse(Request["btime"], out ckbtime)) { tb_btime.Text = Request["btime"]; ods_Fm_Forum.SelectParameters["btime"].DefaultValue = ckbtime.ToString("yyyy/MM/dd HH:mm:ss"); } } if (Request["etime"] != null) { if (DateTime.TryParse(Request["etime"], out cketime)) { tb_btime.Text = Request["etime"]; ods_Fm_Forum.SelectParameters["etime"].DefaultValue = cketime.ToString("yyyy/MM/dd HH:mm:ss"); } } #endregion } #region 檢查頁數是否超過 ods_Fm_Forum.DataBind(); gv_Fm_Forum.DataBind(); if (gv_Fm_Forum.PageCount < gv_Fm_Forum.PageIndex) { gv_Fm_Forum.PageIndex = gv_Fm_Forum.PageCount; gv_Fm_Forum.DataBind(); } lb_pageid.Text = gv_Fm_Forum.PageIndex.ToString(); #endregion }
// 產生對應的 Sql Where 字串 private string GetSqlString(string mg_sid, string mg_id, string mg_name, string mg_nike) { Common_Func cfc = new Common_Func(); string subSql = "", tmpstr = ""; int ckint = 0; // 檢查 mg_sid 是否有值 if (int.TryParse(mg_sid, out ckint)) subSql += " And m.mg_sid = " + ckint.ToString(); // 檢查 mg_id 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(mg_id); if (tmpstr != "") subSql += " And m.mg_id Like '%" + tmpstr + "%'"; // 檢查 mg_name 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(mg_name); if (tmpstr != "") subSql += " And m.mg_name Like '%" + tmpstr + "%'"; // 檢查 mg_nike 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(mg_nike); if (tmpstr != "") subSql += " And m.mg_nike Like '%" + tmpstr + "%'"; return subSql; }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); string tmpstr = ""; // 有輸入 tu_name,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_tu_name.Text.Trim()); if (tmpstr != "") ods_Ts_User.SelectParameters["tu_name"].DefaultValue = tmpstr; else { tb_tu_name.Text = ""; ods_Ts_User.SelectParameters["tu_name"].DefaultValue = ""; } // 有輸入 tu_no,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_tu_no.Text.Trim()); if (tmpstr != "") ods_Ts_User.SelectParameters["tu_no"].DefaultValue = tmpstr; else { tb_tu_no.Text = ""; ods_Ts_User.SelectParameters["tu_no"].DefaultValue = ""; } // 有輸入 tu_ip,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_tu_ip.Text.Trim()); if (tmpstr != "") ods_Ts_User.SelectParameters["tu_ip"].DefaultValue = tmpstr; else { tb_tu_ip.Text = ""; ods_Ts_User.SelectParameters["tu_ip"].DefaultValue = ""; } gv_Ts_User.DataBind(); if (gv_Ts_User.PageCount - 1 < gv_Ts_User.PageIndex) { gv_Ts_User.PageIndex = gv_Ts_User.PageCount; gv_Ts_User.DataBind(); } }
// 產生對應的 Sql Where 字串 private string GetSqlString(string ds_sid, string ds_code, string ds_name, string ds_database) { StringBuilder sbstring = new StringBuilder(); Common_Func cfc = new Common_Func(); string subSql = "", tmpstr = ""; int ckint = 0; // 檢查 ds_sid 是否有值 if (int.TryParse(ds_sid, out ckint)) { subSql += " And ds_sid = " + ckint.ToString(); } // 檢查 ds_code 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(ds_code); if (tmpstr != "") { // 使用 like 時 要用 「%'+@ds_code+'%」 的方式 subSql += " And ds_code Like '%'+@ds_code+'%'"; sbstring.Append("@ds_code"); } // 檢查 ds_name 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(ds_name); if (tmpstr != "") { // 使用 like 時 要用 「%'+@ds_name+'%」 的方式 subSql += " And ds_name Like '%'+@ds_name+'%'"; sbstring.Append("@ds_name"); } // 檢查 ds_database 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(ds_database); if (tmpstr != "") { // 使用 like 時 要用 「%'+@ds_database+'%」 的方式 subSql += " And ds_database Like '%'+@ds_database+'%'"; sbstring.Append("@ds_database"); } if (subSql != "") subSql = " Where" + subSql.Substring(4); ParaString = sbstring.ToString(); return subSql; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int ckint = 0; Common_Func cfc = new Common_Func(); // 檢查使用者權限並存入登入紀錄 //Check_Power("2002", true); #region 接受下一頁返回時的舊查詢條件 if (Request["pageid"] != null) { if (int.TryParse(Request["pageid"], out ckint)) { if (ckint > gv_Fi_Content.PageCount) ckint = gv_Fi_Content.PageCount; gv_Fi_Content.PageIndex = ckint; } else lb_pageid.Text = "0"; } ods_Fi_Content.SelectParameters["fl_no"].DefaultValue = "2"; if (Request["fc_name"] != null) { tb_fc_name.Text = cfc.CleanSQL(Request["fc_name"]); ods_Fi_Content.SelectParameters["fc_name"].DefaultValue = tb_fc_name.Text; } if (Request["fc_ext"] != null) { tb_fc_ext.Text = cfc.CleanSQL(Request["fc_ext"]); ods_Fi_Content.SelectParameters["fc_ext"].DefaultValue = tb_fc_ext.Text; } if (Request["fc_desc"] != null) { tb_fc_desc.Text = cfc.CleanSQL(Request["fc_desc"]); ods_Fi_Content.SelectParameters["fc_desc"].DefaultValue = tb_fc_desc.Text; } #endregion } #region 檢查頁數是否超過 ods_Fi_Content.DataBind(); gv_Fi_Content.DataBind(); if (gv_Fi_Content.PageCount < gv_Fi_Content.PageIndex) { gv_Fi_Content.PageIndex = gv_Fi_Content.PageCount; gv_Fi_Content.DataBind(); } lb_pageid.Text = gv_Fi_Content.PageIndex.ToString(); #endregion }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); string tmpstr = ""; // 有輸入 fc_name,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_fc_name.Text.Trim()); if (tmpstr != "") { tb_fc_name.Text = tmpstr; ods_Fi_Content.SelectParameters["fc_name"].DefaultValue = tmpstr; } else { tb_fc_name.Text = ""; ods_Fi_Content.SelectParameters["fc_name"].DefaultValue = ""; } // 有輸入 fc_exy,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_fc_ext.Text.Trim()); if (tmpstr != "") { tb_fc_ext.Text = tmpstr; ods_Fi_Content.SelectParameters["fc_ext"].DefaultValue = tmpstr; } else { tb_fc_ext.Text = ""; ods_Fi_Content.SelectParameters["fc_ext"].DefaultValue = ""; } // 有輸入 fc_desc,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_fc_desc.Text.Trim()); if (tmpstr != "") { tb_fc_desc.Text = tmpstr; ods_Fi_Content.SelectParameters["fc_desc"].DefaultValue = tmpstr; } else { tb_fc_desc.Text = ""; ods_Fi_Content.SelectParameters["fc_desc"].DefaultValue = ""; } gv_Fi_Content.DataBind(); if (gv_Fi_Content.PageCount - 1 < gv_Fi_Content.PageIndex) { gv_Fi_Content.PageIndex = gv_Fi_Content.PageCount; gv_Fi_Content.DataBind(); } }
// 顯示條件範圍設定 protected void Btn_Set_Click(object sender, EventArgs e) { Common_Func cfc = new Common_Func(); string tmpstr = ""; int ckint = -1; // 有輸入 mg_sid,則設定條件 if (int.TryParse(tb_mg_sid.Text.Trim(), out ckint)) { tb_mg_sid.Text = ckint.ToString(); ods_Func_Power.SelectParameters["mg_sid"].DefaultValue = ckint.ToString(); } else { tb_mg_sid.Text = ""; ods_Func_Power.SelectParameters["mg_sid"].DefaultValue = ""; } // 有輸入 mg_id,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_mg_id.Text.Trim()); if (tmpstr != "") { tb_mg_id.Text = tmpstr; ods_Func_Power.SelectParameters["mg_id"].DefaultValue = tmpstr; } else { tb_mg_id.Text = ""; ods_Func_Power.SelectParameters["mg_id"].DefaultValue = ""; } // 有輸入 mg_name,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_mg_name.Text.Trim()); if (tmpstr != "") { tb_mg_name.Text = tmpstr; ods_Func_Power.SelectParameters["mg_name"].DefaultValue = tmpstr; } else { tb_mg_name.Text = ""; ods_Func_Power.SelectParameters["mg_name"].DefaultValue = ""; } // 有輸入 mg_nike,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_mg_nike.Text.Trim()); if (tmpstr != "") { tb_mg_nike.Text = tmpstr; ods_Func_Power.SelectParameters["mg_nike"].DefaultValue = tmpstr; } else { tb_mg_nike.Text = ""; ods_Func_Power.SelectParameters["mg_nike"].DefaultValue = ""; } // 檢查權限 if (rb_open.Checked) ods_Func_Power.SelectParameters["is_enable"].DefaultValue = "1"; else if (rb_close.Checked) ods_Func_Power.SelectParameters["is_enable"].DefaultValue = "0"; else { ods_Func_Power.SelectParameters["is_enable"].DefaultValue = "-1"; rb_all.Checked = true; } gv_Func_Power.DataBind(); if (gv_Func_Power.PageCount - 1 < gv_Func_Power.PageIndex) { gv_Func_Power.PageIndex = gv_Func_Power.PageCount; gv_Func_Power.DataBind(); } }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); int ckint = 0; DateTime ckbtime, cketime; string tmpstr = ""; // 有輸入編號,則設定條件 if (int.TryParse(tb_mg_sid.Text.Trim(), out ckint)) { sds_Mg_Log.SelectParameters["mg_sid1"].DefaultValue = ckint.ToString(); sds_Mg_Log.SelectParameters["mg_sid2"].DefaultValue = ckint.ToString(); } else { sds_Mg_Log.SelectParameters["mg_sid1"].DefaultValue = Int32.MinValue.ToString(); sds_Mg_Log.SelectParameters["mg_sid2"].DefaultValue = Int32.MaxValue.ToString(); } // 有輸入開始時間範圍,則設定條件 if (DateTime.TryParse(tb_btime.Text.Trim(), out ckbtime)) sds_Mg_Log.SelectParameters["btime"].DefaultValue = ckbtime.ToString("yyyy/MM/dd HH:mm:ss"); else sds_Mg_Log.SelectParameters["btime"].DefaultValue = "1800/01/01"; // 有輸入結束時間範圍,則設定條件 if (DateTime.TryParse(tb_etime.Text.Trim(), out cketime)) sds_Mg_Log.SelectParameters["etime"].DefaultValue = cketime.ToString("yyyy/MM/dd HH:mm:ss"); else sds_Mg_Log.SelectParameters["etime"].DefaultValue = DateTime.MaxValue.ToString("yyyy/MM/dd HH:mm:ss"); // 有輸入姓名,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_mg_name.Text.Trim()); if (tmpstr != "") sds_Mg_Log.SelectParameters["mg_name"].DefaultValue = "%" + tmpstr + "%"; else sds_Mg_Log.SelectParameters["mg_name"].DefaultValue = "%%"; // 有輸入主功能,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_fi_name1.Text.Trim()); if (tmpstr != "") sds_Mg_Log.SelectParameters["fi_name1"].DefaultValue = "%" + tmpstr + "%"; else sds_Mg_Log.SelectParameters["fi_name1"].DefaultValue = "%%"; // 有輸入子功能,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_fi_name2.Text.Trim()); if (tmpstr != "") sds_Mg_Log.SelectParameters["fi_name2"].DefaultValue = "%" + tmpstr + "%"; else sds_Mg_Log.SelectParameters["fi_name2"].DefaultValue = "%%"; // 有輸入使用者 IP,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_lg_ip.Text.Trim()); if (tmpstr != "") sds_Mg_Log.SelectParameters["lg_ip"].DefaultValue = "%" + tmpstr + "%"; else sds_Mg_Log.SelectParameters["lg_ip"].DefaultValue = "%%"; gv_Mg_Log.DataBind(); }
// 產生對應的 Sql Where 字串 private string GetSqlString(string btime, string etime, string mg_sid, string mg_name, string fi_name1, string fi_name2, string lg_ip) { StringBuilder sbstring = new StringBuilder(); Common_Func cfc = new Common_Func(); string subSql = "", tmpstr = ""; int ckint = 0; DateTime cktime; // 檢查開始時間是否有值 if (DateTime.TryParse(btime, out cktime)) { subSql += " And l.lg_time >= '" + cktime.ToString("yyyy/MM/dd HH:mm:ss") + "'"; } // 檢查結束時間是否有值 if (DateTime.TryParse(etime, out cktime)) { subSql += " And l.lg_time <= '" + cktime.ToString("yyyy/MM/dd HH:mm:ss") + "'"; } if (int.TryParse(mg_sid, out ckint)) { subSql += " And l.mg_sid = @mg_sid"; sbstring.Append("@mg_sid"); } // 檢查 mg_name 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(mg_name); if (tmpstr != "") { // 使用 like 時 要用 「%'+@mg_name+'%」 的方式 subSql += " And m.mg_name Like '%'+@mg_name+'%'"; sbstring.Append("@mg_name"); } // 檢查 fi_name1 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(fi_name1); if (tmpstr != "") { // 使用 like 時 要用 「%'+@fi_name1+'%」 的方式 subSql += " And f1.fi_name1 Like '%'+@fi_name1+'%'"; sbstring.Append("@fi_name1"); } // 檢查 fi_name2 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(fi_name2); if (tmpstr != "") { // 使用 like 時 要用 「%'+@fi_name2+'%」 的方式 subSql += " And f2.fi_name2 Like '%'+@fi_name2+'%'"; sbstring.Append("@fi_name2"); } // 檢查 lg_ip 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(lg_ip); if (tmpstr != "") { // 使用 like 時 要用 「%'+@lg_ip+'%」 的方式 subSql += " And l.lg_ip Like '%'+@lg_ip+'%'"; sbstring.Append("@lg_ip"); } if (subSql != "") subSql = " Where" + subSql.Substring(4); ParaString = sbstring.ToString(); return subSql; }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); int ckint = 0; DateTime ckbtime, cketime; string tmpstr = ""; // 有輸入編號,則設定條件 if (int.TryParse(tb_he_sid.Text.Trim(), out ckint)) ods_Html_Edit.SelectParameters["he_sid"].DefaultValue = ckint.ToString(); else { tb_he_sid.Text = ""; ods_Html_Edit.SelectParameters["he_sid"].DefaultValue = ""; } // 有輸入 he_title,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_he_title.Text.Trim()); if (tmpstr != "") ods_Html_Edit.SelectParameters["he_title"].DefaultValue = tmpstr; else { tb_he_title.Text = ""; ods_Html_Edit.SelectParameters["he_title"].DefaultValue = ""; } // 有輸入 he_desc,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_he_desc.Text.Trim()); if (tmpstr != "") ods_Html_Edit.SelectParameters["he_desc"].DefaultValue = tmpstr; else { tb_he_desc.Text = ""; ods_Html_Edit.SelectParameters["he_desc"].DefaultValue = ""; } // 有輸入異動時間開始範圍,則設定條件 if (DateTime.TryParse(tb_btime.Text.Trim(), out ckbtime)) ods_Html_Edit.SelectParameters["btime"].DefaultValue = ckbtime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_btime.Text = ""; ods_Html_Edit.SelectParameters["btime"].DefaultValue = ""; } // 有輸入異動時間結束範圍,則設定條件 if (DateTime.TryParse(tb_etime.Text.Trim(), out cketime)) ods_Html_Edit.SelectParameters["etime"].DefaultValue = cketime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_etime.Text = ""; ods_Html_Edit.SelectParameters["etime"].DefaultValue = ""; } gv_Html_Edit.DataBind(); if (gv_Html_Edit.PageCount - 1 < gv_Html_Edit.PageIndex) { gv_Html_Edit.PageIndex = gv_Html_Edit.PageCount; gv_Html_Edit.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int ckint = 0; Common_Func cfc = new Common_Func(); // 檢查使用者權限並存入登入紀錄 //Check_Power("6002", true); #region 接受下一頁返回時的舊查詢條件 if (Request["pageid"] != null) { if (int.TryParse(Request["pageid"], out ckint)) gv_As_Book.PageIndex = ckint; else lb_pageid.Text = "0"; } if (Request["ab_name"] != null) { tb_ag_name.Text = cfc.CleanSQL(Request["ab_name"]); ods_As_Book.SelectParameters["ab_name"].DefaultValue = tb_ab_name.Text; } if (Request["ab_nike"] != null) { tb_ab_nike.Text = cfc.CleanSQL(Request["ab_nike"]); ods_As_Book.SelectParameters["ab_nike"].DefaultValue = tb_ab_nike.Text; } if (Request["ab_company"] != null) { tb_ab_company.Text = cfc.CleanSQL(Request["ab_company"]); ods_As_Book.SelectParameters["ab_company"].DefaultValue = tb_ab_company.Text; } if (Request["ag_name"] != null) { tb_ag_name.Text = cfc.CleanSQL(Request["ag_name"]); ods_As_Book.SelectParameters["ag_name"].DefaultValue = tb_ag_name.Text; } if (Request["ag_attrib"] != null) { tb_ag_name.Text = cfc.CleanSQL(Request["ag_attrib"]); ods_As_Book.SelectParameters["ag_attrib"].DefaultValue = tb_ag_attrib.Text; } ods_As_Book.SelectParameters["mg_sid"].DefaultValue = Session["mg_sid"].ToString(); #endregion } #region 檢查頁數是否超過 ods_As_Book.DataBind(); gv_As_Book.DataBind(); if (gv_As_Book.PageCount < gv_As_Book.PageIndex) { gv_As_Book.PageIndex = gv_As_Book.PageCount; gv_As_Book.DataBind(); } lb_pageid.Text = gv_As_Book.PageIndex.ToString(); #endregion }
// 產生對應的 Sql Where 字串 private string GetSqlString(string dt_name, string dt_caption, string dt_area) { StringBuilder sbstring = new StringBuilder(); Common_Func cfc = new Common_Func(); string subSql = "", tmpstr = ""; // 檢查 dt_name 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(dt_name); if (tmpstr != "") { // 使用 like 時 要用 「%'+@dt_name+'%」 的方式 subSql += " And dt_name Like '%'+@dt_name+'%'"; sbstring.Append("@dt_name"); } // 檢查 dt_caption 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(dt_caption); if (tmpstr != "") { // 使用 like 時 要用 「%'+@dt_caption+'%」 的方式 subSql += " And dt_caption Like '%'+@dt_caption+'%'"; sbstring.Append("@dt_caption"); } // 檢查 dt_area 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(dt_area); if (tmpstr != "") { // 使用 like 時 要用 「%'+@dt_area+'%」 的方式 subSql += " And dt_area Like '%'+@dt_area+'%'"; sbstring.Append("@dt_area"); } ParaString = sbstring.ToString(); return subSql; }
// 產生對應的 Sql Where 字串 private string GetSqlString(string fi_no1, string fi_name1, string visible1, string fi_no2, string fi_name2, string visible2) { Common_Func cfc = new Common_Func(); string subSql = "", tmpstr = ""; int ckint = 0; // 檢查 fi_no1 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(fi_no1); if (tmpstr != "") subSql += " And f2.fi_no1 = '" + tmpstr + "'"; // 檢查 fi_name1 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(fi_name1); if (tmpstr != "") subSql += " And f1.fi_name1 Like '%" + tmpstr + "%'"; // 檢查 visible1 是否有值 if (int.TryParse(visible1, out ckint)) if (ckint == 0 || ckint == 1) subSql += " And f1.is_visible = " + ckint.ToString(); else subSql += " And f1.is_visible <> 2"; else subSql += " And f1.is_visible <> 2"; // 檢查 fi_no2 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(fi_no2); if (tmpstr != "") subSql += " And f2.fi_no2 = '" + tmpstr + "'"; // 檢查 fi_name2 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(fi_name2); if (tmpstr != "") subSql += " And f2.fi_name2 Like '%" + tmpstr + "%'"; // 檢查 visible2 是否有值 if (int.TryParse(visible2, out ckint)) if (ckint == 0 || ckint == 1) subSql += " And f2.is_visible = " + ckint.ToString(); else subSql += " And f2.is_visible <> 2"; else subSql += " And f1.is_visible <> 2"; if (subSql != "") subSql = " Where" + subSql.Substring(4); return subSql; }
// 產生對應的 Sql Where 字串 private string GetSqlString(string he_sid, string he_title, string he_desc, string btime, string etime) { StringBuilder sbstring = new StringBuilder(); Common_Func cfc = new Common_Func(); string subSql = "", tmpstr = ""; int ckint = 0; DateTime cktime; // 檢查 he_sid 是否有值 if (int.TryParse(he_sid, out ckint)) { subSql += " And he_sid = " + ckint.ToString(); } // 檢查 he_title 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(he_title); if (tmpstr != "") { // 使用 like 時 要用 「%'+@he_title+'%」 的方式 subSql += " And he_title Like '%'+@he_title+'%'"; sbstring.Append("@he_title"); } // 檢查 he_desc 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(he_desc); if (tmpstr != "") { // 使用 like 時 要用 「%'+@he_desc+'%」 的方式 subSql += " And he_desc Like '%'+@he_desc+'%'"; sbstring.Append("@he_desc"); } // 檢查異動時間開始範圍是否有值 if (DateTime.TryParse(btime, out cktime)) subSql += " And init_time >= '" + cktime.ToString("yyyy/MM/dd HH:mm:ss") + "'"; // 檢查異動時間結束範圍是否有值 if (DateTime.TryParse(etime, out cktime)) subSql += " And init_time <= '" + cktime.ToString("yyyy/MM/dd HH:mm:ss") + "'"; if (subSql != "") subSql = " Where" + subSql.Substring(4); ParaString = sbstring.ToString(); return subSql; }
protected void Page_Load(object sender, EventArgs e) { string mErr = ""; if (!IsPostBack) { int tp_sid = -1, ckint = -1; string tmpstr = ""; Common_Func cfc = new Common_Func(); // 檢查使用者權限但不存入登入紀錄 //Check_Power("B001", false); if (Request["sid"] != null) { if (int.TryParse(Request["sid"], out tp_sid)) { lb_tp_sid.Text = tp_sid.ToString(); ods_Ts_User.SelectParameters["tp_sid"].DefaultValue = tp_sid.ToString(); // 取得資料 if (!GetData()) mErr = "找不到相關資料!\\n"; #region 接收下一頁傳來的參數 if (Request["pageid1"] != null) { if (int.TryParse(Request["pageid1"], out ckint)) { if (ckint > gv_Ts_User.PageCount) ckint = gv_Ts_User.PageCount; gv_Ts_User.PageIndex = ckint; } else lb_pageid1.Text = "0"; } if (Request["tu_name"] != null) { tmpstr = cfc.CleanSQL(Request["tu_name"].Trim()); if (tmpstr != "") { tb_tu_name.Text = tmpstr; ods_Ts_User.SelectParameters["tu_name"].DefaultValue = tmpstr; } else { tb_tu_name.Text = ""; ods_Ts_User.SelectParameters["tu_name"].DefaultValue = ""; } } if (Request["tu_no"] != null) { tmpstr = cfc.CleanSQL(Request["tu_no"].Trim()); if (tmpstr != "") { tb_tu_no.Text = tmpstr; ods_Ts_User.SelectParameters["tu_no"].DefaultValue = tmpstr; } else { tb_tu_no.Text = ""; ods_Ts_User.SelectParameters["tu_no"].DefaultValue = ""; } } if (Request["tu_ip"] != null) { tmpstr = cfc.CleanSQL(Request["tu_ip"].Trim()); if (tmpstr != "") { tb_tu_ip.Text = tmpstr; ods_Ts_User.SelectParameters["tu_ip"].DefaultValue = tmpstr; } else { tb_tu_ip.Text = ""; ods_Ts_User.SelectParameters["tu_ip"].DefaultValue = ""; } } #endregion #region 接收上一頁傳來的參數 if (Request["pageid"] != null) lb_page.Text = "?pageid=" + Request["pageid"].Trim(); else lb_page.Text = "?pageid=0"; if (Request["tp_sid"] != null) lb_page.Text += "&tp_sid=" + Request["tp_sid"].Trim(); if (Request["tp_title"] != null) lb_page.Text += "&tp_title=" + Server.UrlEncode(Request["tp_title"].Trim()); if (Request["is_show"] != null) lb_page.Text += "&is_show=" + Request["is_show"].Trim(); if (Request["b_time"] != null) lb_page.Text += "&btime=" + Server.UrlEncode(Request["btime"].Trim()); if (Request["b_time"] != null) lb_page.Text += "&etime=" + Server.UrlEncode(Request["etime"].Trim()); #endregion } else mErr = "參數格式錯誤!\\n"; } else mErr = "參數傳入錯誤!\\n"; } if (mErr == "") { #region 檢查頁數是否超過 ods_Ts_User.DataBind(); gv_Ts_User.DataBind(); if (gv_Ts_User.PageCount < gv_Ts_User.PageIndex) { gv_Ts_User.PageIndex = gv_Ts_User.PageCount; gv_Ts_User.DataBind(); } lb_pageid1.Text = gv_Ts_User.PageIndex.ToString(); #endregion } else ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");location.replace(\"B001.aspx" + lb_page.Text + "\");", true); }
// 產生對應的 Sql Where 字串 private string GetSqlString(string mg_sid, string mg_name, string mg_nike, string btime, string etime) { Common_Func cfc = new Common_Func(); string subSql = "", tmpstr = ""; int ckint = 0; DateTime cktime; if (int.TryParse(mg_sid, out ckint)) subSql += " And mg_sid = " + ckint.ToString(); // 檢查 mg_name 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(mg_name); if (tmpstr != "") subSql += " And mg_name Like '%" + tmpstr + "%'"; // 檢查 mg_nike 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(mg_nike); if (tmpstr != "") subSql += " And mg_nike Like '%" + tmpstr + "%'"; // 檢查開始時間是否有值 if (DateTime.TryParse(btime, out cktime)) subSql += " And last_date >= '" + cktime.ToString("yyyy/MM/dd HH:mm:ss") + "'"; // 檢查結束時間是否有值 if (DateTime.TryParse(etime, out cktime)) subSql += " And last_date <= '" + cktime.ToString("yyyy/MM/dd HH:mm:ss") + "'"; if (subSql != "") subSql = " Where" + subSql.Substring(4); return subSql; }
// 產生對應的 Sql Where 字串 private string GetSqlString(string fc_name, string fc_ext, string fc_desc) { Common_Func cfc = new Common_Func(); string subSql = "", tmpstr = ""; // 檢查 fc_name 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(fc_name); if (tmpstr != "") subSql += " And c.fc_name Like '%" + tmpstr + "%'"; // 檢查 fc_ext 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(fc_ext); if (tmpstr != "") subSql += " And c.fc_ext Like '%" + tmpstr + "%'"; // 檢查 fc_desc 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(fc_desc); if (tmpstr != "") subSql += " And c.fc_desc Like '%" + tmpstr + "%'"; return subSql; }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); int ckint = 0; DateTime ckbtime, cketime; string tmpstr = ""; // 有輸入編號,則設定條件 if (int.TryParse(tb_mg_sid.Text.Trim(), out ckint)) ods_Manager.SelectParameters["mg_sid"].DefaultValue = ckint.ToString(); else { tb_mg_sid.Text = ""; ods_Manager.SelectParameters["mg_sid"].DefaultValue = ""; } // 有輸入姓名,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_mg_name.Text.Trim()); if (tmpstr != "") ods_Manager.SelectParameters["mg_name"].DefaultValue = tmpstr; else { tb_mg_name.Text = ""; ods_Manager.SelectParameters["mg_name"].DefaultValue = ""; } // 有輸入暱稱,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_mg_nike.Text.Trim()); if (tmpstr != "") ods_Manager.SelectParameters["mg_nike"].DefaultValue = tmpstr; else { tb_mg_nike.Text = ""; ods_Manager.SelectParameters["mg_nike"].DefaultValue = ""; } // 有輸入開始時間範圍,則設定條件 if (DateTime.TryParse(tb_btime.Text.Trim(), out ckbtime)) ods_Manager.SelectParameters["btime"].DefaultValue = ckbtime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_btime.Text = ""; ods_Manager.SelectParameters["btime"].DefaultValue = ""; } // 有輸入結束時間範圍,則設定條件 if (DateTime.TryParse(tb_etime.Text.Trim(), out cketime)) ods_Manager.SelectParameters["etime"].DefaultValue = cketime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_etime.Text = ""; ods_Manager.SelectParameters["etime"].DefaultValue = ""; } gv_Manager.DataBind(); if (gv_Manager.PageCount -1 < gv_Manager.PageIndex) { gv_Manager.PageIndex = gv_Manager.PageCount; gv_Manager.DataBind(); } lb_pageid.Text = gv_Manager.PageIndex.ToString(); }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); DateTime ckbtime, cketime; string tmpstr = ""; // 有輸入 ff_desc,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_ff_desc.Text.Trim()); if (tmpstr != "") ods_Fm_Forum.SelectParameters["ff_desc"].DefaultValue = tmpstr; else { tb_ff_desc.Text = ""; ods_Fm_Forum.SelectParameters["ff_desc"].DefaultValue = ""; } // 有輸入 ff_name,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_ff_name.Text.Trim()); if (tmpstr != "") ods_Fm_Forum.SelectParameters["ff_name"].DefaultValue = tmpstr; else { tb_ff_name.Text = ""; ods_Fm_Forum.SelectParameters["ff_name"].DefaultValue = ""; } // 有輸入 ff_topic,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_ff_topic.Text.Trim()); if (tmpstr != "") ods_Fm_Forum.SelectParameters["ff_topic"].DefaultValue = tmpstr; else { tb_ff_topic.Text = ""; ods_Fm_Forum.SelectParameters["ff_topic"].DefaultValue = ""; } // 有輸入 btime 範圍,則設定條件 if (DateTime.TryParse(tb_btime.Text.Trim(), out ckbtime)) ods_Fm_Forum.SelectParameters["btime"].DefaultValue = ckbtime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_btime.Text = ""; ods_Fm_Forum.SelectParameters["btime"].DefaultValue = ""; } // 有輸入 etime 範圍,則設定條件 if (DateTime.TryParse(tb_etime.Text.Trim(), out cketime)) ods_Fm_Forum.SelectParameters["etime"].DefaultValue = cketime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_etime.Text = ""; ods_Fm_Forum.SelectParameters["etime"].DefaultValue = ""; } gv_Fm_Forum.DataBind(); if (gv_Fm_Forum.PageCount - 1 < gv_Fm_Forum.PageIndex) { gv_Fm_Forum.PageIndex = gv_Fm_Forum.PageCount; gv_Fm_Forum.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int ckint = 0; Common_Func cfc = new Common_Func(); DateTime ckbtime, cketime; // 檢查使用者權限並存入使用紀錄。 //Check_Power("1005", true); #region 接受下一頁返回時的舊查詢條件 if (Request["pageid"] != null) { if (int.TryParse(Request["pageid"], out ckint)) gv_Manager.PageIndex = ckint; else lb_pageid.Text = "0"; } if (Request["mg_sid"] != null) { if (int.TryParse(Request["mg_sid"], out ckint)) { tb_mg_sid.Text = ckint.ToString(); ods_Manager.SelectParameters["mg_sid"].DefaultValue = ckint.ToString(); } } if (Request["mg_name"] != null) { tb_mg_name.Text = cfc.CleanSQL(Request["mg_name"]); ods_Manager.SelectParameters["mg_name"].DefaultValue = tb_mg_name.Text; } if (Request["mg_nike"] != null) { tb_mg_nike.Text = cfc.CleanSQL(Request["mg_nike"]); ods_Manager.SelectParameters["mg_nike"].DefaultValue = tb_mg_nike.Text; } if (Request["btime"] != null) if (DateTime.TryParse(Request["btime"], out ckbtime)) { tb_btime.Text = Request["btime"]; ods_Manager.SelectParameters["btime"].DefaultValue = ckbtime.ToString("yyyy/MM/dd HH:mm:ss"); } if (Request["etime"] != null) if (DateTime.TryParse(Request["etime"], out cketime)) { tb_btime.Text = Request["etime"]; ods_Manager.SelectParameters["etime"].DefaultValue = cketime.ToString("yyyy/MM/dd HH:mm:ss"); } #endregion } #region 檢查頁數是否超過 ods_Manager.DataBind(); gv_Manager.DataBind(); if (gv_Manager.PageCount < gv_Manager.PageIndex) { gv_Manager.PageIndex = gv_Manager.PageCount; gv_Manager.DataBind(); } lb_pageid.Text = gv_Manager.PageIndex.ToString(); #endregion }
// 產生對應的 Sql Where 字串 private string GetSqlString(string adm_sid, string adl_sid, string adl_email, string adl_send, string btime, string etime) { StringBuilder sbstring = new StringBuilder(); Common_Func cfc = new Common_Func(); string subSql = "", tmpstr = ""; int ckint = 0; DateTime cktime; // 檢查 adm_sid 是否有值 if (int.TryParse(adm_sid, out ckint)) { subSql += " And adm_sid = " + ckint.ToString(); } // 檢查 adl_sid 是否有值 if (int.TryParse(adl_sid, out ckint)) { subSql += " And adl_sid = " + ckint.ToString(); } // 檢查 adl_send 是否有值 if (int.TryParse(adl_send, out ckint)) { subSql += " And adl_send= " + ckint.ToString(); } // 檢查 adl_email 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(adl_email); if (tmpstr != "") { // 使用 like 時 要用 「%'+@adl_email+'%」 的方式 subSql += " And adl_email Like '%'+@adl_email+'%'"; sbstring.Append("@adl_email"); } // 檢查 send_time 開始範圍是否有值 if (DateTime.TryParse(btime, out cktime)) subSql += " And send_time >= '" + cktime.ToString("yyyy/MM/dd HH:mm:ss") + "'"; // 檢查 send_time 結束範圍是否有值 if (DateTime.TryParse(etime, out cktime)) subSql += " And send_time <= '" + cktime.ToString("yyyy/MM/dd HH:mm:ss") + "'"; if (subSql != "") subSql = " Where" + subSql.Substring(4); ParaString = sbstring.ToString(); return subSql; }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); int ckint = 0; DateTime ckbtime, cketime; string tmpstr = ""; // 有輸入編號,則設定條件 if (int.TryParse(tb_adb_sid.Text.Trim(), out ckint)) ods_Ad_Member.SelectParameters["adb_sid"].DefaultValue = ckint.ToString(); else { tb_adb_sid.Text = ""; ods_Ad_Member.SelectParameters["adb_sid"].DefaultValue = ""; } // 有輸入 adb_name,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_adb_name.Text.Trim()); if (tmpstr != "") ods_Ad_Member.SelectParameters["adb_name"].DefaultValue = tmpstr; else { tb_adb_name.Text = ""; ods_Ad_Member.SelectParameters["adb_name"].DefaultValue = ""; } // 有輸入 adb_email,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_adb_email.Text.Trim()); if (tmpstr != "") ods_Ad_Member.SelectParameters["adb_email"].DefaultValue = tmpstr; else { tb_adb_email.Text = ""; ods_Ad_Member.SelectParameters["adb_email"].DefaultValue = ""; } // 有輸入異動時間開始範圍,則設定條件 if (DateTime.TryParse(tb_ibtime.Text.Trim(), out ckbtime)) ods_Ad_Member.SelectParameters["btime"].DefaultValue = ckbtime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_ibtime.Text = ""; ods_Ad_Member.SelectParameters["btime"].DefaultValue = ""; } // 有輸入異動時間結束範圍,則設定條件 if (DateTime.TryParse(tb_ietime.Text.Trim(), out cketime)) ods_Ad_Member.SelectParameters["etime"].DefaultValue = cketime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_ietime.Text = ""; ods_Ad_Member.SelectParameters["etime"].DefaultValue = ""; } gv_Ad_Member.DataBind(); if (gv_Ad_Member.PageCount - 1 < gv_Ad_Member.PageIndex) { gv_Ad_Member.PageIndex = gv_Ad_Member.PageCount; gv_Ad_Member.DataBind(); lb_pageid1.Text = gv_Ad_Member.PageIndex.ToString(); } }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); int ckint = 0; DateTime ckbtime, cketime; string tmpstr = ""; // 有輸入編號,則設定條件 if (int.TryParse(tb_bh_sid.Text.Trim(), out ckint)) ods_Bt_Head.SelectParameters["bh_sid"].DefaultValue = ckint.ToString(); else { tb_bh_sid.Text = ""; ods_Bt_Head.SelectParameters["bh_sid"].DefaultValue = ""; } // 有輸入 bh_title,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_bh_title.Text.Trim()); if (tmpstr != "") ods_Bt_Head.SelectParameters["bh_title"].DefaultValue = tmpstr; else { tb_bh_title.Text = ""; ods_Bt_Head.SelectParameters["bh_title"].DefaultValue = ""; } // 檢查 rb_is_check if (rb_is_check_all.Checked) ods_Bt_Head.SelectParameters["is_check"].DefaultValue = ""; else { if (rb_is_check0.Checked) ods_Bt_Head.SelectParameters["is_check"].DefaultValue = "0"; else ods_Bt_Head.SelectParameters["is_check"].DefaultValue = "1"; } // 有輸入最後投票時間開始範圍,則設定條件 if (DateTime.TryParse(tb_btime.Text.Trim(), out ckbtime)) ods_Bt_Head.SelectParameters["btime"].DefaultValue = ckbtime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_btime.Text = ""; ods_Bt_Head.SelectParameters["btime"].DefaultValue = ""; } // 有輸入最後投票時間結束範圍,則設定條件 if (DateTime.TryParse(tb_etime.Text.Trim(), out cketime)) ods_Bt_Head.SelectParameters["etime"].DefaultValue = cketime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_etime.Text = ""; ods_Bt_Head.SelectParameters["etime"].DefaultValue = ""; } gv_Bt_Head.DataBind(); if (gv_Bt_Head.PageCount - 1 < gv_Bt_Head.PageIndex) { gv_Bt_Head.PageIndex = gv_Bt_Head.PageCount; gv_Bt_Head.DataBind(); } }
// 產生對應的 Sql Where 字串 private string GetSqlString(string is_close, string mb_name, string mb_email, string mb_desc, string btime, string etime) { StringBuilder sbstring = new StringBuilder(); Common_Func cfc = new Common_Func(); string subSql = "", tmpstr = ""; int ckint = 0; DateTime cktime; // 檢查 is_close 是否有值 if (int.TryParse(is_close, out ckint)) subSql += " And is_close = " + ckint.ToString(); // 檢查 mb_name 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(mb_name); if (tmpstr != "") { // 使用 like 時 要用 「%'+@mb_name+'%」 的方式 subSql += " And mb_name Like '%'+@mb_name+'%'"; sbstring.Append("@mb_name"); } // 檢查 mb_email 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(mb_email); if (tmpstr != "") { // 使用 like 時 要用 「%'+@mb_email+'%」 的方式 subSql += " And mb_email Like '%'+@mb_email+'%'"; sbstring.Append("@mb_email"); } // 檢查 mb_desc 是否有值,並清除 SQL 隱碼攻擊的字元 tmpstr = cfc.CleanSQL(mb_desc); if (tmpstr != "") { // 使用 like 時 要用 「%'+@mb_desc+'%」 的方式 subSql += " And mb_desc Like '%'+@mb_desc+'%'"; sbstring.Append("@mb_desc"); } // 檢查 mb_time 開始範圍是否有值 if (DateTime.TryParse(btime, out cktime)) subSql += " And mb_time >= '" + cktime.ToString("yyyy/MM/dd HH:mm:ss") + "'"; // 檢查 bh_time 結束範圍是否有值 if (DateTime.TryParse(etime, out cktime)) subSql += " And mb_time <= '" + cktime.ToString("yyyy/MM/dd HH:mm:ss") + "'"; ParaString = sbstring.ToString(); if (subSql != "") subSql = " Where" + subSql.Substring(4); return subSql; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int ckint = 0; Common_Func cfc = new Common_Func(); string tmpstr = ""; // 檢查使用者權限並存入登入紀錄 //Check_Power("B003", true); #region 接受下一頁返回時的舊查詢條件 if (Request["pageid"] != null) { if (int.TryParse(Request["pageid"], out ckint)) { if (ckint > gv_Ts_Paper.PageCount) ckint = gv_Ts_Paper.PageCount; gv_Ts_Paper.PageIndex = ckint; } else lb_pageid.Text = "0"; } if (Request["tp_sid"] != null) { if (int.TryParse(Request["tp_sid"], out ckint)) { tb_tp_sid.Text = ckint.ToString(); ods_Ts_Paper.SelectParameters["tp_sid"].DefaultValue = ckint.ToString(); } } if (Request["tp_title"] != null) { tmpstr = cfc.CleanSQL(Request["tp_title"].Trim()); if (tmpstr != "") { tb_tp_title.Text = tmpstr; ods_Ts_Paper.SelectParameters["tp_title"].DefaultValue = tmpstr; } else { tb_tp_title.Text = ""; ods_Ts_Paper.SelectParameters["tp_title"].DefaultValue = ""; } } // 限制開放及截止時間在範圍內 ods_Ts_Paper.SelectParameters["btime"].DefaultValue = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); ods_Ts_Paper.SelectParameters["etime"].DefaultValue = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); // 限制顯示旗標為 1 的才出現 ods_Ts_Paper.SelectParameters["is_show"].DefaultValue = "1"; #endregion } #region 檢查頁數是否超過 ods_Ts_Paper.DataBind(); gv_Ts_Paper.DataBind(); if (gv_Ts_Paper.PageCount < gv_Ts_Paper.PageIndex) { gv_Ts_Paper.PageIndex = gv_Ts_Paper.PageCount; gv_Ts_Paper.DataBind(); } lb_pageid.Text = gv_Ts_Paper.PageIndex.ToString(); #endregion }
// 檢查查詢條件是否改變 private void Chk_Filter() { Common_Func cfc = new Common_Func(); DateTime ckbtime, cketime; string tmpstr = ""; // 有輸入 mb_desc,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_mb_desc.Text.Trim()); if (tmpstr != "") ods_Ms_Board.SelectParameters["mb_desc"].DefaultValue = tmpstr; else { tb_mb_desc.Text = ""; ods_Ms_Board.SelectParameters["mb_desc"].DefaultValue = ""; } // 有輸入 mb_name,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_mb_name.Text.Trim()); if (tmpstr != "") ods_Ms_Board.SelectParameters["mb_name"].DefaultValue = tmpstr; else { tb_mb_name.Text = ""; ods_Ms_Board.SelectParameters["mb_name"].DefaultValue = ""; } // 有輸入 mb_email,則設定條件 (cfc.CleanSQL() => 移除可能為 SQL 隱碼攻擊的字串) tmpstr = cfc.CleanSQL(tb_mb_email.Text.Trim()); if (tmpstr != "") ods_Ms_Board.SelectParameters["mb_email"].DefaultValue = tmpstr; else { tb_mb_email.Text = ""; ods_Ms_Board.SelectParameters["mb_email"].DefaultValue = ""; } // 有輸入 btime 範圍,則設定條件 if (DateTime.TryParse(tb_btime.Text.Trim(), out ckbtime)) ods_Ms_Board.SelectParameters["btime"].DefaultValue = ckbtime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_btime.Text = ""; ods_Ms_Board.SelectParameters["btime"].DefaultValue = ""; } // 有輸入 etime 範圍,則設定條件 if (DateTime.TryParse(tb_etime.Text.Trim(), out cketime)) ods_Ms_Board.SelectParameters["etime"].DefaultValue = cketime.ToString("yyyy/MM/dd HH:mm:ss"); else { tb_etime.Text = ""; ods_Ms_Board.SelectParameters["etime"].DefaultValue = ""; } lv_Ms_Board.DataBind(); }