private void btnDelete_Click(object sender, EventArgs e)
        {
            if (grid.CurrentRow.Index < 0)
            {
                MessageBoxEx.Show("请选择一条数据,在进行操作");
                return;
            }
            DialogResult result = MessageBoxEx.Show(this, "确认要删除吗?", "", MessageBoxButtons.YesNo);

            //如果点击的是"YES"按钮,将form关闭.
            if (result == DialogResult.Yes)
            {
                HRDept dept = list[grid.CurrentRow.Index];
                try
                {
                    dao.Delete(dept.Id);
                }
                catch (Exception ex)
                {
                    MessageBoxEx.Show(this, "删除失败!" + ex.StackTrace, "报错提示", MessageBoxButtons.YesNo);
                    return;
                }
                list.RemoveAt(grid.CurrentRow.Index);
                InitData();
            }
        }
Exemple #2
0
 public void DeleteDept(int deptNo)
 {
     DeptDao.Delete(deptNo);
 }