Exemplo n.º 1
0
        public EditLoanProductView(int id)
            : this()
        {
            _loanProduct.Find(id);
            List <LoanCharge> loanCharges = LoanCharge.GetListByLoanProductId(_loanProduct.ID);

            int countCharges = loanCharges.Count;

            _loanCharge1 = countCharges >= 1 ? loanCharges[0] : new LoanCharge();

            _loanCharge2 = countCharges >= 2 ? loanCharges[1] : new LoanCharge();

            _loanCharge3 = countCharges >= 3 ? loanCharges[2] : new LoanCharge();

            _loanCharge4 = countCharges >= 4 ? loanCharges[3] : new LoanCharge();

            _loanCharge5 = countCharges >= 5 ? loanCharges[4] : new LoanCharge();

            _loanCharge6 = countCharges >= 6 ? loanCharges[5] : new LoanCharge();

            List <LoanDeduction> loanDeductions = LoanDeduction.GetListByLoanProductId(_loanProduct.ID);
            int countDeductions = loanDeductions.Count;

            _loanDeduction1 = countDeductions >= 1 ? loanDeductions[0] : new LoanDeduction();

            _loanDeduction2 = countDeductions >= 2 ? loanDeductions[1] : new LoanDeduction();

            _loanDeduction3 = countDeductions >= 3 ? loanDeductions[2] : new LoanDeduction();

            DataContext            = _loanProduct;
            grdDetails.DataContext = _loanProduct;

            grdCharge1.DataContext = _loanCharge1;
            grdCharge2.DataContext = _loanCharge2;
            grdCharge3.DataContext = _loanCharge3;
            grdCharge4.DataContext = _loanCharge4;
            grdCharge5.DataContext = _loanCharge5;
            grdCharge6.DataContext = _loanCharge6;

            grdDeduction1.DataContext = _loanDeduction1;
            grdDeduction2.DataContext = _loanDeduction2;
            grdDeduction3.DataContext = _loanDeduction3;
        }
Exemplo n.º 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();
        }