Пример #1
0
        /// <summary>
        /// Validates the form.
        /// </summary>
        /// <returns></returns>
        private bool ValidateForm()
        {
            if (string.IsNullOrEmpty(txtCode.Text))
            {
                this.errPatient.SetError(txtCode, "Chưa nhập mã quản lý bệnh nhân");
                return(false);
            }

            if (!ValidationUtil.IsAlphanumeric(txtCode.Text))
            {
                this.errPatient.SetError(txtCode, "Mã bệnh nhân chỉ chấp nhận số hoặc chữ");
                return(false);
            }

            if (string.IsNullOrEmpty(txtName.Text))
            {
                this.errPatient.SetError(txtName, "Chưa nhập tên bệnh nhân");
                return(false);
            }

            if (txtName.Text.Length < 3)
            {
                this.errPatient.SetError(txtName, "Tên phải ít nhất 3 kí tự trở lên");
                return(false);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Validates the form.
        /// </summary>
        /// <returns></returns>
        private bool ValidateForm()
        {
            this.err.Clear();
            if (string.IsNullOrEmpty(txtUser.Text))
            {
                this.err.SetError(txtUser, "Chưa nhập tên đăng nhập");
                return(false);
            }

            if (!ValidationUtil.IsAlphanumeric(txtUser.Text))
            {
                this.err.SetError(txtUser, "Tên đăng nhập chỉ chấp nhận số hoặc chữ");
                return(false);
            }

            if (string.IsNullOrEmpty(txtNewPassword.Text))
            {
                this.err.SetError(txtNewPassword, "Chưa nhập nhập khẩu");
                return(false);
            }

            if (txtNewPassword.Text.Length < 6)
            {
                this.err.SetError(txtNewPassword, "Mật khẩu phải ít nhất 6 kí tự trở lên");
                return(false);
            }

            if (string.IsNullOrEmpty(txtNewPasswordConfirm.Text))
            {
                this.err.SetError(txtNewPasswordConfirm, "Chưa nhập nhập khẩu");
                return(false);
            }

            if (txtNewPasswordConfirm.Text.Length < 6)
            {
                this.err.SetError(txtNewPasswordConfirm, "Mật khẩu phải ít nhất 6 kí tự trở lên");
                return(false);
            }

            if (!txtNewPasswordConfirm.Text.Trim().Equals(txtNewPassword.Text.Trim()))
            {
                this.err.SetError(txtNewPasswordConfirm, "Xác nhận Mật khẩu không đúng. Hãy nhập lại!");
                return(false);
            }

            try
            {
                var isValid = _userRepository.Login(this.txtUser.Text, this.txtOldPassword.Text, AppContext.CurrentClinic.Id);
                if (isValid)
                {
                    AppContext.Authenticated = true;
                    AppContext.LoggedInUser  = _userRepository.Get(this.txtUser.Text);
                    this.Close();
                }
                else
                {
                    this.err.SetError(txtOldPassword, "Mật khẩu cũ đúng");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(true);
        }