Example #1
0
        public bool KiemTraDuLieu()
        {
            BUS_NguoiDung nd = new BUS_NguoiDung();

            ErrorChecker.Clear();  // giả sử ban đầu mọi dữ liệu là đúng
            if (string.IsNullOrWhiteSpace(txtTenDangNhap.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenDangNhap, "Không được để trống.");
                return(false);
            }
            if (nd.KTTaiKhoanTonTai(txtTenDangNhap.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenDangNhap, "Tài khoản không tồn tại trong hệ thống.");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(txtMatKhau.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtMatKhau, "Không được để trống.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }

            return(true);
        }
Example #2
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            if (string.IsNullOrWhiteSpace(txtTenHangHoa.Text) || string.IsNullOrEmpty(txtTenHangHoa.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenHangHoa, "Không được để trống.");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(txtDonGia.Text) || string.IsNullOrEmpty(txtDonGia.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtDonGia, "Không được để trống.");
                return(false);
            }
            if (float.Parse(txtDonGia.Text) < 500)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtDonGia, "Đơn giá không hợp lệ.");
                return(false);
            }
            if (cbDVT.EditValue == null)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(cbDVT, "Không được để trống.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }

            return(true);
        }
        private string SendTextAndCheckResponseForErrors(string url, string text)
        {
            var caller = new ServiceApiCaller(url);

            _loggingService.Log <GlobalCollectService>("Sending: " + text);
            var responseText = caller.Send(text);

            _loggingService.Log <GlobalCollectService>("Receiving: " + responseText);

            var checker = new ErrorChecker(responseText);

            if (checker.Result != "OK")
            {
                _loggingService.Log <GlobalCollectService>(responseText);

                if (checker.Errors.Count == 1)
                {
                    if (checker.Errors[0].Code == 410120)
                    {
                        throw new PaymentAmountOutOfRangeExeption(checker);
                    }
                }
                throw new GlobalCollectException(checker);
            }

            return(responseText);
        }
Example #4
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            if (string.IsNullOrWhiteSpace(txtTopicCode.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTopicCode, "Không được để trống.");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(txtTopicName.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTopicName, "Không được để trống.");
                return(false);
            }
            if (mudNumberTeam.Value == 0)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(mudNumberTeam, "Không được để trống.");
                return(false);
            }
            if (mudNumberStudent.Value == 0)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(mudNumberStudent, "Không được để trống.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }
            return(true);
        }
Example #5
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            if (string.IsNullOrEmpty(txtMatKhauCu.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtMatKhauCu, "Không được để trống.");
                return(false);
            }
            if (string.IsNullOrEmpty(txtMatKhauMoi.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtMatKhauMoi, "Không được để trống.");
                return(false);
            }
            if (txtMatKhauMoi.Text.Length < 6)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtMatKhauMoi, "Mật khẩu phải lớn hơn hoặc bằng 6 ký tự.");
                return(false);
            }
            if (txtMatKhauMoi.Text != txtXacNhanMK.Text)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtXacNhanMK, "Xác nhận mật khẩu phải trùng với mật khẩu mới.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }

            return(true);
        }
Example #6
0
 protected void go()
 {//when btnGo is button is clicked
     RtfOutput.Clear();
     RtfOutputLineNumbers.Clear();
     if (btnGo.Text == "Go!")
     {
         errorChecker = new Logic.ErrorChecker(rtfInput.Text, bot, this);
         if (!errorChecker.HasError)
         {
             _showLineNo = true;
             btnGo.Text  = "Reset";
             displayAsLog();
             interpreter = new Logic.Interpreter(rtfInput.Text, bot, this);
             bot.CheckForExit();
             _attemptNo++;
             if (_attemptNo > 2)
             {
                 lblHint.Visible = true;
             }
         }
         else
         {
             _showLineNo = false;
             displayAsError();
         }
     }
     else
     {
         btnGo.Text = "Go!";
         CallOnLoad();
     }
 }
