private void cmdPayInterest_Click(object sender, EventArgs e) { try { if (lvGeneratedInterest.SelectedIndices.Count > 0 && lvGeneratedInterest.SelectedIndices[0] >= 0) { int _index = lvGeneratedInterest.SelectedIndices[0]; int _interestId = Convert.ToInt32(lvGeneratedInterest.Items[_index].Text); InvestorBondInterest _interest = manager.My_db.InvestorBondInterests.FirstOrDefault(x => x.Id == _interestId); if (_interest != null && !_interest.Extracted) { _interest.Extracted = true; _interest.ExtractionDate = DateTime.Now.Date; //TODO: Generar los movimientos de cuenta para el pago del interes. manager.My_db.SaveChanges(); loadInterests(); lvGeneratedInterest.SelectedIndices.Clear(); } } } catch (Exception _ex) { ErrorMessage.showErrorMessage(_ex); } }
private void lvGeneratedInterest_SelectedIndexChanged(object sender, EventArgs e) { cmdPayInterest.Enabled = false; if (lvGeneratedInterest.SelectedIndices.Count > 0 && lvGeneratedInterest.SelectedIndices[0] >= 0) { int _index = lvGeneratedInterest.SelectedIndices[0]; int _interestId = Convert.ToInt32(lvGeneratedInterest.Items[_index].Text); InvestorBondInterest _interest = manager.My_db.InvestorBondInterests.FirstOrDefault(x => x.Id == _interestId); if (_interest != null) { cmdPayInterest.Enabled = !_interest.Extracted; } } }