private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Length != 0) { SqlClass.NonQuery("insert into groups(gname) values('" + textBox1.Text + "')"); con.FreshContacts(); } }
public ModifyContacts(Contacts con) { InitializeComponent(); this.con = con; DataTable dt = new DataTable(); dt = SqlClass.Fill("select * from groups"); for (int i = 0; i < dt.Rows.Count; ++i) { comboBox1.Items.Add(dt.Rows[i]["gname"].ToString()); ls.Add(new KeyValuePair <string, string>(dt.Rows[i]["gid"].ToString(), dt.Rows[i]["gname"].ToString())); } comboBox1.Text = con.gname; dt = SqlClass.Fill("select * from contacts where id=" + con.id); textBox1.Text = dt.Rows[0]["name"].ToString(); textBox2.Text = dt.Rows[0]["num"].ToString(); }
public void FreshContacts() { DataTable dt = new DataTable(); dt = SqlClass.Fill("select * from groups"); treeView1.Nodes.Clear(); for (int i = 0; i < dt.Rows.Count; ++i) { treeView1.Nodes.Add(dt.Rows[i]["gid"].ToString(), dt.Rows[i]["gname"].ToString()); } foreach (TreeNode tn in treeView1.Nodes) { dt = SqlClass.Fill("select * from contacts where gid='" + tn.Name + "'"); for (int i = 0; i < dt.Rows.Count; ++i) { tn.Nodes.Add(dt.Rows[i]["id"].ToString(), dt.Rows[i]["name"].ToString()); } } treeView1.ExpandAll(); }
private void 除联系人ToolStripMenuItem_Click(object sender, EventArgs e) { SqlClass.NonQuery("delete from contacts where id='" + id + "'"); FreshContacts(); }
private void button1_Click(object sender, EventArgs e) { SqlClass.NonQuery("update groups set gname='" + textBox1.Text + "' where gid='" + con.gid + "'"); con.FreshContacts(); }
private void button1_Click(object sender, EventArgs e) { SqlClass.NonQuery("insert into contacts(name,num,gid) values('" + textBox1.Text + "','" + textBox2.Text + "'," + con.gid + ")"); con.FreshContacts(); }
private void button1_Click(object sender, EventArgs e) { // MessageBox.Show(con.id + " " + ls[comboBox1.SelectedIndex].Key); SqlClass.NonQuery("update contacts set name='" + textBox1.Text + "',num='" + textBox2.Text + "' ,gid=" + ls[comboBox1.SelectedIndex].Key + " where id=" + con.id); con.FreshContacts(); }