Example #7
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            if (string.IsNullOrWhiteSpace(txtTenDVT.Text) || string.IsNullOrEmpty(txtTenDVT.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenDVT, "Không được để trống.");
                return(false);
            }
            BUS_DonViTinh dvt   = new BUS_DonViTinh();
            int           madvt = int.Parse(txtMaDVT.Text);

            if (dvt.KiemTraTenDVT(madvt, txtTenDVT.Text) == false)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenDVT, "Đơn vị tính đã tồn tại.\nGợi ý: Bạn hãy kiểm tra danh sách đơn vị tính ngừng kinh doanh.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }

            return(true);
        }
Example #8
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            if (cbDaiLy.EditValue == null)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(cbDaiLy, "Không được để trống.");
                return(false);
            }
            if (string.IsNullOrEmpty(txtSoTienThu.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtSoTienThu, "Không được để trống.");
                return(false);
            }
            if (float.Parse(txtSoTienThu.Text) <= 0)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtSoTienThu, "Số tiền thu không hợp lệ.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }

            return(true);
        }
        public void WhenHttpResponseContainsBadUserErrorItIsDetectedAndAInvalidApiRequestIsThrown()
        {
            var response = new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent(BadUsernameOrPasswordResponseMessage)
            };

            ErrorChecker.CheckForErrors(response);
        }
Example #10
0
        public IEnumerable <ErrorChecker <ConversationNode> > GetEnabledErrorCheckers()
        {
            var types = Types.Where(v => v.Enabled).Select(a => a.Type);

            foreach (Type t in types)
            {
                var c = t.GetConstructor(Type.EmptyTypes);
                ErrorChecker <ConversationNode> checker = (ErrorChecker <ConversationNode>)c.Invoke(new object[0]);
                yield return(checker);
            }
        }
Example #11
0
 void FunctionErrorCheck(int type, string msj, Control Con)
 {
     if (type == 1)
     {
         ErrorChecker.SetError(Con, msj, DevExpress.XtraEditors.DXErrorProvider.ErrorType.Default);
     }
     else
     {
         ErrorChecker.SetError(Con, "", DevExpress.XtraEditors.DXErrorProvider.ErrorType.None);
     }
 }
Example #12
0
        public void Read_ReplyWithNoErrors()
        {
            // Arrange
            // Act
            var errorChecker = new ErrorChecker(GetPaymentMethodsResponseText);

            // Assert.
            Assert.AreEqual("OK", errorChecker.Result);
            Assert.IsNotNull(errorChecker.Errors);
            Assert.AreEqual(0, errorChecker.Errors.Count());
        }
Example #13
0
        public void Read_ReplyWithErrors2()
        {
            // Arrange
            // Act
            var errorChecker = new ErrorChecker(InsertOrderFailedMessage);

            // Assert.
            Assert.AreEqual("NOK", errorChecker.Result);
            Assert.IsNotNull(errorChecker.Errors);
            Assert.AreEqual(1, errorChecker.Errors.Count());
        }
    public void NonAbstract()
    {
        var checker = new ErrorChecker(null, null);
        var propertyDefinition = DefinitionFinder.FindType<BaseClass>().Properties.First(x => x.Name == "NonAbstractProperty");

        var message = checker.CheckForErrors(new PropertyData
                                                              {
                                                                  PropertyDefinition = propertyDefinition,
                                                                  NotificationAddedDirectly = false
                                                              }, false);
        Assert.IsNull(message);
    }
    public void IsAbstract()
    {
        var checker = new ErrorChecker(null, null);
        var propertyDefinition = DefinitionFinder.FindType<IndexerClass>().Properties.First();

        var message = checker.CheckForErrors(new PropertyData
                                                              {
                                                                  PropertyDefinition = propertyDefinition,
                                                                  NotificationAddedDirectly = true
                                                              }, false);
        Assert.IsNotNull(message);
    }
