private void InitializeClient(IClient pClient, int pContractId) { if (pClient is Person) { _person = (Person)pClient; _client = _person; _oClientType = OClientTypes.Person; InitializeUserControl(_oClientType, _mdiParent); InitializeTitle(string.Format("{0} {1}", _person.FirstName, _person.LastName)); } if (pClient is Group) { _group = (Group)pClient; _client = _group; _oClientType = OClientTypes.Group; InitializeUserControl(_oClientType, _mdiParent); InitializeTitle(_group.Name); } if (pClient is Corporate) { _corporate = (Corporate)pClient; _client = _corporate; _oClientType = OClientTypes.Corporate; InitializeUserControl(_oClientType, _mdiParent); InitializeTitle(_corporate.Name); } _project = pClient.SelectProject(pContractId); _credit = _project.SelectCredit(pContractId); _credit.LoanEntryFeesList = ServicesProvider.GetInstance().GetContractServices().GetInstalledLoanEntryFees(_credit); _product = _credit.Product; if (_product.CycleId != null && _credit.Disbursed == false) { ServicesProvider.GetInstance().GetProductServices().SetCyclesParamsForContract(_product, _credit, _client, false); } else { if (_credit.Product.Amount.HasValue == false) { _amountValueRange = new DecimalValueRange(_credit.Product.AmountMin.Value, _credit.Product.AmountMax.Value); nudLoanAmount.Minimum = _credit.Product.AmountMin.Value; nudLoanAmount.Maximum = _credit.Product.AmountMax.Value; } else { nudLoanAmount.Minimum = nudLoanAmount.Maximum = _credit.Product.Amount.Value; } if (_credit.Product.NbOfInstallments.HasValue == false) { nudLoanNbOfInstallments.Minimum = _credit.Product.NbOfInstallmentsMin.Value; nudLoanNbOfInstallments.Maximum = _credit.Product.NbOfInstallmentsMax.Value; } else { nudLoanNbOfInstallments.Minimum = nudLoanNbOfInstallments.Maximum = _credit.Product.NbOfInstallments.Value; } } if (ServicesProvider.GetInstance().GetGeneralSettings().UseProjects) { tabControlPerson.TabPages.Add(tabPageProject); DisplaySelectedProject(_project); } else { AddProject(_project); } tabControlPerson.TabPages.Add(tabPageLoansDetails); tabControlPerson.TabPages.Add(tabPageAdvancedSettings); tabControlPerson.TabPages.Add(tabPageLoanGuarantees); _credit.LoanInitialOfficer = _credit.LoanOfficer; InitializeTabPageLoansDetails(_credit); tabControlPerson.TabPages.Add(tabPageCreditCommitee); if (_credit.Disbursed) { tabControlPerson.TabPages.Add(tabPageLoanRepayment); //tabControlPerson.TabPages.Add(tabPageLAC); tabControlPerson.SelectedTab = tabPageLoanRepayment; InitializeTabPageLoanRepayment(_credit); } else if (_credit.ContractStatus == OContractStatus.Validated && !_credit.Disbursed) { tabControlPerson.SelectedTab = tabPageLoansDetails; } }
private void InitializeAmount(Loan credit, bool pForCreation) { if (pForCreation) //if it is new contract { nudLoanAmount.DecimalPlaces = (credit.Product.Currency.UseCents || _credit.UseCents) ? 2 : 0; if (!credit.Product.UseLoanCycle) //If product doesn't use any loan cycle { if (!credit.Product.Amount.HasValue) //if credit amount is a range value { try { _amountValueRange = new DecimalValueRange(credit.Product.AmountMin, credit.Product.AmountMax); nudLoanAmount.Enabled = true; labelLoanAmountMinMax.SetRangeText(_amountValueRange.Min, _amountValueRange.Max); nudLoanAmount.Minimum = _amountValueRange.Min.Value; nudLoanAmount.Maximum = _amountValueRange.Max.Value; nudLoanAmount.Value = _amountValueRange.Min.Value; } catch { nudLoanAmount.Minimum = nudLoanAmount.Maximum = credit.Amount.Value; nudLoanAmount.Value = credit.Amount.Value; } } else //if credit amount is a fixed value { try { _amountValueRange = new DecimalValueRange(credit.Product.Amount); OCurrency valueCurrency = _amountValueRange.Value; decimal value = valueCurrency.Value; labelLoanAmountMinMax.SetRangeText(valueCurrency); nudLoanAmount.Minimum = value; nudLoanAmount.Maximum = value; nudLoanAmount.Value = value; nudLoanAmount.Enabled = false; } catch { nudLoanAmount.Minimum = nudLoanAmount.Maximum = credit.Amount.Value; nudLoanAmount.Value = credit.Amount.Value; } } } else //if product uses loan cycles { _amountValueRange = new DecimalValueRange(credit.Product.AmountMin, credit.Product.AmountMax); nudLoanAmount.Enabled = true; labelLoanAmountMinMax.SetRangeText(_amountValueRange.Min, _amountValueRange.Max); nudLoanAmount.Minimum = _amountValueRange.Min.Value; nudLoanAmount.Maximum = _amountValueRange.Max.Value; nudLoanAmount.Value = _amountValueRange.Min.Value; } } else //if it is an existing contract { nudLoanAmount.DecimalPlaces = (credit.Product.Currency.UseCents) ? 2 : 0; if (credit.LoanCycle == null && !credit.AmountMin.HasValue && !credit.AmountMax.HasValue)//if contract doesn't use any loan cycles { if (credit.Product.Amount.HasValue)//if credit amount is a fixed value { try { _amountValueRange = new DecimalValueRange(credit.Product.Amount); labelLoanAmountMinMax.SetRangeText(_amountValueRange.Value); nudLoanAmount.Minimum = nudLoanAmount.Maximum = _amountValueRange.Value.Value; } catch (Exception) { nudLoanAmount.Minimum = nudLoanAmount.Maximum = credit.Amount.Value; nudLoanAmount.Value = credit.Amount.Value; } } else //if credit amount is range vale { try { _amountValueRange = new DecimalValueRange(credit.Product.AmountMin, credit.Product.AmountMax); labelLoanAmountMinMax.SetRangeText(_amountValueRange.Min, _amountValueRange.Max); nudLoanAmount.Minimum = _amountValueRange.Min.Value; nudLoanAmount.Maximum = _amountValueRange.Max.Value; nudLoanAmount.Value = credit.Amount.Value; } catch { nudLoanAmount.Minimum = nudLoanAmount.Maximum = credit.Amount.Value; nudLoanAmount.Value = credit.Amount.Value; } } } else //if product uses loan cycles { try { _amountValueRange = new DecimalValueRange(credit.AmountMin, credit.AmountMax); nudLoanAmount.Enabled = true; labelLoanAmountMinMax.SetRangeText(_amountValueRange.Min, _amountValueRange.Max); nudLoanAmount.Minimum = _amountValueRange.Min.Value; nudLoanAmount.Maximum = _amountValueRange.Max.Value; nudLoanAmount.Value = credit.Amount.Value; } catch { nudLoanAmount.Minimum = nudLoanAmount.Maximum = credit.Amount.Value; nudLoanAmount.Value = credit.Amount.Value; } } } nudLoanAmount.Text = nudLoanAmount.Value.ToString(); //Workaround for text emptyness }