private bool Check()
 {
     if (String.IsNullOrEmpty(txtMaLoi.Text))
     {
         txtMaLoi.Focus();
         throw new InvalidOperationException("Mã Lỗi không được để trống !");
     }
     if (String.IsNullOrEmpty(txtTenLoi.Text))
     {
         txtTenLoi.Focus();
         throw new InvalidOperationException("Tên Lỗi không được để trống !");
     }
     if (DMMaLoiDataProvider.Kiemtra(new DMMaLoiInfor {
         IdMaLoi = frm.Oid, MaLoi = txtMaLoi.Text.Trim()
     }))
     {
         throw new InvalidOperationException("Mã Lỗi đã tồn tại trong hệ thống!");
     }
     return(true);
 }
 private void ucActions1_OnValidate(object obj, ActionState actionMode)
 {
     switch (actionMode)
     {
     case ActionState.ADD:
     case ActionState.UPDATE:
         idMaLoi = getEditId(obj);
         if (txtMaLoi.Text == String.Empty)
         {
             throw new Exception("Mã Lỗi Không Được Để Trống!");
         }
         if (DMMaLoiDataProvider.Kiemtra(new DMMaLoiInfor {
             IdMaLoi = idMaLoi, TenLoi = txtTenLoi.Text
         }))
         {
             //với trường hợp update, delete thì thì phải check xem là đã có bảng nào tham chiếu đến chưa.
             //Nếu có thì không xóa mà warning người dùng và cập nhật lại sudung=0, và phải warning nếu update.
             throw new Exception("Mã Lỗi Đã Tồn Tại!");
         }
         break;
     }
 }