private void clear_button_Click(object sender, EventArgs e) { ID_textBox.Clear(); Intro_textBox.Clear(); Name_textBox.Clear(); Hand_Info_View.Clear(); Hand_Info_View.GridLines = false; }
private void search_button_Click(object sender, EventArgs e) { MainForm father = (MainForm)this.Owner; string id = ID_textBox.Text; string name = Name_textBox.Text; string intro = Intro_textBox.Text; string limit = ""; if (id != "") { limit = "where hand_id = " + id; } else if (name != "" || intro != "") { if (name != "") { name = "`name` like" + "\"%" + name + "%\""; } if (intro != "") { intro = "`intro` like" + "\"%" + intro + "%\""; } if (name != "" && intro != "") { limit = "where " + name + " and " + intro; } else { limit = "where " + name + intro; } } string[] result = father.handsql.FindHand(limit); Hand_Info_View.Clear(); Hand_Info_View.Columns.Add("ID"); Hand_Info_View.Columns.Add("名字"); Hand_Info_View.Columns.Add("介绍"); Hand_Info_View.GridLines = true; foreach (string s in result) { if (s != "") { string[] ss = s.Split('|'); ListViewItem lvi = new ListViewItem(); lvi.Text = ss[0]; lvi.SubItems.Add(ss[1]); lvi.SubItems.Add(ss[2]); Hand_Info_View.Items.Add(lvi); } } }