Example #16
0
    public void IsAbstract()
    {
        var checker            = new ErrorChecker(null, null);
        var propertyDefinition = DefinitionFinder.FindType <IndexerClass>().Properties.First();

        var message = checker.CheckForErrors(new PropertyData
        {
            PropertyDefinition        = propertyDefinition,
            NotificationAddedDirectly = true
        }, false);

        Assert.IsNotNull(message);
    }
    public void WithGet()
    {
        var checker = new ErrorChecker(null, null);

        var propertyDefinition = DefinitionFinder.FindProperty<BeforeAfterWithNoGetErrorCheckerTest>("PropertyWithGet");

        var message = checker.CheckForErrors(new PropertyData
                                                {
                                                    PropertyDefinition = propertyDefinition,
                                                    NotificationAddedDirectly = true,
                                                }, true);
        Assert.IsNull(message);
    }
    public void NonAbstract()
    {
        var checker            = new ErrorChecker(null, null);
        var propertyDefinition = DefinitionFinder.FindType <BaseClass>().Properties.First(x => x.Name == "NonAbstractProperty");

        var message = checker.CheckForErrors(new PropertyData
        {
            PropertyDefinition        = propertyDefinition,
            NotificationAddedDirectly = false
        }, false);

        Assert.IsNull(message);
    }
Example #19
0
        public void Read_ReplyWithErrors()
        {
            // Arrange
            // Act
            var errorChecker = new ErrorChecker(ReplyWithErrorsText);

            // Assert.
            Assert.AreEqual("NOK", errorChecker.Result);
            Assert.IsNotNull(errorChecker.Errors);
            Assert.AreEqual(2, errorChecker.Errors.Count());
            Assert.Contains(21000100, errorChecker.Errors.Select(x => x.Code).ToList());
            Assert.Contains("REQUEST 1189457 VALUE dn OF FIELD ORDER.LANGUAGECODE IS NOT A VALID LANGUAGECODE", errorChecker.Errors.Select(x => x.Message).ToList());
            Assert.Contains("REQUEST 1189457 VALUE dn OF FIELD PAYMENT.LANGUAGECODE IS NOT A VALID LANGUAGECODE", errorChecker.Errors.Select(x => x.Message).ToList());
        }
Example #20
0
    public void WithGet()
    {
        var checker = new ErrorChecker(null, null);

        var propertyDefinition = DefinitionFinder.FindProperty <BeforeAfterWithNoGetErrorCheckerTest>("PropertyWithGet");

        var message = checker.CheckForErrors(new PropertyData
        {
            PropertyDefinition        = propertyDefinition,
            NotificationAddedDirectly = true,
        }, true);

        Assert.IsNull(message);
    }
    public void WithBackingField()
    {
        var checker = new ErrorChecker(null, null);
        var propertyDefinition = DefinitionFinder.FindProperty(() => WithBackingFieldProperty);

        var message = checker.CheckForErrors(new PropertyData
                                                {
                                                    PropertyDefinition = propertyDefinition,
                                                    NotificationAddedDirectly = true,
                                                    CheckForEquality = true,
                                                    BackingFieldReference = propertyDefinition.DeclaringType.Fields[0],
                                                }, false);
        Assert.IsNull(message);
    }
    public void WithBackingField()
    {
        var checker            = new ErrorChecker(null, null);
        var propertyDefinition = DefinitionFinder.FindProperty(() => WithBackingFieldProperty);

        var message = checker.CheckForErrors(new PropertyData
        {
            PropertyDefinition        = propertyDefinition,
            NotificationAddedDirectly = true,
            CheckForEquality          = true,
            BackingFieldReference     = propertyDefinition.DeclaringType.Fields[0],
        }, false);

        Assert.IsNull(message);
    }
