frmCertificadosDeInversion.vb 129 KB

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