Esempio n. 1
0
        private void makeAssessmentBtn_Click(object sender, EventArgs e)
        {
            Account account = null;

            // If row is selected
            if (accountsDgv.SelectedRows.Count != 0)
            {
                // Retrieve row data and cast to account object
                var row = this.accountsDgv.SelectedRows[0];
                account = (Account)row.DataBoundItem;
            }

            if (startDateDtp.Value < DateTime.Now.Date)
            {
                MessageBox.Show($@"Datum ne smije biti manji od {DateTime.Now.Date}");
                return;
            }


            if (IsStandingOrderChecked && account == null)
            {
                MessageBox.Show(@"Niste izabrali račun koji će se trajno teretiti", "Otvaranje štednje",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var loan = new Loan()
            {
                Account = account,
                Capital = (double)capitalNum.Value,
                IsStandingOrderActive = IsStandingOrderChecked,
                LoanStartDate         = startDateDtp.Value,
                LoanEndDate           = startDateDtp.Value.AddYears((int)loanDurationNum.Value),
                LoanDuration          = (int)loanDurationNum.Value,
                Status     = 0,
                LoanType   = LoanType,
                EmployeeId = 1,
                ClientId   = Client.Id
            };

            var assessment = loanAssessment.CalculateLoanAssessmentForPrivateClients(Client.Id, loan) * 100;

            var castAssessment = (int)assessment;

            if (castAssessment > 100)
            {
                castAssessment = 100;
            }
            if (castAssessment < 0)
            {
                castAssessment = 0;
            }

            assessmentProgressBar.Value = castAssessment;
        }
        private void loanRequestsDgv_SelectionChanged(object sender, EventArgs e)
        {
            if (loanRequestsDgv.SelectedRows.Count != 0)
            {
                // Cast row data to account type object
                var row  = this.loanRequestsDgv.SelectedRows[0];
                var loan = (Loan)row.DataBoundItem;

                var client   = this.clientRepository.Get(loan.ClientId);
                var loanType = this.loanTypeRepository.GetById(loan.LoanTypeId);

                firstNameLbl.Text = client.FirstName;
                lastNameLbl.Text  = client.LastName;
                oibLbl.Text       = client.OIB;
                addressLbl.Text   = client.Address;
                incomeLbl.Text    = client.Income.ToString(CultureInfo.InvariantCulture);

                accountNameLbl.Text        = loanType.Name;
                foreignCurrencyChb.Checked = loanType.IsForeignCurrency;
                currencyLbl.Text           = loanType.Currency;
                interestRateLbl.Text       = (loanType.InterestRate * 100) + "%";

                ChangeAssessmentVisibility(client.ClientTypeId == (int)ClientType.Privatni);

                if (client.ClientTypeId == (int)ClientType.Privatni)
                {
                    var assessment = loanAssessment.CalculateLoanAssessmentForPrivateClients(client.Id, loan) * 100;

                    var castAssessment = (int)assessment;
                    if (castAssessment > 100)
                    {
                        castAssessment = 100;
                    }
                    if (castAssessment < 0)
                    {
                        castAssessment = 0;
                    }

                    assessmentProgressBar.Value = castAssessment;
                }
            }
        }