Example #23
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            BUS_NguoiDung nd = new BUS_NguoiDung();

            if (string.IsNullOrWhiteSpace(txtEmail.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtEmail, "Không được để trống.");
                return(false);
            }


            //  Kiểm tra Email hợp lệ
            //  https://stackoverflow.com/a/19475049/7385686
            //  https://docs.microsoft.com/en-us/dotnet/standard/base-types/how-to-verify-that-strings-are-in-valid-email-format
            //  https://docs.microsoft.com/en-us/dotnet/standard/base-types/anchors-in-regular-expressions

            string pattern = @"\A[a-z0-9]+([-._][a-z0-9]+)*@([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,4}\z";

            if (txtEmail.Text.Length == 0)
            {
                ErrorChecker.Clear();
                return(true);
            }
            if (Regex.IsMatch(txtEmail.Text, pattern))
            {
                if (nd.KTEmailTonTai(txtEmail.Text) == true)
                {
                    ErrorChecker.BlinkRate = 500;
                    ErrorChecker.SetError(txtEmail, "Email không tồn tại trong hệ thống.");
                    return(false);
                }
            }
            if (Regex.IsMatch(txtEmail.Text, pattern) == false)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtEmail, "Email không hợp lệ.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }

            return(true);
        }
    public void WithoutBackingField()
    {
        var checker = new ErrorChecker(null, null);

        var propertyDefinition = DefinitionFinder.FindProperty<CheckForEqualityWithNoBackingFieldSetErrorCheckerTest>("WithoutBackingFieldProperty");

        var message = checker.CheckForErrors(new PropertyData
                                                {
                                                    PropertyDefinition = propertyDefinition,
                                                    NotificationAddedDirectly = true,
                                                    CheckForEquality = true,
                                                    BackingFieldReference = null,

                                                }, false);
        Assert.IsNotNull(message);
    }
Example #25
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            if (string.IsNullOrWhiteSpace(txtTeamName.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTeamName, "Không được để trống.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }
            return(true);
        }
    public void WithoutBackingField()
    {
        var checker = new ErrorChecker(null, null);

        var propertyDefinition = DefinitionFinder.FindProperty <CheckForEqualityWithNoBackingFieldSetErrorCheckerTest>("WithoutBackingFieldProperty");

        var message = checker.CheckForErrors(new PropertyData
        {
            PropertyDefinition        = propertyDefinition,
            NotificationAddedDirectly = true,
            CheckForEquality          = true,
            BackingFieldReference     = null,
        }, false);

        Assert.IsNotNull(message);
    }
Example #27
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            if (cbDaiLy.EditValue == null)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(cbDaiLy, "Không được để trống.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }

            return(true);
        }
Example #28
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            if (mudNumberTeam.Value == 0)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(mudNumberTeam, "Không được để trống.");
                return(false);
            }
            if (mudNumberStudent.Value == 0)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(mudNumberStudent, "Không được để trống.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }
            return(true);
        }
Example #29
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            if (string.IsNullOrWhiteSpace(txtTenLoai.Text) || string.IsNullOrEmpty(txtTenLoai.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenLoai, "Không được để trống.");
                return(false);
            }
            BUS_LoaiDaiLy loai   = new BUS_LoaiDaiLy();
            int           maloai = int.Parse(txtMaLoai.Text);

            if (loai.KiemTraTonTai(maloai, txtTenLoai.Text) == false)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenLoai, "Loại đại lý đã tồn tại.\nGợi ý: Bạn hãy kiểm tra danh sách loại đại lý ngừng kinh doanh.");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(txtTienNo.Text) || string.IsNullOrEmpty(txtTienNo.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTienNo, "Không được để trống.");
                return(false);
            }
            if (float.Parse(txtTienNo.Text) < 10000000)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTienNo, "Tối thiểu là 10.000.000");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }

            return(true);
        }
 public PaymentAmountOutOfRangeExeption(ErrorChecker checker) : base(checker)
 {
 }
 public GlobalCollectException(ErrorChecker checker) : base(checker.Errors.First().Message)
 {
     _errors.AddRange(checker.Errors);
 }
Example #32
0
 void ClearError()
 {
     ErrorChecker.ClearErrors();
 }
