frmCertificadosDeInversion.vb 151 KB

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