private List<RateCycle> GetRateCycles() { List<RateCycle> rateCycles = new List<RateCycle>(); var rateCycle = new RateCycle(); rateCycle.CycleId = 2; rateCycle.CycleObjectId = 2; rateCycle.LoanCycle = 0; rateCycle.Min = 0.2m; rateCycle.Max = 0.3m; rateCycles.Add(rateCycle); rateCycle = new RateCycle(); rateCycle.CycleId = 2; rateCycle.CycleObjectId = 2; rateCycle.LoanCycle = 1; rateCycle.Min = 0.15m; rateCycle.Max = 0.2m; rateCycles.Add(rateCycle); rateCycle = new RateCycle(); rateCycle.CycleId = 2; rateCycle.CycleObjectId = 2; rateCycle.LoanCycle = 2; rateCycle.Min = 0.1m; rateCycle.Max = 0.15m; rateCycles.Add(rateCycle); return rateCycles; }
private void buttonAddAmountCycle_Click(object sender, EventArgs e) { int loanCycle; if (listViewLoanCycles.Items.Count == 0) loanCycle = 0; else loanCycle = ((Cycle)listViewLoanCycles.Items[listViewLoanCycles.Items.Count - 1].Tag).LoanCycle + 1; textBoxCycleMin.TextChanged -= textBoxCycleMin_TextChanged; textBoxCycleMax.TextChanged -= textBoxCycleMax_TextChanged; textBoxCycleMin.Text = "0"; textBoxCycleMax.Text = "0"; textBoxCycleMin.TextChanged += textBoxCycleMin_TextChanged; textBoxCycleMax.TextChanged += textBoxCycleMax_TextChanged; buttonRemoveAmountCycles.Enabled = true; buttonAmountCyclesSave.Enabled = true; int cycleObjectId = ((CycleObject)cbxCycleObjects.SelectedItem).Id; switch (cycleObjectId) { case 1: var parameter = new LoanAmountCycle { CycleId = ((LoanCycle)comboBoxLoanCyclesName.SelectedItem).Id, CycleObjectId = cycleObjectId, Min = 0, Max = 0, LoanCycle = loanCycle }; var amountCycleItem = new ListViewItem((parameter.LoanCycle + 1).ToString()) { Tag = parameter }; amountCycleItem.SubItems.Add(parameter.Min.ToString()); amountCycleItem.SubItems.Add(parameter.Max.ToString()); listViewLoanCycles.Items.Add(amountCycleItem); _product.LoanAmountCycleParams.Add(parameter); break; case 2: var rateCycleParam = new RateCycle { CycleId = ((LoanCycle)comboBoxLoanCyclesName.SelectedItem).Id, CycleObjectId = cycleObjectId, Min = 0, Max = 0, LoanCycle = loanCycle }; var interestRateCycleItem = new ListViewItem((rateCycleParam.LoanCycle + 1).ToString()) { Tag = rateCycleParam }; interestRateCycleItem.SubItems.Add(rateCycleParam.Min.ToString()); interestRateCycleItem.SubItems.Add(rateCycleParam.Max.ToString()); listViewLoanCycles.Items.Add(interestRateCycleItem); _product.RateCycleParams.Add(rateCycleParam); break; case 3: var maturityCycleParam = new MaturityCycle { CycleId = ((LoanCycle)comboBoxLoanCyclesName.SelectedItem).Id, CycleObjectId = cycleObjectId, Min = 0, Max = 0, LoanCycle = loanCycle }; var maturityCycleItem = new ListViewItem((maturityCycleParam.LoanCycle + 1).ToString()) { Tag = maturityCycleParam }; maturityCycleItem.SubItems.Add(maturityCycleParam.Min.ToString()); maturityCycleItem.SubItems.Add(maturityCycleParam.Max.ToString()); listViewLoanCycles.Items.Add(maturityCycleItem); _product.MaturityCycleParams.Add(maturityCycleParam); break; default: break; } listViewLoanCycles.Items[listViewLoanCycles.Items.Count - 1].Selected = true; }
public void TestProductWithoutMaturityCycle() { var loanAmountCycles = new List<LoanAmountCycle>(); var loanAmountCycle = new LoanAmountCycle(0, 0, 1,2,1,1); loanAmountCycles.Add(loanAmountCycle); var rateCycles = new List<RateCycle>(); var rateCycle = new RateCycle(0,0,1,2,1,1); var maturityCycles = new List<MaturityCycle>(); rateCycles.Add(rateCycle); Currency currency = new Currency(); currency.Id = 1; var entryFees = new List<EntryFee>(); var nrp = new NonRepaymentPenaltiesNullableValues(100, 200, 10, 0.2); LoanProduct product = CreatePackage( "NewPackage", //package name null, //anticipatedTotalRepaymentPenalties 3, //anticipatedTotalRepaymentPenaltiesMin 6, //anticipatedTotalRepaymentPenaltiesMax 4, //grace period null, //gracePeriodMin null, //gracePeriodMax null, //interestRate null, //interesrRateMin null, //interestRateMax null, //NmbOfInstallments null, //NmbOfInstallmentsMin null, //NmbOfInstallmentsMax entryFees, //List<EntryFee> nrp, //NonRepaymentPenalties null, //NonRepaymentPenaltiesMin null, //NonRepaymentPenaltiesMax _monthly, //InstallmentType null, //amount null, //amountMin null, //AmountMax null, //ExoticInstallmentsTable 1, //cycleId loanAmountCycles, //List<LoanAmountCycle> rateCycles, //List<RateCycle> maturityCycles, //List<MaturityCycle> "CODE1", //ProductCode null, //List<ProductClientType> null, //amountUnderLoc null, //amountUnderLocMin null, //amountUnderLocMax 5, //anticipatedPartialRepaymentPenalties null, //anticipatedPartialRepaymentPenaltiesMin null, //anticipatedPartialRepaymentPenaltiesMax null, //compulsoryAmount null, //compulsoryAmountMin null, //compulsoryAmountMax currency ); ProductServices productServices = new ProductServices(new User() { Id = 1 }); productServices.ParseFieldsAndCheckErrors(product, false); }
public List<RateCycle> SelectRateCycleParams(int cycleId) { List<RateCycle> cycleParameters = new List<RateCycle>(); string q = @"SELECT [id] ,[loan_cycle] ,[min] ,[max] ,[cycle_object_id] ,[cycle_id] FROM [dbo].[CycleParameters] WHERE [cycle_object_id]=2 AND [cycle_id]=@cycle_id ORDER BY [loan_cycle]"; using (SqlConnection conn = GetConnection()) using (OpenCbsCommand c = new OpenCbsCommand(q, conn)) { c.AddParam("@cycle_id", cycleId); using (OpenCbsReader r = c.ExecuteReader()) { while (r.Read()) { RateCycle parameter = new RateCycle(); parameter.Id = r.GetInt("id"); parameter.LoanCycle = r.GetInt("loan_cycle"); parameter.Min = r.GetDecimal("min"); parameter.Max = r.GetDecimal("max"); parameter.CycleObjectId = r.GetInt("cycle_object_id"); parameter.CycleId = r.GetNullInt("cycle_id"); cycleParameters.Add(parameter); } } } return cycleParameters; }