Ejemplo n.º 1
0
        private void WithdrawSavingsAccount()
        {
            var selectedAccount = (AccountDetail)grdDetails.SelectedItem;

            if (selectedAccount == null)
            {
                return;
            }

            //1. must be active
            if (_viewModel.Member.IsAccountClosed)
            {
                MessageWindow.ShowAlertMessage("Closed account!");
                return;
            }
            //2. must be withdrawable account
            if (!_listSavingsDepositCode.Contains(selectedAccount.AccountCode.Trim()))
            {
                MessageWindow.ShowAlertMessage("Not a withdrawable account!");
                return;
            }

            //3. must have sufficient balance
            decimal maintainingBalance = GlobalSettings.AmountOfSavingsDepositMaintainingBalance;

            if (selectedAccount.EndingBalance <= maintainingBalance)
            {
                MessageWindow.ShowAlertMessage("Fund not sufficient");
                return;
            }

            //3. must have sufficient balance
            if (MainController.LoggedUser.TransactionDate != GlobalSettings.DateOfOpenTransaction)
            {
                MessageWindow.ShowAlertMessage(
                    "Record is locked or Transaction Date not set. Please consult your system administrator.");
                return;
            }

            var withdrawalModel = new Withdrawal();

            withdrawalModel.InitializeProperties();
            withdrawalModel.AccountInfo.CurrentBalance = _viewModel.SelectedAccount.Balance;
            withdrawalModel.AccountInfo.MemberCode     = selectedAccount.MemberCode;
            withdrawalModel.AccountInfo.MemberName     = selectedAccount.MemberName;
            withdrawalModel.AccountInfo.AccountCode    = selectedAccount.AccountCode;
            withdrawalModel.AccountInfo.AccountTitle   = selectedAccount.Title;

            var withdrawal = new WithdrawalView(withdrawalModel);

            if (withdrawal.ShowDialog() == true)
            {
                RefreshAccountInformation();
            }
        }