public void Update(object sender, RoutedEventArgs e)
        {
            int loanProductId = _currentLoanCharges.LoanProductId;

            if (string.IsNullOrEmpty(_currentLoanCharges.AccountCode))
            {
                MessageWindow.ShowAlertMessage("Loan Charges of Operation must not be empty!");
                return;
            }
            if (_currentLoanCharges.ID == 0)
            {
                _currentLoanCharges.Create();
                _currentLoanCharges.ID = 0;
            }
            else
            {
                _currentLoanCharges.Update();
            }

            DataContext = _currentLoanCharges = new LoanCharge();
            _currentLoanCharges.LoanProductId = loanProductId;

            MessageWindow.ShowNotifyMessage("Loan Charges information saved!");
            CloseWindow(sender, e);
        }
Example #2
0
        private void OkButtonOnClick()
        {
            string successMessage = "Loan Product has been updated!";

            try
            {
                Result result = _loanProduct.ValidateProperties();
                if (!result.Success)
                {
                    MessageWindow.ShowAlertMessage(result.Message);
                    return;
                }
                if (_loanProduct.ID > 0)
                {
                    result = _loanProduct.Update();
                }
                else
                {
                    result         = _loanProduct.Create();
                    successMessage = "Loan Product has been created!";
                }

                List <LoanCharge> loanCharges = LoanCharge.GetListByLoanProductId(_loanProduct.ID);
                foreach (LoanCharge loanCharge in loanCharges)
                {
                    loanCharge.Destroy();
                }

                List <LoanDeduction> loanDeductions = LoanDeduction.GetListByLoanProductId(_loanProduct.ID);
                foreach (LoanDeduction loanDeduction in loanDeductions)
                {
                    loanDeduction.Destroy();
                }

                if (!string.IsNullOrEmpty(_loanCharge1.AccountCode))
                {
                    _loanCharge1.LoanProductId = _loanProduct.ID;
                    _loanCharge1.Create();
                }
                if (!string.IsNullOrEmpty(_loanCharge2.AccountCode))
                {
                    _loanCharge2.LoanProductId = _loanProduct.ID;
                    _loanCharge2.Create();
                }
                if (!string.IsNullOrEmpty(_loanCharge3.AccountCode))
                {
                    _loanCharge3.LoanProductId = _loanProduct.ID;
                    _loanCharge3.Create();
                }
                if (!string.IsNullOrEmpty(_loanCharge4.AccountCode))
                {
                    _loanCharge4.LoanProductId = _loanProduct.ID;
                    _loanCharge4.Create();
                }
                if (!string.IsNullOrEmpty(_loanCharge5.AccountCode))
                {
                    _loanCharge5.LoanProductId = _loanProduct.ID;
                    _loanCharge5.Create();
                }
                if (!string.IsNullOrEmpty(_loanCharge6.AccountCode))
                {
                    _loanCharge6.LoanProductId = _loanProduct.ID;
                    _loanCharge6.Create();
                }

                if (!string.IsNullOrEmpty(_loanDeduction1.AccountCode))
                {
                    _loanDeduction1.LoanProductId = _loanProduct.ID;
                    _loanDeduction1.Create();
                }
                if (!string.IsNullOrEmpty(_loanDeduction2.AccountCode))
                {
                    _loanDeduction2.LoanProductId = _loanProduct.ID;
                    _loanDeduction2.Create();
                }
                if (!string.IsNullOrEmpty(_loanDeduction3.AccountCode))
                {
                    _loanDeduction3.LoanProductId = _loanProduct.ID;
                    _loanDeduction3.Create();
                }
                if (!result.Success)
                {
                    MessageWindow.ShowAlertMessage(result.Message);
                    return;
                }
            }
            catch (Exception exception)
            {
                MessageWindow.ShowAlertMessage(exception.Message);
            }

            MessageWindow.ShowNotifyMessage(successMessage);
            DialogResult = true;
            Close();
        }