Example #33
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            BUS_NguoiDung nd = new BUS_NguoiDung();

            if (string.IsNullOrWhiteSpace(txtTenDangNhap.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenDangNhap, "Không được để trống.");
                return(false);
            }
            if (nd.KTTaiKhoanTonTai(txtTenDangNhap.Text) == false)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenDangNhap, "Tên đăng nhập đã tồn tại trong hệ thống.");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(txtMatKhau.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtMatKhau, "Không được để trống.");
                return(false);
            }
            if (txtMatKhau.Text.Length < 6)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtMatKhau, "Mật khẩu phải lớn hơn hoặc bằng 6 ký tự.");
                return(false);
            }
            if (txtMatKhau.Text != txtXacNhanMK.Text)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtXacNhanMK, "Mật khẩu phải trùng nhau.");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(txtEmail.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtEmail, "Không được để trống.");
                return(false);
            }
            if (txtSDT.Text.Length > 0 && txtSDT.Text.Length < 10)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtSDT, "Số điện thoại không hợp lệ.");
                return(false);
            }


            //  Kiểm tra Email hợp lệ
            //  https://stackoverflow.com/a/19475049/7385686
            //  https://docs.microsoft.com/en-us/dotnet/standard/base-types/how-to-verify-that-strings-are-in-valid-email-format
            //  https://docs.microsoft.com/en-us/dotnet/standard/base-types/anchors-in-regular-expressions

            string pattern = @"\A[a-z0-9]+([-._][a-z0-9]+)*@([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,4}\z";

            if (txtEmail.Text.Length == 0)
            {
                ErrorChecker.Clear();
                return(true);
            }
            if (Regex.IsMatch(txtEmail.Text, pattern))
            {
                if (nd.KTEmailTonTai(txtEmail.Text) == false)
                {
                    ErrorChecker.BlinkRate = 500;
                    ErrorChecker.SetError(txtEmail, "Email đã tồn tại trong hệ thống.");
                    return(false);
                }
            }
            if (Regex.IsMatch(txtEmail.Text, pattern) == false)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtEmail, "Email không hợp lệ.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }

            return(true);
        }
Example #34
0
        private bool KiemTraDuLieu()
        {
            ErrorChecker.Clear();  //  giả sử ban đầu mọi dữ liệu là đúng

            BUS_DaiLy dl = new BUS_DaiLy();

            if (string.IsNullOrWhiteSpace(txtTenDaiLy.Text) || string.IsNullOrEmpty(txtTenDaiLy.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenDaiLy, "Không được để trống.");
                return(false);
            }
            int madl = int.Parse(txtMaDaiLy.Text);

            if (dl.KiemTraTenDaiLy(madl, txtTenDaiLy.Text) == false)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtTenDaiLy, "Tên đại lý đã tồn tại.\nGợi ý: Bạn hãy kiểm tra danh sách đại lý ngừng kinh doanh.");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(txtDiaChi.Text) || string.IsNullOrEmpty(txtDiaChi.Text))
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtDiaChi, "Không được để trống.");
                return(false);
            }
            if (cbLoaiDL.EditValue == null)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(cbLoaiDL, "Không được để trống.");
                return(false);
            }
            if (cbQuan.EditValue == null)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(cbQuan, "Không được để trống.");
                return(false);
            }

            //  Kiểm tra Email hợp lệ

            //  https://stackoverflow.com/a/19475049/7385686
            //  https://docs.microsoft.com/en-us/dotnet/standard/base-types/how-to-verify-that-strings-are-in-valid-email-format
            //  https://docs.microsoft.com/en-us/dotnet/standard/base-types/anchors-in-regular-expressions

            string pattern = @"\A[a-z0-9]+([-._][a-z0-9]+)*@([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,4}\z";

            if (txtEmail.Text.Length == 0)
            {
                ErrorChecker.Clear();
                return(true);
            }
            if (Regex.IsMatch(txtEmail.Text, pattern))
            {
                if (dl.KTEmailTonTai(int.Parse(txtMaDaiLy.Text), txtEmail.Text) == false)
                {
                    ErrorChecker.BlinkRate = 500;
                    ErrorChecker.SetError(txtEmail, "Email đã tồn tại trong hệ thống.");
                    return(false);
                }
            }
            if (Regex.IsMatch(txtEmail.Text, pattern) == false)
            {
                ErrorChecker.BlinkRate = 500;
                ErrorChecker.SetError(txtEmail, "Email không hợp lệ.");
                return(false);
            }
            else
            {
                ErrorChecker.Clear();
            }
            return(true);
        }