frmBonos.vb 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088
  1. Public Class frmBonos
  2. Dim oBonosCE As New BonosCE
  3. Dim oBonosDAO As New BonosDAO
  4. Dim oDAOGeneral As New DAOGeneral
  5. Dim TotalValorCupones As Double
  6. Dim codigo As String = Variables.Codigo
  7. Dim BonosConsulta As New BonosDAO
  8. Dim Estado As String = String.Empty
  9. Dim Operaciones As New Operaciones
  10. Dim InstrumentoFinanciero As String = oDAOGeneral.ObtenerInstrumento(Variables.Codigo)
  11. 'Private _Modo As String
  12. Private _IdDocumento As Integer
  13. Private _TipoDocumento As String
  14. Private _CodigoInversion As String
  15. Private _TipoTransaccion As String 'N=Nuevo, A=Actualizar, C=Consulta
  16. Public Property TipoTransaccion As String
  17. Get
  18. Return _TipoTransaccion
  19. End Get
  20. Set(value As String)
  21. _TipoTransaccion = value
  22. End Set
  23. End Property
  24. Private Property IdDocumento As Integer
  25. Get
  26. Return _IdDocumento
  27. End Get
  28. Set(value As Integer)
  29. _IdDocumento = value
  30. End Set
  31. End Property
  32. Private Property TipoDocumento As String
  33. Get
  34. Return _TipoDocumento
  35. End Get
  36. Set(value As String)
  37. _TipoDocumento = value
  38. End Set
  39. End Property
  40. Private Property CodigoInversion As String
  41. Get
  42. Return _CodigoInversion
  43. End Get
  44. Set(value As String)
  45. _CodigoInversion = value
  46. End Set
  47. End Property
  48. Private Sub frmBonos_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  49. Call CargarPeriodos()
  50. 'PrepararTablaImpuestosYComisiones()
  51. PrepararTablaIngresos()
  52. If Me.TipoTransaccion Is Nothing Then
  53. Me.TipoTransaccion = "N"
  54. End If
  55. If Me.TipoTransaccion = "C" Then
  56. Call CargarRegistroBD()
  57. End If
  58. CargarIngresos()
  59. 'CargarComisiones()
  60. End Sub
  61. Private Sub btnAceptar_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click
  62. If (TipoTransaccion = "N" Or TipoTransaccion = "A") Then
  63. RefrescarClaseEntidad()
  64. If TipoTransaccion = "N" Then
  65. GuardarNuevoRegistro()
  66. End If
  67. If TipoTransaccion = "A" Then
  68. ActualizarRegistro()
  69. End If
  70. Else
  71. Me.Close()
  72. End If
  73. End Sub
  74. Function RetornarObjeto()
  75. Return oBonosCE
  76. End Function
  77. Public Sub CargarRegistro(vId As Integer, vTipo As String)
  78. TipoTransaccion = "C"
  79. IdDocumento = vId
  80. TipoDocumento = vTipo
  81. End Sub
  82. Public Sub CargarRegistro(ByVal CodInversion As String)
  83. TipoTransaccion = "C"
  84. CodigoInversion = CodInversion
  85. End Sub
  86. Private Sub CargarRegistroBD()
  87. oBonosCE = Nothing
  88. oBonosCE = oBonosDAO.CargarRegistro(Me.CodigoInversion)
  89. TipoTransaccion = "C"
  90. RefrescarValorControles()
  91. End Sub
  92. Private Sub dtpUltimaFechaCuponCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpUltimaFechaCuponCompra.ValueChanged
  93. 'ActivarEdicion()
  94. ControlUltimaFechaCuponCompra()
  95. End Sub
  96. Private Sub dtpSiguienteFechaCuponCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpSiguienteFechaCuponCompra.ValueChanged
  97. 'ActivarEdicion()
  98. ControlSiguienteFechaCuponCompra()
  99. End Sub
  100. Private Sub dtpFechaLiquidacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacionCompra.ValueChanged
  101. 'ActivarEdicion()
  102. ControlFechaLiquidacionCompra()
  103. End Sub
  104. Private Sub dtpFechaVencimientoCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoCompra.ValueChanged
  105. 'ActivarEdicion()
  106. ControlFechaVencimientoCompra()
  107. End Sub
  108. Private Sub txtPorcentajeCuponCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.TextChanged
  109. 'ActivarEdicion()
  110. End Sub
  111. Private Sub txtPrecioCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioCompra.TextChanged
  112. 'ActivarEdicion()
  113. End Sub
  114. Private Sub txtPrecioAlVencimientoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.TextChanged
  115. 'ActivarEdicion()
  116. End Sub
  117. Private Sub txtCostoTransferenciaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.TextChanged
  118. 'RefrescarMontoAPagarCompra()
  119. 'ActivarEdicion()
  120. End Sub
  121. Private Sub dtpFechaVencimientoVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoVenta.ValueChanged
  122. 'ActivarEdicion()
  123. ControlFechaVencimientoVenta()
  124. End Sub
  125. Private Sub ControlFechaVencimientoVenta()
  126. Dim valor As Date
  127. valor = dtpFechaVencimientoVenta.Value.Date
  128. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  129. oBonosCE.FechaVencimientoVenta = valor
  130. RefrescarValorControles()
  131. End If
  132. End Sub
  133. Private Sub cboAnioBaseC_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBaseC.SelectedIndexChanged
  134. 'ActivarEdicion()
  135. ControlAnioBaseCompra()
  136. End Sub
  137. Private Sub cboAnioBaseV_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBaseV.SelectedIndexChanged
  138. 'RefrescarInteresAcumuladoVenta()
  139. 'RefrescarDiasAlVencimientoVenta()
  140. 'RefrescarDiasAcumuladosVenta()
  141. ControlAnioBaseVenta()
  142. 'ActivarEdicion()
  143. End Sub
  144. Private Sub ControlAnioBaseVenta()
  145. Dim valor As Integer
  146. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  147. If cboAnioBaseV.SelectedIndex > -1 Then
  148. oBonosCE.DiasBaseVenta = cboAnioBaseV.SelectedItem
  149. Else
  150. oBonosCE.DiasBaseVenta = 365
  151. End If
  152. End If
  153. End Sub
  154. Sub CargarPeriodos()
  155. Dim vTipoTransaccion As String = Me.TipoTransaccion
  156. TipoTransaccion = "X"
  157. Me.cboPeriodosC.DataSource = oDAOGeneral.ListaPeriodicidad
  158. Me.cboPeriodosC.ValueMember = "Codigo"
  159. Me.cboPeriodosC.DisplayMember = "Descripcion"
  160. Me.cboPeriodosC.SelectedIndex = -1
  161. Me.cboPeriodosV.DataSource = oDAOGeneral.ListaPeriodicidad
  162. Me.cboPeriodosV.ValueMember = "Codigo"
  163. Me.cboPeriodosV.DisplayMember = "Descripcion"
  164. Me.cboPeriodosV.SelectedIndex = -1
  165. TipoTransaccion = vTipoTransaccion
  166. End Sub
  167. Private Sub cboPeriodosC_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodosC.SelectedIndexChanged
  168. ControlPeriodosCompra()
  169. End Sub
  170. Private Sub cboPeriodosV_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodosV.SelectedIndexChanged
  171. 'ActivarEdicion()
  172. End Sub
  173. Function CalcularCupones() As DataTable
  174. Dim dtCupones As New DataTable
  175. Dim vFechaLiquidacionCompra As Date = oBonosCE.FechaLiquidacionCompra
  176. Dim vFechaLiquidacionVenta As Date = oBonosCE.FechaLiquidacionVenta
  177. Dim vSiguienteFechaCuponCompra As Date = oBonosCE.SiguienteFechaCuponCompra
  178. Dim vPeriodicidad As String = oBonosCE.PeriodicidadCompra
  179. Dim vValorNominalCompra As Double = oBonosCE.ValorNominalCompra
  180. Dim vPorcentajeCuponCompra As Double = oBonosCE.PorcentajeCuponCompra
  181. Dim vAnioBaseCompra As Integer = oBonosCE.DiasBaseCompra
  182. Dim vColumnas As DataColumn
  183. Dim vFilas As DataRow
  184. Dim vEstaFecha As Date
  185. Dim vSiguienteFecha As Date
  186. Dim vDias As Integer
  187. Dim vValor As Double
  188. 'CREAMOS COLUMNAS
  189. vColumnas = New DataColumn
  190. vColumnas.DataType = GetType(Date)
  191. vColumnas.ColumnName = "FechaCupon"
  192. vColumnas.Caption = "Fecha Cupon"
  193. vColumnas.AllowDBNull = False
  194. dtCupones.Columns.Add(vColumnas)
  195. vColumnas = New DataColumn
  196. vColumnas.DataType = GetType(Integer)
  197. vColumnas.ColumnName = "Dias"
  198. vColumnas.Caption = "Dias"
  199. vColumnas.AllowDBNull = False
  200. dtCupones.Columns.Add(vColumnas)
  201. vColumnas = New DataColumn
  202. vColumnas.DataType = GetType(Double)
  203. vColumnas.ColumnName = "Valor"
  204. vColumnas.Caption = "Valor Cupon"
  205. vColumnas.AllowDBNull = False
  206. dtCupones.Columns.Add(vColumnas)
  207. vSiguienteFecha = vSiguienteFechaCuponCompra
  208. vDias = DateDiff(DateInterval.Day, vFechaLiquidacionCompra, vSiguienteFechaCuponCompra)
  209. Dim ControlBucle As Integer = 1
  210. While vSiguienteFecha <= vFechaLiquidacionVenta
  211. vEstaFecha = vSiguienteFecha
  212. vFilas = dtCupones.NewRow
  213. vFilas("FechaCupon") = vSiguienteFecha
  214. vFilas("Dias") = vDias
  215. Try
  216. vValor = vValorNominalCompra * vPorcentajeCuponCompra * vDias / vAnioBaseCompra
  217. Catch ex As Exception
  218. vValor = 0
  219. End Try
  220. vFilas("Valor") = vValor
  221. dtCupones.Rows.Add(vFilas)
  222. If vPeriodicidad = "S" Then
  223. vSiguienteFecha = vSiguienteFecha.AddMonths(6)
  224. ElseIf vPeriodicidad = "M" Then
  225. vSiguienteFecha = vSiguienteFecha.AddMonths(1)
  226. Else
  227. Exit While
  228. End If
  229. If vAnioBaseCompra = 360 Then
  230. vDias = Utilidades.Days360(vEstaFecha, vSiguienteFecha)
  231. Else
  232. vDias = DateDiff(DateInterval.Day, vEstaFecha, vSiguienteFecha)
  233. End If
  234. End While
  235. Try
  236. TotalValorCupones = dtCupones.Compute("SUM(Valor)", "")
  237. Catch ex As Exception
  238. TotalValorCupones = 0
  239. End Try
  240. 'Me.txtTotalIngresoCupones.Text = TotalValorCupones.ToString
  241. Return dtCupones
  242. dtCupones.Dispose()
  243. End Function
  244. Private Sub CalcularIngresos(ByVal IdFila As Integer)
  245. Dim vFila As DataGridViewRow = dgvIngresos.Rows(IdFila)
  246. Dim IdFilaAnterior As Integer = IdFila - 1
  247. Dim vFilaAnterior As DataGridViewRow
  248. Dim vNumCupon As Integer
  249. Dim vFechaCupon As Date
  250. Dim vFechaAnteriorCupon As Date
  251. Dim vDias As Integer
  252. Dim vIngreso As Double
  253. Dim vImpuesto As Double
  254. Dim vLiquido As Double
  255. Dim vValorNominal As Double = oBonosCE.ValorNominalCompra
  256. Dim vPorcentajeCupon As Double = oBonosCE.PorcentajeCuponCompra
  257. Dim vDiasBase As Integer = oBonosCE.DiasBaseCompra
  258. If Not vFila.IsNewRow Then
  259. 'Date.TryParse(vFila.Cells("FechaCupon").Value.ToString, vFechaCupon)
  260. If (IdFila) > 0 Then
  261. vFilaAnterior = dgvIngresos.Rows(IdFilaAnterior)
  262. vNumCupon = vFilaAnterior.Cells("NumCupon").Value
  263. vNumCupon += 1
  264. vFechaCupon = vFila.Cells("FechaCupon").Value
  265. vFechaAnteriorCupon = vFilaAnterior.Cells("FechaCupon").Value
  266. vDias = DateDiff(DateInterval.Day, vFechaCupon, vFechaAnteriorCupon)
  267. vIngreso = vValorNominal * vPorcentajeCupon * vDias / vDiasBase
  268. vImpuesto = vIngreso * 0.1
  269. vLiquido = vIngreso - vImpuesto
  270. vFila.Cells("NumCupon").Value = vNumCupon
  271. vFila.Cells("Dias").Value = vDias
  272. vFila.Cells("Ingreso").Value = vIngreso
  273. vFila.Cells("MontoImpuesto").Value = vImpuesto
  274. vFila.Cells("Liquido").Value = vLiquido
  275. Else
  276. vFila.Cells("NumCupon").Value = 1
  277. vFila.Cells("Dias").Value = 0
  278. vFila.Cells("Ingreso").Value = 0
  279. vFila.Cells("MontoImpuesto").Value = 0
  280. vFila.Cells("Liquido").Value = 0
  281. End If
  282. End If
  283. End Sub
  284. 'Sub RefrescarTablaIngresos()
  285. ' 'Me.dgvIngresos.DataSource = CalcularCupones()
  286. 'End Sub
  287. Private Sub RefrescarValorControles()
  288. 'Me.cboCasa_C.SelectedValue = oBonosCE.CodigoCasaCompra.ToString
  289. Me.cboPeriodosC.SelectedValue = oBonosCE.PeriodicidadCompra.ToString
  290. Me.txtValorNominalCompra.Text = oBonosCE.ValorNominalCompra.ToString(Configuraciones.CodigoTXTMontos)
  291. Me.dtpUltimaFechaCuponCompra.Value = oBonosCE.UltimaFechaCuponCompra
  292. Me.dtpSiguienteFechaCuponCompra.Value = oBonosCE.SiguienteFechaCuponCompra
  293. Me.dtpFechaLiquidacionCompra.Value = oBonosCE.FechaLiquidacionCompra
  294. Me.dtpFechaVencimientoCompra.Value = oBonosCE.FechaVencimientoCompra
  295. Me.txtPorcentajeCuponCompra.Text = oBonosCE.PorcentajeCuponCompra.ToString(Configuraciones.CodigoTXTPorcentaje)
  296. Me.txtYTMAlVencimientoCompra.Text = oBonosCE.YTMAlVencimientoCompra.ToString(Configuraciones.CodigoTXTPorcentaje)
  297. Me.txtYTMAlVencimientoComisionCompra.Text = oBonosCE.YTMAlVencimientoComisionCompra.ToString(Configuraciones.CodigoTXTPorcentaje)
  298. Me.txtPrecioAlVencimientoCompra.Text = oBonosCE.PrecioAlVencimientoCompra.ToString(Configuraciones.CodigoTXTPorcentaje)
  299. Me.txtPrecioCompra.Text = oBonosCE.PrecioCompra.ToString(Configuraciones.CodigoTXTPorcentaje)
  300. Me.cboAnioBaseC.SelectedItem = oBonosCE.DiasBaseCompra.ToString
  301. Me.txtDiasAcumuladosCompra.Text = oBonosCE.DiasAcumuladosCompra.ToString
  302. Me.txtDiasAlVencimientoCompra.Text = oBonosCE.DiasAlVencimientoCompra.ToString
  303. Me.txtPorcentajeInteresAcumuladoCompra.Text = oBonosCE.PorcentajeInteresAcumuladoCompra.ToString(Configuraciones.CodigoTXTPorcentaje)
  304. Me.txtInteresAcumuladoCompra.Text = oBonosCE.InteresAcumuladoCompra.ToString(Configuraciones.CodigoTXTMontos)
  305. Me.txtPrecioSucioCompra.Text = oBonosCE.PrecioSucioCompra.ToString(Configuraciones.CodigoTXTPorcentaje)
  306. Me.txtValorTransadoCompra.Text = oBonosCE.ValorTransadoCompra.ToString(Configuraciones.CodigoTXTMontos)
  307. Me.txtMontoAPagar.Text = oBonosCE.MontoAPagarCompra.ToString(Configuraciones.CodigoTXTMontos)
  308. Me.txtCostoTransferenciaCompra.Text = oBonosCE.CostoDeTransferenciaCompra.ToString(Configuraciones.CodigoTXTMontos)
  309. 'Me.cboCasa_V.SelectedValue = oBonosCE.CodigoCasaVenta.ToString
  310. Me.cboPeriodosV.SelectedValue = oBonosCE.PeriodicidadVenta.ToString
  311. Me.txtValorNominalVenta.Text = oBonosCE.ValorNominalVenta.ToString(Configuraciones.CodigoTXTMontos)
  312. Me.dtpUltimaFechaCuponVenta.Value = oBonosCE.UltimaFechaCuponVenta
  313. Me.dtpSiguienteFechaCuponVenta.Value = oBonosCE.SiguienteFechaCuponVenta
  314. Me.dtpFechaLiquidacionVenta.Value = oBonosCE.FechaLiquidacionVenta
  315. Me.dtpFechaVencimientoVenta.Value = oBonosCE.FechaVencimientoVenta
  316. Me.txtPorcentajeCuponVenta.Text = oBonosCE.PorcentajeCuponVenta.ToString(Configuraciones.CodigoTXTPorcentaje)
  317. Me.txtYTMAlVencimientoComisionVenta.Text = oBonosCE.YTMAlVencimientoComisionVenta.ToString(Configuraciones.CodigoTXTPorcentaje)
  318. Me.txtYTMAlVencimientoVenta.Text = oBonosCE.YTMAlVencimientoVenta.ToString(Configuraciones.CodigoTXTPorcentaje)
  319. Me.txtPrecioAlVencimientoVenta.Text = oBonosCE.PrecioAlVencimientoVenta.ToString(Configuraciones.CodigoTXTPorcentaje)
  320. Me.txtPrecioVenta.Text = oBonosCE.PrecioVenta.ToString(Configuraciones.CodigoTXTPorcentaje)
  321. Me.cboAnioBaseV.SelectedItem = oBonosCE.DiasBaseVenta.ToString
  322. Me.txtDiasAcumuladosVenta.Text = oBonosCE.DiasAcumuladosVenta.ToString
  323. Me.txtDiasAlVencimientoVenta.Text = oBonosCE.DiasAlVencimientoVenta.ToString
  324. Me.txtPorcentajeInteresAcumuladoVenta.Text = oBonosCE.InteresAcumuladoPorcentajeVenta.ToString(Configuraciones.CodigoTXTPorcentaje)
  325. Me.txtInteresAcumuladoVenta.Text = oBonosCE.InteresAcumuladoVenta.ToString(Configuraciones.CodigoTXTMontos)
  326. Me.txtPrecioSucioVenta.Text = oBonosCE.PrecioSucioVenta.ToString(Configuraciones.CodigoTXTPorcentaje)
  327. Me.txtValorTransadoVenta.Text = oBonosCE.ValorTransadoVenta.ToString(Configuraciones.CodigoTXTMontos)
  328. Me.txtMontoARecibir.Text = oBonosCE.MontoARecibirVenta.ToString(Configuraciones.CodigoTXTMontos)
  329. Me.txtCostoTransferenciaVenta.Text = oBonosCE.CostoDeTransferenciaVenta.ToString(Configuraciones.CodigoTXTMontos)
  330. Me.txtValorNominal_Op.Text = oBonosCE.ValorNominalRO.ToString(Configuraciones.CodigoTXTMontos)
  331. Me.txtPlazo_Op.Text = oBonosCE.DiasPlazoRO.ToString
  332. Me.txtPrecioCompra_Op.Text = oBonosCE.PrecioCompraRO.ToString(Configuraciones.CodigoTXTMontos)
  333. Me.txtPrecioVenta_Op.Text = oBonosCE.PrecioVentaRO.ToString(Configuraciones.CodigoTXTMontos)
  334. Me.txtGananciaPerdidaCapital_Op.Text = oBonosCE.GananciaPerdidaDeCapital.ToString(Configuraciones.CodigoTXTMontos)
  335. Me.txtIngresosPorIntereses_Op.Text = oBonosCE.IngresoPorInteres.ToString(Configuraciones.CodigoTXTMontos)
  336. Me.txtCostosTotales_Op.Text = oBonosCE.CostosTotales.ToString(Configuraciones.CodigoTXTMontos)
  337. Me.txtGananciaPerdidaTotal_Op.Text = oBonosCE.GananciaPerdidaTotal.ToString(Configuraciones.CodigoTXTMontos)
  338. Me.txtRendimientoGananciaPerdida_Op.Text = oBonosCE.RendimientoGananciaPerdida.ToString(Configuraciones.CodigoTXTPorcentaje)
  339. Me.txtRendimientoIntereses_Op.Text = oBonosCE.RendimientoDeIntereses.ToString(Configuraciones.CodigoTXTPorcentaje)
  340. Me.txtRendimientoAntesISR_Op.Text = oBonosCE.RendimientoAntesImpuestos.ToString(Configuraciones.CodigoTXTPorcentaje)
  341. Me.txtRendimientoDespuesISR_Op.Text = oBonosCE.RendimientoDespuesImpuestos.ToString(Configuraciones.CodigoTXTPorcentaje)
  342. If Me.TipoTransaccion = "N" Then Me.btnAceptar.Text = "Guardar"
  343. If Me.TipoTransaccion = "A" Then Me.btnAceptar.Text = "Guardar"
  344. If Me.TipoTransaccion = "C" Then Me.btnAceptar.Text = "Aceptar"
  345. End Sub
  346. Private Sub RefrescarClaseEntidad()
  347. ControlValorNominalCompra()
  348. ControlUltimaFechaCuponCompra()
  349. ControlSiguienteFechaCuponCompra()
  350. ControlFechaLiquidacionCompra()
  351. ControlFechaVencimientoCompra()
  352. ControlPorcentajeCuponCompra()
  353. 'ControlYTMAlVencimientoCompra()
  354. ControlPrecioAlVencimientoCompra()
  355. ControlPrecioCompra()
  356. ControlAnioBaseCompra()
  357. ControlCostosDeTransferencia()
  358. 'ControlValorNominalv
  359. ControlUltimaFechaCuponCompra()
  360. ControlSiguienteFechaCuponCompra()
  361. ControlFechaLiquidacionCompra()
  362. ControlFechaVencimientoCompra()
  363. ControlPorcentajeCuponCompra()
  364. 'ControlYTMAlVencimientoCompra()
  365. ControlPrecioAlVencimientoCompra()
  366. ControlPrecioCompra()
  367. ControlAnioBaseCompra()
  368. ControlCostosDeTransferencia()
  369. End Sub
  370. Private Sub GuardarNuevoRegistro()
  371. Dim res As Integer
  372. RefrescarClaseEntidad()
  373. res = oBonosDAO.Nuevo(oBonosCE)
  374. If res = 1 Then
  375. MsgBox("Registro Guardado")
  376. Else
  377. MsgBox("Algo no salio bien.")
  378. End If
  379. End Sub
  380. Private Sub ActualizarRegistro()
  381. Dim res As Integer
  382. RefrescarClaseEntidad()
  383. res = oBonosDAO.Actualizar(oBonosCE)
  384. If res = 1 Then
  385. MsgBox("Registro Guardado")
  386. Else
  387. MsgBox("Algo no salio bien.")
  388. End If
  389. End Sub
  390. 'Private Sub ActivarEdicion()
  391. ' If TipoTransaccion = "C" Then
  392. ' Me.TipoTransaccion = "A"
  393. ' Me.btnAceptar.Text = "Guardar"
  394. ' End If
  395. 'End Sub
  396. Private Sub ControlPeriodosCompra()
  397. Dim valor As String
  398. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  399. If Me.cboPeriodosC.SelectedIndex = -1 Then
  400. valor = ""
  401. Else
  402. valor = Me.cboPeriodosC.SelectedValue
  403. End If
  404. oBonosCE.PeriodicidadCompra = valor
  405. RefrescarValorControles()
  406. End If
  407. End Sub
  408. Private Sub ControlValorNominalCompra()
  409. Dim valor As Double
  410. If Not Double.TryParse(Me.txtValorNominalCompra.Text, valor) Then
  411. Me.txtValorNominalCompra.BackColor = Configuraciones.ColorFondoError
  412. Me.txtValorNominalCompra.Focus()
  413. Else
  414. Me.txtValorNominalCompra.BackColor = Configuraciones.ColorFondoPredefinido
  415. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  416. Me.oBonosCE.ValorNominalCompra = valor
  417. RefrescarValorControles()
  418. End If
  419. End If
  420. End Sub
  421. Private Sub ControlUltimaFechaCuponCompra()
  422. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  423. Me.oBonosCE.UltimaFechaCuponCompra = dtpUltimaFechaCuponCompra.Value.Date
  424. RefrescarValorControles()
  425. End If
  426. End Sub
  427. Private Sub ControlSiguienteFechaCuponCompra()
  428. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  429. Me.oBonosCE.SiguienteFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value.Date
  430. RefrescarValorControles()
  431. End If
  432. End Sub
  433. Private Sub ControlFechaLiquidacionCompra()
  434. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  435. Me.oBonosCE.FechaLiquidacionCompra = dtpFechaLiquidacionCompra.Value.Date
  436. RefrescarValorControles()
  437. End If
  438. End Sub
  439. Private Sub ControlFechaVencimientoCompra()
  440. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  441. Me.oBonosCE.FechaVencimientoCompra = dtpFechaVencimientoCompra.Value.Date
  442. RefrescarValorControles()
  443. End If
  444. End Sub
  445. Private Sub ControlPorcentajeCuponCompra()
  446. Dim valor As Double
  447. If Not Double.TryParse(txtPorcentajeCuponCompra.Text.Replace("%", ""), valor) Then
  448. Me.txtPorcentajeCuponCompra.BackColor = Configuraciones.ColorFondoError
  449. Me.txtPorcentajeCuponCompra.Focus()
  450. Else
  451. Me.txtPorcentajeCuponCompra.BackColor = Configuraciones.ColorFondoPredefinido
  452. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  453. Me.oBonosCE.PorcentajeCuponCompra = valor / 100
  454. RefrescarValorControles()
  455. End If
  456. End If
  457. End Sub
  458. Private Sub ControlAnioBaseCompra()
  459. Dim valor As Integer
  460. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  461. valor = cboAnioBaseC.SelectedItem
  462. Me.oBonosCE.DiasBaseCompra = valor
  463. RefrescarValorControles()
  464. End If
  465. End Sub
  466. Private Sub txtValorNominalCompra_LostFocus(sender As Object, e As EventArgs) Handles txtValorNominalCompra.LostFocus
  467. ControlValorNominalCompra()
  468. End Sub
  469. Private Sub ControlPrecioAlVencimientoCompra()
  470. Dim valor As Double
  471. If Not Double.TryParse(Me.txtPrecioAlVencimientoCompra.Text.Replace("%", String.Empty), valor) Then
  472. Me.txtPrecioAlVencimientoCompra.BackColor = Configuraciones.ColorFondoError
  473. Me.txtPrecioAlVencimientoCompra.Focus()
  474. Else
  475. Me.txtPrecioAlVencimientoCompra.BackColor = Configuraciones.ColorFondoPredefinido
  476. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  477. Me.oBonosCE.PrecioAlVencimientoCompra = valor / 100
  478. RefrescarValorControles()
  479. End If
  480. End If
  481. End Sub
  482. Private Sub ControlPrecioCompra()
  483. Dim valor As Double
  484. If Not Double.TryParse(Me.txtPrecioCompra.Text.Replace("%", String.Empty), valor) Then
  485. Me.txtPrecioCompra.BackColor = Configuraciones.ColorFondoError
  486. Me.txtPrecioCompra.Focus()
  487. Else
  488. Me.txtPrecioCompra.BackColor = Configuraciones.ColorFondoPredefinido
  489. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  490. Me.oBonosCE.PrecioCompra = valor / 100
  491. RefrescarValorControles()
  492. End If
  493. End If
  494. End Sub
  495. Private Sub ControlCostosDeTransferencia()
  496. Dim valor As Double
  497. If Not Double.TryParse(Me.txtCostoTransferenciaCompra.Text, valor) Then
  498. Me.txtCostoTransferenciaCompra.BackColor = Configuraciones.ColorFondoError
  499. Me.txtCostoTransferenciaCompra.Focus()
  500. Else
  501. Me.txtCostoTransferenciaCompra.BackColor = Configuraciones.ColorFondoPredefinido
  502. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  503. Me.oBonosCE.CostoDeTransferenciaCompra = valor
  504. RefrescarValorControles()
  505. End If
  506. End If
  507. End Sub
  508. Private Sub txtPorcentajeCuponCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.LostFocus
  509. ControlPorcentajeCuponCompra()
  510. End Sub
  511. Private Sub txtPrecioAlVencimientoCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.LostFocus
  512. ControlPrecioAlVencimientoCompra()
  513. End Sub
  514. Private Sub txtPrecioCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioCompra.LostFocus
  515. ControlPrecioCompra()
  516. End Sub
  517. Private Sub txtCostoTransferenciaCompra_LostFocus(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.LostFocus
  518. ControlCostosDeTransferencia()
  519. End Sub
  520. Private Sub dtpSiguienteFechaCuponVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpSiguienteFechaCuponVenta.ValueChanged
  521. 'ActivarEdicion()
  522. End Sub
  523. Private Sub txtCostoTransferenciaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtCostoTransferenciaVenta.TextChanged
  524. 'ActivarEdicion()
  525. End Sub
  526. 'Private Sub PrepararTablaImpuestosYComisiones()
  527. ' Dim oDataGridViewTextBoxColumn As DataGridViewTextBoxColumn
  528. ' Dim oDataGridViewComboBoxColumn As DataGridViewComboBoxColumn
  529. ' oDataGridViewComboBoxColumn = New DataGridViewComboBoxColumn
  530. ' oDataGridViewComboBoxColumn.Name = "CodImp"
  531. ' oDataGridViewComboBoxColumn.HeaderText = "Tipo Impuesto"
  532. ' oDataGridViewComboBoxColumn.DataSource = oDAOGeneral.ListaTiposImpuesto
  533. ' oDataGridViewComboBoxColumn.ValueMember = "Codigo"
  534. ' oDataGridViewComboBoxColumn.DisplayMember = "Descripcion"
  535. ' oDataGridViewComboBoxColumn.DataPropertyName = "CodImp"
  536. ' oDataGridViewComboBoxColumn.DisplayIndex = 0
  537. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewComboBoxColumn)
  538. ' oDataGridViewComboBoxColumn = New DataGridViewComboBoxColumn
  539. ' oDataGridViewComboBoxColumn.Name = "TipoOper"
  540. ' oDataGridViewComboBoxColumn.HeaderText = "Tipo Operación"
  541. ' oDataGridViewComboBoxColumn.DataSource = oDAOGeneral.ListaTipoOperacion
  542. ' oDataGridViewComboBoxColumn.ValueMember = "Codigo"
  543. ' oDataGridViewComboBoxColumn.DisplayMember = "Descripcion"
  544. ' oDataGridViewComboBoxColumn.DataPropertyName = "TipoOper"
  545. ' oDataGridViewComboBoxColumn.DisplayIndex = 1
  546. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewComboBoxColumn)
  547. ' oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  548. ' oDataGridViewTextBoxColumn.Name = "PorcImp"
  549. ' oDataGridViewTextBoxColumn.HeaderText = "Porcentaje"
  550. ' oDataGridViewTextBoxColumn.DataPropertyName = "PorcImp"
  551. ' oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  552. ' oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTPorcentaje
  553. ' oDataGridViewTextBoxColumn.DisplayIndex = 2
  554. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewTextBoxColumn)
  555. ' oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  556. ' oDataGridViewTextBoxColumn.Name = "MontoSujeto"
  557. ' oDataGridViewTextBoxColumn.HeaderText = "Monto Sujeto"
  558. ' oDataGridViewTextBoxColumn.DataPropertyName = "MontoSujeto"
  559. ' oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  560. ' oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  561. ' oDataGridViewTextBoxColumn.ReadOnly = True
  562. ' oDataGridViewTextBoxColumn.DisplayIndex = 3
  563. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewTextBoxColumn)
  564. ' oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  565. ' oDataGridViewTextBoxColumn.Name = "MontoImp"
  566. ' oDataGridViewTextBoxColumn.HeaderText = "Monto Impuesto"
  567. ' oDataGridViewTextBoxColumn.DataPropertyName = "MontoImp"
  568. ' oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  569. ' oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  570. ' oDataGridViewTextBoxColumn.DisplayIndex = 4
  571. ' oDataGridViewTextBoxColumn.ReadOnly = True
  572. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewTextBoxColumn)
  573. ' oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  574. ' oDataGridViewTextBoxColumn.Name = "CodInv"
  575. ' oDataGridViewTextBoxColumn.DataPropertyName = "CodInv"
  576. ' oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  577. ' oDataGridViewTextBoxColumn.Visible = False
  578. ' Me.dgvImpuestosYComisiones.Columns.Add(oDataGridViewTextBoxColumn)
  579. ' Me.dgvImpuestosYComisiones.DataSource = oBonosCE.ImpuestosYComisiones
  580. 'End Sub
  581. 'Private Sub PrepararImpuestosYComisiones(ByVal IdFila As Integer)
  582. ' Dim vFila As DataGridViewRow = dgvImpuestosYComisiones.Rows(IdFila)
  583. ' If vFila.IsNewRow Then
  584. ' vFila.Cells("TipoOper").Value = "V"
  585. ' vFila.Cells("PorcImp").Value = 0
  586. ' vFila.Cells("MontoSujeto").Value = oBonosCE.ValorTransadoVenta
  587. ' vFila.Cells("MontoImp").Value = 0.00
  588. ' End If
  589. 'End Sub
  590. 'Private Sub CalcularImpuestosYComisiones(ByVal IdFila As Integer, ByVal IdCol As Integer)
  591. ' Dim vFila As DataGridViewRow = dgvImpuestosYComisiones.Rows(IdFila)
  592. ' Dim vTipoOperacion As String
  593. ' Dim vCodigoImpuesto As String
  594. ' Dim vPorcentajeImpuesto As Double
  595. ' Dim vMontoSujeto As Double
  596. ' Dim vMontoImpuesto As Double
  597. ' If Not vFila.IsNewRow Then
  598. ' vCodigoImpuesto = vFila.Cells("CodImp").Value.ToString
  599. ' vTipoOperacion = vFila.Cells("TipoOper").Value.ToString
  600. ' Double.TryParse(vFila.Cells("PorcImp").Value.ToString, vPorcentajeImpuesto)
  601. ' If IdCol = 3 Then
  602. ' vPorcentajeImpuesto = vPorcentajeImpuesto / 100
  603. ' vFila.Cells("PorcImp").Value = vPorcentajeImpuesto
  604. ' End If
  605. ' If vTipoOperacion = "C" Then
  606. ' vMontoSujeto = oBonosCE.ValorTransadoCompra
  607. ' vFila.Cells("MontoSujeto").Value = oBonosCE.ValorTransadoCompra
  608. ' ElseIf vTipoOperacion = "V" Then
  609. ' vMontoSujeto = oBonosCE.ValorTransadoVenta
  610. ' vFila.Cells("MontoSujeto").Value = oBonosCE.ValorTransadoVenta
  611. ' Else
  612. ' vMontoSujeto = 0
  613. ' End If
  614. ' vMontoImpuesto = vMontoSujeto * vPorcentajeImpuesto
  615. ' vFila.Cells("MontoImp").Value = vMontoImpuesto
  616. ' End If
  617. ' RefrescarClaseEntidad()
  618. ' RefrescarValorControles()
  619. 'End Sub
  620. 'Function CalcularComisiones(ByVal TipoImp As String, ByVal TipoOpe As String)
  621. ' Dim Cantidad = dgvImpuestosYComisiones.Rows.Count - 1
  622. ' Dim Comision
  623. ' For i As Integer = 0 To Cantidad
  624. ' Comision = dgvIngresos.Rows(i).Cells(3)
  625. ' Next
  626. 'End Function
  627. 'Private Sub dgvImpuestosYComisiones_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs)
  628. ' 'ActivarEdicion()
  629. ' PrepararImpuestosYComisiones(e.RowIndex)
  630. 'End Sub
  631. 'Private Sub dgvImpuestosYComisiones_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs)
  632. ' CalcularImpuestosYComisiones(e.RowIndex, e.ColumnIndex)
  633. 'End Sub
  634. Private Sub dgvImpuestosYComisiones_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs)
  635. 'ActivarEdicion()
  636. oBonosCE.ImpuestosYComisiones.AcceptChanges()
  637. End Sub
  638. Private Sub PrepararTablaIngresos()
  639. Dim oDataGridViewTextBoxColumn As DataGridViewTextBoxColumn
  640. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  641. oDataGridViewTextBoxColumn.Name = "CodInv"
  642. oDataGridViewTextBoxColumn.DataPropertyName = "CodInv"
  643. oDataGridViewTextBoxColumn.HeaderText = "Código Inversión"
  644. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  645. oDataGridViewTextBoxColumn.Visible = False
  646. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  647. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  648. oDataGridViewTextBoxColumn.Name = "NumCupon"
  649. oDataGridViewTextBoxColumn.DataPropertyName = "NumCupon"
  650. oDataGridViewTextBoxColumn.HeaderText = "No. Cupón"
  651. oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
  652. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  653. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  654. oDataGridViewTextBoxColumn.Name = "FechaCupon"
  655. oDataGridViewTextBoxColumn.DataPropertyName = "FechaCupon"
  656. oDataGridViewTextBoxColumn.HeaderText = "Fecha Cupón"
  657. oDataGridViewTextBoxColumn.ValueType = GetType(Date)
  658. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  659. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  660. oDataGridViewTextBoxColumn.Name = "Dias"
  661. oDataGridViewTextBoxColumn.DataPropertyName = "Dias"
  662. oDataGridViewTextBoxColumn.HeaderText = "Dias "
  663. oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
  664. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  665. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  666. oDataGridViewTextBoxColumn.Name = "Ingreso"
  667. oDataGridViewTextBoxColumn.DataPropertyName = "Ingreso"
  668. oDataGridViewTextBoxColumn.HeaderText = "Ingreso"
  669. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  670. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  671. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  672. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  673. oDataGridViewTextBoxColumn.Name = "PorcentajeImpuesto"
  674. oDataGridViewTextBoxColumn.DataPropertyName = "PorcImpuesto"
  675. oDataGridViewTextBoxColumn.HeaderText = "% Impuesto"
  676. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  677. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  678. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  679. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  680. oDataGridViewTextBoxColumn.Name = "MontoImpuesto"
  681. oDataGridViewTextBoxColumn.DataPropertyName = "MontoImpuesto"
  682. oDataGridViewTextBoxColumn.HeaderText = "Impuesto"
  683. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  684. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  685. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  686. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  687. oDataGridViewTextBoxColumn.Name = "Liquido"
  688. oDataGridViewTextBoxColumn.DataPropertyName = "Liquido"
  689. oDataGridViewTextBoxColumn.HeaderText = "Liquido"
  690. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  691. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  692. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  693. End Sub
  694. Private Sub txtValorNominalVenta_LostFocus(sender As Object, e As EventArgs) Handles txtValorNominalVenta.LostFocus
  695. ControlValorNominalVenta()
  696. End Sub
  697. Private Sub ControlValorNominalVenta()
  698. Dim valor As Double
  699. If Not Double.TryParse(Me.txtValorNominalVenta.Text, valor) Then
  700. Me.txtValorNominalVenta.BackColor = Configuraciones.ColorFondoError
  701. Me.txtValorNominalVenta.Focus()
  702. Else
  703. Me.txtValorNominalVenta.BackColor = Configuraciones.ColorFondoPredefinido
  704. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  705. oBonosCE.ValorNominalVenta = valor
  706. RefrescarValorControles()
  707. End If
  708. End If
  709. End Sub
  710. Private Sub txtPorcentajeCuponVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeCuponVenta.LostFocus
  711. ControlPorcentajeCuponVenta()
  712. End Sub
  713. Private Sub ControlPorcentajeCuponVenta()
  714. Dim valor As Double
  715. If Not Double.TryParse(Me.txtPorcentajeCuponVenta.Text, valor) Then
  716. Me.txtPorcentajeCuponVenta.BackColor = Configuraciones.ColorFondoError
  717. Me.txtPorcentajeCuponVenta.Focus()
  718. Else
  719. Me.txtPorcentajeCuponVenta.BackColor = Configuraciones.ColorFondoPredefinido
  720. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  721. oBonosCE.PorcentajeCuponVenta = valor
  722. RefrescarValorControles()
  723. End If
  724. End If
  725. End Sub
  726. Private Sub txtPrecioAlVencimientoVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoVenta.LostFocus
  727. ControlPrecioAlVencimientoVenta()
  728. End Sub
  729. Private Sub ControlPrecioAlVencimientoVenta()
  730. Dim valor As Double
  731. If Not Double.TryParse(Me.txtPrecioAlVencimientoVenta.Text, valor) Then
  732. Me.txtPrecioAlVencimientoVenta.BackColor = Configuraciones.ColorFondoError
  733. Me.txtPrecioAlVencimientoVenta.Focus()
  734. Else
  735. Me.txtPrecioAlVencimientoVenta.BackColor = Configuraciones.ColorFondoPredefinido
  736. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  737. oBonosCE.PrecioAlVencimientoVenta = valor
  738. RefrescarValorControles()
  739. End If
  740. End If
  741. End Sub
  742. Private Sub txtPrecioVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioVenta.LostFocus
  743. ControlPrecioVenta()
  744. End Sub
  745. Private Sub ControlPrecioVenta()
  746. Dim valor As Double
  747. If Not Double.TryParse(txtPrecioVenta.Text, valor) Then
  748. txtPrecioVenta.BackColor = Configuraciones.ColorFondoError
  749. txtPrecioVenta.Focus()
  750. Else
  751. txtPrecioVenta.BackColor = Configuraciones.ColorFondoPredefinido
  752. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  753. oBonosCE.PrecioVenta = valor
  754. RefrescarValorControles()
  755. End If
  756. End If
  757. End Sub
  758. Private Sub dgvIngresos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellContentClick
  759. End Sub
  760. Private Sub PrepararCalculoIngresos(ByVal IdFila As Integer)
  761. Dim vFila As DataGridViewRow = dgvIngresos.Rows(IdFila)
  762. Dim vFilaAnterior As DataGridViewRow
  763. Dim vNumCupon As Integer
  764. Dim vFechaCupon As Date
  765. Dim vFechaCuponAnterior As Date
  766. Dim vDias As Integer
  767. vFechaCupon = Date.Now.Date
  768. If IdFila > 0 Then
  769. vFilaAnterior = dgvIngresos.Rows(IdFila - 1)
  770. vNumCupon = vFilaAnterior.Cells("NumCupon").Value
  771. vNumCupon += 1
  772. vFechaCuponAnterior = vFilaAnterior.Cells("FechaCupon").Value
  773. 'vFechaCupon = oBonosCE.SiguienteFechaCuponCompra
  774. Else
  775. vNumCupon = 1
  776. vFechaCuponAnterior = oBonosCE.UltimaFechaCuponCompra
  777. End If
  778. vDias = DateDiff(DateInterval.Day, vFechaCuponAnterior, vFechaCupon)
  779. If vFila.IsNewRow Then
  780. vFila.Cells("NumCupon").Value = vNumCupon
  781. vFila.Cells("FechaCupon").Value = vFechaCupon
  782. vFila.Cells("Dias").Value = vDias
  783. vFila.Cells("Ingreso").Value = 0
  784. vFila.Cells("PorcentajeImpuesto").Value = 10
  785. vFila.Cells("MontoImpuesto").Value = 0
  786. vFila.Cells("Liquido").Value = 0.00
  787. End If
  788. End Sub
  789. Private Sub dgvIngresos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvIngresos.CellBeginEdit
  790. 'ActivarEdicion()
  791. PrepararCalculoIngresos(e.RowIndex)
  792. End Sub
  793. Private Sub dgvIngresos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellEndEdit
  794. CalcularIngresos(e.RowIndex)
  795. End Sub
  796. Private Sub dgvIngresos_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs) Handles dgvIngresos.UserDeletedRow
  797. 'ActivarEdicion()
  798. oBonosCE.Ingresos.AcceptChanges()
  799. End Sub
  800. Private Sub dgvImpuestosYComisiones_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  801. End Sub
  802. Private Sub btnAccionComision_Click(sender As Object, e As EventArgs)
  803. If (Estado = "N") Then
  804. 'NuevaComision()
  805. ElseIf (Estado = "M") Then
  806. 'ModificarComision()
  807. ElseIf (Estado = "B") Then
  808. EliminarComision()
  809. End If
  810. End Sub
  811. 'Function ColecccionComisiones()
  812. ' Dim coleccion As New Collection
  813. ' Dim TipoImp, TipOp, MontoSuje, PorcImp, MontoImp As String
  814. ' TipoImp = dgvImpuestosYComisiones.CurrentRow.Cells(0).Value
  815. ' TipOp = dgvImpuestosYComisiones.CurrentRow.Cells(1).Value
  816. ' PorcImp = CDec(dgvImpuestosYComisiones.CurrentRow.Cells(2).Value.ToString.TrimEnd("%") / 100)
  817. ' MontoSuje = dgvImpuestosYComisiones.CurrentRow.Cells(3).Value
  818. ' MontoImp = dgvImpuestosYComisiones.CurrentRow.Cells(4).Value.ToString.TrimEnd("%")
  819. ' coleccion.Add(TipoImp)
  820. ' coleccion.Add(TipOp)
  821. ' coleccion.Add(PorcImp)
  822. ' coleccion.Add(MontoSuje)
  823. ' coleccion.Add(MontoImp)
  824. ' Return coleccion
  825. 'End Function
  826. Function ColeccionIngresos()
  827. Dim coleccion As New Collection
  828. Dim NoCupon, Fecha, Ingreso, PorcImpuesto, Impuesto, Dias As String
  829. NoCupon = dgvIngresos.CurrentRow.Cells(1).Value
  830. Fecha = dgvIngresos.CurrentRow.Cells(2).Value
  831. Dias = dgvIngresos.CurrentRow.Cells(3).Value
  832. Ingreso = dgvIngresos.CurrentRow.Cells(4).Value
  833. PorcImpuesto = dgvIngresos.CurrentRow.Cells(5).Value
  834. Impuesto = dgvIngresos.CurrentRow.Cells(6).Value
  835. coleccion.Add(NocUpon)
  836. coleccion.Add(Fecha)
  837. coleccion.Add(Dias)
  838. coleccion.Add(Ingreso)
  839. coleccion.Add(PorcImpuesto)
  840. coleccion.Add(Impuesto)
  841. Return coleccion
  842. End Function
  843. 'Sub NuevaComision()
  844. ' Dim coleccion = ColecccionComisiones()
  845. ' BonosConsulta.NuevoImpuesto(coleccion, codigo)
  846. 'End Sub
  847. Sub NuevoIngreso()
  848. Dim coleccion = ColeccionIngresos()
  849. ' BonosConsulta.NuevoIngreso(coleccion, codigo)
  850. End Sub
  851. 'Sub ModificarComision()
  852. ' Dim coleccion = ColecccionComisiones()
  853. ' BonosConsulta.ModificarImpuesto(coleccion, codigo)
  854. 'End Sub
  855. Sub ModificarIngreso()
  856. Dim coleccion = ColeccionIngresos()
  857. ' BonosConsulta.ModificarIngreso(coleccion, codigo)
  858. End Sub
  859. Sub EliminarComision()
  860. BonosConsulta.EliminarImpuesto(codigo)
  861. End Sub
  862. Sub EliminarIngreso()
  863. Dim NoCupon = dgvIngresos.CurrentRow.Cells(0).Value
  864. ' BonosConsulta.EliminarIngreso(codigo, NoCupon)
  865. End Sub
  866. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  867. 'btnAccionComision.Text = "Modificar"
  868. btnAccionIngreso.Text = "Modificar"
  869. Estado = "M"
  870. End Sub
  871. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  872. 'btnAccionComision.Text = "Nuevo"
  873. btnAccionIngreso.Text = "Nuevo"
  874. Estado = "N"
  875. End Sub
  876. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  877. 'btnAccionComision.Text = "Eliminar"
  878. btnAccionIngreso.Text = "Eliminar"
  879. Estado = "B"
  880. End Sub
  881. 'Sub CargarComisiones()
  882. ' Dim codigo As String = Variables.Codigo
  883. ' Dim dr = BonosConsulta.CargarImpuestos(codigo)
  884. ' While dr.Read
  885. ' dgvImpuestosYComisiones.Rows.Add(dr("TipoImp"), dr("TipoOp"), ((dr("PorcImp") * 100.0).ToString + "%"), dr("MontoSuje"), dr("MontoImp"))
  886. ' End While
  887. 'End Sub
  888. Sub CargarIngresos()
  889. Dim codigo As String = Variables.Codigo
  890. Dim dr = BonosConsulta.CargarIngreso(codigo, InstrumentoFinanciero)
  891. While dr.Read
  892. dgvIngresos.Rows.Add("", dr("NoCupon"), dr("Fecha"), dr("Dias"), dr("Ingreso"), dr("PorcImpuesto"), dr("Impuesto"))
  893. End While
  894. End Sub
  895. Private Sub btnAccionIngreso_Click(sender As Object, e As EventArgs) Handles btnAccionIngreso.Click
  896. If (Estado = "N") Then
  897. NuevoIngreso()
  898. ElseIf (Estado = "M") Then
  899. ModificarIngreso()
  900. ElseIf (Estado = "B") Then
  901. EliminarIngreso()
  902. End If
  903. End Sub
  904. Private Sub TabPage1_Click(sender As Object, e As EventArgs) Handles TabPage1.Click
  905. End Sub
  906. Private Sub txtValorNominalCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorNominalCompra.KeyPress
  907. 'Operaciones.ValidarEntrada(sender, e)
  908. End Sub
  909. Private Sub txtValorNominalVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorNominalVenta.KeyPress
  910. 'Operaciones.ValidarEntrada(sender, e)
  911. End Sub
  912. Private Sub txtPorcentajeCuponCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeCuponCompra.KeyPress
  913. 'Operaciones.ValidarEntrada(sender, e)
  914. End Sub
  915. Private Sub txtPorcentajeCuponVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeCuponVenta.KeyPress
  916. 'Operaciones.ValidarEntrada(sender, e)
  917. End Sub
  918. Private Sub txtPrecioAlVencimientoCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioAlVencimientoCompra.KeyPress
  919. 'Operaciones.ValidarEntrada(sender, e)
  920. End Sub
  921. Private Sub txtPrecioAlVencimientoVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioAlVencimientoVenta.KeyPress
  922. 'Operaciones.ValidarEntrada(sender, e)
  923. End Sub
  924. Private Sub txtPrecioCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioCompra.KeyPress
  925. 'Operaciones.ValidarEntrada(sender, e)
  926. End Sub
  927. Private Sub txtPrecioVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioVenta.KeyPress
  928. 'Operaciones.ValidarEntrada(sender, e)
  929. End Sub
  930. Private Sub txtCostoTransferenciaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCostoTransferenciaCompra.KeyPress
  931. 'Operaciones.ValidarEntrada(sender, e)
  932. End Sub
  933. Private Sub txtCostoTransferenciaVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCostoTransferenciaVenta.KeyPress
  934. 'Operaciones.ValidarEntrada(sender, e)
  935. End Sub
  936. End Class