这段是什么意思?if里面为什么可以放方法?求大佬解释一下,代码在下面
( if (DBHelper.zsg(sql))
{
listView1.Items.Remove(listView1.SelectedItems[0]);
MessageBox.Show("删除成功!");
})
删除
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
{
string id = listView1.SelectedItems[0].SubItems[0].Text;
string sql = string.Format("delete from student where sid='{0}'", id);
if (DBHelper.zsg(sql))
{
listView1.Items.Remove(listView1.SelectedItems[0]);
MessageBox.Show("删除成功!");
}
}
else
{
MessageBox.Show("请选择一行数据,再删除!");
}
}
DBHelper类
public static bool zsg(string sql)
{
ab();
SqlCommand b = new SqlCommand(sql, a);
int count = b.ExecuteNonQuery();
return count > 0;
}