private void ChangeBtn_Click(object sender, EventArgs e) { Intent.State = "CHANGE"; if (listView1.SelectedItems.Count == 0) { MessageBox.Show("请选择一行"); return; } Teacher t = new Teacher(); t.SetValue( listView1.SelectedItems[0].SubItems[0].Text, listView1.SelectedItems[0].SubItems[1].Text, listView1.SelectedItems[0].SubItems[2].Text, listView1.SelectedItems[0].SubItems[3].Text ); TeacherEdit te = new TeacherEdit(); te.t = t; if (te.ShowDialog() == DialogResult.OK) { sql = @"" + " UPDATE [TEACHERS]" + " SET" + " [TNo]='" + t.TNo + "'," + " [TName]='" + t.TName + "'," + " [DeptName]='" + t.DeptName + "'," + " [RNo]='" + t.RNo + "'"; db.SetBySQL(sql); } UpdateListView(); }
/* ################## Tab1 ################## */ private void AddBtn_Click(object sender, EventArgs e) { Intent.State = "ADD"; TeacherEdit te = new TeacherEdit(); if (te.ShowDialog() == DialogResult.OK) { Teacher t = te.t; sql = @"" + " INSERT INTO [TEACHERS]" + " VALUES" + " (" + " '" + t.TNo + "'," + " '" + t.TName + "'," + " '" + t.DeptName + "'," + " '" + t.RNo + "'" + " )"; db.SetBySQL(sql); } UpdateListView(); }