コード例 #1
0
 private void deleteObj()
 {
     try
     {
         if (objLoaiTaiSan.childs != null && objLoaiTaiSan.childs.Count > 0)
         {
             XtraMessageBox.Show("Không thể xóa!\r\nNguyên do: Có loại tài sản thuộc loại tài sản này", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (objLoaiTaiSan.taisans != null && objLoaiTaiSan.taisans.Count > 0)
         {
             XtraMessageBox.Show("Không thể xóa!\r\nNguyên do: Có tài sản thuộc loại tài sản này", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             if (XtraMessageBox.Show("Bạn có chắc là muốn xóa loại tài sản này?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
             {
                 Guid id = objLoaiTaiSan.parent != null ? objLoaiTaiSan.parent.id : Guid.Empty;
                 if (objLoaiTaiSan.delete() > 0 && DBInstance.commit() > 0)
                 {
                     XtraMessageBox.Show("Xóa loại tài sản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     reLoadAndSelectNode(id, true);
                 }
                 else
                 {
                     XtraMessageBox.Show("Xóa loại tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->deleteObj: " + ex.Message);
     }
 }