Пример #1
0
        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow == null)
            {
                return;
            }
            if (MessageBox.Show("是否要删除该员工?", "请选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int staff_id = int.Parse(dataGridView1.CurrentRow.Cells["staffId"].Value.ToString());

                if (db.DeleteStaff(staff_id) != 0)
                {
                    dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
                    return;
                }
                MessageBox.Show("删除失败!");
            }
        }