Ejemplo n.º 1
0
        //set validation
        public bool isValid(UserProfile userProfile)
        {
            //set validation for transfer funds
            if (txtTarget.Visible == true)
            {
                return
                    (Validator.IsFill(txtAccount) &&
                     Validator.IsFill(txtAmount) &&
                     Validator.IsFill(txtTarget) &&


                     Validator.IsDigit(txtAccount) &&
                     Validator.IsAllowedNumberCharacters(txtAccount, 8) &&
                     Validator.IsSourceAccount(txtAccount, userProfile) &&

                     Validator.IsDecimal(txtAmount) &&
                     Validator.IsNonnegative(txtAmount) &&

                     Validator.IsDigit(txtTarget) &&
                     Validator.IsAllowedNumberCharacters(txtTarget, 8) &&
                     Validator.IsTargetAccount(txtAccount, txtTarget, userProfile) &&

                     Validator.IsMoneyFormate(txtAmount) &&
                     Validator.IsWithinRange(txtAmount, userProfile.
                                             checkBalance(txtAccount.Text)));
            }

            //set validation for check balance
            else if (lbTitle.Text == "Check Balance")
            {
                return
                    (Validator.IsFill(txtAccount) &&

                     Validator.IsDigit(txtAccount) &&
                     Validator.IsAllowedNumberCharacters(txtAccount, 8) &&
                     Validator.IsSourceAccount(txtAccount, userProfile));
            }

            //validation for withdrawal
            else if (lbTitle.Text == "Withdrawal")
            {
                return
                    (Validator.IsFill(txtAccount) &&
                     Validator.IsFill(txtAmount) &&

                     Validator.IsDigit(txtAccount) &&
                     Validator.IsAllowedNumberCharacters(txtAccount, 8) &&
                     Validator.IsSourceAccount(txtAccount, userProfile) &&

                     Validator.IsDecimal(txtAmount) &&
                     Validator.IsNonnegative(txtAmount) &&

                     Validator.IsMoneyFormate(txtAmount) &&
                     Validator.IsWithinRange(txtAmount, userProfile.
                                             checkBalance(txtAccount.Text)));
            }

            //set validation for deposit
            else
            {
                return
                    (Validator.IsFill(txtAccount) &&
                     Validator.IsFill(txtAmount) &&

                     Validator.IsDigit(txtAccount) &&
                     Validator.IsAllowedNumberCharacters(txtAccount, 8) &&
                     Validator.IsSourceAccount(txtAccount, userProfile) &&

                     Validator.IsDecimal(txtAmount) &&
                     Validator.IsNonnegative(txtAmount) &&
                     Validator.IsMoneyFormate(txtAmount));
            }
        }