frmLetes.vb 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663
  1. Imports System.Globalization
  2. Public Class frmLetes
  3. Dim oCELetes As LETESCE
  4. Dim oDAOLetes As New LETESDAO
  5. Dim oDAOGeneral As New DAOGeneral
  6. Dim IndexBase As Integer = 0
  7. Dim TipoTransaccion = "OK"
  8. Dim Operaciones As New Operaciones
  9. Dim V_txtPrecio = 0.0, V_txtValorTransado = 0.0, V_txtComisionCasa = 0.0, V_txtComisionBolsa = 0.0, V_txtIngresoBruto = 0.0, V_txtTotalAPagar = 0.0, V_txtIngresoNeto = 0.0, V_txtRendimientoNeto = 0.0, V_txtDiasAcumulados = 0.0
  10. Dim DecimalesRedondeo As Integer = 4
  11. Private CodigoInversion As String
  12. Dim Instrumento As String
  13. Private _Modo As String
  14. Private _IdDocumento As Integer
  15. Private _TipoDocumento As String
  16. Private _ValorNominal As Double
  17. Private _ValorTransado As Double
  18. Private _Precio As Double
  19. Private _PorcentajeCasa As Double
  20. Private _ComisionCasa As Double
  21. Private _PorcentajeBolsa As Double
  22. Private _ComisionBolsa As Double
  23. Private _TotalAPagar As Double
  24. Private _FechaOperacion As Date
  25. Private _FechaLiquidacion As Date
  26. Private _FechaVencimiento As Date
  27. Private _RendimientoBruto As Double
  28. Private _RendimientoNeto As Double
  29. Private _Periodicidad As String
  30. Private _Plazo As Integer
  31. Private _IngresoBruto As Double
  32. Private _IngresoNeto As Double
  33. Private PBUR As Double = False
  34. Private VCN As Double = False
  35. Private CET As Double = False
  36. Public Property Modo As String
  37. Get
  38. Return _Modo
  39. End Get
  40. Set(value As String)
  41. _Modo = value
  42. End Set
  43. End Property
  44. Private Property IdDocumento As Integer
  45. Get
  46. Return _IdDocumento
  47. End Get
  48. Set(value As Integer)
  49. _IdDocumento = value
  50. End Set
  51. End Property
  52. Private Property TipoDocumento As String
  53. Get
  54. Return _TipoDocumento
  55. End Get
  56. Set(value As String)
  57. _TipoDocumento = value
  58. End Set
  59. End Property
  60. 'GETS
  61. Function GetRendimientoBruto() As Double
  62. Dim valor As Double
  63. If Me.txtRendimientoBruto.Text.Length = 0 Then
  64. valor = 0
  65. Else
  66. valor = Me.txtRendimientoBruto.Text
  67. valor = valor
  68. End If
  69. Return valor
  70. End Function
  71. Function GetFechaOperacion() As Date
  72. Dim valor As Date
  73. valor = dtpFechaOperacion.Value
  74. Return valor
  75. End Function
  76. Function GetFechaLiquidacion() As Date
  77. Dim valor As Date
  78. valor = dtpFechaLiquidacion.Value
  79. Return valor
  80. End Function
  81. Function GetFechaVencimiento() As Date
  82. Dim valor As Date
  83. valor = dtpFechaVencimiento.Value
  84. Return valor
  85. End Function
  86. Function GetPlazoInversion() As Integer
  87. Dim valor As Integer
  88. If Me.txtPlazoInversion.Text.Length = 0 Then
  89. valor = 0
  90. Else
  91. valor = Me.txtPlazoInversion.Text
  92. End If
  93. Return valor
  94. End Function
  95. Function GetValorNominal() As Double
  96. Dim valor As Double
  97. If Me.txtValorNominal.Text.Length = 0 Then
  98. valor = 0
  99. Else
  100. valor = Me.txtValorNominal.Text
  101. End If
  102. Return valor
  103. End Function
  104. Function GetPrecio() As Double
  105. Dim valor As Double
  106. If Me.txtPrecio.Text.Length = 0 Then
  107. valor = 0
  108. Else
  109. Try
  110. valor = Me.txtPrecio.Text
  111. valor = valor / 100
  112. Catch ex As Exception
  113. valor = 0
  114. End Try
  115. End If
  116. Return valor
  117. End Function
  118. Function GetPorcentajeBolsa() As Double
  119. Dim valor As Double
  120. If Me.txtPorcentajeComisionBolsa.Text.Length = 0 Then
  121. valor = 0
  122. Else
  123. valor = Me.txtPorcentajeComisionBolsa.Text
  124. valor = valor / 100
  125. End If
  126. Return valor
  127. End Function
  128. Function GetPorcentajeCasa() As Double
  129. Dim valor As Double
  130. If Me.txtPorcentajeComisionCasa.Text.Length = 0 Then
  131. valor = 0
  132. Else
  133. valor = Me.txtPorcentajeComisionCasa.Text
  134. valor = valor / 100
  135. End If
  136. Return valor
  137. End Function
  138. Function GetValorTransado() As Double
  139. Dim valor As Double
  140. If Me.txtValorTransado.Text.Length = 0 Then
  141. valor = 0
  142. Else
  143. valor = Me.txtValorTransado.Text
  144. End If
  145. Return valor
  146. End Function
  147. Function GetComisionBolsa() As Double
  148. Dim valor As Double
  149. If Me.txtComisionBolsa.Text.Length = 0 Then
  150. valor = 0
  151. Else
  152. valor = Me.txtComisionBolsa.Text
  153. End If
  154. Return valor
  155. End Function
  156. Function GetComisionCasa() As Double
  157. Dim valor As Double
  158. If Me.txtComisionCasa.Text.Length = 0 Then
  159. valor = 0
  160. Else
  161. valor = Me.txtComisionCasa.Text
  162. End If
  163. Return valor
  164. End Function
  165. Function GetTotalAPagar() As Double
  166. Dim valor As Double
  167. If Me.txtTotalAPagar.Text.Length = 0 Then
  168. valor = 0
  169. Else
  170. valor = Me.txtTotalAPagar.Text
  171. End If
  172. Return valor
  173. End Function
  174. Function GetRendimientoNeto() As Double
  175. Dim valor As Double
  176. If Me.txtRendimientoNeto.Text.Length = 0 Then
  177. valor = 0
  178. Else
  179. Try
  180. valor = Me.txtRendimientoNeto.Text
  181. valor = valor / 100
  182. Catch ex As Exception
  183. valor = 0
  184. End Try
  185. End If
  186. Return valor
  187. End Function
  188. Function GetPeriodicidad() As String
  189. Dim valor As String
  190. Try
  191. valor = Me.cboPeriodicidad.SelectedValue
  192. Catch ex As Exception
  193. valor = ""
  194. End Try
  195. Return valor
  196. End Function
  197. Function GetIngresoBruto() As Double
  198. Dim valor As Double
  199. If Me.txtIngresoBruto.Text.Length = 0 Then
  200. valor = 0
  201. Else
  202. Try
  203. valor = Me.txtIngresoBruto.Text
  204. Catch ex As Exception
  205. valor = 0
  206. End Try
  207. End If
  208. Return valor
  209. End Function
  210. Function GetIngresoNeto() As Double
  211. Dim valor As Double
  212. If Me.txtIngresoNeto.Text.Length = 0 Then
  213. valor = 0
  214. Else
  215. Try
  216. valor = Me.txtIngresoNeto.Text
  217. Catch ex As Exception
  218. valor = 0
  219. End Try
  220. End If
  221. Return valor
  222. End Function
  223. Function GetCasa() As String
  224. Dim valor As String
  225. valor = Me.cboCasasCorredoras.SelectedValue
  226. Return valor
  227. End Function
  228. 'CALCULOS
  229. Function CalcularPlazoInversion() As Integer
  230. 'Dim valor As Integer
  231. 'If AnioBase = 360 Then
  232. ' valor = Utilidades.Days360(GetFechaLiquidacion, GetFechaVencimiento)
  233. 'Else
  234. ' valor = DateDiff(DateInterval.Day, GetFechaLiquidacion, GetFechaVencimiento)
  235. 'End If
  236. 'Return valor
  237. End Function
  238. Function CalcularPrecio() As Double
  239. 'Dim valor As Double
  240. 'Try
  241. ' valor = (1 - (GetRendimientoBruto() / (1 + GetRendimientoBruto() * GetPlazoInversion() / AnioBase)) * GetPlazoInversion() / AnioBase)
  242. 'Catch ex As Exception
  243. ' valor = 0
  244. 'End Try
  245. 'valor = valor * 100
  246. 'valor = Math.Round(valor, DecimalesRedondeo)
  247. 'Return valor
  248. End Function
  249. Function CalcularFechaLiquidacion() As Date
  250. Dim valor As Date
  251. valor = GetFechaOperacion()
  252. Return valor
  253. End Function
  254. Function CalcularFechaVencimiento() As Date
  255. Dim valor As Date
  256. valor = GetFechaLiquidacion()
  257. Return valor
  258. End Function
  259. Function CalcularValorTransado() As Double
  260. Dim valor As Double
  261. valor = GetValorNominal() * GetPrecio()
  262. valor = Math.Round(valor, DecimalesRedondeo)
  263. Return valor
  264. End Function
  265. Function CalcularComisionBolsa() As Double
  266. 'Dim valor As Double
  267. 'valor = (GetValorTransado() * GetPorcentajeBolsa()) * (GetPlazoInversion() / AnioBase)
  268. 'valor = Math.Round(valor, DecimalesRedondeo)
  269. 'Return valor
  270. End Function
  271. Function CalcularComisionCasa() As Double
  272. 'Dim valor As Double
  273. 'valor = (GetValorTransado() * GetPorcentajeCasa()) * (GetPlazoInversion() / AnioBase)
  274. 'valor = Math.Round(valor, DecimalesRedondeo)
  275. 'Return valor
  276. End Function
  277. Function CalcularValorApagar() As Double
  278. Dim valor As Double
  279. valor = GetValorTransado() + GetComisionBolsa() + GetComisionCasa()
  280. valor = Math.Round(valor, DecimalesRedondeo)
  281. Return valor
  282. End Function
  283. Function CalcularRendimientoNeto() As Double
  284. 'Dim valor As Double
  285. 'valor = ((GetValorNominal() - GetTotalAPagar()) / GetTotalAPagar()) * (AnioBase / GetPlazoInversion())
  286. 'valor = valor * 100
  287. 'valor = Math.Round(valor, DecimalesRedondeo)
  288. 'Return valor
  289. End Function
  290. Function CalcularIngresoBruto() As Double
  291. Dim valor As Double
  292. valor = GetValorNominal() - GetValorTransado()
  293. valor = Math.Round(valor, DecimalesRedondeo)
  294. Return valor
  295. End Function
  296. Function CalcularIngresoNeto() As Double
  297. Dim valor As Double
  298. valor = GetValorNominal() - GetTotalAPagar()
  299. valor = Math.Round(valor, DecimalesRedondeo)
  300. Return valor
  301. End Function
  302. 'AUTO
  303. Sub RefrescarPlazoInversion()
  304. Me.txtPlazoInversion.Text = CalcularPlazoInversion()
  305. End Sub
  306. Sub RefrescarPrecio()
  307. Me.txtPrecio.Text = CalcularPrecio()
  308. End Sub
  309. Sub RefrescarFechaLiquidacion()
  310. Me.dtpFechaLiquidacion.Value = CalcularFechaLiquidacion()
  311. End Sub
  312. Sub RefrescarFechaVencimiento()
  313. Me.dtpFechaVencimiento.Value = CalcularFechaVencimiento()
  314. End Sub
  315. Sub RefrescarValorTransado()
  316. Me.txtValorTransado.Text = CalcularValorTransado()
  317. End Sub
  318. Sub RefrescarComisionBolsa()
  319. Me.txtComisionBolsa.Text = CalcularComisionBolsa()
  320. End Sub
  321. Sub RefrescarComisionCasa()
  322. Me.txtComisionCasa.Text = CalcularComisionCasa()
  323. End Sub
  324. Sub RefrescarTotalAPagar()
  325. Me.txtTotalAPagar.Text = CalcularValorApagar()
  326. End Sub
  327. Sub RefrescarRendimientoNeto()
  328. Me.txtRendimientoNeto.Text = CalcularRendimientoNeto()
  329. End Sub
  330. Sub RefrescarIngresoBruto()
  331. Me.txtIngresoBruto.Text = CalcularIngresoBruto()
  332. End Sub
  333. Sub RefrescarIngresoNeto()
  334. Me.txtIngresoNeto.Text = CalcularIngresoNeto()
  335. End Sub
  336. 'EVENTOS
  337. Private Sub Button1_Click(sender As Object, e As EventArgs)
  338. RefrescarPlazoInversion()
  339. End Sub
  340. Private Sub txtRendimientoBruto_TextChanged(sender As Object, e As EventArgs)
  341. If Modo = "N" Then
  342. RefrescarPrecio()
  343. End If
  344. End Sub
  345. Private Sub txtPlazoInversion_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoBruto.TextChanged, txtPlazoInversion.TextChanged
  346. 'If Modo = "N" Then
  347. ' RefrescarPlazoInversion()
  348. ' RefrescarPrecio()
  349. ' RefrescarComisionBolsa()
  350. ' RefrescarComisionCasa()
  351. ' RefrescarRendimientoNeto()
  352. 'End If
  353. RellenarDatos()
  354. End Sub
  355. Private Sub dtpFechaVencimiento_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimiento.ValueChanged
  356. ' If Modo = "N" Then
  357. ' RefrescarPlazoInversion()
  358. ' End If
  359. End Sub
  360. Private Sub dtpFechaLiquidacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacion.ValueChanged
  361. 'If Modo = "N" Then
  362. ' RefrescarFechaVencimiento()
  363. ' RefrescarPlazoInversion()
  364. 'End If
  365. RellenarDatos()
  366. End Sub
  367. Private Sub dtpFechaOperacion_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaOperacion.ValueChanged
  368. 'If Modo = "N" Then
  369. ' RefrescarFechaLiquidacion()
  370. 'End If
  371. RellenarDatos()
  372. AgregarDiasExtra()
  373. End Sub
  374. Private Sub txtValorNominal_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominal.TextChanged
  375. RellenarDatos()
  376. End Sub
  377. Private Sub txtPrecio_TextChanged(sender As Object, e As EventArgs) Handles txtPrecio.TextChanged
  378. 'If Modo = "N" Then
  379. ' RefrescarValorTransado()
  380. 'End If
  381. End Sub
  382. Private Sub txtPorcentajeComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.TextChanged
  383. RellenarDatos()
  384. 'If Modo = "N" Then
  385. ' RefrescarComisionCasa()
  386. 'End If
  387. End Sub
  388. Private Sub txtPorcentajeComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.TextChanged
  389. RellenarDatos()
  390. 'If Modo = "N" Then
  391. ' RefrescarComisionBolsa()
  392. 'End If
  393. End Sub
  394. Private Sub txtValorTransado_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransado.TextChanged
  395. 'If Modo = "N" Then
  396. ' RefrescarComisionBolsa()
  397. ' RefrescarComisionCasa()
  398. ' RefrescarTotalAPagar()
  399. ' RefrescarIngresoBruto()
  400. 'End If
  401. End Sub
  402. Private Sub txtComisionCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionCasa.TextChanged
  403. If Modo = "N" Then
  404. RefrescarTotalAPagar()
  405. End If
  406. End Sub
  407. Private Sub txtComisionBolsa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionBolsa.TextChanged
  408. If Modo = "N" Then
  409. RefrescarTotalAPagar()
  410. End If
  411. End Sub
  412. Private Sub txtTotalAPagar_TextChanged(sender As Object, e As EventArgs) Handles txtTotalAPagar.TextChanged
  413. 'If Modo = "N" Then
  414. ' RefrescarRendimientoNeto()
  415. ' RefrescarIngresoNeto()
  416. 'End If
  417. End Sub
  418. Sub ValidarExistencia()
  419. Dim General As New DAOGeneral
  420. Dim Codigo As String = Variables.Codigo
  421. Dim Tabla As String = String.Empty
  422. If PBUR Then
  423. Tabla = "PBUR"
  424. ElseIf VCN Then
  425. Tabla = "VCN"
  426. ElseIf CET Then
  427. Tabla = "CET0"
  428. Else
  429. Tabla = "LET0"
  430. End If
  431. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  432. If (Existe) Then
  433. navNuevo.Enabled = False
  434. navModificar.Enabled = True
  435. navEliminar.Enabled = True
  436. Else
  437. navNuevo.Enabled = True
  438. navModificar.Enabled = False
  439. navEliminar.Enabled = False
  440. 'LimpiarCampos()
  441. End If
  442. TipoTransaccion = String.Empty
  443. btnAceptar.Text = "Aceptar"
  444. End Sub
  445. Function ExisteValidacion()
  446. Dim General As New DAOGeneral
  447. Dim Codigo As String = Variables.Codigo
  448. Dim Tabla As String = String.Empty
  449. If PBUR Then
  450. Tabla = "PBUR"
  451. ElseIf VCN Then
  452. Tabla = "VCN"
  453. ElseIf CET Then
  454. Tabla = "CET0"
  455. Else
  456. Tabla = "LET0"
  457. End If
  458. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  459. Return Existe
  460. End Function
  461. Private Sub frmLetes_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  462. TipInstrumento()
  463. Me.ActiveControl = Me.txtValorNominal
  464. Call CargarCasasCorredoras()
  465. Call CargarBase()
  466. Call CargarPeriodicidad()
  467. If Variables.Codigo.IndexOf("LETE") > -1 Then
  468. Instrumento = "LETE"
  469. ElseIf Variables.Codigo.IndexOf("PBUR") > -1 Then
  470. Instrumento = "PBUR"
  471. lblBono.Text = "PAPEL BURSATIL"
  472. Me.Text = "PAPEL BURSATIL"
  473. lblInteresAcumulado.Visible = True
  474. lblDiasAcumulados.Visible = True
  475. dtpUltimaFecha.Visible = True
  476. txtInteresAcumulado.Visible = True
  477. chbValorPar.Visible = True
  478. ElseIf Variables.Codigo.IndexOf("CETE") > -1 Then
  479. Instrumento = "CETE"
  480. lblBono.Text = "CETES"
  481. Me.Text = "CETE"
  482. lblInteresAcumulado.Visible = True
  483. lblDiasAcumulados.Visible = True
  484. dtpUltimaFecha.Visible = True
  485. txtInteresAcumulado.Visible = True
  486. ConfiguracionCETE()
  487. ElseIf Variables.Codigo.IndexOf("VCN") > -1 Then
  488. Instrumento = "VCN"
  489. lblBono.Text = "VALORES COMERCIALES"
  490. Me.Text = "VALORES COMERCIALES"
  491. lblInteresAcumulado.Visible = True
  492. lblDiasAcumulados.Visible = True
  493. lblOtrosCostos.Visible = True
  494. dtpUltimaFecha.Visible = True
  495. txtInteresAcumulado.Visible = True
  496. txtOtrosCostos.Visible = True
  497. chbValorPar.Visible = True
  498. Else
  499. Instrumento = "NADA"
  500. End If
  501. CargarReg(Instrumento)
  502. Call CargarRegistroBD()
  503. SetPeriodicidad()
  504. AgregarPorcentaje()
  505. Rellenar()
  506. ExisteInversion()
  507. ValidarExistencia()
  508. CargarTransladoNuevo()
  509. End Sub
  510. Sub TipInstrumento()
  511. If Variables.Codigo.IndexOf("PBUR") > -1 Then
  512. PBUR = True
  513. End If
  514. If Variables.Codigo.IndexOf("VCN") > -1 Then
  515. VCN = True
  516. End If
  517. If Variables.Codigo.IndexOf("CETE") > -1 Then
  518. CET = True
  519. End If
  520. End Sub
  521. Sub SetPeriodicidad()
  522. If String.IsNullOrEmpty(Variables.Periodicidad) Then
  523. cboPeriodicidad.SelectedValue = "M"
  524. Else
  525. cboPeriodicidad.SelectedValue = Variables.Periodicidad
  526. End If
  527. End Sub
  528. Function ExisteInversion()
  529. Dim Codigo As String = Variables.Codigo
  530. Dim TablaINV As String = "INV0"
  531. Dim TablaPINV As String = "PIN0"
  532. Dim General As New DAOGeneral
  533. Dim InvPro = Variables.InvPro
  534. If InvPro = "I" Then
  535. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  536. If INV0 Then
  537. navNuevo.Visible = True
  538. Return True
  539. Else
  540. navNuevo.Visible = False
  541. Return False
  542. End If
  543. End If
  544. If InvPro = "P" Then
  545. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  546. If PINV0 Then
  547. navNuevo.Visible = True
  548. Return True
  549. Else
  550. navNuevo.Visible = False
  551. Return False
  552. End If
  553. End If
  554. Return False
  555. End Function
  556. Sub ConfiguracionCETE()
  557. txtPrecio.Text = "100%"
  558. End Sub
  559. Private Sub CargarReg(Instrumento)
  560. Dim Letes As New LETESDAO
  561. Dim Base As Integer = 0
  562. Dim dat = Letes.Cargar(Variables.Codigo, Instrumento)
  563. If (Not dat(1).ToString = "False") Then
  564. txtValorNominal.Text = dat(1)
  565. dtpFechaOperacion.Value = dat(2)
  566. dtpFechaLiquidacion.Value = dat(3)
  567. txtPlazoInversion.Text = dat(4)
  568. If (String.IsNullOrEmpty(txtRendimientoBruto.Text)) Then
  569. txtRendimientoBruto.Text = 0
  570. txtRendimientoBruto.Text = CStr(Format((txtRendimientoBruto.Text), "0.00")) + "%"
  571. Else
  572. txtRendimientoBruto.Text = CStr(dat(5) * 100) + "%"
  573. End If
  574. cboCasasCorredoras.SelectedValue = dat(6)
  575. cboPeriodicidad.SelectedValue = dat(7)
  576. If (dat(8) = 0) Then
  577. Base = 0
  578. ElseIf (dat(8) = 1) Then
  579. Base = 1
  580. ElseIf (dat(8) = 2) Then
  581. Base = 2
  582. ElseIf (dat(8) = 3) Then
  583. Base = 3
  584. End If
  585. cboBase.SelectedIndex = Base
  586. If (String.IsNullOrEmpty(dat(9).ToString)) Then
  587. txtPorcentajeComisionCasa.Text = 0
  588. txtPorcentajeComisionCasa.Text = Format(((txtPorcentajeComisionCasa.Text.Trim("%")) * 100), "0.00").ToString + "%"
  589. Else
  590. txtPorcentajeComisionCasa.Text = CStr(dat(9) * 100) + "%"
  591. End If
  592. If (String.IsNullOrEmpty(dat(10).ToString)) Then
  593. txtPorcentajeComisionBolsa.Text = "0.0"
  594. txtPorcentajeComisionBolsa.Text = Format((txtPorcentajeComisionBolsa.Text.Trim("%")) * 100, "0.00").ToString + "%"
  595. Else
  596. txtPorcentajeComisionBolsa.Text = CStr(dat(10) * 100) + "%"
  597. End If
  598. If (Not String.IsNullOrEmpty(dat(12).ToString)) Then
  599. cboCasasCorredoras.SelectedValue = dat(12)
  600. End If
  601. If (PBUR Or VCN) Then
  602. If (Not String.IsNullOrEmpty(dat(13).ToString)) Then
  603. chbValorPar.Checked = CBool(dat(13))
  604. End If
  605. If (Not String.IsNullOrEmpty(dat(14).ToString)) Then
  606. dtpUltimaFecha.Value = CDate(dat(14))
  607. End If
  608. ElseIf CET Then
  609. If (Not String.IsNullOrEmpty(dat(13).ToString)) Then
  610. dtpUltimaFecha.Value = CDate(dat(13))
  611. End If
  612. End If
  613. If VCN Then
  614. If (String.IsNullOrEmpty(dat(15).ToString)) Then
  615. txtOtrosCostos.Text = "0.0"
  616. Else
  617. txtOtrosCostos.Text = CDec(dat(15))
  618. End If
  619. End If
  620. End If
  621. End Sub
  622. Private Sub Modificar(ByVal Instrumento As String)
  623. Dim ValNom = txtValorNominal.Text
  624. Dim FOpe = dtpFechaOperacion.Value
  625. Dim FLiq = dtpFechaLiquidacion.Value
  626. Dim RendBruto = txtRendimientoBruto.Text.Trim("%") / 100
  627. Dim Plazo = txtPlazoInversion.Text
  628. Dim PorcentajeComisionCasa = txtPorcentajeComisionCasa.Text.Trim("%") / 100
  629. Dim PorcentajeComisionBolsa = txtPorcentajeComisionBolsa.Text.Trim("%") / 100
  630. Dim ValTrans As Double = txtValorTransado.Text
  631. Dim Precio As Double = CDec(txtPrecio.Text.ToString.Trim("%") / 100)
  632. Dim TotPagar As Double = txtTotalAPagar.Text
  633. Dim RendNeto As Double = CDec(txtRendimientoNeto.Text.ToString.Trim("%")) / 100
  634. Dim IngrBruto As Double = txtIngresoBruto.Text
  635. Dim IngrNeto As Double = txtIngresoNeto.Text
  636. Dim ComisionCasaValor As Double = txtComisionCasa.Text
  637. Dim ComisionBolsaValor As Double = txtComisionBolsa.Text
  638. Dim FUlt As Date = dtpUltimaFecha.Value
  639. Dim FRed As Date = dtpRedencion.Value
  640. Dim FVenc As Date = dtpFechaVencimiento.Value
  641. Dim IntAcumulado As Double = CDec(txtInteresAcumulado.Text.ToString.Trim("%") / 100)
  642. Dim OtrosCostos As Double = txtOtrosCostos.Text
  643. Dim periodo
  644. If Not cboPeriodicidad.SelectedIndex = -1 Then
  645. periodo = cboPeriodicidad.SelectedValue
  646. Else
  647. periodo = DBNull.Value
  648. End If
  649. Dim Casas
  650. If Not cboCasasCorredoras.SelectedIndex = -1 Then
  651. Casas = cboCasasCorredoras.SelectedValue
  652. Else
  653. Casas = DBNull.Value
  654. End If
  655. Dim ValorPar As Boolean = chbValorPar.Checked
  656. Dim Base As Integer
  657. Dim FechaUltima As Date = dtpUltimaFecha.Value
  658. If (cboBase.SelectedIndex = 0) Then
  659. Base = 0
  660. ElseIf (cboBase.SelectedIndex = 1) Then
  661. Base = 1
  662. ElseIf (cboBase.SelectedIndex = 2) Then
  663. Base = 2
  664. Else
  665. Base = 3
  666. End If
  667. Dim coleccion As New Collection
  668. coleccion.Add(ValNom)
  669. coleccion.Add(FOpe)
  670. coleccion.Add(FLiq)
  671. coleccion.Add(RendBruto)
  672. coleccion.Add(Plazo)
  673. coleccion.Add(Variables.Codigo)
  674. coleccion.Add(PorcentajeComisionCasa)
  675. coleccion.Add(PorcentajeComisionBolsa)
  676. coleccion.Add(periodo)
  677. coleccion.Add(Base)
  678. coleccion.Add(Casas)
  679. If (PBUR Or VCN) Then
  680. coleccion.Add(ValorPar)
  681. coleccion.Add(FechaUltima)
  682. ElseIf CET Then
  683. coleccion.Add(FechaUltima)
  684. End If
  685. If VCN Then
  686. coleccion.Add(OtrosCostos)
  687. End If
  688. coleccion.Add(ValTrans)
  689. coleccion.Add(Precio)
  690. coleccion.Add(TotPagar)
  691. coleccion.Add(RendNeto)
  692. coleccion.Add(IngrBruto)
  693. coleccion.Add(IngrNeto)
  694. coleccion.Add(ComisionCasaValor)
  695. coleccion.Add(ComisionBolsaValor)
  696. coleccion.Add(FUlt)
  697. coleccion.Add(FRed)
  698. coleccion.Add(FVenc)
  699. If CET Or PBUR Or VCN Then
  700. coleccion.Add(IntAcumulado)
  701. End If
  702. oDAOLetes.ActualizarLETE(coleccion, Instrumento)
  703. End Sub
  704. Public Function Nuevo(ByVal Instrumento As String)
  705. Dim ValNom = txtValorNominal.Text
  706. Dim FOpe = dtpFechaOperacion.Value
  707. Dim FLiq = dtpFechaLiquidacion.Value
  708. Dim RendBruto = txtRendimientoBruto.Text.Trim("%") / 100
  709. Dim Plazo = txtPlazoInversion.Text
  710. Dim PorcentajeComisionCasa = txtPorcentajeComisionCasa.Text.Trim("%") / 100
  711. Dim PorcentajeComisionBolsa = txtPorcentajeComisionBolsa.Text.Trim("%") / 100
  712. Dim ValTrans As Double = txtValorTransado.Text
  713. Dim Precio As Double = CDec(txtPrecio.Text.ToString.Trim("%") / 100)
  714. Dim TotPagar As Double = txtTotalAPagar.Text
  715. Dim RendNeto As Double = CDec(txtRendimientoNeto.Text.ToString.Trim("%")) / 100
  716. Dim IngrBruto As Double = txtIngresoBruto.Text
  717. Dim IngrNeto As Double = txtIngresoNeto.Text
  718. Dim ComisionCasaValor As Double = txtComisionCasa.Text
  719. Dim ComisionBolsaValor As Double = txtComisionBolsa.Text
  720. Dim FUlt As Date = dtpUltimaFecha.Value
  721. Dim FRed As Date = dtpRedencion.Value
  722. Dim FVenc As Date = dtpFechaVencimiento.Value
  723. Dim IntAcumulado As Double = CDec(txtInteresAcumulado.Text.ToString.Trim("%") / 100)
  724. Dim periodo
  725. If Not cboPeriodicidad.SelectedIndex = -1 Then
  726. periodo = cboPeriodicidad.SelectedValue
  727. Else
  728. periodo = DBNull.Value
  729. End If
  730. Dim Casas
  731. If Not cboCasasCorredoras.SelectedIndex = -1 Then
  732. Casas = cboCasasCorredoras.SelectedValue
  733. Else
  734. Casas = DBNull.Value
  735. End If
  736. Dim ValorPar As Boolean = chbValorPar.Checked
  737. Dim Base As Integer
  738. Dim FechaUltima As Date = dtpUltimaFecha.Value
  739. Dim OtrosCostos = txtOtrosCostos.Text
  740. If (cboBase.SelectedIndex = 0) Then
  741. Base = 0
  742. ElseIf (cboBase.SelectedIndex = 1) Then
  743. Base = 1
  744. ElseIf (cboBase.SelectedIndex = 2) Then
  745. Base = 2
  746. Else
  747. Base = 3
  748. End If
  749. Dim coleccion As New Collection
  750. coleccion.Add(ValNom)
  751. coleccion.Add(FOpe)
  752. coleccion.Add(FLiq)
  753. coleccion.Add(RendBruto)
  754. coleccion.Add(Plazo)
  755. coleccion.Add(Variables.Codigo)
  756. coleccion.Add(PorcentajeComisionCasa)
  757. coleccion.Add(PorcentajeComisionBolsa)
  758. coleccion.Add(periodo)
  759. coleccion.Add(Base)
  760. coleccion.Add(Casas)
  761. If (PBUR Or VCN) Then
  762. coleccion.Add(ValorPar)
  763. coleccion.Add(FechaUltima)
  764. ElseIf CET Then
  765. coleccion.Add(FechaUltima)
  766. End If
  767. If VCN Then
  768. coleccion.Add(OtrosCostos)
  769. End If
  770. coleccion.Add(ValTrans)
  771. coleccion.Add(Precio)
  772. coleccion.Add(TotPagar)
  773. coleccion.Add(RendNeto)
  774. coleccion.Add(IngrBruto)
  775. coleccion.Add(IngrNeto)
  776. coleccion.Add(ComisionCasaValor)
  777. coleccion.Add(ComisionBolsaValor)
  778. coleccion.Add(FUlt)
  779. coleccion.Add(FRed)
  780. coleccion.Add(FVenc)
  781. If CET Or PBUR Or VCN Then
  782. coleccion.Add(IntAcumulado)
  783. End If
  784. 'oDAOLetes.NuevoIngreso(coleccion, Instrumento)
  785. Return coleccion
  786. End Function
  787. Sub NuevoRegistro(ByVal Instrumento As String)
  788. Dim Coleccion As New Collection
  789. Coleccion = Nuevo(Instrumento)
  790. If Coleccion.Count > 0 Then
  791. oDAOLetes.NuevoIngreso(Coleccion, Instrumento)
  792. Coleccion.Clear()
  793. End If
  794. End Sub
  795. Private Sub Eliminar(ByVal Instrumento As String)
  796. oDAOLetes.Eliminar(Variables.Codigo, Instrumento)
  797. End Sub
  798. Private Sub btnAceptar_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click
  799. If (TipoTransaccion = "M") Then
  800. Modificar(Instrumento)
  801. ValidarExistencia()
  802. ElseIf (TipoTransaccion = "N") Then
  803. NuevoRegistro(Instrumento)
  804. ValidarExistencia()
  805. ElseIf (TipoTransaccion = "B") Then
  806. Eliminar(Instrumento)
  807. ValidarExistencia()
  808. ElseIf Not ExisteValidacion() Then
  809. Variables.ColeccionLETE = Nuevo(Instrumento)
  810. Close()
  811. End If
  812. End Sub
  813. Function RetornarObjeto()
  814. Return oCELetes
  815. End Function
  816. Sub CargarCasasCorredoras()
  817. If Me.cboCasasCorredoras.Items.Count = 0 Or Me.cboCasasCorredoras.Items.Count = 1 Then
  818. Me.cboCasasCorredoras.DataSource = oDAOGeneral.ListaCasasCorredoras.Tables("CasasCorredoras")
  819. Me.cboCasasCorredoras.DisplayMember = "Descripcion"
  820. Me.cboCasasCorredoras.ValueMember = "Codigo"
  821. Me.cboCasasCorredoras.SelectedIndex = 0
  822. End If
  823. End Sub
  824. Sub CargarPeriodicidad()
  825. If cboPeriodicidad.Items.Count = 0 Or cboPeriodicidad.Items.Count = 1 Then
  826. Me.cboPeriodicidad.DataSource = oDAOGeneral.ListaPeriodicidad
  827. Me.cboPeriodicidad.DisplayMember = "Descripcion"
  828. Me.cboPeriodicidad.ValueMember = "Codigo"
  829. Me.cboPeriodicidad.SelectedIndex = 0
  830. End If
  831. End Sub
  832. Sub CargarBase()
  833. If Me.cboBase.Items.Count = 0 Or Me.cboBase.Items.Count = 1 Then
  834. Me.cboBase.DataSource = oDAOGeneral.ListaBase
  835. Me.cboBase.DisplayMember = "Descripcion"
  836. Me.cboBase.ValueMember = "Codigo"
  837. Me.cboBase.SelectedIndex = 0
  838. End If
  839. End Sub
  840. Function ValidarControles() As Boolean
  841. Dim valor As Boolean = True
  842. Dim vValorNominal As Double = GetValorNominal()
  843. Dim vPlazoInversion As Integer = GetPlazoInversion()
  844. Dim vCasa As String = GetCasa()
  845. Dim vPeriodicidad As String = GetPeriodicidad()
  846. If vValorNominal = 0 Then valor = False
  847. If vPlazoInversion = 0 Then valor = False
  848. If vCasa = "" Then valor = False
  849. If vPeriodicidad = "" Then valor = False
  850. Return valor
  851. End Function
  852. Private Sub CargarRegistroBD()
  853. 'oCELetes = New CELetes
  854. 'oDAOLetes.CargarRegistro(oCELetes, TipoDocumento, IdDocumento)
  855. Dim oCELetes As LETESCE
  856. CodigoInversion = Variables.Codigo
  857. oCELetes = oDAOLetes.CargarRegistro(CodigoInversion)
  858. If Not oCELetes Is Nothing Then
  859. Dim vValorNominal As Double = oCELetes.ValorNominal
  860. Dim vFechaOperacion As Date = oCELetes.FechaOperacion
  861. Dim vFechaLiquidacion As Date = oCELetes.FechaLiquidacion
  862. Dim vFechaVencimiento As Date = oCELetes.FechaVencimiento
  863. Dim vPlazoInversion As Integer = oCELetes.Plazo
  864. Dim vCodigoCasa As String = oCELetes.CodigoCasa
  865. Dim vPeriodicidad As String = oCELetes.Periodicidad
  866. Dim vRendimientoBruto As Double = oCELetes.RendimientoBruto
  867. Dim vRendimientoNeto As Double = oCELetes.RendimientoNeto
  868. Dim vIngresoBruto As Double = oCELetes.IngresoBruto
  869. Dim vIngresoNeto As Double = oCELetes.IngresoNeto
  870. Dim vValorTransado As Double = oCELetes.ValorNominal
  871. Dim vPrecio As Double = oCELetes.Precio
  872. Dim vTotalAPagar As Double = oCELetes.TotalaPagar
  873. vRendimientoBruto = vRendimientoBruto * 100
  874. vRendimientoNeto = vRendimientoNeto * 100
  875. vPrecio = vPrecio * 100
  876. 'Me.txtValorNominal.Text = vValorNominal.ToString
  877. 'Me.dtpFechaOperacion.Value = vFechaOperacion
  878. 'Me.dtpFechaLiquidacion.Value = vFechaLiquidacion
  879. 'Me.dtpFechaVencimiento.Value = vFechaVencimiento
  880. 'Me.txtPlazoInversion.Text = vPlazoInversion.ToString
  881. 'Me.cboCasasCorredoras.SelectedValue = vCodigoCasa
  882. 'Me.cboPeriodicidad.SelectedValue = vPeriodicidad
  883. 'Me.txtRendimientoBruto.Text = vRendimientoBruto.ToString
  884. 'Me.txtRendimientoNeto.Text = vRendimientoNeto.ToString
  885. 'Me.txtIngresoBruto.Text = vIngresoBruto.ToString
  886. 'Me.txtIngresoNeto.Text = vIngresoNeto.ToString
  887. 'Me.txtValorTransado.Text = vValorNominal.ToString
  888. 'Me.txtPrecio.Text = vPrecio.ToString
  889. 'Me.txtTotalAPagar.Text = vTotalAPagar.ToString
  890. End If
  891. End Sub
  892. Public Sub CargarRegistro(vId As Integer, vTipo As String)
  893. Modo = "C"
  894. IdDocumento = vId
  895. TipoDocumento = vTipo
  896. End Sub
  897. Public Sub CargarRegistro(ByVal CodInversion As String)
  898. Modo = "C"
  899. CodigoInversion = CodInversion
  900. End Sub
  901. Sub GuardarRegistro()
  902. End Sub
  903. Private Sub txtRendimientoBruto_MouseCaptureChanged(sender As Object, e As EventArgs) Handles txtRendimientoBruto.MouseCaptureChanged
  904. End Sub
  905. Function ValorTrasado()
  906. If (Double.TryParse(txtValorNominal.Text, Nothing) And Double.TryParse(V_txtPrecio.TrimEnd("%"), Nothing)) Then
  907. Return CDec(txtValorNominal.Text) * CDec((V_txtPrecio.TrimEnd("%")) / 100)
  908. End If
  909. Return 0
  910. End Function
  911. Function Precio()
  912. If (Double.TryParse(txtRendimientoBruto.Text.TrimEnd("%"), Nothing) And Double.TryParse(txtPlazoInversion.Text.TrimEnd("%"), Nothing)) Then
  913. Dim Rendimiento = CDec(txtRendimientoBruto.Text.TrimEnd("%"))
  914. Dim Plazo = CDec((txtPlazoInversion.Text))
  915. Dim Pr = 0.0
  916. If (IndexBase = 0) Then
  917. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 360)) * Plazo / 360)) * 100
  918. Return Pr
  919. ElseIf (IndexBase = 1) Then
  920. Dim FechaInicial = dtpFechaLiquidacion.Value
  921. Dim FechaFinal = dtpFechaVencimiento.Value
  922. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  923. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  924. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  925. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  926. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  927. If (Not CambioDeFecha = 0) Then
  928. If CambioDeFecha = 1 Then
  929. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  930. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  931. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 366)) * DiasPrimeraFecha / 366))
  932. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 365)) * DiasSegundaFecha / 365))
  933. ElseIf CambioDeFecha = 2 Then
  934. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  935. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  936. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 365)) * DiasPrimeraFecha / 365))
  937. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 366)) * DiasSegundaFecha / 366))
  938. End If
  939. Pr = (1 - (PrOpc1 + PrOpc2)) * 100
  940. Else
  941. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  942. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 365)) * Plazo / 365)) * 100
  943. End If
  944. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  945. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 366)) * Plazo / 366)) * 100
  946. End If
  947. End If
  948. Return Pr
  949. ElseIf (IndexBase = 2) Then
  950. ''''''''''''''''''
  951. Dim FechaInicial = dtpFechaLiquidacion.Value
  952. Dim FechaFinal = dtpFechaVencimiento.Value
  953. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  954. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  955. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase360(FechaInicial)
  956. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase360(FechaFinal)
  957. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  958. If (Not CambioDeFecha = 0) Then
  959. If CambioDeFecha = 1 Then
  960. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  961. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  962. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 366)) * DiasPrimeraFecha / 366))
  963. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 365)) * DiasSegundaFecha / 365))
  964. ElseIf CambioDeFecha = 2 Then
  965. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  966. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  967. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 365)) * DiasPrimeraFecha / 365))
  968. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 366)) * DiasSegundaFecha / 366))
  969. End If
  970. Pr = (1 - (PrOpc1 + PrOpc2)) * 100
  971. Else
  972. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  973. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 365)) * Plazo / 365)) * 100
  974. End If
  975. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  976. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 366)) * Plazo / 366)) * 100
  977. End If
  978. End If
  979. Return Pr
  980. Else
  981. Dim FechaInicial = dtpFechaLiquidacion.Value
  982. Dim FechaFinal = dtpFechaVencimiento.Value
  983. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  984. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  985. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  986. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  987. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  988. If (Not CambioDeFecha = 0) Then
  989. If CambioDeFecha = 1 Then
  990. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  991. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  992. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 360)) * DiasPrimeraFecha / 360))
  993. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 360)) * DiasSegundaFecha / 360))
  994. ElseIf CambioDeFecha = 2 Then
  995. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  996. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  997. PrOpc1 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasPrimeraFecha / 360)) * DiasPrimeraFecha / 360))
  998. PrOpc2 = ((((Rendimiento / 100) / (1 + (Rendimiento / 100) * DiasSegundaFecha / 360)) * DiasSegundaFecha / 360))
  999. End If
  1000. Pr = (1 - (PrOpc1 + PrOpc2)) * 100
  1001. Else
  1002. Pr = ((1 - ((Rendimiento / 100) / (1 + (Rendimiento / 100) * Plazo / 360)) * Plazo / 360)) * 100
  1003. End If
  1004. Return Pr
  1005. End If
  1006. End If
  1007. Return 0
  1008. End Function
  1009. Function ComisionCasa()
  1010. Dim ValorTras = ValorTrasado()
  1011. Dim ComisionDeCasa = txtPorcentajeComisionCasa.Text.TrimEnd("%")
  1012. Dim PlazoInversion = txtPlazoInversion.Text
  1013. Dim Comision = 0.0
  1014. If (Double.TryParse(ValorTras, Nothing) And Double.TryParse(ComisionDeCasa, Nothing) And Double.TryParse(PlazoInversion, Nothing)) Then
  1015. If (IndexBase = 0) Then
  1016. Comision = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(PlazoInversion) / 360)
  1017. Return Comision
  1018. ElseIf IndexBase = 1 Then
  1019. Dim FechaInicial = dtpFechaLiquidacion.Value
  1020. Dim FechaFinal = dtpFechaVencimiento.Value
  1021. Dim ComisionOpc1 = 0.0, ComisionOpc2 = 0.0
  1022. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  1023. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  1024. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  1025. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1026. If (Not CambioDeFecha = 0) Then
  1027. If CambioDeFecha = 1 Then
  1028. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1029. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1030. ComisionOpc1 = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(DiasPrimeraFecha) / 366)
  1031. ComisionOpc2 = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(DiasSegundaFecha) / 365)
  1032. ElseIf CambioDeFecha = 2 Then
  1033. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1034. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1035. ComisionOpc1 = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(DiasPrimeraFecha) / 365)
  1036. ComisionOpc2 = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(DiasSegundaFecha) / 366)
  1037. End If
  1038. Comision = ComisionOpc1 + ComisionOpc2
  1039. Else
  1040. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  1041. Comision = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(PlazoInversion) / 365)
  1042. End If
  1043. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  1044. Comision = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(PlazoInversion) / 366)
  1045. End If
  1046. End If
  1047. Return Comision
  1048. ElseIf IndexBase = 2 Then
  1049. Dim FechaInicial = dtpFechaLiquidacion.Value
  1050. Dim FechaFinal = dtpFechaVencimiento.Value
  1051. Dim ComisionOpc1 = 0.0, ComisionOpc2 = 0.0
  1052. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  1053. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase360(FechaInicial)
  1054. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase360(FechaFinal)
  1055. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1056. If (Not CambioDeFecha = 0) Then
  1057. If CambioDeFecha = 1 Then
  1058. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1059. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1060. ComisionOpc1 = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(DiasPrimeraFecha) / 366)
  1061. ComisionOpc2 = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(DiasSegundaFecha) / 365)
  1062. ElseIf CambioDeFecha = 2 Then
  1063. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1064. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1065. ComisionOpc1 = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(DiasPrimeraFecha) / 365)
  1066. ComisionOpc2 = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(DiasSegundaFecha) / 366)
  1067. End If
  1068. Comision = ComisionOpc1 + ComisionOpc2
  1069. Else
  1070. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  1071. Comision = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(PlazoInversion) / 365)
  1072. End If
  1073. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  1074. Comision = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(PlazoInversion) / 366)
  1075. End If
  1076. End If
  1077. Return Comision
  1078. Else
  1079. Comision = (CDec(ValorTras) * (CDec(ComisionDeCasa)) / 100) * (CDec(PlazoInversion) / 360)
  1080. Return Comision
  1081. End If
  1082. End If
  1083. Return 0
  1084. End Function
  1085. Function ComisionBolsa()
  1086. Dim ValorTras = ValorTrasado()
  1087. Dim ComisionDeBolsa = txtPorcentajeComisionBolsa.Text.TrimEnd("%")
  1088. Dim PlazoInversion = txtPlazoInversion.Text
  1089. Dim Comision = 0.0
  1090. If (Double.TryParse(ValorTras, Nothing) And Double.TryParse(ComisionDeBolsa, Nothing) And Double.TryParse(PlazoInversion, Nothing)) Then
  1091. If (IndexBase = 0) Then
  1092. Comision = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(PlazoInversion) / 360)
  1093. Return Comision
  1094. ElseIf (IndexBase = 1) Then
  1095. Dim FechaInicial = dtpFechaLiquidacion.Value
  1096. Dim FechaFinal = dtpFechaVencimiento.Value
  1097. Dim ComisionOpc1 = 0.0, ComisionOpc2 = 0.0
  1098. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  1099. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  1100. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  1101. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1102. If (Not CambioDeFecha = 0) Then
  1103. If CambioDeFecha = 1 Then
  1104. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1105. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1106. ComisionOpc1 = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(DiasPrimeraFecha) / 366)
  1107. ComisionOpc2 = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(DiasSegundaFecha) / 365)
  1108. ElseIf CambioDeFecha = 2 Then
  1109. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1110. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1111. ComisionOpc1 = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(DiasPrimeraFecha) / 365)
  1112. ComisionOpc2 = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(DiasSegundaFecha) / 366)
  1113. End If
  1114. Comision = ComisionOpc1 + ComisionOpc2
  1115. Else
  1116. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  1117. Comision = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(PlazoInversion) / 365)
  1118. End If
  1119. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  1120. Comision = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(PlazoInversion) / 366)
  1121. End If
  1122. End If
  1123. Return Comision
  1124. ElseIf (IndexBase = 2) Then
  1125. Dim FechaInicial = dtpFechaLiquidacion.Value
  1126. Dim FechaFinal = dtpFechaVencimiento.Value
  1127. Dim ComisionOpc1 = 0.0, ComisionOpc2 = 0.0
  1128. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  1129. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase360(FechaInicial)
  1130. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase360(FechaFinal)
  1131. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1132. If (Not CambioDeFecha = 0) Then
  1133. If CambioDeFecha = 1 Then
  1134. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1135. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1136. ComisionOpc1 = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(DiasPrimeraFecha) / 366)
  1137. ComisionOpc2 = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(DiasSegundaFecha) / 365)
  1138. ElseIf CambioDeFecha = 2 Then
  1139. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1140. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1141. ComisionOpc1 = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(DiasPrimeraFecha) / 365)
  1142. ComisionOpc2 = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(DiasSegundaFecha) / 366)
  1143. End If
  1144. Comision = ComisionOpc1 + ComisionOpc2
  1145. Else
  1146. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  1147. Comision = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(PlazoInversion) / 365)
  1148. End If
  1149. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  1150. Comision = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(PlazoInversion) / 366)
  1151. End If
  1152. End If
  1153. Return Comision
  1154. Else
  1155. Comision = (CDec(ValorTras) * (CDec(ComisionDeBolsa)) / 100) * (CDec(PlazoInversion) / 360)
  1156. Return Comision
  1157. End If
  1158. End If
  1159. Return 0
  1160. End Function
  1161. Function RendimientoNeto()
  1162. Dim ValorNominal = txtValorNominal.Text
  1163. Dim TotalPagar = V_txtTotalAPagar
  1164. Dim PlazoInversion As Integer = 0
  1165. If Not String.IsNullOrEmpty(txtPlazoInversion.Text) Then
  1166. PlazoInversion = txtPlazoInversion.Text
  1167. End If
  1168. Dim RendBruto As Double = 0
  1169. Dim ComisionCasa As Double = 0
  1170. Dim ComisionBolsa As Double = 0
  1171. If Not String.IsNullOrEmpty(txtRendimientoBruto.Text.ToString.Trim("%")) Then
  1172. RendBruto = txtRendimientoBruto.Text.ToString.Trim("%")
  1173. End If
  1174. If Not String.IsNullOrEmpty(txtPorcentajeComisionCasa.Text.ToString.Trim("%")) Then
  1175. ComisionCasa = txtPorcentajeComisionCasa.Text.ToString.Trim("%")
  1176. End If
  1177. If Not String.IsNullOrEmpty(txtPorcentajeComisionBolsa.Text.ToString.Trim("%")) Then
  1178. ComisionBolsa = txtPorcentajeComisionBolsa.Text.ToString.Trim("%")
  1179. End If
  1180. If (CDec(TotalPagar) = 0 Or CDec(PlazoInversion) = 0) Then
  1181. Return 0
  1182. End If
  1183. If (Double.TryParse(RendBruto, Nothing) And Double.TryParse(RendBruto, Nothing) And Double.TryParse(CDec(ValorNominal), Nothing) And Double.TryParse(CDec(TotalPagar), Nothing) And Double.TryParse(CDec(PlazoInversion), Nothing)) Then
  1184. Dim RendimientoNet As Double = 0
  1185. If ((chbValorPar.Checked And (VCN Or PBUR))) Then
  1186. RendimientoNet = (RendBruto - ComisionCasa - ComisionBolsa) * 0.9
  1187. Return RendimientoNet
  1188. ElseIf CET Then
  1189. RendimientoNet = (RendBruto - ComisionCasa - ComisionBolsa)
  1190. Return RendimientoNet
  1191. Else
  1192. If (IndexBase = 0) Then
  1193. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (360 / CDec(PlazoInversion))) * 100)
  1194. Return RendimientoNet
  1195. ElseIf IndexBase = 1 Then
  1196. Dim FechaInicial = dtpFechaLiquidacion.Value
  1197. Dim FechaFinal = dtpFechaVencimiento.Value
  1198. Dim RendimientoNetOpc1 = 0.0, RendimientoNetOpc2 = 0.0
  1199. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  1200. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase(FechaInicial)
  1201. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase(FechaFinal)
  1202. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1203. If (Not CambioDeFecha = 0) Then
  1204. If CambioDeFecha = 1 Then
  1205. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1206. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1207. RendimientoNetOpc1 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(DiasPrimeraFecha))) * 100)
  1208. RendimientoNetOpc2 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(DiasSegundaFecha))) * 100)
  1209. ElseIf CambioDeFecha = 2 Then
  1210. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha365(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1211. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha366(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1212. RendimientoNetOpc1 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(DiasPrimeraFecha))) * 100)
  1213. RendimientoNetOpc2 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(DiasSegundaFecha))) * 100)
  1214. End If
  1215. RendimientoNet = RendimientoNetOpc1 + RendimientoNetOpc2
  1216. Else
  1217. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  1218. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(PlazoInversion))) * 100)
  1219. End If
  1220. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  1221. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(PlazoInversion))) * 100)
  1222. End If
  1223. End If
  1224. Return RendimientoNet
  1225. ElseIf IndexBase = 2 Then
  1226. Dim FechaInicial = dtpFechaLiquidacion.Value
  1227. Dim FechaFinal = dtpFechaVencimiento.Value
  1228. Dim RendimientoNetOpc1 = 0.0, RendimientoNetOpc2 = 0.0
  1229. Dim CambioDeFecha As Integer = Operaciones.CambioBase(FechaInicial, FechaFinal)
  1230. Dim PrimeraFechaUltima = Operaciones.PrimeraFechaCambioBase360(FechaInicial)
  1231. Dim UltimaFechaPrimero = Operaciones.FinalFechaCambioBase360(FechaFinal)
  1232. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1233. If (Not CambioDeFecha = 0) Then
  1234. If CambioDeFecha = 1 Then
  1235. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1236. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1237. RendimientoNetOpc1 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(DiasPrimeraFecha))) * 100)
  1238. RendimientoNetOpc2 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(DiasSegundaFecha))) * 100)
  1239. ElseIf CambioDeFecha = 2 Then
  1240. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(FechaInicial, PrimeraFechaUltima, CambioDeFecha)
  1241. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(UltimaFechaPrimero, FechaFinal, CambioDeFecha)
  1242. RendimientoNetOpc1 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(DiasPrimeraFecha))) * 100)
  1243. RendimientoNetOpc2 = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(DiasSegundaFecha))) * 100)
  1244. End If
  1245. RendimientoNet = RendimientoNetOpc1 + RendimientoNetOpc2
  1246. Else
  1247. If (Operaciones.AñoBisiesto(FechaInicial) = 364) Then
  1248. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (365 / CDec(PlazoInversion))) * 100)
  1249. End If
  1250. If (Operaciones.AñoBisiesto(FechaInicial) = 365) Then
  1251. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (366 / CDec(PlazoInversion))) * 100)
  1252. End If
  1253. End If
  1254. Return RendimientoNet
  1255. Else
  1256. RendimientoNet = ((((CDec(ValorNominal) - CDec(TotalPagar)) / CDec(TotalPagar)) * (360 / CDec(PlazoInversion))) * 100)
  1257. Return RendimientoNet
  1258. End If
  1259. End If
  1260. End If
  1261. Return 0
  1262. End Function
  1263. Function IngresoBruto()
  1264. Dim ValorNominal As Double = 0
  1265. Dim ValorTrasado As Double = 0
  1266. If Not String.IsNullOrEmpty(txtValorNominal.Text) Then
  1267. ValorNominal = txtValorNominal.Text
  1268. End If
  1269. If Not String.IsNullOrEmpty(V_txtValorTransado) Then
  1270. ValorTrasado = V_txtValorTransado
  1271. End If
  1272. Dim TasaPeriodo = txtRendimientoBruto.Text.ToString.Trim("%")
  1273. If String.IsNullOrEmpty(TasaPeriodo) Then
  1274. TasaPeriodo = 0
  1275. Else
  1276. TasaPeriodo = CDec(txtRendimientoBruto.Text.ToString.Trim("%")) / 100
  1277. End If
  1278. Dim Base As Integer = 365
  1279. Dim Bruto As Double = 0
  1280. Dim Plazo As Integer = 0
  1281. If Not String.IsNullOrEmpty(txtPlazoInversion.Text) Then
  1282. Plazo = txtPlazoInversion.Text
  1283. End If
  1284. If (chbValorPar.Checked Or CET) Then
  1285. Dim PlazoDias As Integer = 0
  1286. Dim Fecha1 = dtpFechaLiquidacion.Value
  1287. Dim Fecha2 = dtpFechaVencimiento.Value
  1288. IndexBase = cboBase.SelectedIndex
  1289. Dim Valor As Double = 0
  1290. If (IndexBase = 0) Then
  1291. Valor = CDec(ValorNominal * TasaPeriodo * Plazo) / 360
  1292. Return Valor
  1293. ElseIf (IndexBase = 1) Then
  1294. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1295. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1296. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1297. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1298. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1299. PrOpc1 = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 366
  1300. PrOpc2 = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 365
  1301. Valor = PrOpc1 + PrOpc2
  1302. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1303. Valor = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 365
  1304. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1305. Valor = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 366
  1306. Else
  1307. Valor = 0
  1308. End If
  1309. Return Valor
  1310. ElseIf (IndexBase = 2) Then
  1311. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1312. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1313. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1314. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1315. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1316. PrOpc1 = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 366
  1317. PrOpc2 = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 365
  1318. Valor = PrOpc1 + PrOpc2
  1319. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1320. Valor = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 365
  1321. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1322. Valor = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 366
  1323. Else
  1324. Valor = 0
  1325. End If
  1326. Return Valor
  1327. Else
  1328. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1329. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1330. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1331. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1332. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1333. PrOpc1 = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 360
  1334. PrOpc2 = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 360
  1335. Valor = PrOpc1 + PrOpc2
  1336. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1337. Valor = CDec(ValorNominal * TasaPeriodo * DiasSegundaFecha) / 360
  1338. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1339. Valor = CDec(ValorNominal * TasaPeriodo * DiasPrimeraFecha) / 360
  1340. Else
  1341. Valor = 0
  1342. End If
  1343. Return Valor
  1344. End If
  1345. Else
  1346. If (Double.TryParse(ValorNominal, Nothing) And Double.TryParse(ValorTrasado, Nothing)) Then
  1347. Bruto = CDec(ValorNominal) - CDec(ValorTrasado)
  1348. Return Bruto
  1349. End If
  1350. End If
  1351. Return 0
  1352. End Function
  1353. Function IngresoNeto()
  1354. Dim ValorNominal = txtValorNominal.Text
  1355. Dim TotalPagar = V_txtTotalAPagar
  1356. Dim Neto As Double = 0
  1357. If chbValorPar.Checked Or CET Then
  1358. Dim IngBruto = txtIngresoBruto.Text
  1359. Dim Descuentos = (CDec(txtComisionBolsa.Text) + CDec(txtComisionCasa.Text))
  1360. Neto = (IngBruto * 0.9) - Descuentos
  1361. Return Neto
  1362. End If
  1363. If (Double.TryParse(ValorNominal, Nothing) And Double.TryParse(TotalPagar, Nothing)) Then
  1364. Neto = CDec(ValorNominal) - CDec(TotalPagar)
  1365. Return Neto
  1366. End If
  1367. Return 0
  1368. End Function
  1369. Function TotalPagar()
  1370. Dim ValorTrasado = V_txtValorTransado
  1371. Dim ComisionCasa = V_txtComisionCasa.TrimEnd("%")
  1372. Dim ComisionBolsa = V_txtComisionBolsa.TrimEnd("%")
  1373. Dim OtrCost As Double = 0.0
  1374. If (Not String.IsNullOrEmpty(txtOtrosCostos.Text.ToString)) Then
  1375. OtrCost = CDec(txtOtrosCostos.Text)
  1376. End If
  1377. If (String.IsNullOrEmpty(txtInteresAcumulado.Text.ToString)) Then
  1378. txtInteresAcumulado.Text = 0
  1379. End If
  1380. Dim InteresAcumulado = CDec(txtInteresAcumulado.Text.ToString.Trim("%"))
  1381. If (PBUR Or CET) Then
  1382. If (Double.TryParse(ValorTrasado, Nothing) And Double.TryParse(ComisionCasa, Nothing) And Double.TryParse(ComisionBolsa, Nothing)) Then
  1383. Dim Total = CDec(ValorTrasado) + CDec(ComisionCasa) + CDec(ComisionBolsa) + InteresAcumulado
  1384. Return Total
  1385. End If
  1386. ElseIf VCN Then
  1387. If (Double.TryParse(ValorTrasado, Nothing) And Double.TryParse(ComisionCasa, Nothing) And Double.TryParse(ComisionBolsa, Nothing)) Then
  1388. Dim Total = CDec(ValorTrasado) + CDec(ComisionCasa) + CDec(ComisionBolsa) + InteresAcumulado + OtrCost
  1389. Return Total
  1390. End If
  1391. Else
  1392. If (Double.TryParse(ValorTrasado, Nothing) And Double.TryParse(ComisionCasa, Nothing) And Double.TryParse(ComisionBolsa, Nothing)) Then
  1393. Dim Total = CDec(ValorTrasado) + CDec(ComisionCasa) + CDec(ComisionBolsa)
  1394. Return Total
  1395. End If
  1396. End If
  1397. Return 0
  1398. End Function
  1399. Sub Rellenar()
  1400. If (String.IsNullOrEmpty(txtOtrosCostos.Text.ToString)) Then
  1401. txtOtrosCostos.Text = "0.0"
  1402. End If
  1403. If (String.IsNullOrEmpty(txtPlazoInversion.Text.ToString)) Then
  1404. txtPlazoInversion.Text = "0.0"
  1405. End If
  1406. If (String.IsNullOrEmpty(txtValorNominal.Text.ToString.Trim("%"))) Then
  1407. txtValorNominal.Text = 0
  1408. txtValorNominal.Text = Format(txtValorNominal.Text, "0.0")
  1409. End If
  1410. If (String.IsNullOrEmpty(txtPorcentajeComisionCasa.Text.ToString.Trim("%"))) Then
  1411. txtPorcentajeComisionCasa.Text = 0
  1412. txtPorcentajeComisionCasa.Text = Format(txtPorcentajeComisionCasa.Text, "0.0")
  1413. End If
  1414. If (String.IsNullOrEmpty(txtPorcentajeComisionBolsa.Text.ToString.Trim("%"))) Then
  1415. txtPorcentajeComisionBolsa.Text = 0
  1416. txtPorcentajeComisionBolsa.Text = Format(txtPorcentajeComisionBolsa.Text, "0.0")
  1417. End If
  1418. If (String.IsNullOrEmpty(txtRendimientoBruto.Text.ToString.Trim("%"))) Then
  1419. txtRendimientoBruto.Text = 0
  1420. txtRendimientoBruto.Text = Format(txtRendimientoBruto.Text, "0.0")
  1421. End If
  1422. If (String.IsNullOrEmpty(txtInteresAcumulado.Text.ToString.Trim("%"))) Then
  1423. txtInteresAcumulado.Text = "0.0%"
  1424. End If
  1425. If (txtPorcentajeComisionCasa.Text.ToString.IndexOf("%") = -1) Then
  1426. txtPorcentajeComisionCasa.Text += "%"
  1427. End If
  1428. If (txtPorcentajeComisionBolsa.ToString.IndexOf("%") = -1) Then
  1429. txtPorcentajeComisionBolsa.Text += "%"
  1430. End If
  1431. If (txtRendimientoBruto.ToString.IndexOf("%") = -1) Then
  1432. txtRendimientoBruto.Text += "%"
  1433. End If
  1434. End Sub
  1435. Sub RellenarDatos()
  1436. If (cboBase.SelectedIndex = 0) Then
  1437. IndexBase = 0
  1438. ElseIf (cboBase.SelectedIndex = 1) Then
  1439. IndexBase = 1
  1440. ElseIf (cboBase.SelectedIndex = 2) Then
  1441. IndexBase = 2
  1442. ElseIf (cboBase.SelectedIndex = 3) Then
  1443. IndexBase = 3
  1444. End If
  1445. Dim FechaOperacion = Date.Now.Date, FechaLiquidacion = Date.Now.Date
  1446. AgregarDias()
  1447. If (CET) Then
  1448. V_txtPrecio = "100"
  1449. Else
  1450. If (chbValorPar.Checked) Then
  1451. V_txtPrecio = "100"
  1452. txtPrecio.Text = "100%"
  1453. Else
  1454. txtPrecio.Text = Format(Precio(), "0.0000")
  1455. V_txtPrecio = Format(Precio(), "0.000000000")
  1456. End If
  1457. End If
  1458. txtValorTransado.Text = Format(ValorTrasado(), "0.0000")
  1459. V_txtValorTransado = Format(ValorTrasado(), "0.000000000")
  1460. txtComisionCasa.Text = Format(ComisionCasa(), "0.0000")
  1461. V_txtComisionCasa = Format(ComisionCasa(), "0.000000000")
  1462. txtComisionBolsa.Text = Format(ComisionBolsa(), "0.0000")
  1463. V_txtComisionBolsa = Format(ComisionBolsa(), "0.000000000")
  1464. txtIngresoBruto.Text = Format(IngresoBruto(), "0.0000")
  1465. V_txtIngresoBruto = Format(IngresoBruto(), "0.000000000")
  1466. FechaOperacion = dtpFechaOperacion.Value
  1467. FechaLiquidacion = dtpFechaLiquidacion.Value
  1468. 'txtDiasAcumulados.Text = Operaciones.DiasAcumulados(FechaOperacion, FechaLiquidacion, 1).ToString()
  1469. Dim Dias = 0
  1470. Dim Fecha As String = Format(dtpUltimaFecha.Value, "yyyy/MM/dd")
  1471. dtpUltimaFecha.Value = Fecha
  1472. Dim FechaLiq As String = Format(dtpFechaLiquidacion.Value, "yyyy/MM/dd")
  1473. dtpFechaLiquidacion.Value = FechaLiq
  1474. If (IndexBase = 0 Or IndexBase = 2) Then
  1475. Dias = Operaciones.Base360(dtpUltimaFecha.Value, dtpFechaLiquidacion.Value)
  1476. ElseIf IndexBase = 1 Or IndexBase = 3 Then
  1477. Dias = Operaciones.Base365(dtpUltimaFecha.Value, dtpFechaLiquidacion.Value)
  1478. End If
  1479. V_txtDiasAcumulados = Dias
  1480. Dim ValorNominal, RendBruto
  1481. ValorNominal = txtValorNominal.Text
  1482. If String.IsNullOrEmpty(ValorNominal.ToString) Then
  1483. ValorNominal = 0
  1484. End If
  1485. RendBruto = txtRendimientoBruto.Text
  1486. If String.IsNullOrEmpty(RendBruto.ToString.Trim("%")) Then
  1487. RendBruto = 0
  1488. Else
  1489. RendBruto = txtRendimientoBruto.Text.TrimEnd("%") / 100
  1490. End If
  1491. txtInteresAcumulado.Text = Format(CDec(Operaciones.InteresAcumuladoPBUR(ValorNominal, RendBruto, V_txtDiasAcumulados, IndexBase, dtpUltimaFecha.Value, dtpFechaLiquidacion.Value)), "0.0000").ToString + "%"
  1492. txtTotalAPagar.Text = Format(TotalPagar(), "0.0000")
  1493. V_txtTotalAPagar = Format(TotalPagar(), "0.000000000")
  1494. txtIngresoNeto.Text = Format(IngresoNeto(), "0.0000")
  1495. V_txtIngresoNeto = Format(IngresoNeto(), "0.000000000")
  1496. txtRendimientoNeto.Text = Format(RendimientoNeto(), "0.0000")
  1497. V_txtRendimientoNeto = Format(RendimientoNeto(), "0.000000000")
  1498. AgregarPorcentaje()
  1499. End Sub
  1500. Private Sub Button1_Click_1(sender As Object, e As EventArgs)
  1501. End Sub
  1502. Sub AgregarDias()
  1503. Dim Dias As Integer = 0
  1504. If Not String.IsNullOrEmpty(txtPlazoInversion.Text) Then
  1505. Dias = txtPlazoInversion.Text
  1506. End If
  1507. Dim Fechaliquidacion = dtpFechaLiquidacion.Value
  1508. 'If (cboBase.SelectedIndex = 0) Then
  1509. If (IndexBase = 0 Or IndexBase = 2) Then
  1510. dtpFechaVencimiento.Value = Operaciones.FechaDias360(Fechaliquidacion, Dias)
  1511. ElseIf IndexBase = 1 Or IndexBase = 3 Then
  1512. dtpFechaVencimiento.Value = dtpFechaLiquidacion.Value.AddDays(Dias)
  1513. End If
  1514. End Sub
  1515. Sub AgregarPorcentaje()
  1516. If (txtRendimientoBruto.ToString.IndexOf("%") = -1) Then
  1517. txtRendimientoBruto.Text += "%"
  1518. End If
  1519. If (txtPorcentajeComisionCasa.Text.ToString.IndexOf("%") = -1) Then
  1520. txtPorcentajeComisionCasa.Text += "%"
  1521. End If
  1522. If (txtPorcentajeComisionBolsa.ToString.IndexOf("%") = -1) Then
  1523. txtPorcentajeComisionBolsa.Text += "%"
  1524. End If
  1525. If (txtRendimientoNeto.ToString.IndexOf("%") = -1) Then
  1526. txtRendimientoNeto.Text += "%"
  1527. End If
  1528. If (txtPrecio.ToString.IndexOf("%") = -1) Then
  1529. txtPrecio.Text += "%"
  1530. End If
  1531. End Sub
  1532. Private Sub txtRendimientoBruto_Leave(sender As Object, e As EventArgs) Handles txtRendimientoBruto.Leave
  1533. ' txtRendimientoBruto.Text = CStr(GetRendimientoBruto())
  1534. Rellenar()
  1535. End Sub
  1536. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  1537. TipoTransaccion = "M"
  1538. btnAceptar.Text = "Modificar"
  1539. End Sub
  1540. Private Sub txtValorNominal_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorNominal.KeyPress
  1541. If String.IsNullOrEmpty(txtValorNominal.Text) Then
  1542. If e.KeyChar = "." Then
  1543. txtValorNominal.Text = "0"
  1544. Exit Sub
  1545. End If
  1546. End If
  1547. If (Not txtValorNominal.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1548. Operaciones.ValidarEntrada(sender, e, True)
  1549. Else
  1550. Operaciones.ValidarEntrada(sender, e, False)
  1551. End If
  1552. End Sub
  1553. Private Sub txtPlazoInversion_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPlazoInversion.KeyPress
  1554. If String.IsNullOrEmpty(txtPlazoInversion.Text) Then
  1555. If e.KeyChar = "." Then
  1556. txtPlazoInversion.Text = "0"
  1557. Exit Sub
  1558. End If
  1559. End If
  1560. If (Not txtPlazoInversion.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1561. Operaciones.ValidarEntrada(sender, e, True)
  1562. Else
  1563. Operaciones.ValidarEntrada(sender, e, False)
  1564. End If
  1565. End Sub
  1566. Private Sub txtPorcentajeComisionCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeComisionCasa.KeyPress
  1567. If String.IsNullOrEmpty(txtPorcentajeComisionCasa.Text) Then
  1568. If e.KeyChar = "." Then
  1569. txtPorcentajeComisionCasa.Text = "0"
  1570. Exit Sub
  1571. End If
  1572. End If
  1573. If (Not txtPorcentajeComisionCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1574. Operaciones.ValidarEntrada(sender, e, True)
  1575. Else
  1576. Operaciones.ValidarEntrada(sender, e, False)
  1577. End If
  1578. End Sub
  1579. Private Sub txtPorcentajeComisionBolsa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeComisionBolsa.KeyPress
  1580. If String.IsNullOrEmpty(txtPorcentajeComisionBolsa.Text) Then
  1581. If e.KeyChar = "." Then
  1582. txtPorcentajeComisionBolsa.Text = "0"
  1583. Exit Sub
  1584. End If
  1585. End If
  1586. If (Not txtPorcentajeComisionBolsa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1587. Operaciones.ValidarEntrada(sender, e, True)
  1588. Else
  1589. Operaciones.ValidarEntrada(sender, e, False)
  1590. End If
  1591. End Sub
  1592. Private Sub txtRendimientoBruto_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtRendimientoBruto.KeyPress
  1593. If String.IsNullOrEmpty(txtRendimientoBruto.Text) Then
  1594. If e.KeyChar = "." Then
  1595. txtRendimientoBruto.Text = "0"
  1596. Exit Sub
  1597. End If
  1598. End If
  1599. If (Not txtRendimientoBruto.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1600. Operaciones.ValidarEntrada(sender, e, True)
  1601. Else
  1602. Operaciones.ValidarEntrada(sender, e, False)
  1603. End If
  1604. End Sub
  1605. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  1606. TipoTransaccion = "N"
  1607. btnAceptar.Text = "Agregar"
  1608. End Sub
  1609. Private Sub chbValorPar_CheckedChanged(sender As Object, e As EventArgs) Handles chbValorPar.CheckedChanged
  1610. RellenarDatos()
  1611. End Sub
  1612. Private Sub txtRendimientoNeto_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoNeto.TextChanged
  1613. End Sub
  1614. Private Sub txtInteresAcumulado_TextChanged(sender As Object, e As EventArgs) Handles txtInteresAcumulado.TextChanged
  1615. End Sub
  1616. Private Sub txtIngresoBruto_TextChanged(sender As Object, e As EventArgs) Handles txtIngresoBruto.TextChanged
  1617. End Sub
  1618. Private Sub dtpUltimaFecha_ValueChanged(sender As Object, e As EventArgs)
  1619. RellenarDatos()
  1620. End Sub
  1621. Private Sub Label14_Click(sender As Object, e As EventArgs) Handles Label14.Click
  1622. End Sub
  1623. Private Sub cboPeriodicidad_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodicidad.SelectedIndexChanged
  1624. RellenarDatos()
  1625. End Sub
  1626. Private Sub cboCasasCorredoras_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCasasCorredoras.SelectedIndexChanged
  1627. RellenarDatos()
  1628. End Sub
  1629. Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
  1630. End Sub
  1631. Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
  1632. End Sub
  1633. Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click
  1634. End Sub
  1635. Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click
  1636. End Sub
  1637. Private Sub Label10_Click(sender As Object, e As EventArgs) Handles Label10.Click
  1638. End Sub
  1639. Private Sub Label5_Click(sender As Object, e As EventArgs) Handles Label5.Click
  1640. End Sub
  1641. Private Sub Label11_Click(sender As Object, e As EventArgs) Handles Label11.Click
  1642. End Sub
  1643. Private Sub txtIngresoNeto_TextChanged(sender As Object, e As EventArgs) Handles txtIngresoNeto.TextChanged
  1644. End Sub
  1645. Private Sub Label12_Click(sender As Object, e As EventArgs) Handles Label12.Click
  1646. End Sub
  1647. Private Sub Label13_Click(sender As Object, e As EventArgs) Handles Label13.Click
  1648. End Sub
  1649. Private Sub Label15_Click(sender As Object, e As EventArgs) Handles Label15.Click
  1650. End Sub
  1651. Private Sub Label16_Click(sender As Object, e As EventArgs) Handles Label16.Click
  1652. End Sub
  1653. Private Sub Label17_Click(sender As Object, e As EventArgs) Handles Label17.Click
  1654. End Sub
  1655. Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
  1656. End Sub
  1657. Private Sub lblInteresAcumulado_Click(sender As Object, e As EventArgs) Handles lblInteresAcumulado.Click
  1658. End Sub
  1659. Private Sub dtpUltimaFecha_ValueChanged_1(sender As Object, e As EventArgs) Handles dtpUltimaFecha.ValueChanged
  1660. RellenarDatos()
  1661. End Sub
  1662. Private Sub txtOtrosCostos_TextChanged(sender As Object, e As EventArgs) Handles txtOtrosCostos.TextChanged
  1663. RellenarDatos()
  1664. End Sub
  1665. Private Sub txtOtrosCostos_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtOtrosCostos.KeyPress
  1666. If String.IsNullOrEmpty(txtOtrosCostos.Text) Then
  1667. If e.KeyChar = "." Then
  1668. txtOtrosCostos.Text = "0"
  1669. Exit Sub
  1670. End If
  1671. End If
  1672. If (Not txtOtrosCostos.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1673. Operaciones.ValidarEntrada(sender, e, True)
  1674. Else
  1675. Operaciones.ValidarEntrada(sender, e, False)
  1676. End If
  1677. End Sub
  1678. Private Sub btnRedencion_Click(sender As Object, e As EventArgs) Handles btnRedencion.Click
  1679. If (btnRedencion.Text = "Redención") Then
  1680. lblRedencion.Visible = True
  1681. dtpRedencion.Visible = True
  1682. btnRedencion.Text = "Cancelar"
  1683. Else
  1684. lblRedencion.Visible = False
  1685. dtpRedencion.Visible = False
  1686. btnRedencion.Text = "Redención"
  1687. End If
  1688. End Sub
  1689. Private Sub txtDiasAcumulados_TextChanged(sender As Object, e As EventArgs)
  1690. RellenarDatos()
  1691. End Sub
  1692. Private Sub txtValorNominal_Leave(sender As Object, e As EventArgs) Handles txtValorNominal.Leave
  1693. Rellenar()
  1694. End Sub
  1695. Private Sub txtPlazoInversion_Leave(sender As Object, e As EventArgs) Handles txtPlazoInversion.Leave
  1696. Rellenar()
  1697. End Sub
  1698. Private Sub txtOtrosCostos_Leave(sender As Object, e As EventArgs) Handles txtOtrosCostos.Leave
  1699. Rellenar()
  1700. End Sub
  1701. Private Sub txtValorNominal_ModifiedChanged(sender As Object, e As EventArgs) Handles txtValorNominal.ModifiedChanged
  1702. End Sub
  1703. Private Sub txtValorNominal_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorNominal.KeyUp
  1704. If txtValorNominal.Text = "." Then
  1705. txtValorNominal.Text = ".0"
  1706. End If
  1707. End Sub
  1708. Private Sub txtPlazoInversion_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPlazoInversion.KeyUp
  1709. If txtPlazoInversion.Text = "." Then
  1710. txtPlazoInversion.Text = ".0"
  1711. End If
  1712. End Sub
  1713. Private Sub txtPorcentajeComisionCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentajeComisionCasa.KeyUp
  1714. If txtPorcentajeComisionCasa.Text = "." Then
  1715. txtPorcentajeComisionCasa.Text = ".0"
  1716. End If
  1717. End Sub
  1718. Private Sub txtPorcentajeComisionBolsa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentajeComisionBolsa.KeyUp
  1719. If txtPorcentajeComisionBolsa.Text = "." Then
  1720. txtPorcentajeComisionBolsa.Text = ".0"
  1721. End If
  1722. End Sub
  1723. Private Sub txtRendimientoBruto_KeyUp(sender As Object, e As KeyEventArgs) Handles txtRendimientoBruto.KeyUp
  1724. If txtRendimientoBruto.Text = "." Then
  1725. txtRendimientoBruto.Text = ".0"
  1726. End If
  1727. End Sub
  1728. Private Sub txtOtrosCostos_KeyUp(sender As Object, e As KeyEventArgs) Handles txtOtrosCostos.KeyUp
  1729. If txtOtrosCostos.Text = "." Then
  1730. txtOtrosCostos.Text = ".0"
  1731. End If
  1732. End Sub
  1733. Private Sub dtpRedencion_ValueChanged(sender As Object, e As EventArgs) Handles dtpRedencion.ValueChanged
  1734. End Sub
  1735. Private Sub btnReporto_Click(sender As Object, e As EventArgs)
  1736. End Sub
  1737. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  1738. TipoTransaccion = "B"
  1739. btnAceptar.Text = "Eliminar"
  1740. End Sub
  1741. Private Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
  1742. Me.Close()
  1743. End Sub
  1744. Private Sub cboBase_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboBase.SelectedIndexChanged
  1745. RellenarDatos()
  1746. End Sub
  1747. Private Sub BindingNavigator1_RefreshItems(sender As Object, e As EventArgs) Handles BindingNavigator1.RefreshItems
  1748. End Sub
  1749. Private Sub txtPorcentajeComisionCasa_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeComisionCasa.Leave
  1750. Rellenar()
  1751. End Sub
  1752. Private Sub txtPorcentajeComisionBolsa_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeComisionBolsa.Leave
  1753. Rellenar()
  1754. End Sub
  1755. Sub AgregarDiasExtra()
  1756. dtpFechaLiquidacion.Value = dtpFechaOperacion.Value.AddDays(2)
  1757. End Sub
  1758. Sub LimpiarCampos()
  1759. chbValorPar.Checked = False
  1760. txtValorNominal.Text = 0
  1761. txtPlazoInversion.Text = 0
  1762. cboCasasCorredoras.SelectedIndex = -1
  1763. cboBase.SelectedIndex = -1
  1764. txtPorcentajeComisionBolsa.Text = 0
  1765. txtPorcentajeComisionCasa.Text = 0
  1766. txtComisionBolsa.Text = 0
  1767. txtComisionCasa.Text = 0
  1768. txtRendimientoBruto.Text = 0
  1769. txtRendimientoNeto.Text = 0
  1770. txtIngresoBruto.Text = 0
  1771. txtIngresoNeto.Text = 0
  1772. txtValorTransado.Text = 0
  1773. txtPrecio.Text = 0
  1774. txtTotalAPagar.Text = 0
  1775. dtpFechaOperacion.Value = Date.Now.Date
  1776. dtpFechaLiquidacion.Value = Date.Now.Date
  1777. dtpFechaVencimiento.Value = Date.Now.Date
  1778. dtpUltimaFecha.Value = Date.Now.Date
  1779. dtpRedencion.Value = Date.Now.Date
  1780. txtInteresAcumulado.Text = 0
  1781. txtOtrosCostos.Text = 0
  1782. End Sub
  1783. Sub CargarTransladoNuevo()
  1784. Dim Existe As Boolean = ExisteInversion()
  1785. If Not RetCodigoInversionExiste And Not Existe Then
  1786. txtValorNominal.Text = Variables.RetMonto
  1787. txtRendimientoBruto.Text = Variables.RetRendimiento
  1788. End If
  1789. End Sub
  1790. End Class