예제 #1
0
 private void btn_Xoa_Click(object sender, EventArgs e)
 {
     if (dtgv_DSLoaiDonVi.CurrentRow != null)
     {
         if (MessageBox.Show("Bạn thực sự muốn xoá loại đơn vị này? ", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             //vanbang = ToDepartmentObject(dtg_DepartmentList.CurrentRow);
             LoaiDonVi.ID = (Convert.ToInt16(dtgv_DSLoaiDonVi.CurrentRow.Cells[0].Value.ToString()));
             try
             {
                 LoaiDonVi.Delete();
                 RefreshDataSource();
                 MessageBox.Show("Xoá thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.ToString(), "Xoá không thành công.", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     return;
 }