frmCertificadosDeInversion.vb 128 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418
  1. Public Class frmCertificadosDeInversion
  2. Dim oCEPrincipal As New CertificadoDeInversionCE
  3. Dim oDAOPrincipal As New CertificadosDeInversionDAO
  4. Dim oDAOGeneral As New DAOGeneral
  5. Dim Bonos As New BonosCE
  6. Dim TotalValorCupones As Double
  7. Dim Index
  8. Dim BonoCalculo As New FormulasBonoCE
  9. Dim Cargar As Boolean = True
  10. Dim BonosConsulta As New BonosDAO
  11. Dim Operaciones As New Operaciones
  12. Dim ModificarRenta As Boolean = True
  13. Dim TipoDeCalculoDeFecha As Integer = 0
  14. Dim IndexBaseC As Integer = 0
  15. Dim IndexBaseV As Integer = 0
  16. Dim PeriodoC As Integer = 0
  17. Dim PeriodoV As Integer = 0
  18. Private _IdDocumento As Integer
  19. Private _TipoDocumento As String
  20. Private _CodigoInversion As String
  21. Private _TipoTransaccion As String 'N=Nuevo, A=Actualizar, C=Consulta
  22. Private TipoPeriodicidad As Integer = 0
  23. Public InstanciaAmortizacion As New DataGridView
  24. Public InstanciaIngresos As New DataGridView
  25. Private TipoOperacion As String
  26. Public Sub New()
  27. InitializeComponent()
  28. End Sub
  29. Public Sub New(TipoOper As String)
  30. Me.New
  31. TipoOperacion = TipoOper
  32. End Sub
  33. Sub CargarBase()
  34. If cboAnioBaseC.Items.Count = 0 Or cboAnioBaseC.Items.Count = 1 Then
  35. Me.cboAnioBaseC.DataSource = oDAOGeneral.ListaBase
  36. Me.cboAnioBaseC.DisplayMember = "Descripcion"
  37. Me.cboAnioBaseC.ValueMember = "Codigo"
  38. Me.cboAnioBaseC.SelectedIndex = 0
  39. End If
  40. If cboAnioBaseV.Items.Count = 0 Or cboAnioBaseV.Items.Count = 1 Then
  41. Me.cboAnioBaseV.DataSource = oDAOGeneral.ListaBase
  42. Me.cboAnioBaseV.DisplayMember = "Descripcion"
  43. Me.cboAnioBaseV.ValueMember = "Codigo"
  44. Me.cboAnioBaseV.SelectedIndex = 0
  45. End If
  46. End Sub
  47. Public Property TipoTransaccion As String
  48. Get
  49. Return _TipoTransaccion
  50. End Get
  51. Set(value As String)
  52. _TipoTransaccion = value
  53. End Set
  54. End Property
  55. Private Property IdDocumento As Integer
  56. Get
  57. Return _IdDocumento
  58. End Get
  59. Set(value As Integer)
  60. _IdDocumento = value
  61. End Set
  62. End Property
  63. Private Property TipoDocumento As String
  64. Get
  65. Return _TipoDocumento
  66. End Get
  67. Set(value As String)
  68. _TipoDocumento = value
  69. End Set
  70. End Property
  71. Private Property CodigoInversion As String
  72. Get
  73. Return _CodigoInversion
  74. End Get
  75. Set(value As String)
  76. _CodigoInversion = value
  77. End Set
  78. End Property
  79. Function FechaCupon(ByVal liquidacion As Date, ByVal Vencimiento As Date, ByVal frecuencia As Integer)
  80. Dim periodos As Integer = 0
  81. If frecuencia = 1 Then
  82. periodos = -12
  83. ElseIf frecuencia = 2 Then
  84. periodos = -6
  85. ElseIf frecuencia = 4 Then
  86. periodos = -3
  87. ElseIf frecuencia = 12 Then
  88. periodos = -1
  89. End If
  90. If (Not periodos = 0) Then
  91. While Vencimiento > liquidacion
  92. Vencimiento = Vencimiento.AddMonths(periodos)
  93. End While
  94. Else
  95. Return liquidacion
  96. End If
  97. Return Vencimiento
  98. End Function
  99. Sub ValidarExistencia()
  100. Dim General As New DAOGeneral
  101. Dim Codigo As String = Variables.Codigo
  102. Dim Tabla As String = String.Empty
  103. Dim Ins As String = Instrumento()
  104. If (Ins = "TIT") Then
  105. Tabla = "TIT"
  106. ElseIf (Ins = "EURB") Then
  107. Tabla = "EURB0"
  108. ElseIf (Ins = "BONO") Then
  109. Tabla = "BON0"
  110. ElseIf (Ins = "CINV") Then
  111. Tabla = "CIN0"
  112. End If
  113. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  114. If Tabla = "TIT" Then
  115. If (Existe) Then
  116. navNuevo.Enabled = False
  117. navModificar.Enabled = True
  118. navEliminar.Enabled = True
  119. btnIngresos.Enabled = True
  120. Else
  121. navNuevo.Enabled = True
  122. navModificar.Enabled = False
  123. navEliminar.Enabled = False
  124. btnIngresos.Enabled = False
  125. End If
  126. Else
  127. If (Existe) Then
  128. navNuevo.Enabled = False
  129. navModificar.Enabled = True
  130. navEliminar.Enabled = True
  131. btnIngresos.Enabled = True
  132. Else
  133. navNuevo.Enabled = True
  134. navModificar.Enabled = False
  135. navEliminar.Enabled = False
  136. btnIngresos.Enabled = False
  137. End If
  138. End If
  139. TipoTransaccion = String.Empty
  140. btnAceptar.Text = "Aceptar"
  141. End Sub
  142. Function ExisteValidacion()
  143. Dim General As New DAOGeneral
  144. Dim Codigo As String = Variables.Codigo
  145. Dim Tabla As String = String.Empty
  146. Dim Ins As String = Instrumento()
  147. If (Ins = "TIT") Then
  148. Tabla = "TIT"
  149. ElseIf (Ins = "EURB") Then
  150. Tabla = "EURB0"
  151. ElseIf (Ins = "BONO") Then
  152. Tabla = "BON0"
  153. ElseIf (Ins = "CINV") Then
  154. Tabla = "CIN0"
  155. End If
  156. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  157. Return Existe
  158. End Function
  159. Private Sub frmBonos_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  160. Dim VExisteInversion As Boolean = False
  161. If Variables.TipoOperacionCMVTA = "C" Then
  162. GrpVenta.Enabled = False
  163. GrpCompra.Enabled = True
  164. Else
  165. GrpVenta.Enabled = True
  166. GrpCompra.Enabled = False
  167. End If
  168. VExisteInversion = ExisteInversion()
  169. ValidarExistencia()
  170. Dim Ins As String = Instrumento()
  171. CargarBase()
  172. AsignacionPeriodicidad()
  173. If (Not Ins = "TIT") Then
  174. btnIngresos.Visible = False
  175. End If
  176. If (Ins = "TIT") Then
  177. btnIngresos.Visible = True
  178. lblBono.Text = "Titularizacion"
  179. ConfTitularizacion()
  180. ElseIf (Ins = "EURB") Then
  181. lblBono.Text = "Euro Bonos"
  182. ElseIf (Ins = "BONO") Then
  183. lblBono.Text = "Bonos"
  184. End If
  185. Bono()
  186. TipoDeCalculoDeFecha = 1
  187. Call CargarPeriodos()
  188. PrepararTablaIngresos()
  189. If Me.TipoTransaccion Is Nothing Then
  190. Me.TipoTransaccion = "N"
  191. End If
  192. CargarIngresos()
  193. RefrescarValorControles()
  194. Cargar = False
  195. BotonQuitar()
  196. CamposTiempo()
  197. ConfiguracionCMVTA(VExisteInversion)
  198. End Sub
  199. Sub ConfiguracionCMVTA(ByRef VExisteInversion As Boolean)
  200. Dim Codigo As String = Variables.Codigo
  201. Dim ExisteCMVTA As Boolean = oDAOGeneral.ExisteCMVTA(Codigo)
  202. If Not ExisteCMVTA And Variables.InvocadorProInv = "frmINV" Then
  203. btnVenderTitulo.Visible = True
  204. End If
  205. If CantFormAbierto = False And Not VExisteInversion Then
  206. If Not Variables.TrasladarCMVTA Is Nothing Then
  207. cboAnioBaseC.SelectedIndex = Variables.TrasladarCMVTA.BaseCINV
  208. txtPorcentajeCuponCompra.Text = Variables.TrasladarCMVTA.CuponCINV
  209. dtpFechaLiquidacionCompra.Value = Variables.TrasladarCMVTA.FechaLiquidacionCINV
  210. dtpFechaVencimientoCompra.Value = Variables.TrasladarCMVTA.FechaVencimientoCINV
  211. cboPeriodosC.SelectedValue = Variables.TrasladarCMVTA.PeriodicidadCINV
  212. txtComisionPorBolsaCompra.Text = Variables.TrasladarCMVTA.PorcentajeComisionBolsaCINV
  213. txtComisionPorCompraCasa.Text = Variables.TrasladarCMVTA.PorcentajeComisionCasaCINV
  214. txtPrecioCompra.Text = Variables.TrasladarCMVTA.PrecioCompraCINV
  215. txtPrecioAlVencimientoCompra.Text = Variables.TrasladarCMVTA.PrecioVencimientoCINV
  216. dtpUltimaFechaCuponCompra.Value = Variables.TrasladarCMVTA.UltimaFechaCuponCINV
  217. txtValorNominalCompra.Text = Variables.TrasladarCMVTA.ValorNominalCINV
  218. txtYTMAlVencimientoCompra.Text = Variables.TrasladarCMVTA.YTMVencimientoCINV
  219. End If
  220. End If
  221. End Sub
  222. Sub CamposTiempo()
  223. If Not TypeOf cboPeriodosC.SelectedValue Is DataRowView Then
  224. Variables.PeriodicidadTIT = cboPeriodosC.SelectedValue
  225. End If
  226. Variables.BaseTIT = cboAnioBaseC.SelectedIndex
  227. End Sub
  228. Sub ConfTitularizacion()
  229. dgvIngresos.Dispose()
  230. TbIngresos.Parent = Nothing
  231. Dim TbAmortizacion As New TabPage
  232. Dim frmTitularizacion As New frmResultadoTitularizacion()
  233. TbAmortizacion.Name = "tbAmortizacion"
  234. TbAmortizacion.Text = "Amortizacion"
  235. If TabCampos.TabCount = 2 Then
  236. frmTitularizacion.Dock = DockStyle.Fill
  237. frmTitularizacion.TopLevel = False
  238. frmTitularizacion.Parent = TbAmortizacion
  239. TabCampos.Controls.Add(TbAmortizacion)
  240. frmTitularizacion.Show()
  241. End If
  242. End Sub
  243. Function ExisteInversion()
  244. Dim Codigo As String = Variables.Codigo
  245. Dim TablaINV As String = "INV0"
  246. Dim TablaPINV As String = "PIN0"
  247. Dim General As New DAOGeneral
  248. Dim InvPro = Variables.InvPro
  249. If InvPro = "I" Then
  250. Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
  251. If INV0 Then
  252. navNuevo.Visible = True
  253. Return True
  254. Else
  255. navNuevo.Visible = False
  256. Return False
  257. End If
  258. End If
  259. If InvPro = "P" Then
  260. Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
  261. If PINV0 Then
  262. navNuevo.Visible = True
  263. Return True
  264. Else
  265. navNuevo.Visible = False
  266. Return False
  267. End If
  268. End If
  269. Return False
  270. End Function
  271. Sub Bono()
  272. dtpSiguienteFechaCuponCompra.Enabled = False
  273. dtpSiguienteFechaCuponVenta.Enabled = False
  274. dtpUltimaFechaCuponCompra.Enabled = True
  275. dtpUltimaFechaCuponVenta.Enabled = True
  276. End Sub
  277. Private Function Parametros()
  278. Dim Coleccion As New Collection
  279. Dim PeriodoCompra = cboPeriodosC.SelectedValue
  280. Dim ValorNominalCompra = Operaciones.ConvertirDecimal(txtValorNominalCompra.Text.ToString)
  281. Dim UltCuponCompra = Operaciones.ConvertirFecha(dtpUltimaFechaCuponCompra.Value.ToString)
  282. Dim SigFechaCuponCompra = Operaciones.ConvertirFecha(dtpSiguienteFechaCuponCompra.Value.ToString)
  283. Dim FechaLiqCompra = Operaciones.ConvertirFecha(dtpFechaLiquidacionCompra.Value.ToString)
  284. Dim FechaVenCompra = Operaciones.ConvertirFecha(dtpFechaVencimientoCompra.Value.ToString)
  285. Dim PorcentajeCuponCompra = Operaciones.ConvertirDecimal(txtPorcentajeCuponCompra.Text.ToString) / 100
  286. Dim PrecioVenciCompra = Operaciones.ConvertirDecimal(txtPrecioAlVencimientoCompra.Text.ToString)
  287. Dim PrecioCompra = Operaciones.ConvertirDecimal(txtPrecioCompra.Text.ToString)
  288. Dim DiasBase = IndexBaseC
  289. Dim CostoTransCompra = Operaciones.ConvertirDecimal(txtCostoTransferenciaCompra.Text.ToString)
  290. Dim PorcCupC = Operaciones.ConvertirDecimal(txtPorcentajeCuponCompra.Text.ToString) / 100
  291. Dim PeriodoVenta = cboPeriodosV.SelectedValue
  292. Dim ValorNominalVenta = Operaciones.ConvertirDecimal(txtValorNominalVenta.Text.ToString)
  293. Dim UltCuponVenta = Operaciones.ConvertirFecha(dtpUltimaFechaCuponVenta.Value.ToString)
  294. Dim SigFechaCuponVenta = Operaciones.ConvertirFecha(dtpSiguienteFechaCuponVenta.Value.ToString)
  295. Dim FechaLiqVenta = Operaciones.ConvertirFecha(dtpFechaLiquidacionVenta.Value.ToString)
  296. Dim FechaVenVenta = Operaciones.ConvertirFecha(dtpFechaVencimientoVenta.Value.ToString)
  297. Dim PorcentajeCuponVenta = Operaciones.ConvertirDecimal(txtPorcentajeCuponVenta.Text.ToString) / 100
  298. Dim PrecioVenciVenta = Operaciones.ConvertirDecimal(txtPrecioAlVencimientoVenta.Text.ToString)
  299. Dim PrecioVenta = Operaciones.ConvertirDecimal(txtPrecioVenta.Text.ToString)
  300. Dim DiasBaseV = IndexBaseV
  301. Dim CostoTransVenta = Operaciones.ConvertirDecimal(txtCuponesRecibidos.Text.ToString)
  302. Dim PorcCupV = Operaciones.ConvertirDecimal(txtPorcentajeCuponVenta.Text.ToString) / 100
  303. Dim ComisionPorCompraCasa = Operaciones.ConvertirDecimal(txtComisionPorCompraCasa.Text.ToString) / 100
  304. Dim ComisionPorCompraBolsa = Operaciones.ConvertirDecimal(txtComisionPorBolsaCompra.Text.ToString) / 100
  305. Dim ComisionPorVentaCasa = Operaciones.ConvertirDecimal(txtComisionPorVentaCasa.Text.ToString) / 100
  306. Dim ComisionPorVentaBolsa = Operaciones.ConvertirDecimal(txtComisionPorBolsaVenta.Text.ToString) / 100
  307. Dim YTMCompra = Operaciones.ConvertirDecimal(txtYTMAlVencimientoComisionCompra.Text.ToString) / 100
  308. Dim YTMVenta = Operaciones.ConvertirDecimal(txtYTMAlVencimientoComisionVenta.Text.ToString) / 100
  309. Dim DiasVenC, DiasVenV, DiasAcuC, DiasAcuV, YTMVenC, YTMVenV, IntAcuC, IntAcuV, IntPorAcuC, IntPorAcuV, PrecSucioC, PrecSucioV
  310. Dim ComisionCasaC, ComisionCasaV, ComisionBolsaC, ComisionBolsaV, ValTransC, ValTransV, MontoPagar, MontoRecibir, CostTrans, CupRecibidos
  311. DiasVenC = Operaciones.ConvertirEntero(txtDiasAlVencimientoCompra.Text.ToString)
  312. DiasVenV = Operaciones.ConvertirEntero(txtDiasAlVencimientoVenta.Text.ToString)
  313. DiasAcuC = Operaciones.ConvertirEntero(txtDiasAcumuladosCompra.Text.ToString)
  314. DiasAcuV = Operaciones.ConvertirEntero(txtDiasAcumuladosVenta.Text.ToString)
  315. YTMVenC = Operaciones.ConvertirDecimal(txtYTMAlVencimientoCompra.Text.ToString) / 100
  316. YTMVenV = Operaciones.ConvertirDecimal(txtYTMAlVencimientoVenta.Text.ToString) / 100
  317. IntAcuC = Operaciones.ConvertirDecimal(txtInteresAcumuladoCompra.Text.ToString)
  318. IntAcuV = Operaciones.ConvertirDecimal(txtInteresAcumuladoVenta.Text.ToString)
  319. IntPorAcuC = Operaciones.ConvertirDecimal(txtPorcentajeInteresAcumuladoCompra.Text.ToString) / 100
  320. IntPorAcuV = Operaciones.ConvertirDecimal(txtPorcentajeInteresAcumuladoVenta.Text.ToString) / 100
  321. PrecSucioC = Operaciones.ConvertirDecimal(txtPrecioSucioCompra.Text.ToString) / 100
  322. PrecSucioV = Operaciones.ConvertirDecimal(txtPrecioSucioVenta.Text.ToString) / 100
  323. ComisionCasaC = Operaciones.ConvertirDecimal(txtComisionCompraCasa.Text.ToString)
  324. ComisionCasaV = Operaciones.ConvertirDecimal(txtComisionVentaCasa.Text.ToString)
  325. ComisionBolsaC = Operaciones.ConvertirDecimal(txtComisionCompraBolsa.Text.ToString)
  326. ComisionBolsaV = Operaciones.ConvertirDecimal(txtComisionVentaBolsa.Text.ToString)
  327. ValTransC = Operaciones.ConvertirDecimal(txtValorTransadoCompra.Text.ToString)
  328. ValTransV = Operaciones.ConvertirDecimal(txtValorTransadoVenta.Text.ToString)
  329. MontoPagar = Operaciones.ConvertirDecimal(txtMontoAPagar.Text.ToString)
  330. MontoRecibir = Operaciones.ConvertirDecimal(txtMontoARecibir.Text.ToString)
  331. CostTrans = Operaciones.ConvertirDecimal(txtCostoTransferenciaCompra.Text.ToString)
  332. CupRecibidos = Operaciones.ConvertirEntero(txtCuponesRecibidos.Text.ToString)
  333. Dim Codigo = Variables.Codigo
  334. Coleccion.Add(PeriodoCompra)
  335. Coleccion.Add(ValorNominalCompra)
  336. Coleccion.Add(UltCuponCompra)
  337. Coleccion.Add(SigFechaCuponCompra)
  338. Coleccion.Add(FechaLiqCompra)
  339. Coleccion.Add(FechaVenCompra)
  340. Coleccion.Add(PorcentajeCuponCompra)
  341. Coleccion.Add(PrecioVenciCompra)
  342. Coleccion.Add(PrecioCompra)
  343. Coleccion.Add(DiasBase)
  344. Coleccion.Add(CostoTransCompra)
  345. Coleccion.Add(PeriodoVenta)
  346. Coleccion.Add(ValorNominalVenta)
  347. Coleccion.Add(UltCuponVenta)
  348. Coleccion.Add(SigFechaCuponVenta)
  349. Coleccion.Add(FechaLiqVenta)
  350. Coleccion.Add(FechaVenVenta)
  351. Coleccion.Add(PorcentajeCuponVenta)
  352. Coleccion.Add(PrecioVenciVenta)
  353. Coleccion.Add(PrecioVenta)
  354. Coleccion.Add(DiasBaseV)
  355. Coleccion.Add(CostoTransVenta)
  356. Coleccion.Add(Codigo)
  357. Coleccion.Add(PorcCupC)
  358. Coleccion.Add(PorcCupV)
  359. Coleccion.Add(ComisionPorCompraCasa)
  360. Coleccion.Add(ComisionPorCompraBolsa)
  361. Coleccion.Add(ComisionPorVentaCasa)
  362. Coleccion.Add(ComisionPorVentaBolsa)
  363. Coleccion.Add(YTMCompra)
  364. Coleccion.Add(YTMVenta)
  365. Coleccion.Add(DiasVenC)
  366. Coleccion.Add(DiasVenV)
  367. Coleccion.Add(DiasAcuC)
  368. Coleccion.Add(DiasAcuV)
  369. Coleccion.Add(YTMVenC)
  370. Coleccion.Add(YTMVenV)
  371. Coleccion.Add(IntAcuC)
  372. Coleccion.Add(IntAcuV)
  373. Coleccion.Add(IntPorAcuC)
  374. Coleccion.Add(IntPorAcuV)
  375. Coleccion.Add(PrecSucioC)
  376. Coleccion.Add(PrecSucioV)
  377. Coleccion.Add(ComisionCasaC)
  378. Coleccion.Add(ComisionCasaV)
  379. Coleccion.Add(ComisionBolsaC)
  380. Coleccion.Add(ComisionBolsaV)
  381. Coleccion.Add(ValTransC)
  382. Coleccion.Add(ValTransV)
  383. Coleccion.Add(MontoPagar)
  384. Coleccion.Add(MontoRecibir)
  385. Coleccion.Add(CostTrans)
  386. Coleccion.Add(CupRecibidos)
  387. Return Coleccion
  388. End Function
  389. Private Sub LimpiarElementos()
  390. Dim Fecha = DateTime.Today
  391. dgvIngresos.Rows.Clear()
  392. cboPeriodosC.SelectedIndex = -1
  393. txtValorNominalCompra.Text = String.Empty
  394. dtpUltimaFechaCuponCompra.Value = Fecha
  395. dtpSiguienteFechaCuponCompra.Value = Fecha
  396. dtpFechaLiquidacionCompra.Value = Fecha
  397. dtpFechaVencimientoCompra.Value = Fecha
  398. txtPorcentajeCuponCompra.Text = String.Empty
  399. txtPrecioAlVencimientoCompra.Text = String.Empty
  400. txtPrecioCompra.Text = String.Empty
  401. cboAnioBaseC.SelectedIndex = 0
  402. txtCostoTransferenciaCompra.Text = String.Empty
  403. txtYTMAlVencimientoCompra.Text = String.Empty
  404. txtYTMAlVencimientoComisionCompra.Text = String.Empty
  405. txtComisionCompraCasa.Text = String.Empty
  406. txtComisionCompraBolsa.Text = String.Empty
  407. cboPeriodosV.SelectedIndex = -1
  408. txtValorNominalVenta.Text = String.Empty
  409. dtpUltimaFechaCuponVenta.Value = Fecha
  410. dtpSiguienteFechaCuponVenta.Value = Fecha
  411. dtpFechaLiquidacionVenta.Value = Fecha
  412. dtpFechaVencimientoVenta.Value = Fecha
  413. txtPorcentajeCuponVenta.Text = String.Empty
  414. txtPrecioAlVencimientoVenta.Text = String.Empty
  415. txtPrecioVenta.Text = String.Empty
  416. cboAnioBaseV.SelectedIndex = 0
  417. txtCuponesRecibidos.Text = String.Empty
  418. txtYTMAlVencimientoVenta.Text = String.Empty
  419. txtYTMAlVencimientoComisionVenta.Text = String.Empty
  420. txtComisionVentaCasa.Text = String.Empty
  421. txtComisionVentaBolsa.Text = String.Empty
  422. End Sub
  423. Private Sub btnAceptar_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click
  424. Dim Codigo = Variables.Codigo
  425. If TipoTransaccion = "N" Then
  426. oDAOPrincipal.Nuevo(Parametros, Instrumento)
  427. ElseIf Not ExisteValidacion() Then
  428. Variables.ColeccionCINV = Parametros()
  429. Me.Close()
  430. End If
  431. If TipoTransaccion = "M" Then
  432. Dim Diccionario As New Dictionary(Of Integer, Collection)
  433. Diccionario = ModificarIngreso()
  434. oDAOPrincipal.ProcesoDatos(Parametros, Diccionario, Instrumento)
  435. End If
  436. If TipoTransaccion = "B" Then
  437. oDAOPrincipal.
  438. Eliminar(Codigo, Instrumento)
  439. LimpiarElementos()
  440. End If
  441. ValidarExistencia()
  442. End Sub
  443. Public Sub CargarRegistro(ByVal CodInversion As String)
  444. TipoTransaccion = "C"
  445. CodigoInversion = CodInversion
  446. End Sub
  447. Private Sub dtpUltimaFechaCuponCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpUltimaFechaCuponCompra.ValueChanged
  448. Formato()
  449. Calculos()
  450. ValidacionErrores()
  451. End Sub
  452. Private Sub dtpSiguienteFechaCuponCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpSiguienteFechaCuponCompra.ValueChanged
  453. Formato()
  454. Calculos()
  455. ValidacionErrores()
  456. End Sub
  457. Private Sub dtpFechaLiquidacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacionCompra.ValueChanged
  458. Formato()
  459. Calculos()
  460. ValidacionErrores()
  461. End Sub
  462. Private Sub dtpFechaVencimientoCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoCompra.ValueChanged
  463. Formato()
  464. Calculos()
  465. ValidacionErrores()
  466. End Sub
  467. Private Sub txtPorcentajeCuponCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.TextChanged
  468. Calculos()
  469. ValidacionErrores()
  470. End Sub
  471. Private Sub txtPrecioCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioCompra.TextChanged
  472. Calculos()
  473. ValidacionErrores()
  474. End Sub
  475. Private Sub txtPrecioAlVencimientoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.TextChanged
  476. Calculos()
  477. ValidacionErrores()
  478. End Sub
  479. Private Sub txtCostoTransferenciaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.TextChanged
  480. Calculos()
  481. ValidacionErrores()
  482. End Sub
  483. Private Sub dtpFechaVencimientoVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoVenta.ValueChanged
  484. Formato()
  485. Calculos()
  486. ValidacionErrores()
  487. End Sub
  488. Private Sub cboAnioBaseC_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBaseC.SelectedIndexChanged
  489. Formato()
  490. Calculos()
  491. ValidacionErrores()
  492. CamposTiempo()
  493. End Sub
  494. Private Sub cboAnioBaseV_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBaseV.SelectedIndexChanged
  495. Formato()
  496. Calculos()
  497. ValidacionErrores()
  498. CamposTiempo()
  499. End Sub
  500. Sub CargarPeriodos()
  501. If cboPeriodosC.Items.Count = 0 Or cboPeriodosC.Items.Count = 1 Then
  502. Me.cboPeriodosC.DataSource = oDAOGeneral.ListaPeriodicidad
  503. Me.cboPeriodosC.ValueMember = "Codigo"
  504. Me.cboPeriodosC.DisplayMember = "Descripcion"
  505. Me.cboPeriodosC.SelectedIndex = 0
  506. End If
  507. If cboPeriodosV.Items.Count = 0 Or cboPeriodosV.Items.Count = 1 Then
  508. Me.cboPeriodosV.DataSource = oDAOGeneral.ListaPeriodicidad
  509. Me.cboPeriodosV.ValueMember = "Codigo"
  510. Me.cboPeriodosV.DisplayMember = "Descripcion"
  511. Me.cboPeriodosV.SelectedIndex = 0
  512. End If
  513. End Sub
  514. Private Sub cboPeriodosC_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodosC.SelectedIndexChanged
  515. Formato()
  516. Calculos()
  517. ControlPeriodosCompra()
  518. ValidacionErrores()
  519. CamposTiempo()
  520. End Sub
  521. Private Sub cboPeriodosV_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodosV.SelectedIndexChanged
  522. Formato()
  523. Calculos()
  524. ValidacionErrores()
  525. CamposTiempo()
  526. End Sub
  527. Private Sub RefrescarValorControles()
  528. Dim codigo = Variables.Codigo
  529. Dim coleccion = oDAOPrincipal.CargarRegistro(codigo, Instrumento)
  530. If (Not coleccion.Count = 1) Then
  531. Dim Operaciones As New Operaciones
  532. IndexBaseC = Operaciones.ConvertirEntero(coleccion(10).ToString)
  533. IndexBaseV = Operaciones.ConvertirEntero(coleccion(21).ToString)
  534. cboPeriodosC.SelectedValue = coleccion(1).ToString
  535. txtValorNominalCompra.Text = Operaciones.ConvertirDecimal(coleccion(2).ToString)
  536. dtpUltimaFechaCuponCompra.Value = Operaciones.ConvertirFecha(coleccion(3).ToString)
  537. dtpSiguienteFechaCuponCompra.Value = Operaciones.ConvertirFecha(coleccion(4).ToString)
  538. dtpFechaLiquidacionCompra.Value = Operaciones.ConvertirFecha(coleccion(5).ToString)
  539. dtpFechaVencimientoCompra.Value = Operaciones.ConvertirFecha(coleccion(6).ToString)
  540. txtPrecioAlVencimientoCompra.Text = Operaciones.ConvertirDecimal(coleccion(8).ToString)
  541. txtPrecioCompra.Text = Operaciones.ConvertirDecimal(coleccion(9).ToString)
  542. cboAnioBaseC.SelectedIndex = IndexBaseC
  543. txtCostoTransferenciaCompra.Text = Operaciones.ConvertirDecimal(coleccion(11).ToString)
  544. txtPorcentajeInteresAcumuladoCompra.Text = Operaciones.ConvertirDecimal(txtPorcentajeInteresAcumuladoCompra.Text.ToString)
  545. txtPorcentajeCuponCompra.Text = Operaciones.ConvertirDecimal(coleccion(23).ToString) * 100
  546. txtComisionPorCompraCasa.Text = Operaciones.ConvertirDecimal(txtComisionPorCompraCasa.Text.ToString)
  547. txtValorTransadoCompra.Text = Operaciones.ConvertirDecimal(txtValorTransadoCompra.Text.ToString)
  548. txtComisionPorBolsaCompra.Text = Operaciones.ConvertirDecimal(txtComisionPorBolsaCompra.Text.ToString)
  549. txtComisionCompraCasa.Text = Operaciones.Comisiones(Operaciones.ConvertirDecimal(txtComisionPorCompraCasa.Text.ToString) / 100, Operaciones.ConvertirDecimal(txtValorTransadoCompra.Text.ToString).ToString)
  550. txtComisionCompraBolsa.Text = Operaciones.Comisiones(Operaciones.ConvertirDecimal(txtComisionPorBolsaCompra.Text.ToString) / 100, Operaciones.ConvertirDecimal(txtValorTransadoCompra.Text.ToString).ToString)
  551. txtYTMAlVencimientoCompra.Text = Operaciones.ConvertirDecimal(txtYTMAlVencimientoCompra.Text.ToString)
  552. cboPeriodosV.SelectedValue = coleccion(12).ToString
  553. txtValorNominalVenta.Text = Operaciones.ConvertirDecimal(coleccion(13).ToString)
  554. dtpUltimaFechaCuponVenta.Value = Operaciones.ConvertirFecha(coleccion(14).ToString)
  555. dtpSiguienteFechaCuponVenta.Value = Operaciones.ConvertirFecha(coleccion(15).ToString)
  556. dtpFechaLiquidacionVenta.Value = Operaciones.ConvertirFecha(coleccion(16).ToString)
  557. dtpFechaVencimientoVenta.Value = Operaciones.ConvertirFecha(coleccion(17).ToString)
  558. txtPorcentajeCuponVenta.Text = Operaciones.ConvertirDecimal(coleccion(24).ToString) * 100
  559. txtPrecioAlVencimientoVenta.Text = Operaciones.ConvertirDecimal(coleccion(19).ToString)
  560. txtPrecioVenta.Text = Operaciones.ConvertirDecimal(coleccion(20).ToString)
  561. cboAnioBaseV.SelectedIndex = IndexBaseV
  562. txtCuponesRecibidos.Text = Operaciones.ConvertirEntero(coleccion(22).ToString)
  563. txtComisionPorVentaCasa.Text = Operaciones.ConvertirDecimal(txtComisionPorVentaCasa.Text.ToString)
  564. txtComisionPorBolsaVenta.Text = Operaciones.ConvertirDecimal(txtComisionPorBolsaVenta.Text.ToString)
  565. txtYTMAlVencimientoVenta.Text = Operaciones.ConvertirDecimal(txtYTMAlVencimientoVenta.Text.ToString)
  566. txtComisionPorCompraCasa.Text = Operaciones.ConvertirDecimal(coleccion(25).ToString) * 100
  567. txtComisionPorBolsaCompra.Text = Operaciones.ConvertirDecimal(coleccion(26).ToString) * 100
  568. txtComisionPorVentaCasa.Text = Operaciones.ConvertirDecimal(coleccion(27).ToString) * 100
  569. txtComisionPorBolsaVenta.Text = Operaciones.ConvertirDecimal(coleccion(28).ToString) * 100
  570. txtYTMAlVencimientoComisionCompra.Text = Operaciones.ConvertirDecimal(coleccion(29).ToString) * 100
  571. txtYTMAlVencimientoComisionVenta.Text = Operaciones.ConvertirDecimal(coleccion(30).ToString) * 100
  572. 'Campos Extras'
  573. txtDiasAlVencimientoCompra.Text = Operaciones.ConvertirEntero(coleccion(31).ToString)
  574. txtDiasAlVencimientoVenta.Text = Operaciones.ConvertirEntero(coleccion(32).ToString)
  575. txtDiasAcumuladosCompra.Text = Operaciones.ConvertirEntero(coleccion(33).ToString)
  576. txtDiasAcumuladosVenta.Text = Operaciones.ConvertirEntero(coleccion(34).ToString)
  577. txtYTMAlVencimientoCompra.Text = (Operaciones.ConvertirDecimal(coleccion(35).ToString) * 100).ToString + "%"
  578. txtYTMAlVencimientoVenta.Text = (Operaciones.ConvertirDecimal(coleccion(36).ToString) * 100).ToString + "%"
  579. txtPorcentajeInteresAcumuladoCompra.Text = (Operaciones.ConvertirDecimal(coleccion(37).ToString) * 100).ToString + "%"
  580. txtPorcentajeInteresAcumuladoVenta.Text = (Operaciones.ConvertirDecimal(coleccion(38).ToString) * 100).ToString + "%"
  581. txtInteresAcumuladoCompra.Text = Operaciones.ConvertirDecimal(coleccion(39).ToString)
  582. txtInteresAcumuladoVenta.Text = Operaciones.ConvertirDecimal(coleccion(40).ToString)
  583. txtPrecioSucioCompra.Text = Operaciones.ConvertirDecimal(coleccion(41).ToString) * 100
  584. txtPrecioSucioVenta.Text = Operaciones.ConvertirDecimal(coleccion(42).ToString) * 100
  585. txtComisionCompraCasa.Text = Operaciones.ConvertirDecimal(coleccion(43).ToString)
  586. txtComisionVentaCasa.Text = Operaciones.ConvertirDecimal(coleccion(44).ToString)
  587. txtComisionCompraBolsa.Text = Operaciones.ConvertirDecimal(coleccion(45).ToString)
  588. txtComisionVentaBolsa.Text = Operaciones.ConvertirDecimal(coleccion(46).ToString)
  589. txtValorTransadoCompra.Text = Operaciones.ConvertirDecimal(coleccion(47).ToString)
  590. txtValorTransadoVenta.Text = Operaciones.ConvertirDecimal(coleccion(48).ToString)
  591. txtMontoAPagar.Text = Operaciones.ConvertirDecimal(coleccion(49).ToString)
  592. txtMontoARecibir.Text = Operaciones.ConvertirDecimal(coleccion(50).ToString)
  593. txtCuponesRecibidos.Text = Operaciones.ConvertirEntero(coleccion(51).ToString)
  594. End If
  595. End Sub
  596. Sub Formato()
  597. If cboPeriodosC.SelectedIndex = -1 Then
  598. If cboPeriodosC.Items.Count > 0 Then
  599. cboPeriodosC.SelectedIndex = 0
  600. End If
  601. End If
  602. If cboPeriodosV.SelectedIndex = -1 Then
  603. If cboPeriodosV.Items.Count > 0 Then
  604. cboPeriodosV.SelectedIndex = 0
  605. End If
  606. End If
  607. If cboAnioBaseC.SelectedIndex = -1 Then
  608. If cboAnioBaseC.Items.Count > 0 Then
  609. cboAnioBaseC.SelectedIndex = 0
  610. End If
  611. End If
  612. If cboAnioBaseV.SelectedIndex = -1 Then
  613. If cboAnioBaseV.Items.Count > 0 Then
  614. cboAnioBaseV.SelectedIndex = 0
  615. End If
  616. End If
  617. If IsNumeric(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
  618. If Double.IsNaN(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
  619. txtPorcentajeInteresAcumuladoCompra.Text = "0.0%"
  620. End If
  621. End If
  622. If IsNumeric(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
  623. If Double.IsNaN(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
  624. txtPorcentajeInteresAcumuladoVenta.Text = "0.0%"
  625. End If
  626. End If
  627. If IsNumeric(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
  628. If Double.IsNaN(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
  629. txtPrecioSucioCompra.Text = "0.0%"
  630. End If
  631. End If
  632. If IsNumeric(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
  633. If Double.IsNaN(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
  634. txtPrecioSucioVenta.Text = "0.0%"
  635. End If
  636. End If
  637. If (String.IsNullOrEmpty(txtValorNominalCompra.Text.ToString)) Then
  638. txtValorNominalCompra.Text = "0.0"
  639. End If
  640. If (String.IsNullOrEmpty(txtDiasAlVencimientoCompra.Text)) Then
  641. txtDiasAlVencimientoCompra.Text = "0.0"
  642. End If
  643. If (String.IsNullOrEmpty(txtDiasAcumuladosCompra.Text)) Then
  644. txtDiasAcumuladosCompra.Text = "0.0"
  645. End If
  646. If (String.IsNullOrEmpty(txtPorcentajeCuponCompra.Text)) Then
  647. txtPorcentajeCuponCompra.Text = "0.0"
  648. End If
  649. If (String.IsNullOrEmpty(txtYTMAlVencimientoComisionCompra.Text)) Then
  650. txtYTMAlVencimientoComisionCompra.Text = "0.0"
  651. End If
  652. If (String.IsNullOrEmpty(txtYTMAlVencimientoCompra.Text)) Then
  653. txtYTMAlVencimientoCompra.Text = "0.0"
  654. End If
  655. If (String.IsNullOrEmpty(txtPrecioAlVencimientoCompra.Text)) Then
  656. txtPrecioAlVencimientoCompra.Text = "0.0"
  657. End If
  658. If (String.IsNullOrEmpty(txtPrecioCompra.Text)) Then
  659. txtPrecioCompra.Text = "0.0"
  660. End If
  661. If (String.IsNullOrEmpty(txtInteresAcumuladoCompra.Text)) Then
  662. txtInteresAcumuladoCompra.Text = "0.0"
  663. End If
  664. If (String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoCompra.Text)) Then
  665. txtPorcentajeInteresAcumuladoCompra.Text = "0.0"
  666. End If
  667. If (String.IsNullOrEmpty(txtPrecioSucioCompra.Text)) Then
  668. txtPrecioSucioCompra.Text = "0.0"
  669. End If
  670. If (String.IsNullOrEmpty(txtComisionPorCompraCasa.Text)) Then
  671. txtComisionPorCompraCasa.Text = "0.0"
  672. End If
  673. If (String.IsNullOrEmpty(txtComisionCompraCasa.Text)) Then
  674. txtComisionCompraCasa.Text = "0.0"
  675. End If
  676. If (String.IsNullOrEmpty(txtComisionPorBolsaCompra.Text)) Then
  677. txtComisionPorBolsaCompra.Text = "0.0"
  678. End If
  679. If (String.IsNullOrEmpty(txtComisionCompraBolsa.Text)) Then
  680. txtComisionCompraBolsa.Text = "0.0"
  681. End If
  682. If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
  683. txtValorTransadoCompra.Text = "0.0"
  684. End If
  685. If (String.IsNullOrEmpty(txtMontoAPagar.Text)) Then
  686. txtMontoAPagar.Text = "0.0"
  687. End If
  688. If (String.IsNullOrEmpty(txtCostoTransferenciaCompra.Text)) Then
  689. txtCostoTransferenciaCompra.Text = "0.0"
  690. End If
  691. If (String.IsNullOrEmpty(txtValorNominalVenta.Text)) Then
  692. txtValorNominalVenta.Text = "0.0"
  693. End If
  694. If (String.IsNullOrEmpty(txtDiasAlVencimientoVenta.Text)) Then
  695. txtDiasAlVencimientoVenta.Text = "0.0"
  696. End If
  697. If (String.IsNullOrEmpty(txtDiasAcumuladosVenta.Text)) Then
  698. txtDiasAcumuladosVenta.Text = "0.0"
  699. End If
  700. If (String.IsNullOrEmpty(txtPorcentajeCuponVenta.Text)) Then
  701. txtPorcentajeCuponVenta.Text = "0.0"
  702. End If
  703. If (String.IsNullOrEmpty(txtYTMAlVencimientoComisionVenta.Text)) Then
  704. txtYTMAlVencimientoComisionVenta.Text = "0.0"
  705. End If
  706. If (String.IsNullOrEmpty(txtYTMAlVencimientoVenta.Text)) Then
  707. txtYTMAlVencimientoVenta.Text = "0.0"
  708. End If
  709. If (String.IsNullOrEmpty(txtPrecioAlVencimientoVenta.Text)) Then
  710. txtPrecioAlVencimientoVenta.Text = "0.0"
  711. End If
  712. If (String.IsNullOrEmpty(txtPrecioVenta.Text)) Then
  713. txtPrecioVenta.Text = "0.0"
  714. End If
  715. If (String.IsNullOrEmpty(txtInteresAcumuladoVenta.Text)) Then
  716. txtInteresAcumuladoVenta.Text = "0.0"
  717. End If
  718. If (String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoVenta.Text)) Then
  719. txtPorcentajeInteresAcumuladoVenta.Text = "0.0"
  720. End If
  721. If (String.IsNullOrEmpty(txtPrecioSucioVenta.Text)) Then
  722. txtPrecioSucioVenta.Text = "0.0"
  723. End If
  724. If (String.IsNullOrEmpty(txtComisionPorVentaCasa.Text)) Then
  725. txtComisionPorVentaCasa.Text = "0.0"
  726. End If
  727. If (String.IsNullOrEmpty(txtComisionVentaCasa.Text)) Then
  728. txtComisionVentaCasa.Text = "0.0"
  729. End If
  730. If (String.IsNullOrEmpty(txtComisionPorBolsaVenta.Text)) Then
  731. txtComisionPorBolsaVenta.Text = "0.0"
  732. End If
  733. If (String.IsNullOrEmpty(txtComisionVentaBolsa.Text)) Then
  734. txtComisionVentaBolsa.Text = "0.0"
  735. End If
  736. If (String.IsNullOrEmpty(txtValorTransadoVenta.Text)) Then
  737. txtValorTransadoVenta.Text = "0.0"
  738. End If
  739. If (String.IsNullOrEmpty(txtMontoARecibir.Text)) Then
  740. txtMontoARecibir.Text = "0.0"
  741. End If
  742. If (String.IsNullOrEmpty(txtCuponesRecibidos.Text)) Then
  743. txtCuponesRecibidos.Text = "0.0"
  744. End If
  745. If (txtPorcentajeCuponCompra.ToString.IndexOf("%") = -1) Then
  746. txtPorcentajeCuponCompra.Text += "%"
  747. End If
  748. If (txtYTMAlVencimientoCompra.ToString.IndexOf("%") = -1) Then
  749. txtYTMAlVencimientoCompra.Text += "%"
  750. End If
  751. If (txtPorcentajeCuponVenta.ToString.IndexOf("%") = -1) Then
  752. txtPorcentajeCuponVenta.Text += "%"
  753. End If
  754. If (txtYTMAlVencimientoVenta.ToString.IndexOf("%") = -1) Then
  755. txtYTMAlVencimientoVenta.Text += "%"
  756. End If
  757. If (txtComisionPorCompraCasa.ToString.IndexOf("%") = -1) Then
  758. txtComisionPorCompraCasa.Text += "%"
  759. End If
  760. If (txtComisionPorBolsaCompra.ToString.IndexOf("%") = -1) Then
  761. txtComisionPorBolsaCompra.Text += "%"
  762. End If
  763. If (txtComisionPorVentaCasa.ToString.IndexOf("%") = -1) Then
  764. txtComisionPorVentaCasa.Text += "%"
  765. End If
  766. If (txtComisionPorBolsaVenta.ToString.IndexOf("%") = -1) Then
  767. txtComisionPorBolsaVenta.Text += "%"
  768. End If
  769. End Sub
  770. Sub Calculos()
  771. If (Not Cargar) Then
  772. Dim V_dtpSiguienteFechaCuponCompra = Date.Now.Date, V_dtpFechaVencimientoCompra = Date.Now.Date, V_dtpFechaLiquidacionCompra = Date.Now.Date, V_dtpUltimaFechaCuponCompra = Date.Now.Date
  773. Dim V_txtValorNominalCompra = 0.0, V_txtPorcentajeCuponCompra = 0.0, V_txtDiasAcumuladosCompra = 0, V_txtInteresAcumuladoCompra = 0.0
  774. Dim V_txtPorcentajeInteresAcumuladoCompra = 0.0, V_txtComisionPorCompraCasa = 0.0, V_txtValorTransadoCompra = 0.0
  775. Dim V_txtComisionPorBolsaCompra = 0.0, V_txtComisionCompraCasa = 0.0, V_txtComisionCompraBolsa = 0.0
  776. Dim V_txtYTMAlVencimientoCompra = 0.0, V_txtYTMAlVencimientoComisionCompra = 0.0, V_txtMontoAPagar = 0.0, V_txtPrecioCompra = 0.0
  777. Dim V_txtPrecioAlVencimientoCompra = 0.0, V_txtCostoTransferenciaCompra = 0.0, V_txtPrecioSucioCompra = 0.0
  778. Dim V_txtDiasAlVencimientoCompra = 0
  779. Dim TipoPeriodoCompra As Integer = 0
  780. Dim V_dtpSiguienteFechaCuponVenta = Date.Now.Date, V_dtpFechaVencimientoVenta = Date.Now.Date, V_dtpFechaLiquidacionVenta = Date.Now.Date, V_dtpUltimaFechaCuponVenta = Date.Now.Date
  781. Dim V_txtValorNominalVenta = 0.0, V_txtPorcentajeCuponVenta = 0.0, V_txtDiasAcumuladosVenta = 0, V_txtInteresAcumuladoVenta = 0.0
  782. Dim V_txtPorcentajeInteresAcumuladoVenta = 0.0, V_txtComisionPorVentaCasa = 0.0, V_txtValorTransadoVenta = 0.0
  783. Dim V_txtComisionPorBolsaVenta = 0.0, V_txtComisionVentaCasa = 0.0, V_txtComisionVentaBolsa = 0.0
  784. Dim V_txtYTMAlVencimientoVenta = 0.0, V_txtYTMAlVencimientoComisionVenta = 0.0, V_txtPrecioVenta = 0.0
  785. Dim V_txtPrecioAlVencimientoVenta = 0.0, V_txtCostoTransferenciaVenta = 0.0, V_txtPrecioSucioVenta = 0.0
  786. Dim V_txtDiasAlVencimientoVenta = 0.0, V_txtMontoARecibir = 0.0, V_txtCuponesRecibidos = 0.0
  787. Dim TipoPeriodoVenta As Integer = 0
  788. V_dtpSiguienteFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value
  789. V_dtpSiguienteFechaCuponVenta = dtpSiguienteFechaCuponVenta.Value
  790. V_dtpUltimaFechaCuponCompra = dtpUltimaFechaCuponCompra.Value
  791. V_dtpUltimaFechaCuponVenta = dtpUltimaFechaCuponVenta.Value
  792. V_dtpFechaVencimientoCompra = dtpFechaVencimientoCompra.Value
  793. V_dtpFechaVencimientoVenta = dtpFechaVencimientoVenta.Value
  794. V_dtpFechaLiquidacionCompra = dtpFechaLiquidacionCompra.Value
  795. V_dtpFechaLiquidacionVenta = dtpFechaLiquidacionVenta.Value
  796. V_txtValorNominalCompra = Operaciones.ConvertirDecimal(txtValorNominalCompra.Text.ToString)
  797. V_txtValorNominalVenta = Operaciones.ConvertirDecimal(txtValorNominalVenta.Text.ToString)
  798. V_txtPorcentajeCuponCompra = Operaciones.ConvertirDecimal(txtPorcentajeCuponCompra.Text.ToString) / 100
  799. V_txtPorcentajeCuponVenta = Operaciones.ConvertirDecimal(txtPorcentajeCuponVenta.Text.ToString) / 100
  800. V_txtYTMAlVencimientoCompra = Operaciones.ConvertirDecimal(txtYTMAlVencimientoCompra.Text.ToString) / 100
  801. V_txtYTMAlVencimientoVenta = Operaciones.ConvertirDecimal(txtYTMAlVencimientoVenta.Text.ToString) / 100
  802. V_txtPrecioCompra = Operaciones.ConvertirDecimal(txtPrecioCompra.Text.ToString)
  803. V_txtPrecioVenta = Operaciones.ConvertirDecimal(txtPrecioVenta.Text.ToString)
  804. V_txtPrecioAlVencimientoCompra = Operaciones.ConvertirDecimal(txtPrecioAlVencimientoCompra.Text.ToString)
  805. V_txtPrecioAlVencimientoVenta = Operaciones.ConvertirDecimal(txtPrecioAlVencimientoVenta.Text.ToString)
  806. V_txtComisionPorCompraCasa = Operaciones.ConvertirDecimal(txtComisionPorCompraCasa.Text.ToString) / 100
  807. V_txtComisionPorVentaCasa = Operaciones.ConvertirDecimal(txtComisionPorVentaCasa.Text.ToString) / 100
  808. V_txtComisionCompraCasa = Operaciones.ConvertirDecimal(txtComisionCompraCasa.Text.ToString)
  809. V_txtComisionVentaCasa = Operaciones.ConvertirDecimal(txtComisionVentaCasa.Text.ToString)
  810. V_txtComisionPorBolsaCompra = Operaciones.ConvertirDecimal(txtComisionPorBolsaCompra.Text.ToString) / 100
  811. V_txtComisionPorBolsaVenta = Operaciones.ConvertirDecimal(txtComisionPorBolsaVenta.Text.ToString) / 100
  812. V_txtComisionCompraBolsa = Operaciones.ConvertirDecimal(txtComisionCompraBolsa.Text.ToString)
  813. V_txtComisionVentaBolsa = Operaciones.ConvertirDecimal(txtComisionVentaBolsa.Text.ToString)
  814. V_txtCostoTransferenciaCompra = Operaciones.ConvertirDecimal(txtCostoTransferenciaCompra.Text.ToString)
  815. If (cboPeriodosC.SelectedValue = "M") Then
  816. TipoPeriodoCompra = 12
  817. PeriodoC = 1
  818. ElseIf (cboPeriodosC.SelectedValue = "T") Then
  819. TipoPeriodoCompra = 4
  820. PeriodoC = 3
  821. ElseIf (cboPeriodosC.SelectedValue = "S") Then
  822. TipoPeriodoCompra = 2
  823. PeriodoC = 6
  824. ElseIf (cboPeriodosC.SelectedValue = "A") Then
  825. TipoPeriodoCompra = 1
  826. PeriodoC = 12
  827. End If
  828. If (cboPeriodosV.SelectedValue = "M") Then
  829. TipoPeriodoVenta = 12
  830. PeriodoV = 1
  831. ElseIf (cboPeriodosV.SelectedValue = "T") Then
  832. TipoPeriodoVenta = 4
  833. PeriodoV = 3
  834. ElseIf (cboPeriodosV.SelectedValue = "S") Then
  835. TipoPeriodoVenta = 2
  836. PeriodoV = 6
  837. ElseIf (cboPeriodosV.SelectedValue = "A") Then
  838. TipoPeriodoVenta = 1
  839. PeriodoV = 12
  840. End If
  841. If cboAnioBaseC.SelectedIndex = 0 Then
  842. IndexBaseC = 0
  843. ElseIf cboAnioBaseC.SelectedIndex = 1 Then
  844. IndexBaseC = 1
  845. ElseIf cboAnioBaseC.SelectedIndex = 2 Then
  846. IndexBaseC = 2
  847. Else
  848. IndexBaseC = 3
  849. End If
  850. If cboAnioBaseV.SelectedIndex = 0 Then
  851. IndexBaseV = 0
  852. ElseIf cboAnioBaseV.SelectedIndex = 1 Then
  853. IndexBaseV = 1
  854. ElseIf cboAnioBaseV.SelectedIndex = 2 Then
  855. IndexBaseV = 2
  856. Else
  857. IndexBaseV = 3
  858. End If
  859. If (TipoDeCalculoDeFecha = 0) Then
  860. dtpUltimaFechaCuponCompra.Value = FechaCupon(V_dtpFechaLiquidacionCompra, V_dtpFechaVencimientoCompra, TipoPeriodoCompra)
  861. dtpUltimaFechaCuponVenta.Value = FechaCupon(V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, TipoPeriodoVenta)
  862. Else
  863. dtpSiguienteFechaCuponCompra.Value = FechaTipo(V_dtpUltimaFechaCuponCompra, TipoPeriodoCompra)
  864. dtpSiguienteFechaCuponVenta.Value = FechaTipo(V_dtpUltimaFechaCuponVenta, TipoPeriodoVenta)
  865. End If
  866. V_dtpSiguienteFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value
  867. V_dtpSiguienteFechaCuponVenta = dtpSiguienteFechaCuponVenta.Value
  868. V_dtpUltimaFechaCuponCompra = dtpUltimaFechaCuponCompra.Value
  869. V_dtpUltimaFechaCuponVenta = dtpUltimaFechaCuponVenta.Value
  870. V_dtpFechaVencimientoCompra = dtpFechaVencimientoCompra.Value
  871. V_dtpFechaVencimientoVenta = dtpFechaVencimientoVenta.Value
  872. V_dtpFechaLiquidacionCompra = dtpFechaLiquidacionCompra.Value
  873. V_dtpFechaLiquidacionVenta = dtpFechaLiquidacionVenta.Value
  874. 'Valores de Compra
  875. V_txtDiasAlVencimientoCompra = BonoCalculo.DiasVencimiento(V_dtpFechaLiquidacionCompra, V_dtpFechaVencimientoCompra, IndexBaseC)
  876. V_txtDiasAcumuladosCompra = Operaciones.DiasAcumulados(V_dtpUltimaFechaCuponCompra, V_dtpFechaLiquidacionCompra, IndexBaseC)
  877. V_txtInteresAcumuladoCompra = BonoCalculo.InteresAcumulado(V_txtValorNominalCompra, V_txtPorcentajeCuponCompra, V_dtpUltimaFechaCuponCompra, V_dtpFechaLiquidacionCompra, V_txtDiasAcumuladosCompra, IndexBaseC)
  878. V_txtPorcentajeInteresAcumuladoCompra = BonoCalculo.InteresAcumuladoPor(V_txtInteresAcumuladoCompra, V_txtValorNominalCompra, PeriodoC, IndexBaseC) * 100
  879. V_txtPrecioSucioCompra = BonoCalculo.PrecioSucio(V_txtPrecioCompra, V_txtPorcentajeInteresAcumuladoCompra / 100)
  880. V_txtValorTransadoCompra = BonoCalculo.ValorTrasado(V_txtPrecioCompra, V_txtValorNominalCompra)
  881. V_txtComisionCompraCasa = CalcularComision(V_txtComisionPorCompraCasa, V_txtValorTransadoCompra)
  882. V_txtComisionCompraBolsa = CalcularComision(V_txtComisionPorBolsaCompra, V_txtValorTransadoCompra)
  883. V_txtYTMAlVencimientoComisionCompra = Bonos.CalcularYTMComision(V_txtYTMAlVencimientoCompra, V_txtComisionPorCompraCasa, V_txtDiasAlVencimientoCompra, V_txtComisionPorBolsaCompra, V_dtpFechaLiquidacionCompra, V_dtpFechaVencimientoCompra, IndexBaseC)
  884. V_txtMontoAPagar = BonoCalculo.MontoPagar(V_txtValorTransadoCompra, V_txtComisionCompraBolsa, V_txtComisionCompraCasa, V_txtInteresAcumuladoCompra, V_txtCostoTransferenciaCompra)
  885. 'Valores de Venta
  886. V_txtDiasAlVencimientoVenta = BonoCalculo.DiasVencimiento(V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, IndexBaseV)
  887. V_txtDiasAcumuladosVenta = Operaciones.DiasAcumulados(V_dtpUltimaFechaCuponVenta, V_dtpFechaLiquidacionVenta, IndexBaseV)
  888. V_txtInteresAcumuladoVenta = BonoCalculo.InteresAcumulado(V_txtValorNominalVenta, V_txtPorcentajeCuponVenta, V_dtpUltimaFechaCuponVenta, V_dtpFechaLiquidacionVenta, V_txtDiasAcumuladosVenta, IndexBaseV)
  889. V_txtPorcentajeInteresAcumuladoVenta = BonoCalculo.InteresAcumuladoPor(V_txtInteresAcumuladoVenta, V_txtValorNominalVenta, PeriodoV, IndexBaseV) * 100
  890. V_txtPrecioSucioVenta = BonoCalculo.PrecioSucio(V_txtPrecioVenta, V_txtPorcentajeInteresAcumuladoVenta / 100)
  891. V_txtValorTransadoVenta = BonoCalculo.ValorTrasado(V_txtPrecioVenta, V_txtValorNominalVenta)
  892. V_txtComisionVentaCasa = CalcularComision(V_txtComisionPorVentaCasa, V_txtValorTransadoVenta)
  893. V_txtComisionVentaBolsa = CalcularComision(V_txtComisionPorBolsaVenta, V_txtValorTransadoVenta)
  894. V_txtYTMAlVencimientoComisionVenta = Bonos.CalcularYTMComision(V_txtYTMAlVencimientoVenta, V_txtComisionPorVentaCasa, V_txtDiasAlVencimientoVenta, V_txtComisionPorBolsaVenta, V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, IndexBaseV)
  895. V_txtMontoARecibir = BonoCalculo.MontoRecibir(V_txtValorTransadoVenta, V_txtComisionVentaBolsa, V_txtComisionVentaCasa, V_txtInteresAcumuladoVenta)
  896. V_txtCuponesRecibidos = Recibido()
  897. 'Valores de Compra
  898. txtDiasAlVencimientoCompra.Text = Format(V_txtDiasAlVencimientoCompra, "0.0000")
  899. txtDiasAcumuladosCompra.Text = Format(V_txtDiasAcumuladosCompra, "0.0000")
  900. txtInteresAcumuladoCompra.Text = Format(V_txtInteresAcumuladoCompra, "0.0000")
  901. txtPorcentajeInteresAcumuladoCompra.Text = CStr(Format(V_txtPorcentajeInteresAcumuladoCompra, "0.000")) + "%"
  902. txtPrecioSucioCompra.Text = Format(V_txtPrecioSucioCompra, "0.0000")
  903. txtValorTransadoCompra.Text = Format(V_txtValorTransadoCompra, "0.0000")
  904. txtComisionCompraCasa.Text = Format(V_txtComisionCompraCasa, "0.0000")
  905. txtComisionCompraBolsa.Text = Format(V_txtComisionCompraBolsa, "0.0000")
  906. txtYTMAlVencimientoComisionCompra.Text = CStr(Format(V_txtYTMAlVencimientoComisionCompra, "0.0000") * 100) + "%"
  907. txtMontoAPagar.Text = Format(V_txtMontoAPagar, "0.0000")
  908. txtComisionCompraCasa.Text = Format(V_txtComisionCompraCasa, "0.0000")
  909. txtComisionCompraBolsa.Text = Format(V_txtComisionCompraBolsa, "0.0000")
  910. 'Valores de Venta
  911. FechaCupon(V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, TipoPeriodoVenta)
  912. txtDiasAlVencimientoVenta.Text = Format(V_txtDiasAlVencimientoVenta, "0.0000")
  913. txtDiasAcumuladosVenta.Text = Format(V_txtDiasAcumuladosVenta, "0.0000")
  914. txtInteresAcumuladoVenta.Text = Format(V_txtInteresAcumuladoVenta, "0.0000")
  915. txtPorcentajeInteresAcumuladoVenta.Text = CStr(Format(V_txtPorcentajeInteresAcumuladoVenta, "0.0000")) + "%"
  916. txtPrecioSucioVenta.Text = Format(V_txtPrecioSucioVenta, "0.0000")
  917. txtValorTransadoVenta.Text = Format(V_txtValorTransadoVenta, "0.0000")
  918. txtComisionVentaCasa.Text = Format(V_txtComisionVentaCasa, "0.0000")
  919. txtComisionVentaBolsa.Text = Format(V_txtComisionVentaBolsa, "0.0000")
  920. txtYTMAlVencimientoComisionVenta.Text = CStr(Format(V_txtYTMAlVencimientoComisionVenta, "0.0000") * 100) + "%"
  921. txtMontoARecibir.Text = Format(V_txtMontoARecibir, "0.0000")
  922. txtCuponesRecibidos.Text = Format(V_txtCuponesRecibidos, "0.0000")
  923. txtComisionVentaCasa.Text = Format(V_txtComisionVentaCasa, "0.0000")
  924. txtComisionVentaBolsa.Text = Format(V_txtComisionVentaBolsa, "0.0000")
  925. End If
  926. CorrelativoSinBD()
  927. End Sub
  928. Function CalcularComision(ByVal Porcentaje As Double, ByVal VTransado As Double)
  929. Return Porcentaje * VTransado
  930. End Function
  931. Private Sub RefrescarClaseEntidad()
  932. ControlUltimaFechaCuponCompra()
  933. ControlSiguienteFechaCuponCompra()
  934. ControlFechaLiquidacionCompra()
  935. ControlFechaVencimientoCompra()
  936. ControlAnioBaseCompra()
  937. ControlUltimaFechaCuponCompra()
  938. ControlSiguienteFechaCuponCompra()
  939. ControlFechaLiquidacionCompra()
  940. ControlFechaVencimientoCompra()
  941. ControlAnioBaseCompra()
  942. End Sub
  943. Private Sub ControlPeriodosCompra()
  944. Dim valor As String
  945. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  946. If Me.cboPeriodosC.SelectedIndex = -1 Then
  947. valor = ""
  948. Else
  949. If (String.IsNullOrEmpty(Me.cboPeriodosC.SelectedValue)) Then
  950. valor = String.Empty
  951. Else
  952. valor = Me.cboPeriodosC.SelectedValue
  953. End If
  954. End If
  955. oCEPrincipal.PeriodicidadCompra = valor
  956. End If
  957. End Sub
  958. Function FechaTipo(ByVal ultimafecha As DateTime, ByVal frecuencia As Integer)
  959. Dim periodos As Integer = 0
  960. Dim Fecha As Date
  961. If frecuencia = 1 Then
  962. periodos = 12
  963. ElseIf frecuencia = 2 Then
  964. periodos = 6
  965. ElseIf frecuencia = 4 Then
  966. periodos = 3
  967. ElseIf frecuencia = 12 Then
  968. periodos = 1
  969. End If
  970. Fecha = ultimafecha.AddMonths(periodos)
  971. Return Fecha
  972. End Function
  973. Private Sub ControlUltimaFechaCuponCompra()
  974. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  975. Me.oCEPrincipal.UltimaFechaCuponCompra = dtpUltimaFechaCuponCompra.Value.Date
  976. End If
  977. End Sub
  978. Private Sub ControlSiguienteFechaCuponCompra()
  979. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  980. Me.oCEPrincipal.SiguienteFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value.Date
  981. End If
  982. End Sub
  983. Private Sub ControlFechaLiquidacionCompra()
  984. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  985. Me.oCEPrincipal.FechaLiquidacionCompra = dtpFechaLiquidacionCompra.Value.Date
  986. End If
  987. End Sub
  988. Private Sub ControlFechaVencimientoCompra()
  989. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  990. Me.oCEPrincipal.FechaVencimientoCompra = dtpFechaVencimientoCompra.Value.Date
  991. End If
  992. End Sub
  993. Private Sub ControlAnioBaseCompra()
  994. Dim valor As Integer
  995. If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
  996. valor = cboAnioBaseC.SelectedItem
  997. Me.oCEPrincipal.DiasBaseCompra = valor
  998. End If
  999. End Sub
  1000. Private Sub txtValorNominalCompra_LostFocus(sender As Object, e As EventArgs) Handles txtValorNominalCompra.LostFocus
  1001. End Sub
  1002. Private Sub txtPorcentajeCuponCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.LostFocus
  1003. End Sub
  1004. Private Sub txtPrecioAlVencimientoCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.LostFocus
  1005. End Sub
  1006. Private Sub txtPrecioCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioCompra.LostFocus
  1007. End Sub
  1008. Private Sub txtCostoTransferenciaCompra_LostFocus(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.LostFocus
  1009. End Sub
  1010. Private Sub dtpSiguienteFechaCuponVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpSiguienteFechaCuponVenta.ValueChanged
  1011. Formato()
  1012. Calculos()
  1013. ValidacionErrores()
  1014. End Sub
  1015. Private Sub txtCostoTransferenciaVenta_TextChanged(sender As Object, e As EventArgs)
  1016. End Sub
  1017. Private Sub dgvImpuestosYComisiones_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs)
  1018. End Sub
  1019. Private Sub dgvImpuestosYComisiones_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellContentClick
  1020. Formato()
  1021. End Sub
  1022. Private Sub dgvImpuestosYComisiones_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs)
  1023. oCEPrincipal.ImpuestosYComisiones.AcceptChanges()
  1024. End Sub
  1025. Private Sub PrepararTablaIngresos()
  1026. Dim CantidadColumnas As Integer = dgvIngresos.ColumnCount
  1027. If CantidadColumnas = 0 Then
  1028. Dim oDataGridViewTextBoxColumn As DataGridViewTextBoxColumn
  1029. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1030. oDataGridViewTextBoxColumn.Name = "CodInv"
  1031. oDataGridViewTextBoxColumn.DataPropertyName = "CodInv"
  1032. oDataGridViewTextBoxColumn.HeaderText = "Código Inversión"
  1033. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1034. oDataGridViewTextBoxColumn.Visible = False
  1035. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1036. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1037. oDataGridViewTextBoxColumn.Name = "NumCupon"
  1038. oDataGridViewTextBoxColumn.DataPropertyName = "NumCupon"
  1039. oDataGridViewTextBoxColumn.HeaderText = "No. Cupón"
  1040. oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
  1041. oDataGridViewTextBoxColumn.Visible = False
  1042. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1043. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1044. oDataGridViewTextBoxColumn.Name = "Correlativo"
  1045. oDataGridViewTextBoxColumn.DataPropertyName = "Correlativo"
  1046. oDataGridViewTextBoxColumn.HeaderText = "No. Cupón"
  1047. oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
  1048. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1049. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1050. oDataGridViewTextBoxColumn.Name = "FechaCupon"
  1051. oDataGridViewTextBoxColumn.DataPropertyName = "FechaCupon"
  1052. oDataGridViewTextBoxColumn.HeaderText = "Fecha Cupón"
  1053. oDataGridViewTextBoxColumn.ValueType = GetType(Date)
  1054. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1055. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1056. oDataGridViewTextBoxColumn.Name = "Dias"
  1057. oDataGridViewTextBoxColumn.DataPropertyName = "Dias"
  1058. oDataGridViewTextBoxColumn.HeaderText = "Dias "
  1059. oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
  1060. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1061. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1062. oDataGridViewTextBoxColumn.Name = "Ingreso"
  1063. oDataGridViewTextBoxColumn.DataPropertyName = "Ingreso"
  1064. oDataGridViewTextBoxColumn.HeaderText = "Ingreso"
  1065. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1066. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1067. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1068. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1069. oDataGridViewTextBoxColumn.Name = "PorcentajeImpuesto"
  1070. oDataGridViewTextBoxColumn.DataPropertyName = "PorcImpuesto"
  1071. oDataGridViewTextBoxColumn.HeaderText = "% Impuesto"
  1072. oDataGridViewTextBoxColumn.ValueType = GetType(String)
  1073. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1074. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1075. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1076. oDataGridViewTextBoxColumn.Name = "MontoImpuesto"
  1077. oDataGridViewTextBoxColumn.DataPropertyName = "MontoImpuesto"
  1078. oDataGridViewTextBoxColumn.HeaderText = "Impuesto"
  1079. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1080. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1081. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1082. oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
  1083. oDataGridViewTextBoxColumn.Name = "Liquido"
  1084. oDataGridViewTextBoxColumn.DataPropertyName = "Liquido"
  1085. oDataGridViewTextBoxColumn.HeaderText = "Liquido"
  1086. oDataGridViewTextBoxColumn.ValueType = GetType(Double)
  1087. oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
  1088. Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
  1089. End If
  1090. End Sub
  1091. Private Sub txtValorNominalVenta_LostFocus(sender As Object, e As EventArgs) Handles txtValorNominalVenta.LostFocus
  1092. End Sub
  1093. Private Sub txtPorcentajeCuponVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeCuponVenta.LostFocus
  1094. End Sub
  1095. Private Sub txtPrecioAlVencimientoVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoVenta.LostFocus
  1096. End Sub
  1097. Private Sub txtPrecioVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioVenta.LostFocus
  1098. End Sub
  1099. Private Sub dgvIngresos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  1100. End Sub
  1101. Private Sub dgvIngresos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvIngresos.CellBeginEdit
  1102. End Sub
  1103. Private Sub dgvIngresos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellEndEdit
  1104. Dim Tabla As String = Instrumento()
  1105. If Not Tabla = "TIT" Then
  1106. CalculoIngresosBONO()
  1107. End If
  1108. End Sub
  1109. Private Sub dgvIngresos_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs) Handles dgvIngresos.UserDeletedRow
  1110. oCEPrincipal.Ingresos.AcceptChanges()
  1111. End Sub
  1112. Private Sub txtValorNominal_Op_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominal_Op.TextChanged
  1113. End Sub
  1114. Private Sub LLenarResultadosOperacion()
  1115. Dim FechaCompra = dtpFechaLiquidacionCompra.Value
  1116. Dim FechaVenta = dtpFechaLiquidacionVenta.Value
  1117. Dim Dias As Integer = Operaciones.Dias(FechaCompra, FechaVenta, IndexBaseC)
  1118. txtValorNominal_Op.Text = Operaciones.ConvertirDecimal(txtValorNominalCompra.Text.ToString)
  1119. txtPlazo_Op.Text = Operaciones.ConvertirDecimal(PlazoOperacion().ToString)
  1120. txtPrecioCompra_Op.Text = Operaciones.ConvertirDecimal(txtPrecioCompra.Text.ToString)
  1121. txtPrecioVenta_Op.Text = Operaciones.ConvertirDecimal(txtPrecioVenta.Text.ToString)
  1122. txtGananciaPerdidaCapital_Op.Text = Operaciones.ConvertirDecimal(GananciaPerdida().ToString)
  1123. txtIngresosPorIntereses_Op.Text = Operaciones.ConvertirDecimal(IngresosInteres().ToString)
  1124. txtCostosTotales_Op.Text = Operaciones.ConvertirDecimal(CostosTotales().ToString)
  1125. txtGananciaPerdidaTotal_Op.Text = Operaciones.ConvertirDecimal(MontoGananciaPerdida().ToString)
  1126. txtRendimientoGananciaPerdida_Op.Text = Operaciones.ConvertirDecimal(RendimientoGananciaPerdida(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
  1127. txtRendimientoIntereses_Op.Text = Operaciones.ConvertirDecimal(RendimientoInteres(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
  1128. txtRendimientoAntesISR_Op.Text = Operaciones.ConvertirDecimal(RendimientoNeto(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
  1129. txtRendimientoDespuesISR_Op.Text = Operaciones.ConvertirDecimal(RendimientoNetoDespues(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
  1130. End Sub
  1131. Private Function PlazoOperacion()
  1132. Dim FechaVenta As Date = dtpFechaLiquidacionVenta.Value
  1133. Dim FechaCompra As Date = dtpFechaLiquidacionCompra.Value
  1134. Dim Dias = Operaciones.Dias(FechaCompra, FechaVenta, IndexBaseC)
  1135. Return Dias
  1136. End Function
  1137. Private Function GananciaPerdida()
  1138. Dim ValorTrasadoVenta As Double = Operaciones.ConvertirDecimal(txtValorTransadoVenta.Text.ToString)
  1139. Dim ValorTrasadoCompra As Double = Operaciones.ConvertirDecimal(txtValorTransadoCompra.Text.ToString)
  1140. Dim Total = ValorTrasadoVenta - ValorTrasadoCompra
  1141. Return Total
  1142. End Function
  1143. Private Function IngresosInteres()
  1144. Dim Registros = dgvIngresos.Rows.Count
  1145. Dim Suma As Double = 0.0
  1146. Registros = Registros - 2
  1147. For i As Integer = 0 To Registros
  1148. Suma = Suma + Double.Parse(dgvIngresos.Item(4, i).Value)
  1149. Next
  1150. Dim InteresAcumulado As Double = Operaciones.ConvertirDecimal(txtInteresAcumuladoVenta.Text.ToString)
  1151. Return (Suma + InteresAcumulado)
  1152. End Function
  1153. Private Function CostosTotales()
  1154. Dim ComisionCompraCasa As Double = Operaciones.ConvertirDecimal(txtComisionCompraCasa.Text.ToString)
  1155. Dim ComisionVentaCasa As Double = Operaciones.ConvertirDecimal(txtComisionVentaCasa.Text.ToString)
  1156. Dim ComisionCompraBolsa = Operaciones.ConvertirDecimal(txtComisionCompraBolsa.Text.ToString)
  1157. Dim ComisionVentaBolsa = Operaciones.ConvertirDecimal(txtComisionVentaBolsa.Text.ToString)
  1158. Dim CostoTransferenciaCompra = Operaciones.ConvertirDecimal(txtCostoTransferenciaCompra.Text.ToString)
  1159. If (Double.TryParse(ComisionCompraCasa, Nothing) And Double.TryParse(ComisionCompraBolsa, Nothing) And Double.TryParse(CostoTransferenciaCompra, Nothing) And Double.TryParse(ComisionCompraBolsa, Nothing) And Double.TryParse(ComisionVentaBolsa, Nothing)) Then
  1160. Dim Total = (CDec(ComisionCompraCasa) + CDec(ComisionCompraBolsa) + CDec(CostoTransferenciaCompra) + CDec(ComisionVentaCasa) + CDec(ComisionVentaBolsa)) * -1
  1161. Return Total
  1162. End If
  1163. Return "0"
  1164. End Function
  1165. Private Function MontoGananciaPerdida()
  1166. Dim GananciaPerdida As Double = Operaciones.ConvertirDecimal(txtGananciaPerdidaCapital_Op.Text.ToString)
  1167. Dim CostosTotales As Double = Operaciones.ConvertirDecimal(txtCostosTotales_Op.Text.ToString)
  1168. Dim IngresoInteres As Double = Operaciones.ConvertirDecimal(txtIngresosPorIntereses_Op.Text.ToString)
  1169. Dim Total = GananciaPerdida + CostosTotales + IngresoInteres
  1170. Return Total
  1171. End Function
  1172. Private Function RendimientoGananciaPerdida(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
  1173. Dim GananciaCapital As Double = Operaciones.ConvertirDecimal(txtGananciaPerdidaCapital_Op.Text.ToString)
  1174. Dim ValorNominal As Double = Operaciones.ConvertirDecimal(txtValorNominal_Op.Text.ToString)
  1175. Dim Valor As Double = 0
  1176. If (IndexBase = 0) Then
  1177. Valor = GananciaCapital / ValorNominal * 360 / Dias
  1178. Return (Valor * 100).ToString() + "%"
  1179. ElseIf (IndexBase = 1) Then
  1180. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1181. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1182. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1183. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1184. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1185. PrOpc1 = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
  1186. PrOpc2 = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
  1187. Valor = PrOpc1 + PrOpc2
  1188. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1189. Valor = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
  1190. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1191. Valor = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
  1192. Else
  1193. Valor = 0
  1194. End If
  1195. Return (Valor * 100).ToString() + "%"
  1196. ElseIf (IndexBase = 2) Then
  1197. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1198. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1199. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1200. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1201. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1202. PrOpc1 = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
  1203. PrOpc2 = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
  1204. Valor = PrOpc1 + PrOpc2
  1205. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1206. Valor = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
  1207. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1208. Valor = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
  1209. Else
  1210. Valor = 0
  1211. End If
  1212. Return (Valor * 100).ToString() + "%"
  1213. Else
  1214. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1215. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1216. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1217. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1218. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1219. PrOpc1 = GananciaCapital / ValorNominal * 360 / DiasPrimeraFecha
  1220. PrOpc2 = GananciaCapital / ValorNominal * 360 / DiasSegundaFecha
  1221. Valor = PrOpc1 + PrOpc2
  1222. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1223. Valor = GananciaCapital / ValorNominal * 360 / DiasSegundaFecha
  1224. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1225. Valor = GananciaCapital / ValorNominal * 360 / DiasPrimeraFecha
  1226. Else
  1227. Valor = 0
  1228. End If
  1229. Return (Valor * 100).ToString() + "%"
  1230. End If
  1231. Return (Valor * 100).ToString() + "%"
  1232. End Function
  1233. Private Function RendimientoInteres(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
  1234. Dim IngresosInteres As Double = Operaciones.ConvertirDecimal(txtIngresosPorIntereses_Op.Text.ToString)
  1235. Dim ValorNominal As Double = Operaciones.ConvertirDecimal(txtValorNominal_Op.Text.ToString)
  1236. Dim Valor As Double = 0
  1237. If (IndexBase = 0) Then
  1238. Valor = IngresosInteres / ValorNominal * 360 / Dias
  1239. Return (Valor * 100).ToString() + "%"
  1240. ElseIf (IndexBase = 1) Then
  1241. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1242. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1243. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1244. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1245. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1246. PrOpc1 = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
  1247. PrOpc2 = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
  1248. Valor = PrOpc1 + PrOpc2
  1249. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1250. Valor = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
  1251. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1252. Valor = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
  1253. Else
  1254. Valor = 0
  1255. End If
  1256. Return (Valor * 100).ToString() + "%"
  1257. ElseIf (IndexBase = 2) Then
  1258. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1259. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1260. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1261. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1262. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1263. PrOpc1 = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
  1264. PrOpc2 = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
  1265. Valor = PrOpc1 + PrOpc2
  1266. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1267. Valor = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
  1268. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1269. Valor = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
  1270. Else
  1271. Valor = 0
  1272. End If
  1273. Return (Valor * 100).ToString() + "%"
  1274. Else
  1275. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1276. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1277. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1278. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1279. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1280. PrOpc1 = IngresosInteres / ValorNominal * 360 / DiasPrimeraFecha
  1281. PrOpc2 = IngresosInteres / ValorNominal * 360 / DiasSegundaFecha
  1282. Valor = PrOpc1 + PrOpc2
  1283. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1284. Valor = IngresosInteres / ValorNominal * 360 / DiasSegundaFecha
  1285. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1286. Valor = IngresosInteres / ValorNominal * 360 / DiasPrimeraFecha
  1287. Else
  1288. Valor = 0
  1289. End If
  1290. Return (Valor * 100).ToString() + "%"
  1291. End If
  1292. End Function
  1293. Private Function RendimientoNeto(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
  1294. Dim MontoGananciaPerdidaTotal As Double = Operaciones.ConvertirDecimal(txtGananciaPerdidaTotal_Op.Text.ToString)
  1295. Dim ValorNominal As Double = Operaciones.ConvertirDecimal(txtValorNominal_Op.Text.ToString)
  1296. Dim Valor As Double = 0
  1297. If (IndexBase = 0) Then
  1298. Valor = MontoGananciaPerdidaTotal / ValorNominal * 360 / Dias
  1299. Return (Valor * 100).ToString() + "%"
  1300. ElseIf (IndexBase = 1) Then
  1301. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1302. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1303. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1304. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1305. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1306. PrOpc1 = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
  1307. PrOpc2 = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
  1308. Valor = PrOpc1 + PrOpc2
  1309. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1310. Valor = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
  1311. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1312. Valor = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
  1313. Else
  1314. Valor = 0
  1315. End If
  1316. Return (Valor * 100).ToString() + "%"
  1317. ElseIf (IndexBase = 2) Then
  1318. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1319. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1320. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1321. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1322. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1323. PrOpc1 = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
  1324. PrOpc2 = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
  1325. Valor = PrOpc1 + PrOpc2
  1326. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1327. Valor = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
  1328. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1329. Valor = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
  1330. Else
  1331. Valor = 0
  1332. End If
  1333. Return (Valor * 100).ToString() + "%"
  1334. Else
  1335. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1336. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1337. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1338. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1339. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1340. PrOpc1 = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasPrimeraFecha
  1341. PrOpc2 = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasSegundaFecha
  1342. Valor = PrOpc1 + PrOpc2
  1343. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1344. Valor = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasSegundaFecha
  1345. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1346. Valor = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasPrimeraFecha
  1347. Else
  1348. Valor = 0
  1349. End If
  1350. Return (Valor * 100).ToString() + "%"
  1351. End If
  1352. End Function
  1353. Private Function Recibido()
  1354. Dim Registros = dgvIngresos.Rows.Count
  1355. Dim Suma As Double = 0.0
  1356. Registros = Registros - 1
  1357. For i As Integer = 0 To Registros
  1358. Suma = Suma + Operaciones.ConvertirDecimal(dgvIngresos.Rows(i).Cells("Ingreso").Value)
  1359. Next
  1360. Return Suma
  1361. End Function
  1362. Private Function RendimientoNetoDespues(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
  1363. Dim Registros = dgvIngresos.Rows.Count
  1364. Dim Suma As Double = 0.0
  1365. Registros = Registros - 1
  1366. For i As Integer = 0 To Registros
  1367. Suma = Suma + Operaciones.ConvertirDecimal(dgvIngresos.Rows(i).Cells("MontoImpuesto").Value)
  1368. Next
  1369. Dim MontoGananciaTotal As Double = Operaciones.ConvertirDecimal(txtGananciaPerdidaTotal_Op.Text.ToString)
  1370. Dim Impuesto As Double = Suma
  1371. Dim ValorNominal As Double = Operaciones.ConvertirDecimal(txtValorNominal_Op.Text.ToString)
  1372. Dim Valor As Double = 0
  1373. If (IndexBase = 0) Then
  1374. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / Dias
  1375. Return (Valor * 100).ToString() + "%"
  1376. ElseIf (IndexBase = 1) Then
  1377. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1378. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1379. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1380. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1381. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1382. PrOpc1 = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
  1383. PrOpc2 = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
  1384. Valor = PrOpc1 + PrOpc2
  1385. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1386. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
  1387. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1388. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
  1389. Else
  1390. Valor = 0
  1391. End If
  1392. Return (Valor * 100).ToString() + "%"
  1393. ElseIf (IndexBase = 2) Then
  1394. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1395. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1396. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1397. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1398. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1399. PrOpc1 = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
  1400. PrOpc2 = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
  1401. Valor = PrOpc1 + PrOpc2
  1402. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1403. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
  1404. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1405. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
  1406. Else
  1407. Valor = 0
  1408. End If
  1409. Return (Valor * 100).ToString() + "%"
  1410. Else
  1411. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1412. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1413. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1414. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1415. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1416. PrOpc1 = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasPrimeraFecha
  1417. PrOpc2 = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasSegundaFecha
  1418. Valor = PrOpc1 + PrOpc2
  1419. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1420. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasSegundaFecha
  1421. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1422. Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasPrimeraFecha
  1423. Else
  1424. Valor = 0
  1425. End If
  1426. Return (Valor * 100).ToString() + "%"
  1427. End If
  1428. End Function
  1429. Private Sub TabPage4_Click(sender As Object, e As EventArgs) Handles TabPage4.Click
  1430. End Sub
  1431. Private Sub TabPage1_Click(sender As Object, e As EventArgs) Handles TabPage1.Click
  1432. End Sub
  1433. Private Sub TabPage2_Click(sender As Object, e As EventArgs) Handles TbIngresos.Click
  1434. End Sub
  1435. Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
  1436. TipoTransaccion = "M"
  1437. btnAceptar.Text = "Modificar"
  1438. 'btnAccionComisiones.Text = "Modificar"
  1439. End Sub
  1440. Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
  1441. TipoTransaccion = "N"
  1442. btnAceptar.Text = "Nuevo"
  1443. End Sub
  1444. Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
  1445. TipoTransaccion = "B"
  1446. btnAceptar.Text = "Eliminar"
  1447. End Sub
  1448. Private Sub txtYTMAlVencimientoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoCompra.TextChanged
  1449. Calculos()
  1450. ValidacionErrores()
  1451. End Sub
  1452. Private Sub txtPorcentajeInteresAcumuladoVenta_TextChanged(sender As Object, e As EventArgs)
  1453. End Sub
  1454. Private Sub txtYTMAlVencimientoComisionCompra_TextChanged(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoComisionCompra.TextChanged
  1455. End Sub
  1456. Private Sub txtValorNominalVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominalVenta.TextChanged
  1457. Calculos()
  1458. ValidacionErrores()
  1459. End Sub
  1460. Private Sub txtPorcentajeCuponVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeCuponVenta.TextChanged
  1461. Calculos()
  1462. ValidacionErrores()
  1463. End Sub
  1464. Private Sub txtPrecioAlVencimientoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoVenta.TextChanged
  1465. Calculos()
  1466. ValidacionErrores()
  1467. End Sub
  1468. Private Sub txtValorNominalCompra_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominalCompra.TextChanged
  1469. Calculos()
  1470. ValidacionErrores()
  1471. End Sub
  1472. Private Sub txtPrecioSucioCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioCompra.TextChanged
  1473. End Sub
  1474. Private Sub Button1_Click(sender As Object, e As EventArgs)
  1475. RefrescarValorControles()
  1476. End Sub
  1477. Private Sub txtPrecioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioVenta.TextChanged
  1478. Calculos()
  1479. ValidacionErrores()
  1480. End Sub
  1481. Private Sub btnAccionIngreso_Click(sender As Object, e As EventArgs)
  1482. End Sub
  1483. Private Sub TabControl1_TabIndexChanged(sender As Object, e As EventArgs) Handles TabCampos.TabIndexChanged
  1484. Formato()
  1485. Formato()
  1486. End Sub
  1487. Private Sub dgvIngresos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellClick
  1488. Index = e.RowIndex
  1489. PrepararCalculos()
  1490. Formato()
  1491. End Sub
  1492. Private Sub txtDiasAcumuladosCompra_TextChanged(sender As Object, e As EventArgs) Handles txtDiasAcumuladosCompra.TextChanged
  1493. End Sub
  1494. Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabCampos.SelectedIndexChanged
  1495. ValidacionErrores()
  1496. BotonQuitar()
  1497. If (dgvIngresos.Rows.Count < 2) Then
  1498. End If
  1499. If (TabCampos.SelectedIndex = 2) Or (TabCampos.SelectedIndex = 1) Then
  1500. LLenarResultadosOperacion()
  1501. End If
  1502. End Sub
  1503. Private Sub dtpUltimaFechaCuponVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpUltimaFechaCuponVenta.ValueChanged
  1504. Formato()
  1505. Calculos()
  1506. ValidacionErrores()
  1507. End Sub
  1508. Private Sub dtpFechaLiquidacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacionVenta.ValueChanged
  1509. Formato()
  1510. Calculos()
  1511. ValidacionErrores()
  1512. End Sub
  1513. Private Sub txtYTMAlVencimientoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoVenta.TextChanged
  1514. Calculos()
  1515. ValidacionErrores()
  1516. End Sub
  1517. Private Sub btnAmortizacion_Click(sender As Object, e As EventArgs)
  1518. frmResultadoTitularizacion.Show()
  1519. End Sub
  1520. Function ColeccionIngresos(ByRef index As Integer)
  1521. Dim coleccion As New Collection
  1522. Dim NoCupon, Fecha, Ingreso, PorcImpuesto, Impuesto, Dias, Liquido As String
  1523. NoCupon = dgvIngresos.Rows(index).Cells("NumCupon").Value
  1524. Fecha = dgvIngresos.Rows(index).Cells("FechaCupon").Value
  1525. Dias = dgvIngresos.Rows(index).Cells("Dias").Value
  1526. Ingreso = dgvIngresos.Rows(index).Cells("Ingreso").Value
  1527. PorcImpuesto = dgvIngresos.Rows(index).Cells("PorcentajeImpuesto").Value
  1528. If Not PorcImpuesto Is Nothing Then
  1529. PorcImpuesto = CDec((PorcImpuesto.ToString().Trim("%")) / 100)
  1530. End If
  1531. Impuesto = dgvIngresos.Rows(index).Cells("MontoImpuesto").Value
  1532. Liquido = dgvIngresos.Rows(index).Cells("Liquido").Value
  1533. coleccion.Add(NoCupon)
  1534. coleccion.Add(Fecha)
  1535. coleccion.Add(Dias)
  1536. coleccion.Add(Ingreso)
  1537. coleccion.Add(PorcImpuesto)
  1538. coleccion.Add(Impuesto)
  1539. coleccion.Add(Liquido)
  1540. Return coleccion
  1541. End Function
  1542. Function Instrumento()
  1543. Dim codigo As String = Variables.Codigo
  1544. Dim Tabla As String = String.Empty
  1545. If codigo.IndexOf("TIT") > -1 Then
  1546. Tabla = "TIT"
  1547. ElseIf codigo.IndexOf("EURB") > -1 Then
  1548. Tabla = "EURB"
  1549. ElseIf codigo.IndexOf("BONO") > -1 Then
  1550. Tabla = "BONO"
  1551. ElseIf codigo.IndexOf("CINV") > -1 Then
  1552. Tabla = "CINV"
  1553. End If
  1554. Return Tabla
  1555. End Function
  1556. Function ModificarIngreso()
  1557. Dim i As Integer = 0
  1558. Dim Cantidad As Integer = dgvIngresos.Rows.Count - 2
  1559. Dim Diccionario As New Dictionary(Of Integer, Collection)
  1560. While i <= Cantidad
  1561. Dim coleccion = ColeccionIngresos(i)
  1562. Diccionario.Add(i, coleccion)
  1563. i += 1
  1564. End While
  1565. Return Diccionario
  1566. End Function
  1567. Sub CargarIngresos()
  1568. Dim codigo As String = Variables.Codigo
  1569. Dim dr = BonosConsulta.CargarIngreso(codigo, Instrumento)
  1570. While dr.Read
  1571. Dim Porc = dr("PorcImpuesto")
  1572. If String.IsNullOrEmpty(Porc.ToString) Then
  1573. Porc = "0.0%"
  1574. Else
  1575. Porc = (Porc * 100).ToString + "%"
  1576. End If
  1577. dgvIngresos.Rows.Add("", dr("NumCupon"), "", dr("FechaCupon"), dr("Dias"), dr("Ingreso"), Porc, dr("MontoImpuesto"), dr("Liquido"))
  1578. End While
  1579. End Sub
  1580. Private Sub txtComisionPorCompraCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorCompraCasa.TextChanged
  1581. Calculos()
  1582. ValidacionErrores()
  1583. End Sub
  1584. Private Sub txtComisionPorBolsaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorBolsaCompra.TextChanged
  1585. Calculos()
  1586. ValidacionErrores()
  1587. End Sub
  1588. Private Sub txtComisionPorVentaCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorVentaCasa.TextChanged
  1589. Calculos()
  1590. ValidacionErrores()
  1591. End Sub
  1592. Private Sub txtComisionPorBolsaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorBolsaVenta.TextChanged
  1593. Calculos()
  1594. ValidacionErrores()
  1595. End Sub
  1596. Private Sub txtMontoARecibir_TextChanged(sender As Object, e As EventArgs) Handles txtMontoARecibir.TextChanged
  1597. Calculos()
  1598. End Sub
  1599. Private Sub txtCostosTotales_Op_TextChanged(sender As Object, e As EventArgs) Handles txtCostosTotales_Op.TextChanged
  1600. End Sub
  1601. Private Sub txtRendimientoDespuesISR_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoDespuesISR_Op.TextChanged
  1602. End Sub
  1603. Private Sub txtPrecioSucioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioVenta.TextChanged
  1604. End Sub
  1605. Private Sub txtGananciaPerdidaCapital_Op_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaPerdidaCapital_Op.TextChanged
  1606. End Sub
  1607. Private Sub txtValorNominalCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorNominalCompra.KeyPress
  1608. If String.IsNullOrEmpty(txtValorNominalCompra.Text) Then
  1609. If e.KeyChar = "." Then
  1610. txtValorNominalCompra.Text = "0"
  1611. Exit Sub
  1612. End If
  1613. End If
  1614. If (Not txtValorNominalCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1615. Operaciones.ValidarEntrada(sender, e, True)
  1616. Else
  1617. Operaciones.ValidarEntrada(sender, e, False)
  1618. End If
  1619. End Sub
  1620. Private Sub txtValorNominalVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorNominalVenta.KeyPress
  1621. If String.IsNullOrEmpty(txtValorNominalVenta.Text) Then
  1622. If e.KeyChar = "." Then
  1623. txtValorNominalVenta.Text = "0"
  1624. Exit Sub
  1625. End If
  1626. End If
  1627. If (Not txtValorNominalVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1628. Operaciones.ValidarEntrada(sender, e, True)
  1629. Else
  1630. Operaciones.ValidarEntrada(sender, e, False)
  1631. End If
  1632. End Sub
  1633. Private Sub txtPorcentajeCuponCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeCuponCompra.KeyPress
  1634. If String.IsNullOrEmpty(txtPorcentajeCuponCompra.Text) Then
  1635. If e.KeyChar = "." Then
  1636. txtPorcentajeCuponCompra.Text = "0"
  1637. Exit Sub
  1638. End If
  1639. End If
  1640. If (Not txtPorcentajeCuponCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1641. Operaciones.ValidarEntrada(sender, e, True)
  1642. Else
  1643. Operaciones.ValidarEntrada(sender, e, False)
  1644. End If
  1645. End Sub
  1646. Private Sub txtPorcentajeCuponVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeCuponVenta.KeyPress
  1647. If String.IsNullOrEmpty(txtPorcentajeCuponVenta.Text) Then
  1648. If e.KeyChar = "." Then
  1649. txtPorcentajeCuponVenta.Text = "0"
  1650. Exit Sub
  1651. End If
  1652. End If
  1653. If (Not txtPorcentajeCuponVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1654. Operaciones.ValidarEntrada(sender, e, True)
  1655. Else
  1656. Operaciones.ValidarEntrada(sender, e, False)
  1657. End If
  1658. End Sub
  1659. Private Sub txtYTMAlVencimientoCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtYTMAlVencimientoCompra.KeyPress
  1660. If String.IsNullOrEmpty(txtYTMAlVencimientoCompra.Text) Then
  1661. If e.KeyChar = "." Then
  1662. txtYTMAlVencimientoCompra.Text = "0"
  1663. Exit Sub
  1664. End If
  1665. End If
  1666. If (Not txtYTMAlVencimientoCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1667. Operaciones.ValidarEntrada(sender, e, True)
  1668. Else
  1669. Operaciones.ValidarEntrada(sender, e, False)
  1670. End If
  1671. End Sub
  1672. Private Sub txtYTMAlVencimientoVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtYTMAlVencimientoVenta.KeyPress
  1673. If String.IsNullOrEmpty(txtYTMAlVencimientoVenta.Text) Then
  1674. If e.KeyChar = "." Then
  1675. txtYTMAlVencimientoVenta.Text = "0"
  1676. Exit Sub
  1677. End If
  1678. End If
  1679. If (Not txtYTMAlVencimientoVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1680. Operaciones.ValidarEntrada(sender, e, True)
  1681. Else
  1682. Operaciones.ValidarEntrada(sender, e, False)
  1683. End If
  1684. End Sub
  1685. Private Sub txtPrecioAlVencimientoCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioAlVencimientoCompra.KeyPress
  1686. If String.IsNullOrEmpty(txtPrecioAlVencimientoCompra.Text) Then
  1687. If e.KeyChar = "." Then
  1688. txtPrecioAlVencimientoCompra.Text = "0"
  1689. Exit Sub
  1690. End If
  1691. End If
  1692. If (Not txtPrecioAlVencimientoCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1693. Operaciones.ValidarEntrada(sender, e, True)
  1694. Else
  1695. Operaciones.ValidarEntrada(sender, e, False)
  1696. End If
  1697. End Sub
  1698. Private Sub txtPrecioAlVencimientoVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioAlVencimientoVenta.KeyPress
  1699. If String.IsNullOrEmpty(txtPrecioAlVencimientoVenta.Text) Then
  1700. If e.KeyChar = "." Then
  1701. txtPrecioAlVencimientoVenta.Text = "0"
  1702. Exit Sub
  1703. End If
  1704. End If
  1705. If (Not txtPrecioAlVencimientoVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1706. Operaciones.ValidarEntrada(sender, e, True)
  1707. Else
  1708. Operaciones.ValidarEntrada(sender, e, False)
  1709. End If
  1710. End Sub
  1711. Private Sub txtPrecioCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioCompra.KeyPress
  1712. If String.IsNullOrEmpty(txtPrecioCompra.Text) Then
  1713. If e.KeyChar = "." Then
  1714. txtPrecioCompra.Text = "0"
  1715. Exit Sub
  1716. End If
  1717. End If
  1718. If (Not txtPrecioCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1719. Operaciones.ValidarEntrada(sender, e, True)
  1720. Else
  1721. Operaciones.ValidarEntrada(sender, e, False)
  1722. End If
  1723. End Sub
  1724. Private Sub txtPrecioVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioVenta.KeyPress
  1725. If String.IsNullOrEmpty(txtPrecioVenta.Text) Then
  1726. If e.KeyChar = "." Then
  1727. txtPrecioVenta.Text = "0"
  1728. Exit Sub
  1729. End If
  1730. End If
  1731. If (Not txtPrecioVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1732. Operaciones.ValidarEntrada(sender, e, True)
  1733. Else
  1734. Operaciones.ValidarEntrada(sender, e, False)
  1735. End If
  1736. End Sub
  1737. Private Sub txtComisionPorCompraCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorCompraCasa.KeyPress
  1738. If String.IsNullOrEmpty(txtComisionPorCompraCasa.Text) Then
  1739. If e.KeyChar = "." Then
  1740. txtComisionPorCompraCasa.Text = "0"
  1741. Exit Sub
  1742. End If
  1743. End If
  1744. If (Not txtComisionPorCompraCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1745. Operaciones.ValidarEntrada(sender, e, True)
  1746. Else
  1747. Operaciones.ValidarEntrada(sender, e, False)
  1748. End If
  1749. End Sub
  1750. Private Sub txtComisionPorVentaCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorVentaCasa.KeyPress
  1751. If String.IsNullOrEmpty(txtComisionPorVentaCasa.Text) Then
  1752. If e.KeyChar = "." Then
  1753. txtComisionPorVentaCasa.Text = "0"
  1754. Exit Sub
  1755. End If
  1756. End If
  1757. If (Not txtComisionPorVentaCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1758. Operaciones.ValidarEntrada(sender, e, True)
  1759. Else
  1760. Operaciones.ValidarEntrada(sender, e, False)
  1761. End If
  1762. End Sub
  1763. Private Sub txtComisionPorBolsaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorBolsaCompra.KeyPress
  1764. If String.IsNullOrEmpty(txtComisionPorBolsaCompra.Text) Then
  1765. If e.KeyChar = "." Then
  1766. txtComisionPorBolsaCompra.Text = "0"
  1767. Exit Sub
  1768. End If
  1769. End If
  1770. If (Not txtComisionPorBolsaCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1771. Operaciones.ValidarEntrada(sender, e, True)
  1772. Else
  1773. Operaciones.ValidarEntrada(sender, e, False)
  1774. End If
  1775. End Sub
  1776. Private Sub txtComisionPorBolsaVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorBolsaVenta.KeyPress
  1777. If String.IsNullOrEmpty(txtComisionPorBolsaVenta.Text) Then
  1778. If e.KeyChar = "." Then
  1779. txtComisionPorBolsaVenta.Text = "0"
  1780. Exit Sub
  1781. End If
  1782. End If
  1783. If (Not txtComisionPorBolsaVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1784. Operaciones.ValidarEntrada(sender, e, True)
  1785. Else
  1786. Operaciones.ValidarEntrada(sender, e, False)
  1787. End If
  1788. End Sub
  1789. Private Sub txtCostoTransferenciaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCostoTransferenciaCompra.KeyPress
  1790. If String.IsNullOrEmpty(txtCostoTransferenciaCompra.Text) Then
  1791. If e.KeyChar = "." Then
  1792. txtCostoTransferenciaCompra.Text = "0"
  1793. Exit Sub
  1794. End If
  1795. End If
  1796. If (Not txtCostoTransferenciaCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1797. Operaciones.ValidarEntrada(sender, e, True)
  1798. Else
  1799. Operaciones.ValidarEntrada(sender, e, False)
  1800. End If
  1801. End Sub
  1802. Private Sub txtMontoARecibir_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtMontoARecibir.KeyPress
  1803. If String.IsNullOrEmpty(txtMontoARecibir.Text) Then
  1804. If e.KeyChar = "." Then
  1805. txtMontoARecibir.Text = "0"
  1806. Exit Sub
  1807. End If
  1808. End If
  1809. If (Not txtMontoARecibir.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  1810. Operaciones.ValidarEntrada(sender, e, True)
  1811. Else
  1812. Operaciones.ValidarEntrada(sender, e, False)
  1813. End If
  1814. End Sub
  1815. Private Sub txtPrecioCompra_Op_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioCompra_Op.TextChanged
  1816. End Sub
  1817. Private Sub txtPrecioVenta_Op_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioVenta_Op.TextChanged
  1818. End Sub
  1819. Private Sub txtInteresAcumuladoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtInteresAcumuladoCompra.TextChanged
  1820. End Sub
  1821. Sub AsignacionPeriodicidad()
  1822. Dim Periodicidad As String = cboPeriodosC.SelectedValue
  1823. If (Periodicidad = "M") Then
  1824. TipoPeriodicidad = 1
  1825. ElseIf (Periodicidad = "T") Then
  1826. TipoPeriodicidad = 3
  1827. ElseIf (Periodicidad = "S") Then
  1828. TipoPeriodicidad = 6
  1829. ElseIf (Periodicidad = "A") Then
  1830. TipoPeriodicidad = 12
  1831. End If
  1832. End Sub
  1833. Sub PrepararCalculos()
  1834. AsignacionPeriodicidad()
  1835. Dim Index = dgvIngresos.CurrentRow.Index
  1836. Dim IndexAnterior = Index - 1
  1837. Dim Respaldo As String = Format(dtpSiguienteFechaCuponCompra.Value, "dd/MM/yyyy")
  1838. Dim FechaSig = Operaciones.ConvertirFecha(Respaldo.ToString)
  1839. Dim Fechaliq = dtpFechaLiquidacionCompra.Value
  1840. Dim FechaCupon, Dias, Ingreso, PorcentajeImpuesto, MontoImpuesto, Liquido
  1841. FechaCupon = Operaciones.ConvertirFecha(dgvIngresos.Rows(Index).Cells("FechaCupon").Value)
  1842. Dias = Operaciones.ConvertirEntero(dgvIngresos.Rows(Index).Cells("Dias").Value)
  1843. Ingreso = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("Ingreso").Value)
  1844. PorcentajeImpuesto = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value) / 100
  1845. MontoImpuesto = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("MontoImpuesto").Value)
  1846. Liquido = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("Liquido").Value)
  1847. If (String.IsNullOrEmpty(FechaCupon)) Then
  1848. If (Index = 0) Then
  1849. FechaCupon = FechaSig
  1850. Else
  1851. Dim FechaAnterior As Date = Operaciones.ConvertirFecha(dgvIngresos.Rows(IndexAnterior).Cells("FechaCupon").Value)
  1852. FechaCupon = Operaciones.Meses(TipoPeriodicidad, FechaAnterior, FechaSig)
  1853. End If
  1854. dgvIngresos.Rows(Index).Cells("FechaCupon").Value = FechaCupon
  1855. End If
  1856. If (String.IsNullOrEmpty(Dias)) Then
  1857. Dim Dia As Integer = 0
  1858. If (Index = 0) Then
  1859. Dia = Operaciones.DiasAcumulados(Fechaliq, FechaSig, IndexBaseC)
  1860. Else
  1861. Dim DiaAnterior As Date = Operaciones.ConvertirFecha(dgvIngresos.Rows(IndexAnterior).Cells("FechaCupon").Value)
  1862. Dim DiaActual As Date = Operaciones.ConvertirFecha(dgvIngresos.Rows(Index).Cells("FechaCupon").Value)
  1863. Dia = Operaciones.DiasAcumulados(DiaAnterior, DiaActual, IndexBaseC)
  1864. End If
  1865. dgvIngresos.Rows(Index).Cells("Dias").Value = Dia
  1866. End If
  1867. If (String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("NumCupon").Value)) Then
  1868. dgvIngresos.Rows(Index).Cells("NumCupon").Value = Correlativo()
  1869. End If
  1870. dgvIngresos.Rows(Index).Cells("Ingreso").Value = Ingreso
  1871. If (Index = 0) Then
  1872. If (String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value)) Then
  1873. dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value = "0.0%"
  1874. End If
  1875. Else
  1876. dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value = dgvIngresos.Rows(IndexAnterior).Cells("PorcentajeImpuesto").Value
  1877. End If
  1878. If dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value.ToString.IndexOf("%") = -1 Then
  1879. dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value = dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value.ToString + "%"
  1880. End If
  1881. If (String.IsNullOrEmpty(MontoImpuesto)) Then
  1882. dgvIngresos.Rows(Index).Cells("MontoImpuesto").Value = 0
  1883. End If
  1884. If (String.IsNullOrEmpty(Liquido)) Then
  1885. dgvIngresos.Rows(Index).Cells("Liquido").Value = 0
  1886. End If
  1887. CorrelativoSinBD()
  1888. End Sub
  1889. Function Correlativo()
  1890. Dim Index As Integer = 0
  1891. Dim IndexCantidad As Integer = dgvIngresos.Rows.Count - 2
  1892. Dim NumeroMayor As Integer = 0
  1893. While Index <= IndexCantidad
  1894. Dim Numero As Integer = Operaciones.ConvertirEntero(dgvIngresos.Rows(Index).Cells("NumCupon").Value)
  1895. If Numero > NumeroMayor Then
  1896. NumeroMayor = Numero
  1897. End If
  1898. Index += 1
  1899. End While
  1900. Return NumeroMayor + 1
  1901. End Function
  1902. Sub CorrelativoSinBD()
  1903. Dim Index As Integer = 0
  1904. Dim IndexCantidad As Integer = dgvIngresos.Rows.Count - 2
  1905. Dim NumeroMayor As Integer = 0
  1906. While Index <= IndexCantidad
  1907. dgvIngresos.Rows(Index).Cells("Correlativo").Value = Index + 1
  1908. Index += 1
  1909. End While
  1910. End Sub
  1911. Function PeriodoGracia()
  1912. Dim FechaEmision As Date = Variables.FechaEmisionTIT
  1913. Dim FechaPeriodoGracia As Date = FechaEmision
  1914. Dim CantidadPeriodoGracia As Integer = 0
  1915. Dim TipoPeriodoGracia As String = Variables.TipoPeriodoGracia
  1916. Dim CantidadPeriodo As String = Variables.CantidadPeriodo
  1917. If String.IsNullOrEmpty(CantidadPeriodo) Or CantidadPeriodo = "0" Then
  1918. Return False
  1919. Else
  1920. CantidadPeriodoGracia = CantidadPeriodo
  1921. End If
  1922. If TipoPeriodoGracia = "D" Or TipoPeriodoGracia = "M" Or TipoPeriodoGracia = "A" Then
  1923. If TipoPeriodoGracia = "D" Then
  1924. FechaPeriodoGracia = FechaEmision.AddDays(CantidadPeriodoGracia)
  1925. ElseIf TipoPeriodoGracia = "M" Then
  1926. FechaPeriodoGracia = FechaEmision.AddMonths(CantidadPeriodoGracia)
  1927. Else
  1928. FechaPeriodoGracia = FechaEmision.AddYears(CantidadPeriodoGracia)
  1929. End If
  1930. Return FechaPeriodoGracia
  1931. Else
  1932. Return False
  1933. End If
  1934. End Function
  1935. Function IngresosIntereses(ByVal ValorNominal As Double, ByVal PorcCupon As Double, ByVal Dias As Integer, ByVal Fecha1 As Date, Fecha2 As Date, ByVal IndexBase As Integer)
  1936. Dim Valor As Double = 0
  1937. If (IndexBase = 0) Then
  1938. Valor = ValorNominal * PorcCupon * Dias / 360
  1939. Return Valor
  1940. ElseIf (IndexBase = 1) Then
  1941. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1942. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1943. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1944. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1945. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1946. PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
  1947. PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 365
  1948. Valor = PrOpc1 + PrOpc2
  1949. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1950. Valor = ValorNominal * PorcCupon * DiasSegundaFecha / 365
  1951. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1952. Valor = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
  1953. Else
  1954. Valor = 0
  1955. End If
  1956. Return Valor
  1957. ElseIf (IndexBase = 2) Then
  1958. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1959. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1960. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
  1961. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
  1962. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1963. PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
  1964. PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 365
  1965. Valor = PrOpc1 + PrOpc2
  1966. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1967. Valor = ValorNominal * PorcCupon * DiasSegundaFecha / 365
  1968. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1969. Valor = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
  1970. Else
  1971. Valor = 0
  1972. End If
  1973. Return Valor
  1974. Else
  1975. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  1976. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1977. DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
  1978. DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
  1979. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1980. PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 360
  1981. PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 360
  1982. Valor = PrOpc1 + PrOpc2
  1983. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  1984. Valor = ValorNominal * PorcCupon * DiasSegundaFecha / 360
  1985. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  1986. Valor = ValorNominal * PorcCupon * DiasPrimeraFecha / 360
  1987. Else
  1988. Valor = 0
  1989. End If
  1990. Return Valor
  1991. End If
  1992. Return Valor
  1993. End Function
  1994. Function IngresosInteresesTIT(ByVal ValorSaldo As Double, ByVal PorcCupon As Double, ByVal Dias As Integer, ByVal PrimerosDias As Integer, ByVal RestantesDias As Integer, ByVal IndexBase As Integer)
  1995. Dim Valor As Double = 0
  1996. Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
  1997. DiasPrimeraFecha = PrimerosDias
  1998. DiasSegundaFecha = RestantesDias
  1999. If (IndexBase = 0) Then
  2000. Valor = ValorSaldo * PorcCupon * Dias / 360
  2001. Return Valor
  2002. ElseIf (IndexBase = 1) Then
  2003. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  2004. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2005. PrOpc1 = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
  2006. PrOpc2 = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
  2007. Valor = PrOpc1 + PrOpc2
  2008. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2009. Valor = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
  2010. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  2011. Valor = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
  2012. Else
  2013. Valor = 0
  2014. End If
  2015. Return Valor
  2016. ElseIf (IndexBase = 2) Then
  2017. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  2018. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2019. PrOpc1 = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
  2020. PrOpc2 = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
  2021. Valor = PrOpc1 + PrOpc2
  2022. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2023. Valor = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
  2024. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  2025. Valor = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
  2026. Else
  2027. Valor = 0
  2028. End If
  2029. Return Valor
  2030. Else
  2031. Dim PrOpc1 = 0.0, PrOpc2 = 0.0
  2032. If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2033. PrOpc1 = ValorSaldo * PorcCupon * DiasPrimeraFecha / 360
  2034. PrOpc2 = ValorSaldo * PorcCupon * DiasSegundaFecha / 360
  2035. Valor = PrOpc1 + PrOpc2
  2036. ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
  2037. Valor = ValorSaldo * PorcCupon * DiasSegundaFecha / 360
  2038. ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
  2039. Valor = ValorSaldo * PorcCupon * DiasPrimeraFecha / 360
  2040. Else
  2041. Valor = 0
  2042. End If
  2043. Return Valor
  2044. End If
  2045. Return Valor
  2046. End Function
  2047. Function Impuestos(ByVal Ingresos As Double, PorcentajeRenta As Double)
  2048. Dim Total As Double
  2049. Total = Ingresos * PorcentajeRenta
  2050. Return Total
  2051. End Function
  2052. Function Liquido(ByVal Ingreso As Double, ByVal Renta As Double)
  2053. Dim Total As Double
  2054. Total = Ingreso - Renta
  2055. Return Total
  2056. End Function
  2057. Sub CalculoIngresosBONO()
  2058. Dim Ingreso As Double = 0
  2059. Dim ValorNominal = 0.0, PorcCupon = 0.0, Ingresos = 0.0, PorcentajeRenta = 0.0
  2060. Dim IngresosInt = 0.0, Impuestos = 0.0, Liquido = 0.0
  2061. ValorNominal = Operaciones.ConvertirDecimal(txtValorNominalCompra.Text.ToString)
  2062. PorcCupon = Operaciones.ConvertirDecimal(txtPorcentajeCuponCompra.Text.ToString) / 100
  2063. Dim Index As Integer = dgvIngresos.CurrentRow.Index
  2064. Dim Fecha1 As Date = Date.Now.Date
  2065. Dim Fecha2 As Date = Date.Now.Date
  2066. Dim Dias As Integer = Operaciones.ConvertirEntero(dgvIngresos.Rows(Index).Cells("Dias").Value)
  2067. If (Index = 0) Then
  2068. Dim RespaldoFecha As String = Format(dtpFechaLiquidacionCompra.Value, "yyyy/MM/dd")
  2069. Fecha1 = RespaldoFecha
  2070. Fecha2 = Operaciones.ConvertirFecha(dgvIngresos.Rows(Index).Cells("FechaCupon").Value)
  2071. Else
  2072. Fecha1 = Operaciones.ConvertirFecha(dgvIngresos.Rows(Index - 1).Cells("FechaCupon").Value)
  2073. Fecha2 = Operaciones.ConvertirFecha(dgvIngresos.Rows(Index).Cells("FechaCupon").Value)
  2074. End If
  2075. If (Not dgvIngresos.CurrentRow.Cells("PorcentajeImpuesto").Value Is Nothing) Then
  2076. PorcentajeRenta = CDec(dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value.ToString.Trim("%")) / 100
  2077. Else
  2078. PorcentajeRenta = 0
  2079. End If
  2080. IngresosInt = IngresosIntereses(ValorNominal, PorcCupon, Dias, Fecha1, Fecha2, IndexBaseC)
  2081. Ingresos = Me.Impuestos(IngresosInt, PorcentajeRenta)
  2082. Liquido = Me.Liquido(IngresosInt, Ingresos)
  2083. dgvIngresos.CurrentRow.Cells("Ingreso").Value = IngresosInt
  2084. dgvIngresos.CurrentRow.Cells("MontoImpuesto").Value = Ingresos
  2085. dgvIngresos.CurrentRow.Cells("Liquido").Value = Liquido
  2086. End Sub
  2087. Sub PrepararIngresosTIT(ByVal Index As Integer, ByRef Amortizacion As DataGridView)
  2088. AsignacionPeriodicidad()
  2089. Dim IndexAnterior = Index - 1
  2090. Dim Respaldo As String = Format(dtpSiguienteFechaCuponCompra.Value, "dd/MM/yyyy")
  2091. Dim Dias, Ingreso, PorcentajeImpuesto, MontoImpuesto, Liquido, PorcentajeImpuestoAnterior
  2092. Dias = Operaciones.ConvertirEntero(dgvIngresos.Rows(Index).Cells("Dias").Value)
  2093. Ingreso = Operaciones.ConvertirDecimal(dgvIngresos.Rows(Index).Cells("Ingreso").Value)
  2094. PorcentajeImpuesto = 10
  2095. MontoImpuesto = 0
  2096. Liquido = 0
  2097. If (Index = 0) Then
  2098. PorcentajeImpuestoAnterior = "10.0%"
  2099. Else
  2100. PorcentajeImpuestoAnterior = Operaciones.ConvertirDecimal(dgvIngresos.Rows(IndexAnterior).Cells("PorcentajeImpuesto").Value)
  2101. End If
  2102. Dim Dia As Integer = 0
  2103. Dim Fecha As Date = Date.Now.Date
  2104. Dia = Operaciones.ConvertirEntero(Amortizacion.Rows(Index).Cells("Dias").Value)
  2105. Fecha = Operaciones.ConvertirFecha(Amortizacion.Rows(Index).Cells("Fecha").Value)
  2106. dgvIngresos.Rows.Add(0, 0, 0, Fecha, Dia, 0, PorcentajeImpuestoAnterior, 0, 0)
  2107. End Sub
  2108. Sub CalculoIngresosTIT()
  2109. Dim FechaPeriodoGracia = PeriodoGracia()
  2110. Dim CantidadAmortizacion As Integer = Variables.dgvAmortizacion.Rows.Count - 1
  2111. Dim Amortizacion = Variables.dgvAmortizacion
  2112. Dim Index As Integer = 0
  2113. Dim j As Integer = 0
  2114. While Index <= CantidadAmortizacion
  2115. PrepararIngresosTIT(Index, Amortizacion)
  2116. Index += 1
  2117. End While
  2118. While j <= CantidadAmortizacion
  2119. Dim PrimerosDias As Double = Operaciones.ConvertirDecimal(Amortizacion.Rows(j).Cells("PrimerosDias").Value)
  2120. Dim RestantesDias As Double = Operaciones.ConvertirDecimal(Amortizacion.Rows(j).Cells("RestantesDias").Value)
  2121. Dim FechaActualCupon = Operaciones.ConvertirFecha(dgvIngresos.Rows(j).Cells("FechaCupon").Value)
  2122. Dim Ingreso As Double = 0
  2123. Dim ValorSaldo = 0.0, PorcCupon = 0.0, Ingresos = 0.0, PorcentajeRenta = 0.0
  2124. Dim IngresosInt = 0.0, Impuestos = 0.0, Liquido = 0.0
  2125. Dim SaldoPendiente As Double = 0
  2126. 'If TypeOf FechaPeriodoGracia Is Boolean Then
  2127. If j = 0 Then
  2128. ValorSaldo = Variables.MontoCompraTIT
  2129. Else
  2130. ValorSaldo = Operaciones.ConvertirDecimal(Amortizacion.Rows(j - 1).Cells("Saldos").Value)
  2131. End If
  2132. PorcCupon = Operaciones.ConvertirDecimal(txtPorcentajeCuponCompra.Text.ToString) / 100
  2133. Dim Fecha1 As Date = Date.Now.Date
  2134. Dim Fecha2 As Date = Date.Now.Date
  2135. Dim Dias As Integer = Operaciones.ConvertirEntero(dgvIngresos.Rows(j).Cells("Dias").Value)
  2136. If (j = 0) Then
  2137. Dim RespaldoFecha As String = Format(dtpFechaLiquidacionCompra.Value, "yyyy/MM/dd")
  2138. Fecha1 = RespaldoFecha
  2139. Fecha2 = Operaciones.ConvertirFecha(dgvIngresos.Rows(j).Cells("FechaCupon").Value)
  2140. Else
  2141. Fecha1 = Operaciones.ConvertirFecha(dgvIngresos.Rows(j - 1).Cells("FechaCupon").Value)
  2142. Fecha2 = Operaciones.ConvertirFecha(dgvIngresos.Rows(j).Cells("FechaCupon").Value)
  2143. End If
  2144. If (Not dgvIngresos.Rows(j).Cells("PorcentajeImpuesto").Value Is Nothing) Then
  2145. PorcentajeRenta = Operaciones.ConvertirDecimal(dgvIngresos.Rows(j).Cells("PorcentajeImpuesto").Value.ToString) / 100
  2146. Else
  2147. PorcentajeRenta = 0
  2148. End If
  2149. IngresosInt = IngresosInteresesTIT(ValorSaldo, PorcCupon, Dias, PrimerosDias, RestantesDias, IndexBaseC)
  2150. Ingresos = Me.Impuestos(IngresosInt, PorcentajeRenta)
  2151. Liquido = Me.Liquido(IngresosInt, Ingresos)
  2152. dgvIngresos.Rows(j).Cells("Ingreso").Value = IngresosInt
  2153. dgvIngresos.Rows(j).Cells("MontoImpuesto").Value = Ingresos
  2154. dgvIngresos.Rows(j).Cells("Liquido").Value = Liquido
  2155. j += 1
  2156. End While
  2157. End Sub
  2158. Private Sub txtPorcentajeInteresAcumuladoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeInteresAcumuladoCompra.TextChanged
  2159. End Sub
  2160. Private Sub btnQuitar_Click(sender As Object, e As EventArgs) Handles btnQuitar.Click
  2161. QuitarFila()
  2162. Calculos()
  2163. End Sub
  2164. Sub QuitarFila()
  2165. Dim CantidadFilas As Integer = dgvIngresos.Rows.Count - 1
  2166. If CantidadFilas > 0 Then
  2167. Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
  2168. ' Test result.
  2169. Dim codigo As String = Variables.Codigo
  2170. Dim Numero As Integer = dgvIngresos.CurrentRow.Cells("NumCupon").Value
  2171. If result = MsgBoxResult.Ok Then
  2172. Try
  2173. dgvIngresos.Rows.Remove(dgvIngresos.CurrentRow)
  2174. BonosConsulta.EliminarIngreso(codigo, Numero, Instrumento)
  2175. Catch ex As Exception
  2176. MsgBox("No ha seleccionado una fila")
  2177. End Try
  2178. End If
  2179. Else
  2180. MsgBox("Actualmente no tiene registros")
  2181. End If
  2182. End Sub
  2183. Private Sub txtCuponesRecibidos_TextChanged(sender As Object, e As EventArgs) Handles txtCuponesRecibidos.TextChanged
  2184. End Sub
  2185. Private Sub txtIngresosPorIntereses_Op_TextChanged(sender As Object, e As EventArgs) Handles txtIngresosPorIntereses_Op.TextChanged
  2186. End Sub
  2187. Private Sub txtRendimientoGananciaPerdida_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoGananciaPerdida_Op.TextChanged
  2188. End Sub
  2189. Private Sub txtRendimientoIntereses_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoIntereses_Op.TextChanged
  2190. End Sub
  2191. Private Sub txtRendimientoAntesISR_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoAntesISR_Op.TextChanged
  2192. End Sub
  2193. Private Sub txtPlazo_Op_TextChanged(sender As Object, e As EventArgs) Handles txtPlazo_Op.TextChanged
  2194. End Sub
  2195. Private Sub txtDiasAcumuladosVenta_TextChanged(sender As Object, e As EventArgs) Handles txtDiasAcumuladosVenta.TextChanged
  2196. End Sub
  2197. Private Sub pnlPie_Paint(sender As Object, e As PaintEventArgs) Handles pnlPie.Paint
  2198. End Sub
  2199. Private Sub txtValorNominalCompra_Leave(sender As Object, e As EventArgs) Handles txtValorNominalCompra.Leave
  2200. Formato()
  2201. End Sub
  2202. Private Sub txtPorcentajeCuponCompra_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.Leave
  2203. Formato()
  2204. End Sub
  2205. Private Sub txtYTMAlVencimientoCompra_Leave(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoCompra.Leave
  2206. Formato()
  2207. End Sub
  2208. Private Sub txtPrecioAlVencimientoCompra_Leave(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.Leave
  2209. Formato()
  2210. End Sub
  2211. Private Sub txtPrecioCompra_Leave(sender As Object, e As EventArgs) Handles txtPrecioCompra.Leave
  2212. Formato()
  2213. End Sub
  2214. Private Sub txtComisionPorCompraCasa_Leave(sender As Object, e As EventArgs) Handles txtComisionPorCompraCasa.Leave
  2215. Formato()
  2216. End Sub
  2217. Private Sub txtComisionPorBolsaCompra_Leave(sender As Object, e As EventArgs) Handles txtComisionPorBolsaCompra.Leave
  2218. Formato()
  2219. End Sub
  2220. Private Sub txtCostoTransferenciaCompra_Leave(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.Leave
  2221. Formato()
  2222. End Sub
  2223. Private Sub txtValorNominalVenta_Leave(sender As Object, e As EventArgs) Handles txtValorNominalVenta.Leave
  2224. Formato()
  2225. End Sub
  2226. Private Sub txtPorcentajeCuponVenta_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeCuponVenta.Leave
  2227. Formato()
  2228. End Sub
  2229. Private Sub txtYTMAlVencimientoVenta_Leave(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoVenta.Leave
  2230. Formato()
  2231. End Sub
  2232. Private Sub txtPrecioAlVencimientoVenta_Leave(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoVenta.Leave
  2233. Formato()
  2234. End Sub
  2235. Private Sub txtPrecioVenta_Leave(sender As Object, e As EventArgs) Handles txtPrecioVenta.Leave
  2236. Formato()
  2237. End Sub
  2238. Private Sub txtComisionPorVentaCasa_Leave(sender As Object, e As EventArgs) Handles txtComisionPorVentaCasa.Leave
  2239. Formato()
  2240. End Sub
  2241. Private Sub txtComisionPorBolsaVenta_Leave(sender As Object, e As EventArgs) Handles txtComisionPorBolsaVenta.Leave
  2242. Formato()
  2243. End Sub
  2244. Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles btnIngresos.Click
  2245. CalculoIngresosTIT()
  2246. End Sub
  2247. Private Sub txtValorNominalCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorNominalCompra.KeyUp
  2248. If txtValorNominalCompra.Text = "." Then
  2249. txtValorNominalCompra.Text = ".0"
  2250. End If
  2251. End Sub
  2252. Private Sub txtPorcentajeCuponCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentajeCuponCompra.KeyUp
  2253. If txtPorcentajeCuponCompra.Text = "." Then
  2254. txtPorcentajeCuponCompra.Text = ".0"
  2255. End If
  2256. End Sub
  2257. Private Sub txtYTMAlVencimientoCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtYTMAlVencimientoCompra.KeyUp
  2258. If txtYTMAlVencimientoCompra.Text = "." Then
  2259. txtYTMAlVencimientoCompra.Text = ".0"
  2260. End If
  2261. End Sub
  2262. Private Sub txtPrecioAlVencimientoCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioAlVencimientoCompra.KeyUp
  2263. If txtPrecioAlVencimientoCompra.Text = "." Then
  2264. txtPrecioAlVencimientoCompra.Text = ".0"
  2265. End If
  2266. End Sub
  2267. Private Sub txtPrecioCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioCompra.KeyUp
  2268. If txtPrecioCompra.Text = "." Then
  2269. txtPrecioCompra.Text = ".0"
  2270. End If
  2271. End Sub
  2272. Private Sub txtComisionPorCompraCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorCompraCasa.KeyUp
  2273. If txtComisionPorCompraCasa.Text = "." Then
  2274. txtComisionPorCompraCasa.Text = ".0"
  2275. End If
  2276. End Sub
  2277. Private Sub txtComisionPorBolsaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorBolsaCompra.KeyUp
  2278. If txtComisionPorBolsaCompra.Text = "." Then
  2279. txtComisionPorBolsaCompra.Text = ".0"
  2280. End If
  2281. End Sub
  2282. Private Sub txtCostoTransferenciaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCostoTransferenciaCompra.KeyUp
  2283. If txtCostoTransferenciaCompra.Text = "." Then
  2284. txtCostoTransferenciaCompra.Text = ".0"
  2285. End If
  2286. End Sub
  2287. Private Sub txtValorNominalVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorNominalVenta.KeyUp
  2288. If txtValorNominalVenta.Text = "." Then
  2289. txtValorNominalVenta.Text = ".0"
  2290. End If
  2291. End Sub
  2292. Private Sub txtPorcentajeCuponVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentajeCuponVenta.KeyUp
  2293. If txtPorcentajeCuponVenta.Text = "." Then
  2294. txtPorcentajeCuponVenta.Text = ".0"
  2295. End If
  2296. End Sub
  2297. Private Sub txtYTMAlVencimientoVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtYTMAlVencimientoVenta.KeyUp
  2298. If txtYTMAlVencimientoVenta.Text = "." Then
  2299. txtYTMAlVencimientoVenta.Text = ".0"
  2300. End If
  2301. End Sub
  2302. Private Sub txtPrecioAlVencimientoVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioAlVencimientoVenta.KeyUp
  2303. If txtPrecioAlVencimientoVenta.Text = "." Then
  2304. txtPrecioAlVencimientoVenta.Text = ".0"
  2305. End If
  2306. End Sub
  2307. Private Sub txtPrecioVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioVenta.KeyUp
  2308. If txtPrecioVenta.Text = "." Then
  2309. txtPrecioVenta.Text = ".0"
  2310. End If
  2311. End Sub
  2312. Private Sub txtComisionPorVentaCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorVentaCasa.KeyUp
  2313. If txtComisionPorVentaCasa.Text = "." Then
  2314. txtComisionPorVentaCasa.Text = ".0"
  2315. End If
  2316. End Sub
  2317. Private Sub txtComisionPorBolsaVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorBolsaVenta.KeyUp
  2318. If txtComisionPorBolsaVenta.Text = "." Then
  2319. txtComisionPorBolsaVenta.Text = ".0"
  2320. End If
  2321. End Sub
  2322. Private Sub dgvIngresos_KeyPress(sender As Object, e As KeyPressEventArgs) Handles dgvIngresos.KeyPress
  2323. Formato()
  2324. End Sub
  2325. Private Sub dgvIngresos_Leave(sender As Object, e As EventArgs) Handles dgvIngresos.Leave
  2326. End Sub
  2327. Private Sub dgvIngresos_Click(sender As Object, e As EventArgs) Handles dgvIngresos.Click
  2328. Formato()
  2329. End Sub
  2330. Private Sub dgvIngresos_CellLeave(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellLeave
  2331. Formato()
  2332. End Sub
  2333. Sub ValidacionErrores()
  2334. If Not String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
  2335. If Double.IsNaN(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
  2336. txtPorcentajeInteresAcumuladoCompra.Text = "0.0%"
  2337. End If
  2338. If Double.IsInfinity(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
  2339. txtPorcentajeInteresAcumuladoCompra.Text = "0.0%"
  2340. End If
  2341. End If
  2342. If Not String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
  2343. If Double.IsNaN(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
  2344. txtPorcentajeInteresAcumuladoVenta.Text = "0.0%"
  2345. End If
  2346. If Double.IsInfinity(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
  2347. txtPorcentajeInteresAcumuladoVenta.Text = "0.0%"
  2348. End If
  2349. End If
  2350. If Not String.IsNullOrEmpty(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
  2351. If Double.IsNaN(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
  2352. txtPrecioSucioCompra.Text = "0.0%"
  2353. End If
  2354. If Double.IsInfinity(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
  2355. txtPrecioSucioCompra.Text = "0.0%"
  2356. End If
  2357. End If
  2358. If Not String.IsNullOrEmpty(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
  2359. If Double.IsNaN(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
  2360. txtPrecioSucioVenta.Text = "0.0%"
  2361. End If
  2362. If Double.IsInfinity(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
  2363. txtPrecioSucioVenta.Text = "0.0%"
  2364. End If
  2365. End If
  2366. End Sub
  2367. Sub BotonQuitar()
  2368. If TabCampos.SelectedIndex = 1 Then
  2369. btnQuitar.Visible = True
  2370. btnQuitar.Enabled = True
  2371. Else
  2372. btnQuitar.Visible = False
  2373. btnQuitar.Enabled = False
  2374. End If
  2375. End Sub
  2376. Private Sub lblRedencion_Click(sender As Object, e As EventArgs)
  2377. End Sub
  2378. Private Sub txtValorTransadoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoVenta.TextChanged
  2379. End Sub
  2380. Private Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
  2381. End Sub
  2382. Private Sub Button1_Click_1(sender As Object, e As EventArgs)
  2383. End Sub
  2384. Private Sub btnVenderTitulo_Click(sender As Object, e As EventArgs) Handles btnVenderTitulo.Click
  2385. If Variables.InvocadorProInv = "frmINV" Then
  2386. Dim TrasladarDatos As New TrasladarDatosCMVTA
  2387. Dim General As New DAOGeneral
  2388. Dim Codigo = Variables.Codigo
  2389. Dim Tabla As String = "INV0"
  2390. TrasladarDatos = RellenarDatosCMVTA()
  2391. Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
  2392. If Existe Then
  2393. Dim CodigoInversion As String = Variables.Codigo
  2394. Dim frmPINVCMVTA As New frmPIN("V", CodigoInversion, TrasladarDatos)
  2395. frmINV.Close()
  2396. Me.Close()
  2397. frmPINVCMVTA.ShowDialog()
  2398. End If
  2399. End If
  2400. End Sub
  2401. Function RellenarDatosCMVTA()
  2402. Dim TrasladarDatos As New TrasladarDatosCMVTA
  2403. TrasladarDatos.BaseCINV = Operaciones.ConvertirEntero(cboAnioBaseC.SelectedIndex.ToString)
  2404. TrasladarDatos.CuponCINV = Operaciones.ConvertirDecimal(txtPorcentajeCuponCompra.Text.ToString)
  2405. TrasladarDatos.FechaLiquidacionCINV = Operaciones.ConvertirFecha(dtpFechaLiquidacionCompra.Value.ToString)
  2406. TrasladarDatos.FechaVencimientoCINV = Operaciones.ConvertirFecha(dtpFechaVencimientoCompra.Value.ToString)
  2407. TrasladarDatos.PeriodicidadCINV = cboPeriodosC.SelectedValue.ToString
  2408. TrasladarDatos.PorcentajeComisionBolsaCINV = Operaciones.ConvertirDecimal(txtComisionPorBolsaCompra.Text.ToString)
  2409. TrasladarDatos.PorcentajeComisionCasaCINV = Operaciones.ConvertirDecimal(txtComisionPorCompraCasa.Text.ToString)
  2410. TrasladarDatos.PrecioCompraCINV = Operaciones.ConvertirDecimal(txtPrecioCompra.Text.ToString)
  2411. TrasladarDatos.PrecioVencimientoCINV = Operaciones.ConvertirDecimal(txtPrecioAlVencimientoCompra.Text.ToString)
  2412. TrasladarDatos.UltimaFechaCuponCINV = Operaciones.ConvertirFecha(dtpUltimaFechaCuponCompra.Value)
  2413. TrasladarDatos.ValorNominalCINV = Operaciones.ConvertirDecimal(txtValorNominalCompra.Text.ToString)
  2414. TrasladarDatos.YTMVencimientoCINV = Operaciones.ConvertirDecimal(txtYTMAlVencimientoCompra.Text.ToString)
  2415. TrasladarDatos.NombreInstrumento = "CINV"
  2416. TrasladarDatos.AgregarCMVTA = True
  2417. Return TrasladarDatos
  2418. End Function
  2419. End Class