日期:2014-05-18 浏览次数:20994 次
/// <summary> /// 开始搜索 /// </summary> private void startSearch() { string keys = ""; if (txtSearch.Text.Trim() == "") { MessageBox.Show("请输入要查询的内容", "提示"); return; } else { keys = HttpUtility.UrlEncode(txtSearch.Text, Encoding.GetEncoding("GB2312")); } dgv17173Data.AutoGenerateColumns = false; dgvLocalData.AutoGenerateColumns = false; //-------------本地数据-----------------// string sql = string.Format("select Id,Q,A from Question where q like '%{0}%'", rePlaceSpecialSign(txtSearch.Text.Trim())); int count; dgvLocalData.DataSource = DBhelper.ExecuteReader(sql, out count); lblCount.Text = count.ToString(); //--------------17173------------------// string url = "http://moyu.db.17173.com/default.aspx?kval=" + keys; List<Question> list = ParseIndexPage(url); dgv17173Data.DataSource = list; lbl17173Count.Text = list==null?"0":list.Count.ToString(); //百度题库 LoadBaidu(keys); }
/// <summary> /// 搜索按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSearch_Click(object sender, EventArgs e) { startSearch(); }
private void button1_Click(object sender, EventArgs e) { Control.CheckForIllegalCrossThreadCalls = false; Thread thread = new Thread(new ThreadStart(LoadLocalData)); thread.Start(); } private void LoadLocalData() { //-------------本地数据-----------------// string sql = string.Format("select Id,Q,A from Question where q like '%{0}%'", rePlaceSpecialSign(txtSearch.Text.Trim())); int count; dgvLocalData.DataSource = DBhelper.ExecuteReader(sql, out count); lblCount.Text = count.ToString(); }