| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993 |
- Public Class frmCertificadosDeInversion
- Dim oCEPrincipal As New CertificadoDeInversionCE
- Dim oDAOPrincipal As New CertificadosDeInversionDAO
- Dim oDAOGeneral As New DAOGeneral
- Dim Bonos As New BonosCE
- Dim TotalValorCupones As Double
- Dim Index
- Dim BonoCalculo As New FormulasBonoCE
- Dim Cargar As Boolean = True
- Dim BonosConsulta As New BonosDAO
- Dim Operaciones As New Operaciones
- Dim ModificarRenta As Boolean = True
- Dim Tipo As Integer = 0
- Dim IndexBaseC As Integer = 0
- Dim IndexBaseV As Integer = 0
- Dim PeriodoC As Integer = 0
- Dim PeriodoV As Integer = 0
- Private _IdDocumento As Integer
- Private _TipoDocumento As String
- Private _CodigoInversion As String
- Private _TipoTransaccion As String 'N=Nuevo, A=Actualizar, C=Consulta
- Private TipoPeriodicidad As Integer = 0
- Public InstanciaAmortizacion As New DataGridView
- Public InstanciaIngresos As New DataGridView
- Private TipoOperacion As String
- Public Sub New()
- InitializeComponent()
- End Sub
- Public Sub New(TipoOper As String)
- Me.New
- TipoOperacion = TipoOper
- End Sub
- Sub CargarBase()
- If cboAnioBaseC.Items.Count = 0 Or cboAnioBaseC.Items.Count = 1 Then
- Me.cboAnioBaseC.DataSource = oDAOGeneral.ListaBase
- Me.cboAnioBaseC.DisplayMember = "Descripcion"
- Me.cboAnioBaseC.ValueMember = "Codigo"
- Me.cboAnioBaseC.SelectedIndex = 0
- End If
- If cboAnioBaseV.Items.Count = 0 Or cboAnioBaseV.Items.Count = 1 Then
- Me.cboAnioBaseV.DataSource = oDAOGeneral.ListaBase
- Me.cboAnioBaseV.DisplayMember = "Descripcion"
- Me.cboAnioBaseV.ValueMember = "Codigo"
- Me.cboAnioBaseV.SelectedIndex = 0
- End If
- End Sub
- Public Property TipoTransaccion As String
- Get
- Return _TipoTransaccion
- End Get
- Set(value As String)
- _TipoTransaccion = value
- End Set
- End Property
- Private Property IdDocumento As Integer
- Get
- Return _IdDocumento
- End Get
- Set(value As Integer)
- _IdDocumento = value
- End Set
- End Property
- Private Property TipoDocumento As String
- Get
- Return _TipoDocumento
- End Get
- Set(value As String)
- _TipoDocumento = value
- End Set
- End Property
- Private Property CodigoInversion As String
- Get
- Return _CodigoInversion
- End Get
- Set(value As String)
- _CodigoInversion = value
- End Set
- End Property
- Function FechaCupon(ByVal liquidacion As Date, ByVal Vencimiento As Date, ByVal frecuencia As Integer)
- Dim periodos As Integer = 0
- If frecuencia = 1 Then
- periodos = -12
- ElseIf frecuencia = 2 Then
- periodos = -6
- ElseIf frecuencia = 4 Then
- periodos = -3
- ElseIf frecuencia = 12 Then
- periodos = -1
- End If
- If (Not periodos = 0) Then
- While Vencimiento > liquidacion
- Vencimiento = Vencimiento.AddMonths(periodos)
- End While
- Else
- Return liquidacion
- End If
- Return Vencimiento
- End Function
- Sub ValidarExistencia()
- Dim General As New DAOGeneral
- Dim Codigo As String = Variables.Codigo
- Dim Tabla As String = String.Empty
- Dim Ins As String = Instrumento()
- If (Ins = "TIT") Then
- Tabla = "TIT"
- ElseIf (Ins = "EURB") Then
- Tabla = "EURB0"
- ElseIf (Ins = "BONO") Then
- Tabla = "BON0"
- ElseIf (Ins = "CINV") Then
- Tabla = "CIN0"
- End If
- Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
- If Tabla = "TIT" Then
- If (Existe) Then
- navNuevo.Enabled = False
- navModificar.Enabled = True
- navEliminar.Enabled = True
- btnIngresos.Enabled = True
- Else
- navNuevo.Enabled = True
- navModificar.Enabled = False
- navEliminar.Enabled = False
- btnIngresos.Enabled = False
- End If
- Else
- If (Existe) Then
- navNuevo.Enabled = False
- navModificar.Enabled = True
- navEliminar.Enabled = True
- btnIngresos.Enabled = True
- Else
- navNuevo.Enabled = True
- navModificar.Enabled = False
- navEliminar.Enabled = False
- btnIngresos.Enabled = False
- End If
- End If
- TipoTransaccion = String.Empty
- btnAceptar.Text = "Aceptar"
- End Sub
- Function ExisteValidacion()
- Dim General As New DAOGeneral
- Dim Codigo As String = Variables.Codigo
- Dim Tabla As String = String.Empty
- Dim Ins As String = Instrumento()
- If (Ins = "TIT") Then
- Tabla = "TIT"
- ElseIf (Ins = "EURB") Then
- Tabla = "EURB0"
- ElseIf (Ins = "BONO") Then
- Tabla = "BON0"
- ElseIf (Ins = "CINV") Then
- Tabla = "CIN0"
- End If
- Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
- Return Existe
- End Function
- Private Sub frmBonos_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Dim VExisteInversion As Boolean = False
- If Variables.TipoOperacionCMVTA = "C" Then
- GrpVenta.Enabled = False
- GrpCompra.Enabled = True
- Else
- GrpVenta.Enabled = True
- GrpCompra.Enabled = False
- End If
- VExisteInversion = ExisteInversion()
- ValidarExistencia()
- Dim Ins As String = Instrumento()
- CargarBase()
- AsignacionPeriodicidad()
- If (Not Ins = "TIT") Then
- btnIngresos.Visible = False
- End If
- If (Ins = "TIT") Then
- btnIngresos.Visible = True
- lblBono.Text = "Titularizacion"
- ConfTitularizacion()
- ElseIf (Ins = "EURB") Then
- lblBono.Text = "Euro Bonos"
- ElseIf (Ins = "BONO") Then
- lblBono.Text = "Bonos"
- End If
- Bono()
- Tipo = 1
- Call CargarPeriodos()
- PrepararTablaIngresos()
- If Me.TipoTransaccion Is Nothing Then
- Me.TipoTransaccion = "N"
- End If
- CargarIngresos()
- RefrescarValorControles()
- Cargar = False
- BotonQuitar()
- CamposTiempo()
- CargarTransladoNuevo()
- ConfiguracionCMVTA(VExisteInversion)
- End Sub
- Sub ConfiguracionCMVTA(ByRef VExisteInversion As Boolean)
- Dim Codigo As String = Variables.Codigo
- Dim ExisteCMVTA As Boolean = oDAOGeneral.ExisteCMVTA(Codigo)
- If Not ExisteCMVTA And Variables.InvocadorProInv = "frmINV" Then
- btnVenderTitulo.Visible = True
- End If
- If CantFormAbierto = False And Not VExisteInversion Then
- If Not Variables.TrasladarCMVTA Is Nothing Then
- cboAnioBaseC.SelectedIndex = Variables.TrasladarCMVTA.BaseCINV
- txtPorcentajeCuponCompra.Text = Variables.TrasladarCMVTA.CuponCINV
- dtpFechaLiquidacionCompra.Value = Variables.TrasladarCMVTA.FechaLiquidacionCINV
- dtpFechaVencimientoCompra.Value = Variables.TrasladarCMVTA.FechaVencimientoCINV
- cboPeriodosC.SelectedValue = Variables.TrasladarCMVTA.PeriodicidadCINV
- txtComisionPorBolsaCompra.Text = Variables.TrasladarCMVTA.PorcentajeComisionBolsaCINV
- txtComisionPorCompraCasa.Text = Variables.TrasladarCMVTA.PorcentajeComisionCasaCINV
- txtPrecioCompra.Text = Variables.TrasladarCMVTA.PrecioCompraCINV
- txtPrecioAlVencimientoCompra.Text = Variables.TrasladarCMVTA.PrecioVencimientoCINV
- dtpUltimaFechaCuponCompra.Value = Variables.TrasladarCMVTA.UltimaFechaCuponCINV
- txtValorNominalCompra.Text = Variables.TrasladarCMVTA.ValorNominalCINV
- txtYTMAlVencimientoCompra.Text = Variables.TrasladarCMVTA.YTMVencimientoCINV
- End If
- End If
- End Sub
- Sub CamposTiempo()
- If Not TypeOf cboPeriodosC.SelectedValue Is DataRowView Then
- Variables.PeriodicidadTIT = cboPeriodosC.SelectedValue
- End If
- Variables.BaseTIT = cboAnioBaseC.SelectedIndex
- End Sub
- Sub ConfTitularizacion()
- dgvIngresos.Dispose()
- TbIngresos.Parent = Nothing
- Dim TbAmortizacion As New TabPage
- Dim frmTitularizacion As New frmResultadoTitularizacion()
- TbAmortizacion.Name = "tbAmortizacion"
- TbAmortizacion.Text = "Amortizacion"
- If TabCampos.TabCount = 2 Then
- frmTitularizacion.Dock = DockStyle.Fill
- frmTitularizacion.TopLevel = False
- frmTitularizacion.Parent = TbAmortizacion
- TabCampos.Controls.Add(TbAmortizacion)
- frmTitularizacion.Show()
- End If
- End Sub
- Function ExisteInversion()
- Dim Codigo As String = Variables.Codigo
- Dim TablaINV As String = "INV0"
- Dim TablaPINV As String = "PIN0"
- Dim General As New DAOGeneral
- Dim InvPro = Variables.InvPro
- If InvPro = "I" Then
- Dim INV0 As Boolean = General.ExisteTitulo(Codigo, TablaINV)
- If INV0 Then
- navNuevo.Visible = True
- Return True
- Else
- navNuevo.Visible = False
- Return False
- End If
- End If
- If InvPro = "P" Then
- Dim PINV0 As Boolean = General.ExisteTitulo(Codigo, TablaPINV)
- If PINV0 Then
- navNuevo.Visible = True
- Return True
- Else
- navNuevo.Visible = False
- Return False
- End If
- End If
- Return False
- End Function
- Sub Bono()
- dtpSiguienteFechaCuponCompra.Enabled = False
- dtpSiguienteFechaCuponVenta.Enabled = False
- dtpUltimaFechaCuponCompra.Enabled = True
- dtpUltimaFechaCuponVenta.Enabled = True
- End Sub
- Private Function Parametros()
- Dim Coleccion As New Collection
- Dim PeriodoCompra = cboPeriodosC.SelectedValue
- Dim ValorNominalCompra = txtValorNominalCompra.Text
- Dim UltCuponCompra = dtpUltimaFechaCuponCompra.Value
- Dim SigFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value
- Dim FechaLiqCompra = dtpFechaLiquidacionCompra.Value
- Dim FechaVenCompra = dtpFechaVencimientoCompra.Value
- Dim PorcentajeCuponCompra = txtPorcentajeCuponCompra.Text.TrimEnd("%") / 100
- Dim PrecioVenciCompra = txtPrecioAlVencimientoCompra.Text
- Dim PrecioCompra = txtPrecioCompra.Text
- Dim DiasBase = IndexBaseC
- Dim CostoTransCompra = txtCostoTransferenciaCompra.Text
- Dim PorcCupC = txtPorcentajeCuponCompra.Text.TrimEnd("%") / 100
- Dim PeriodoVenta = cboPeriodosV.SelectedValue
- Dim ValorNominalVenta = txtValorNominalVenta.Text
- Dim UltCuponVenta = dtpUltimaFechaCuponVenta.Value
- Dim SigFechaCuponVenta = dtpSiguienteFechaCuponVenta.Value
- Dim FechaLiqVenta = dtpFechaLiquidacionVenta.Value
- Dim FechaVenVenta = dtpFechaVencimientoVenta.Value
- Dim PorcentajeCuponVenta = txtPorcentajeCuponVenta.Text.TrimEnd("%") / 100
- Dim PrecioVenciVenta = txtPrecioAlVencimientoVenta.Text
- Dim PrecioVenta = txtPrecioVenta.Text
- Dim DiasBaseV = IndexBaseV
- Dim CostoTransVenta = txtCuponesRecibidos.Text
- Dim PorcCupV = txtPorcentajeCuponVenta.Text.TrimEnd("%") / 100
- Dim ComisionPorCompraCasa = txtComisionPorCompraCasa.Text.TrimEnd("%") / 100
- Dim ComisionPorCompraBolsa = txtComisionPorBolsaCompra.Text.TrimEnd("%") / 100
- Dim ComisionPorVentaCasa = txtComisionPorVentaCasa.Text.TrimEnd("%") / 100
- Dim ComisionPorVentaBolsa = txtComisionPorBolsaVenta.Text.TrimEnd("%") / 100
- Dim YTMCompra = txtYTMAlVencimientoComisionCompra.Text.TrimEnd("%") / 100
- Dim YTMVenta = txtYTMAlVencimientoComisionVenta.Text.TrimEnd("%") / 100
- Dim DiasVenC, DiasVenV, DiasAcuC, DiasAcuV, YTMVenC, YTMVenV, IntAcuC, IntAcuV, IntPorAcuC, IntPorAcuV, PrecSucioC, PrecSucioV
- Dim ComisionCasaC, ComisionCasaV, ComisionBolsaC, ComisionBolsaV, ValTransC, ValTransV, MontoPagar, MontoRecibir, CostTrans, CupRecibidos
- DiasVenC = txtDiasAlVencimientoCompra.Text
- DiasVenV = txtDiasAlVencimientoVenta.Text
- DiasAcuC = txtDiasAcumuladosCompra.Text
- DiasAcuV = txtDiasAcumuladosVenta.Text
- YTMVenC = txtYTMAlVencimientoCompra.Text.ToString.Trim("%") / 100
- YTMVenV = txtYTMAlVencimientoVenta.Text.ToString.Trim("%") / 100
- IntAcuC = txtInteresAcumuladoCompra.Text
- IntAcuV = txtInteresAcumuladoVenta.Text
- IntPorAcuC = txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%") / 100
- IntPorAcuV = txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%") / 100
- PrecSucioC = txtPrecioSucioCompra.Text.ToString.Trim("%") / 100
- PrecSucioV = txtPrecioSucioVenta.Text.ToString.Trim("%") / 100
- ComisionCasaC = txtComisionCompraCasa.Text
- ComisionCasaV = txtComisionVentaCasa.Text
- ComisionBolsaC = txtComisionCompraBolsa.Text
- ComisionBolsaV = txtComisionVentaBolsa.Text
- ValTransC = txtValorTransadoCompra.Text
- ValTransV = txtValorTransadoVenta.Text
- MontoPagar = txtMontoAPagar.Text
- MontoRecibir = txtMontoARecibir.Text
- CostTrans = txtCostoTransferenciaCompra.Text
- CupRecibidos = txtCuponesRecibidos.Text
- Dim Codigo = Variables.Codigo
- Coleccion.Add(PeriodoCompra)
- Coleccion.Add(ValorNominalCompra)
- Coleccion.Add(UltCuponCompra)
- Coleccion.Add(SigFechaCuponCompra)
- Coleccion.Add(FechaLiqCompra)
- Coleccion.Add(FechaVenCompra)
- Coleccion.Add(PorcentajeCuponCompra)
- Coleccion.Add(PrecioVenciCompra)
- Coleccion.Add(PrecioCompra)
- Coleccion.Add(DiasBase)
- Coleccion.Add(CostoTransCompra)
- Coleccion.Add(PeriodoVenta)
- Coleccion.Add(ValorNominalVenta)
- Coleccion.Add(UltCuponVenta)
- Coleccion.Add(SigFechaCuponVenta)
- Coleccion.Add(FechaLiqVenta)
- Coleccion.Add(FechaVenVenta)
- Coleccion.Add(PorcentajeCuponVenta)
- Coleccion.Add(PrecioVenciVenta)
- Coleccion.Add(PrecioVenta)
- Coleccion.Add(DiasBaseV)
- Coleccion.Add(CostoTransVenta)
- Coleccion.Add(Codigo)
- Coleccion.Add(PorcCupC)
- Coleccion.Add(PorcCupV)
- Coleccion.Add(ComisionPorCompraCasa)
- Coleccion.Add(ComisionPorCompraBolsa)
- Coleccion.Add(ComisionPorVentaCasa)
- Coleccion.Add(ComisionPorVentaBolsa)
- Coleccion.Add(YTMCompra)
- Coleccion.Add(YTMVenta)
- Coleccion.Add(CInt(DiasVenC))
- Coleccion.Add(CInt(DiasVenV))
- Coleccion.Add(CInt(DiasAcuC))
- Coleccion.Add(CInt(DiasAcuV))
- Coleccion.Add(CDec(YTMVenC))
- Coleccion.Add(CDec(YTMVenV))
- Coleccion.Add(CDec(IntAcuC))
- Coleccion.Add(CDec(IntAcuV))
- Coleccion.Add(CDec(IntPorAcuC))
- Coleccion.Add(CDec(IntPorAcuV))
- Coleccion.Add(CDec(PrecSucioC))
- Coleccion.Add(CDec(PrecSucioV))
- Coleccion.Add(CDec(ComisionCasaC))
- Coleccion.Add(CDec(ComisionCasaV))
- Coleccion.Add(CDec(ComisionBolsaC))
- Coleccion.Add(CDec(ComisionBolsaV))
- Coleccion.Add(CDec(ValTransC))
- Coleccion.Add(CDec(ValTransV))
- Coleccion.Add(CDec(MontoPagar))
- Coleccion.Add(CDec(MontoRecibir))
- Coleccion.Add(CDec(CostTrans))
- Coleccion.Add(CDec(CupRecibidos))
- Return Coleccion
- End Function
- Private Sub LimpiarElementos()
- Dim Fecha = DateTime.Today
- dgvIngresos.Rows.Clear()
- cboPeriodosC.SelectedIndex = -1
- txtValorNominalCompra.Text = String.Empty
- dtpUltimaFechaCuponCompra.Value = Fecha
- dtpSiguienteFechaCuponCompra.Value = Fecha
- dtpFechaLiquidacionCompra.Value = Fecha
- dtpFechaVencimientoCompra.Value = Fecha
- txtPorcentajeCuponCompra.Text = String.Empty
- txtPrecioAlVencimientoCompra.Text = String.Empty
- txtPrecioCompra.Text = String.Empty
- cboAnioBaseC.SelectedIndex = 0
- txtCostoTransferenciaCompra.Text = String.Empty
- txtYTMAlVencimientoCompra.Text = String.Empty
- txtYTMAlVencimientoComisionCompra.Text = String.Empty
- txtComisionCompraCasa.Text = String.Empty
- txtComisionCompraBolsa.Text = String.Empty
- cboPeriodosV.SelectedIndex = -1
- txtValorNominalVenta.Text = String.Empty
- dtpUltimaFechaCuponVenta.Value = Fecha
- dtpSiguienteFechaCuponVenta.Value = Fecha
- dtpFechaLiquidacionVenta.Value = Fecha
- dtpFechaVencimientoVenta.Value = Fecha
- txtPorcentajeCuponVenta.Text = String.Empty
- txtPrecioAlVencimientoVenta.Text = String.Empty
- txtPrecioVenta.Text = String.Empty
- cboAnioBaseV.SelectedIndex = 0
- txtCuponesRecibidos.Text = String.Empty
- txtYTMAlVencimientoVenta.Text = String.Empty
- txtYTMAlVencimientoComisionVenta.Text = String.Empty
- txtComisionVentaCasa.Text = String.Empty
- txtComisionVentaBolsa.Text = String.Empty
- End Sub
- Private Sub btnAceptar_Click(sender As Object, e As EventArgs) Handles btnAceptar.Click
- Dim Codigo = Variables.Codigo
- If TipoTransaccion = "N" Then
- oDAOPrincipal.Nuevo(Parametros, Instrumento)
- ElseIf Not ExisteValidacion() Then
- Variables.ColeccionCINV = Parametros()
- Me.Close()
- End If
- If TipoTransaccion = "M" Then
- Dim Diccionario As New Dictionary(Of Integer, Collection)
- Diccionario = ModificarIngreso()
- oDAOPrincipal.ProcesoDatos(Parametros, Diccionario, Instrumento)
- End If
- If TipoTransaccion = "B" Then
- oDAOPrincipal.
- Eliminar(Codigo, Instrumento)
- LimpiarElementos()
- End If
- ValidarExistencia()
- End Sub
- Public Sub CargarRegistro(ByVal CodInversion As String)
- TipoTransaccion = "C"
- CodigoInversion = CodInversion
- End Sub
- Private Sub dtpUltimaFechaCuponCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpUltimaFechaCuponCompra.ValueChanged
- Formato()
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub dtpSiguienteFechaCuponCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpSiguienteFechaCuponCompra.ValueChanged
- Formato()
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub dtpFechaLiquidacionCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacionCompra.ValueChanged
- Formato()
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub dtpFechaVencimientoCompra_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoCompra.ValueChanged
- Formato()
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtPorcentajeCuponCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtPrecioCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioCompra.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtPrecioAlVencimientoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtCostoTransferenciaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub dtpFechaVencimientoVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaVencimientoVenta.ValueChanged
- Formato()
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub cboAnioBaseC_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBaseC.SelectedIndexChanged
- Formato()
- Calculos()
- ValidacionErrores()
- CamposTiempo()
- End Sub
- Private Sub cboAnioBaseV_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboAnioBaseV.SelectedIndexChanged
- Formato()
- Calculos()
- ValidacionErrores()
- CamposTiempo()
- End Sub
- Sub CargarPeriodos()
- If cboPeriodosC.Items.Count = 0 Or cboPeriodosC.Items.Count = 1 Then
- Me.cboPeriodosC.DataSource = oDAOGeneral.ListaPeriodicidad
- Me.cboPeriodosC.ValueMember = "Codigo"
- Me.cboPeriodosC.DisplayMember = "Descripcion"
- Me.cboPeriodosC.SelectedIndex = 0
- End If
- If cboPeriodosV.Items.Count = 0 Or cboPeriodosV.Items.Count = 1 Then
- Me.cboPeriodosV.DataSource = oDAOGeneral.ListaPeriodicidad
- Me.cboPeriodosV.ValueMember = "Codigo"
- Me.cboPeriodosV.DisplayMember = "Descripcion"
- Me.cboPeriodosV.SelectedIndex = 0
- End If
- End Sub
- Private Sub cboPeriodosC_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodosC.SelectedIndexChanged
- Formato()
- Calculos()
- ControlPeriodosCompra()
- ValidacionErrores()
- CamposTiempo()
- End Sub
- Private Sub cboPeriodosV_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPeriodosV.SelectedIndexChanged
- Formato()
- Calculos()
- ValidacionErrores()
- CamposTiempo()
- End Sub
- Private Sub RefrescarValorControles()
- Dim codigo = Variables.Codigo
- Dim coleccion = oDAOPrincipal.CargarRegistro(codigo, Instrumento)
- If (Not coleccion.Count = 1) Then
- Dim Operaciones As New Operaciones
- If coleccion(10) = 0 Then
- IndexBaseC = 0
- ElseIf coleccion(10) = 1 Then
- IndexBaseC = 1
- ElseIf coleccion(10) = 2 Then
- IndexBaseC = 2
- Else
- IndexBaseC = 3
- End If
- If coleccion(21) = 0 Then
- IndexBaseV = 0
- ElseIf coleccion(21) = 1 Then
- IndexBaseV = 1
- ElseIf coleccion(21) = 2 Then
- IndexBaseV = 2
- Else
- IndexBaseV = 3
- End If
- cboPeriodosC.SelectedValue = coleccion(1).ToString
- If (String.IsNullOrEmpty(coleccion(2).ToString)) Then
- txtValorNominalCompra.Text = 0
- Else
- txtValorNominalCompra.Text = coleccion(2).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(3).ToString)) Then
- dtpUltimaFechaCuponCompra.Value = Date.Now.Date
- Else
- dtpUltimaFechaCuponCompra.Value = coleccion(3).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(4).ToString)) Then
- dtpSiguienteFechaCuponCompra.Value = Date.Now.Date
- Else
- dtpSiguienteFechaCuponCompra.Value = coleccion(4).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(5).ToString)) Then
- dtpFechaLiquidacionCompra.Value = Date.Now.Date
- Else
- dtpFechaLiquidacionCompra.Value = coleccion(5).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(6).ToString)) Then
- dtpFechaVencimientoCompra.Value = Date.Now.Date
- Else
- dtpFechaVencimientoCompra.Value = coleccion(6).ToString
- End If
- ' txtPorcentajeCuponCompra.Text = coleccion(7)
- If (String.IsNullOrEmpty(coleccion(8).ToString)) Then
- txtPrecioAlVencimientoCompra.Text = 0
- Else
- txtPrecioAlVencimientoCompra.Text = coleccion(8).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(9).ToString)) Then
- Else
- txtPrecioCompra.Text = coleccion(9).ToString
- End If
- cboAnioBaseC.SelectedIndex = IndexBaseC
- If (String.IsNullOrEmpty(coleccion(11).ToString)) Then
- txtCostoTransferenciaCompra.Text = 0
- Else
- txtCostoTransferenciaCompra.Text = coleccion(11).ToString
- End If
- txtPorcentajeInteresAcumuladoCompra.Text = String.Empty
- If (String.IsNullOrEmpty(coleccion(23).ToString)) Then
- txtPorcentajeCuponCompra.Text = 0
- Else
- txtPorcentajeCuponCompra.Text = (CDec(coleccion(23) * 100).ToString)
- End If
- If (String.IsNullOrEmpty(txtComisionPorCompraCasa.Text)) Then
- txtComisionPorCompraCasa.Text = 0
- End If
- If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
- txtValorTransadoCompra.Text = 0
- End If
- If (String.IsNullOrEmpty(txtComisionPorBolsaCompra.Text)) Then
- txtComisionPorBolsaCompra.Text = 0
- End If
- txtComisionCompraCasa.Text = Operaciones.Comisiones(CDec(txtComisionPorCompraCasa.Text.TrimEnd("%") / 100), CDec(txtValorTransadoCompra.Text)).ToString
- txtComisionCompraBolsa.Text = Operaciones.Comisiones(CDec(txtComisionPorBolsaCompra.Text.TrimEnd("%") / 100), CDec(txtValorTransadoCompra.Text)).ToString
- If (String.IsNullOrEmpty(txtYTMAlVencimientoCompra.Text.ToString)) Then
- txtYTMAlVencimientoCompra.Text = 0
- End If
- If (String.IsNullOrEmpty(coleccion(12).ToString)) Then
- cboPeriodosV.SelectedValue = 0
- Else
- cboPeriodosV.SelectedValue = coleccion(12).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(13).ToString)) Then
- txtValorNominalVenta.Text = 0
- Else
- txtValorNominalVenta.Text = coleccion(13).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(14).ToString)) Then
- dtpUltimaFechaCuponVenta.Value = Date.Now.Date
- Else
- dtpUltimaFechaCuponVenta.Value = coleccion(14).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(15).ToString)) Then
- dtpSiguienteFechaCuponVenta.Value = Date.Now.Date
- Else
- dtpSiguienteFechaCuponVenta.Value = coleccion(15).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(16).ToString)) Then
- dtpFechaLiquidacionVenta.Value = Date.Now.Date
- Else
- dtpFechaLiquidacionVenta.Value = coleccion(16).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(17).ToString)) Then
- dtpFechaVencimientoVenta.Value = Date.Now.Date
- Else
- dtpFechaVencimientoVenta.Value = coleccion(17).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(24).ToString)) Then
- txtPorcentajeCuponVenta.Text = 0
- Else
- txtPorcentajeCuponVenta.Text = CDec(coleccion(24) * 100).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(19).ToString)) Then
- txtPrecioAlVencimientoVenta.Text = 0
- Else
- txtPrecioAlVencimientoVenta.Text = coleccion(19).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(20).ToString)) Then
- txtPrecioVenta.Text = 0
- Else
- txtPrecioVenta.Text = coleccion(20).ToString
- End If
- cboAnioBaseV.SelectedIndex = IndexBaseV
- If (String.IsNullOrEmpty(coleccion(22).ToString)) Then
- txtCuponesRecibidos.Text = 0
- Else
- txtCuponesRecibidos.Text = coleccion(22).ToString
- End If
- If (String.IsNullOrEmpty(txtComisionPorVentaCasa.Text)) Then
- txtComisionPorVentaCasa.Text = 0
- End If
- If (String.IsNullOrEmpty(txtComisionPorBolsaVenta.Text)) Then
- txtComisionPorBolsaVenta.Text = 0
- End If
- If String.IsNullOrEmpty(txtYTMAlVencimientoVenta.Text.ToString) Then
- txtYTMAlVencimientoVenta.Text = 0
- End If
- If (String.IsNullOrEmpty(coleccion(25).ToString)) Then
- txtComisionPorCompraCasa.Text = 0
- Else
- txtComisionPorCompraCasa.Text = (CDec(coleccion(25)) * 100).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(26).ToString)) Then
- txtComisionPorBolsaCompra.Text = 0
- Else
- txtComisionPorBolsaCompra.Text = (CDec(coleccion(26)) * 100).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(27).ToString)) Then
- txtComisionPorVentaCasa.Text = 0
- Else
- txtComisionPorVentaCasa.Text = (CDec(coleccion(27)) * 100).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(28).ToString)) Then
- txtComisionPorBolsaVenta.Text = 0
- Else
- txtComisionPorBolsaVenta.Text = (CDec(coleccion(28)) * 100).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(29).ToString)) Then
- txtYTMAlVencimientoComisionCompra.Text = 0
- Else
- txtYTMAlVencimientoComisionCompra.Text = (CDec(coleccion(29)) * 100).ToString
- End If
- If (String.IsNullOrEmpty(coleccion(30).ToString)) Then
- txtYTMAlVencimientoComisionVenta.Text = 0
- Else
- txtYTMAlVencimientoComisionVenta.Text = (CDec(coleccion(30)) * 100).ToString
- End If
- 'Campos Extras'
- If Not String.IsNullOrEmpty(coleccion(31).ToString) Then
- txtDiasAlVencimientoCompra.Text = coleccion(31).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(32).ToString) Then
- txtDiasAlVencimientoVenta.Text = coleccion(32).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(33).ToString) Then
- txtDiasAcumuladosCompra.Text = coleccion(33).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(34).ToString) Then
- txtDiasAcumuladosVenta.Text = coleccion(34).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(35).ToString) Then
- txtYTMAlVencimientoCompra.Text = (coleccion(35) * 100).ToString + "%"
- End If
- If Not String.IsNullOrEmpty(coleccion(36).ToString) Then
- txtYTMAlVencimientoVenta.Text = (coleccion(36) * 100).ToString + "%"
- End If
- If Not String.IsNullOrEmpty(coleccion(37).ToString) Then
- txtPorcentajeInteresAcumuladoCompra.Text = (coleccion(37) * 100).ToString + "%"
- End If
- If Not String.IsNullOrEmpty(coleccion(38).ToString) Then
- txtPorcentajeInteresAcumuladoVenta.Text = (coleccion(38) * 100).ToString + "%"
- End If
- If Not String.IsNullOrEmpty(coleccion(39).ToString) Then
- txtInteresAcumuladoCompra.Text = coleccion(39).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(40).ToString) Then
- txtInteresAcumuladoVenta.Text = coleccion(40).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(41).ToString) Then
- txtPrecioSucioCompra.Text = (coleccion(41) * 100).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(42).ToString) Then
- txtPrecioSucioVenta.Text = (coleccion(42) * 100).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(43).ToString) Then
- txtComisionCompraCasa.Text = coleccion(43).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(44).ToString) Then
- txtComisionVentaCasa.Text = coleccion(44).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(45).ToString) Then
- txtComisionCompraBolsa.Text = coleccion(45).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(46).ToString) Then
- txtComisionVentaBolsa.Text = coleccion(46).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(47).ToString) Then
- txtValorTransadoCompra.Text = coleccion(47).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(48).ToString) Then
- txtValorTransadoVenta.Text = coleccion(48).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(49).ToString) Then
- txtMontoAPagar.Text = coleccion(49).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(50).ToString) Then
- txtMontoARecibir.Text = coleccion(50).ToString
- End If
- If Not String.IsNullOrEmpty(coleccion(51).ToString) Then
- txtCuponesRecibidos.Text = coleccion(51).ToString
- End If
- End If
- End Sub
- Sub Formato()
- If cboPeriodosC.SelectedIndex = -1 Then
- If cboPeriodosC.Items.Count > 0 Then
- cboPeriodosC.SelectedIndex = 0
- End If
- End If
- If cboPeriodosV.SelectedIndex = -1 Then
- If cboPeriodosV.Items.Count > 0 Then
- cboPeriodosV.SelectedIndex = 0
- End If
- End If
- If cboAnioBaseC.SelectedIndex = -1 Then
- If cboAnioBaseC.Items.Count > 0 Then
- cboAnioBaseC.SelectedIndex = 0
- End If
- End If
- If cboAnioBaseV.SelectedIndex = -1 Then
- If cboAnioBaseV.Items.Count > 0 Then
- cboAnioBaseV.SelectedIndex = 0
- End If
- End If
- If IsNumeric(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
- If Double.IsNaN(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
- txtPorcentajeInteresAcumuladoCompra.Text = "0.0%"
- End If
- End If
- If IsNumeric(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
- If Double.IsNaN(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
- txtPorcentajeInteresAcumuladoVenta.Text = "0.0%"
- End If
- End If
- If IsNumeric(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
- If Double.IsNaN(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
- txtPrecioSucioCompra.Text = "0.0%"
- End If
- End If
- If IsNumeric(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
- If Double.IsNaN(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
- txtPrecioSucioVenta.Text = "0.0%"
- End If
- End If
- If (String.IsNullOrEmpty(txtValorNominalCompra.Text.ToString)) Then
- txtValorNominalCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtDiasAlVencimientoCompra.Text)) Then
- txtDiasAlVencimientoCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtDiasAcumuladosCompra.Text)) Then
- txtDiasAcumuladosCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPorcentajeCuponCompra.Text)) Then
- txtPorcentajeCuponCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtYTMAlVencimientoComisionCompra.Text)) Then
- txtYTMAlVencimientoComisionCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtYTMAlVencimientoCompra.Text)) Then
- txtYTMAlVencimientoCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPrecioAlVencimientoCompra.Text)) Then
- txtPrecioAlVencimientoCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPrecioCompra.Text)) Then
- txtPrecioCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtInteresAcumuladoCompra.Text)) Then
- txtInteresAcumuladoCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoCompra.Text)) Then
- txtPorcentajeInteresAcumuladoCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPrecioSucioCompra.Text)) Then
- txtPrecioSucioCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtComisionPorCompraCasa.Text)) Then
- txtComisionPorCompraCasa.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtComisionCompraCasa.Text)) Then
- txtComisionCompraCasa.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtComisionPorBolsaCompra.Text)) Then
- txtComisionPorBolsaCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtComisionCompraBolsa.Text)) Then
- txtComisionCompraBolsa.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtValorTransadoCompra.Text)) Then
- txtValorTransadoCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtMontoAPagar.Text)) Then
- txtMontoAPagar.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtCostoTransferenciaCompra.Text)) Then
- txtCostoTransferenciaCompra.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtValorNominalVenta.Text)) Then
- txtValorNominalVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtDiasAlVencimientoVenta.Text)) Then
- txtDiasAlVencimientoVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtDiasAcumuladosVenta.Text)) Then
- txtDiasAcumuladosVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPorcentajeCuponVenta.Text)) Then
- txtPorcentajeCuponVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtYTMAlVencimientoComisionVenta.Text)) Then
- txtYTMAlVencimientoComisionVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtYTMAlVencimientoVenta.Text)) Then
- txtYTMAlVencimientoVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPrecioAlVencimientoVenta.Text)) Then
- txtPrecioAlVencimientoVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPrecioVenta.Text)) Then
- txtPrecioVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtInteresAcumuladoVenta.Text)) Then
- txtInteresAcumuladoVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoVenta.Text)) Then
- txtPorcentajeInteresAcumuladoVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtPrecioSucioVenta.Text)) Then
- txtPrecioSucioVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtComisionPorVentaCasa.Text)) Then
- txtComisionPorVentaCasa.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtComisionVentaCasa.Text)) Then
- txtComisionVentaCasa.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtComisionPorBolsaVenta.Text)) Then
- txtComisionPorBolsaVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtComisionVentaBolsa.Text)) Then
- txtComisionVentaBolsa.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtValorTransadoVenta.Text)) Then
- txtValorTransadoVenta.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtMontoARecibir.Text)) Then
- txtMontoARecibir.Text = "0.0"
- End If
- If (String.IsNullOrEmpty(txtCuponesRecibidos.Text)) Then
- txtCuponesRecibidos.Text = "0.0"
- End If
- If (txtPorcentajeCuponCompra.ToString.IndexOf("%") = -1) Then
- txtPorcentajeCuponCompra.Text += "%"
- End If
- If (txtYTMAlVencimientoCompra.ToString.IndexOf("%") = -1) Then
- txtYTMAlVencimientoCompra.Text += "%"
- End If
- If (txtPorcentajeCuponVenta.ToString.IndexOf("%") = -1) Then
- txtPorcentajeCuponVenta.Text += "%"
- End If
- If (txtYTMAlVencimientoVenta.ToString.IndexOf("%") = -1) Then
- txtYTMAlVencimientoVenta.Text += "%"
- End If
- If (txtComisionPorCompraCasa.ToString.IndexOf("%") = -1) Then
- txtComisionPorCompraCasa.Text += "%"
- End If
- If (txtComisionPorBolsaCompra.ToString.IndexOf("%") = -1) Then
- txtComisionPorBolsaCompra.Text += "%"
- End If
- If (txtComisionPorVentaCasa.ToString.IndexOf("%") = -1) Then
- txtComisionPorVentaCasa.Text += "%"
- End If
- If (txtComisionPorBolsaVenta.ToString.IndexOf("%") = -1) Then
- txtComisionPorBolsaVenta.Text += "%"
- End If
- End Sub
- Sub Calculos()
- If (Not Cargar) Then
- Dim V_dtpSiguienteFechaCuponCompra = Date.Now.Date, V_dtpFechaVencimientoCompra = Date.Now.Date, V_dtpFechaLiquidacionCompra = Date.Now.Date, V_dtpUltimaFechaCuponCompra = Date.Now.Date
- Dim V_txtValorNominalCompra = 0.0, V_txtPorcentajeCuponCompra = 0.0, V_txtDiasAcumuladosCompra = 0, V_txtInteresAcumuladoCompra = 0.0
- Dim V_txtPorcentajeInteresAcumuladoCompra = 0.0, V_txtComisionPorCompraCasa = 0.0, V_txtValorTransadoCompra = 0.0
- Dim V_txtComisionPorBolsaCompra = 0.0, V_txtComisionCompraCasa = 0.0, V_txtComisionCompraBolsa = 0.0
- Dim V_txtYTMAlVencimientoCompra = 0.0, V_txtYTMAlVencimientoComisionCompra = 0.0, V_txtMontoAPagar = 0.0, V_txtPrecioCompra = 0.0
- Dim V_txtPrecioAlVencimientoCompra = 0.0, V_txtCostoTransferenciaCompra = 0.0, V_txtPrecioSucioCompra = 0.0
- Dim V_txtDiasAlVencimientoCompra = 0
- Dim TipoPeriodoCompra As Integer = 0
- Dim V_dtpSiguienteFechaCuponVenta = Date.Now.Date, V_dtpFechaVencimientoVenta = Date.Now.Date, V_dtpFechaLiquidacionVenta = Date.Now.Date, V_dtpUltimaFechaCuponVenta = Date.Now.Date
- Dim V_txtValorNominalVenta = 0.0, V_txtPorcentajeCuponVenta = 0.0, V_txtDiasAcumuladosVenta = 0, V_txtInteresAcumuladoVenta = 0.0
- Dim V_txtPorcentajeInteresAcumuladoVenta = 0.0, V_txtComisionPorVentaCasa = 0.0, V_txtValorTransadoVenta = 0.0
- Dim V_txtComisionPorBolsaVenta = 0.0, V_txtComisionVentaCasa = 0.0, V_txtComisionVentaBolsa = 0.0
- Dim V_txtYTMAlVencimientoVenta = 0.0, V_txtYTMAlVencimientoComisionVenta = 0.0, V_txtPrecioVenta = 0.0
- Dim V_txtPrecioAlVencimientoVenta = 0.0, V_txtCostoTransferenciaVenta = 0.0, V_txtPrecioSucioVenta = 0.0
- Dim V_txtDiasAlVencimientoVenta = 0.0, V_txtMontoARecibir = 0.0, V_txtCuponesRecibidos = 0.0
- Dim TipoPeriodoVenta As Integer = 0
- V_dtpSiguienteFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value
- V_dtpSiguienteFechaCuponVenta = dtpSiguienteFechaCuponVenta.Value
- V_dtpUltimaFechaCuponCompra = dtpUltimaFechaCuponCompra.Value
- V_dtpUltimaFechaCuponVenta = dtpUltimaFechaCuponVenta.Value
- V_dtpFechaVencimientoCompra = dtpFechaVencimientoCompra.Value
- V_dtpFechaVencimientoVenta = dtpFechaVencimientoVenta.Value
- V_dtpFechaLiquidacionCompra = dtpFechaLiquidacionCompra.Value
- V_dtpFechaLiquidacionVenta = dtpFechaLiquidacionVenta.Value
- If String.IsNullOrEmpty(txtValorNominalCompra.Text) Then
- V_txtValorNominalCompra = 0
- Else
- V_txtValorNominalCompra = txtValorNominalCompra.Text
- End If
- If String.IsNullOrEmpty(txtValorNominalVenta.Text) Then
- V_txtValorNominalVenta = 0
- Else
- V_txtValorNominalVenta = txtValorNominalVenta.Text
- End If
- If String.IsNullOrEmpty(txtPorcentajeCuponCompra.Text.Trim("%")) Then
- V_txtPorcentajeCuponCompra = 0
- Else
- V_txtPorcentajeCuponCompra = CDec(txtPorcentajeCuponCompra.Text.Trim("%") / 100)
- End If
- If String.IsNullOrEmpty(txtPorcentajeCuponVenta.Text.Trim("%")) Then
- V_txtPorcentajeCuponVenta = 0
- Else
- V_txtPorcentajeCuponVenta = CDec(txtPorcentajeCuponVenta.Text.Trim("%") / 100)
- End If
- If String.IsNullOrEmpty(txtYTMAlVencimientoCompra.Text.Trim("%")) Then
- V_txtYTMAlVencimientoCompra = 0
- Else
- V_txtYTMAlVencimientoCompra = CDec(txtYTMAlVencimientoCompra.Text.Trim("%") / 100)
- End If
- If String.IsNullOrEmpty(txtYTMAlVencimientoVenta.Text.Trim("%")) Then
- V_txtYTMAlVencimientoVenta = 0
- Else
- V_txtYTMAlVencimientoVenta = CDec(txtYTMAlVencimientoVenta.Text.Trim("%") / 100)
- End If
- If String.IsNullOrEmpty(txtPrecioCompra.Text) Then
- V_txtPrecioCompra = 0
- Else
- V_txtPrecioCompra = txtPrecioCompra.Text
- End If
- If String.IsNullOrEmpty(txtPrecioVenta.Text) Then
- V_txtPrecioVenta = 0
- Else
- V_txtPrecioVenta = txtPrecioVenta.Text
- End If
- If String.IsNullOrEmpty(txtPrecioAlVencimientoCompra.Text) Then
- V_txtPrecioAlVencimientoCompra = 0
- Else
- V_txtPrecioAlVencimientoCompra = txtPrecioAlVencimientoCompra.Text
- End If
- If String.IsNullOrEmpty(txtPrecioAlVencimientoVenta.Text) Then
- V_txtPrecioAlVencimientoVenta = 0
- Else
- V_txtPrecioAlVencimientoVenta = txtPrecioAlVencimientoVenta.Text
- End If
- If String.IsNullOrEmpty(txtComisionPorCompraCasa.Text.Trim("%")) Then
- V_txtComisionPorCompraCasa = 0
- Else
- V_txtComisionPorCompraCasa = CDec(txtComisionPorCompraCasa.Text.Trim("%")) / 100
- End If
- If String.IsNullOrEmpty(txtComisionPorVentaCasa.Text.Trim("%")) Then
- V_txtComisionPorVentaCasa = 0
- Else
- V_txtComisionPorVentaCasa = CDec(txtComisionPorVentaCasa.Text.Trim("%")) / 100
- End If
- If String.IsNullOrEmpty(txtComisionCompraCasa.Text) Then
- V_txtComisionCompraCasa = 0
- Else
- V_txtComisionCompraCasa = txtComisionCompraCasa.Text
- End If
- If String.IsNullOrEmpty(txtComisionVentaCasa.Text) Then
- V_txtComisionVentaCasa = 0
- Else
- V_txtComisionVentaCasa = txtComisionVentaCasa.Text
- End If
- If String.IsNullOrEmpty(txtComisionPorBolsaCompra.Text.Trim("%")) Then
- V_txtComisionPorBolsaCompra = 0
- Else
- V_txtComisionPorBolsaCompra = CDec(txtComisionPorBolsaCompra.Text.Trim("%")) / 100
- End If
- If String.IsNullOrEmpty(txtComisionPorBolsaVenta.Text.Trim("%")) Then
- V_txtComisionPorBolsaVenta = 0
- Else
- V_txtComisionPorBolsaVenta = CDec(txtComisionPorBolsaVenta.Text.Trim("%")) / 100
- End If
- If String.IsNullOrEmpty(txtComisionCompraBolsa.Text) Then
- V_txtComisionCompraBolsa = 0
- Else
- V_txtComisionCompraBolsa = txtComisionCompraBolsa.Text
- End If
- If String.IsNullOrEmpty(txtComisionVentaBolsa.Text) Then
- V_txtComisionVentaBolsa = 0
- Else
- V_txtComisionVentaBolsa = txtComisionVentaBolsa.Text
- End If
- If String.IsNullOrEmpty(txtCostoTransferenciaCompra.Text) Then
- V_txtCostoTransferenciaCompra = 0
- Else
- V_txtCostoTransferenciaCompra = txtCostoTransferenciaCompra.Text
- End If
- If (cboPeriodosC.SelectedValue = "M") Then
- TipoPeriodoCompra = 12
- PeriodoC = 1
- ElseIf (cboPeriodosC.SelectedValue = "T") Then
- TipoPeriodoCompra = 4
- PeriodoC = 3
- ElseIf (cboPeriodosC.SelectedValue = "S") Then
- TipoPeriodoCompra = 2
- PeriodoC = 6
- ElseIf (cboPeriodosC.SelectedValue = "A") Then
- TipoPeriodoCompra = 1
- PeriodoC = 12
- End If
- If (cboPeriodosV.SelectedValue = "M") Then
- TipoPeriodoVenta = 12
- PeriodoV = 1
- ElseIf (cboPeriodosV.SelectedValue = "T") Then
- TipoPeriodoVenta = 4
- PeriodoV = 3
- ElseIf (cboPeriodosV.SelectedValue = "S") Then
- TipoPeriodoVenta = 2
- PeriodoV = 6
- ElseIf (cboPeriodosV.SelectedValue = "A") Then
- TipoPeriodoVenta = 1
- PeriodoV = 12
- End If
- If cboAnioBaseC.SelectedIndex = 0 Then
- IndexBaseC = 0
- ElseIf cboAnioBaseC.SelectedIndex = 1 Then
- IndexBaseC = 1
- ElseIf cboAnioBaseC.SelectedIndex = 2 Then
- IndexBaseC = 2
- Else
- IndexBaseC = 3
- End If
- If cboAnioBaseV.SelectedIndex = 0 Then
- IndexBaseV = 0
- ElseIf cboAnioBaseV.SelectedIndex = 1 Then
- IndexBaseV = 1
- ElseIf cboAnioBaseV.SelectedIndex = 2 Then
- IndexBaseV = 2
- Else
- IndexBaseV = 3
- End If
- If (Tipo = 0) Then
- dtpUltimaFechaCuponCompra.Value = FechaCupon(V_dtpFechaLiquidacionCompra, V_dtpFechaVencimientoCompra, TipoPeriodoCompra)
- dtpUltimaFechaCuponVenta.Value = FechaCupon(V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, TipoPeriodoVenta)
- Else
- dtpSiguienteFechaCuponCompra.Value = FechaTipo(V_dtpUltimaFechaCuponCompra, TipoPeriodoCompra)
- dtpSiguienteFechaCuponVenta.Value = FechaTipo(V_dtpUltimaFechaCuponVenta, TipoPeriodoVenta)
- End If
- V_dtpSiguienteFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value
- V_dtpSiguienteFechaCuponVenta = dtpSiguienteFechaCuponVenta.Value
- V_dtpUltimaFechaCuponCompra = dtpUltimaFechaCuponCompra.Value
- V_dtpUltimaFechaCuponVenta = dtpUltimaFechaCuponVenta.Value
- V_dtpFechaVencimientoCompra = dtpFechaVencimientoCompra.Value
- V_dtpFechaVencimientoVenta = dtpFechaVencimientoVenta.Value
- V_dtpFechaLiquidacionCompra = dtpFechaLiquidacionCompra.Value
- V_dtpFechaLiquidacionVenta = dtpFechaLiquidacionVenta.Value
- 'Valores de Compra
- V_txtDiasAlVencimientoCompra = BonoCalculo.DiasVencimiento(V_dtpFechaLiquidacionCompra, V_dtpFechaVencimientoCompra, IndexBaseC)
- V_txtDiasAcumuladosCompra = Operaciones.DiasAcumulados(V_dtpUltimaFechaCuponCompra, V_dtpFechaLiquidacionCompra, IndexBaseC)
- V_txtInteresAcumuladoCompra = BonoCalculo.InteresAcumulado(V_txtValorNominalCompra, V_txtPorcentajeCuponCompra, V_dtpUltimaFechaCuponCompra, V_dtpFechaLiquidacionCompra, V_txtDiasAcumuladosCompra, IndexBaseC)
- V_txtPorcentajeInteresAcumuladoCompra = BonoCalculo.InteresAcumuladoPor(V_txtInteresAcumuladoCompra, V_txtValorNominalCompra, PeriodoC, IndexBaseC) * 100
- V_txtPrecioSucioCompra = BonoCalculo.PrecioSucio(V_txtPrecioCompra, V_txtPorcentajeInteresAcumuladoCompra / 100)
- V_txtValorTransadoCompra = BonoCalculo.ValorTrasado(V_txtPrecioCompra, V_txtValorNominalCompra)
- V_txtComisionCompraCasa = CalcularComision(V_txtComisionPorCompraCasa, V_txtValorTransadoCompra)
- V_txtComisionCompraBolsa = CalcularComision(V_txtComisionPorBolsaCompra, V_txtValorTransadoCompra)
- V_txtYTMAlVencimientoComisionCompra = Bonos.CalcularYTMComision(CDec(V_txtYTMAlVencimientoCompra), CDec(V_txtComisionPorCompraCasa), V_txtDiasAlVencimientoCompra, CDec(V_txtComisionPorBolsaCompra), V_dtpFechaLiquidacionCompra, V_dtpFechaVencimientoCompra, IndexBaseC)
- V_txtMontoAPagar = BonoCalculo.MontoPagar(V_txtValorTransadoCompra, V_txtComisionCompraBolsa, V_txtComisionCompraCasa, V_txtInteresAcumuladoCompra, V_txtCostoTransferenciaCompra)
- 'Valores de Venta
- V_txtDiasAlVencimientoVenta = BonoCalculo.DiasVencimiento(V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, IndexBaseV)
- V_txtDiasAcumuladosVenta = Operaciones.DiasAcumulados(V_dtpUltimaFechaCuponVenta, V_dtpFechaLiquidacionVenta, IndexBaseV)
- V_txtInteresAcumuladoVenta = BonoCalculo.InteresAcumulado(V_txtValorNominalVenta, V_txtPorcentajeCuponVenta, V_dtpUltimaFechaCuponVenta, V_dtpFechaLiquidacionVenta, V_txtDiasAcumuladosVenta, IndexBaseV)
- V_txtPorcentajeInteresAcumuladoVenta = BonoCalculo.InteresAcumuladoPor(V_txtInteresAcumuladoVenta, V_txtValorNominalVenta, PeriodoV, IndexBaseV) * 100
- V_txtPrecioSucioVenta = BonoCalculo.PrecioSucio(V_txtPrecioVenta, V_txtPorcentajeInteresAcumuladoVenta / 100)
- V_txtValorTransadoVenta = BonoCalculo.ValorTrasado(V_txtPrecioVenta, V_txtValorNominalVenta)
- V_txtComisionVentaCasa = CalcularComision(V_txtComisionPorVentaCasa, V_txtValorTransadoVenta)
- V_txtComisionVentaBolsa = CalcularComision(V_txtComisionPorBolsaVenta, V_txtValorTransadoVenta)
- V_txtYTMAlVencimientoComisionVenta = Bonos.CalcularYTMComision(V_txtYTMAlVencimientoVenta, V_txtComisionPorVentaCasa, V_txtDiasAlVencimientoVenta, V_txtComisionPorBolsaVenta, V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, IndexBaseV)
- V_txtMontoARecibir = BonoCalculo.MontoRecibir(V_txtValorTransadoVenta, V_txtComisionVentaBolsa, V_txtComisionVentaCasa, V_txtInteresAcumuladoVenta)
- V_txtCuponesRecibidos = Recibido()
- 'Valores de Compra
- txtDiasAlVencimientoCompra.Text = Format(V_txtDiasAlVencimientoCompra, "0.0000")
- txtDiasAcumuladosCompra.Text = Format(V_txtDiasAcumuladosCompra, "0.0000")
- txtInteresAcumuladoCompra.Text = Format(V_txtInteresAcumuladoCompra, "0.0000")
- txtPorcentajeInteresAcumuladoCompra.Text = CStr(Format(V_txtPorcentajeInteresAcumuladoCompra, "0.000")) + "%"
- txtPrecioSucioCompra.Text = Format(V_txtPrecioSucioCompra, "0.0000")
- txtValorTransadoCompra.Text = Format(V_txtValorTransadoCompra, "0.0000")
- txtComisionCompraCasa.Text = Format(V_txtComisionCompraCasa, "0.0000")
- txtComisionCompraBolsa.Text = Format(V_txtComisionCompraBolsa, "0.0000")
- txtYTMAlVencimientoComisionCompra.Text = CStr(Format(V_txtYTMAlVencimientoComisionCompra, "0.0000") * 100) + "%"
- txtMontoAPagar.Text = Format(V_txtMontoAPagar, "0.0000")
- txtComisionCompraCasa.Text = Format(V_txtComisionCompraCasa, "0.0000")
- txtComisionCompraBolsa.Text = Format(V_txtComisionCompraBolsa, "0.0000")
- 'Valores de Venta
- FechaCupon(V_dtpFechaLiquidacionVenta, V_dtpFechaVencimientoVenta, TipoPeriodoVenta)
- txtDiasAlVencimientoVenta.Text = Format(V_txtDiasAlVencimientoVenta, "0.0000")
- txtDiasAcumuladosVenta.Text = Format(V_txtDiasAcumuladosVenta, "0.0000")
- txtInteresAcumuladoVenta.Text = Format(V_txtInteresAcumuladoVenta, "0.0000")
- txtPorcentajeInteresAcumuladoVenta.Text = CStr(Format(V_txtPorcentajeInteresAcumuladoVenta, "0.0000")) + "%"
- txtPrecioSucioVenta.Text = Format(V_txtPrecioSucioVenta, "0.0000")
- txtValorTransadoVenta.Text = Format(V_txtValorTransadoVenta, "0.0000")
- txtComisionVentaCasa.Text = Format(V_txtComisionVentaCasa, "0.0000")
- txtComisionVentaBolsa.Text = Format(V_txtComisionVentaBolsa, "0.0000")
- txtYTMAlVencimientoComisionVenta.Text = CStr(Format(V_txtYTMAlVencimientoComisionVenta, "0.0000") * 100) + "%"
- txtMontoARecibir.Text = Format(V_txtMontoARecibir, "0.0000")
- txtCuponesRecibidos.Text = Format(V_txtCuponesRecibidos, "0.0000")
- txtComisionVentaCasa.Text = Format(V_txtComisionVentaCasa, "0.0000")
- txtComisionVentaBolsa.Text = Format(V_txtComisionVentaBolsa, "0.0000")
- End If
- CorrelativoSinBD()
- End Sub
- Function CalcularComision(ByVal Porcentaje As Double, ByVal VTransado As Double)
- Return Porcentaje * VTransado
- End Function
- Private Sub RefrescarClaseEntidad()
- ControlUltimaFechaCuponCompra()
- ControlSiguienteFechaCuponCompra()
- ControlFechaLiquidacionCompra()
- ControlFechaVencimientoCompra()
- ControlAnioBaseCompra()
- ControlUltimaFechaCuponCompra()
- ControlSiguienteFechaCuponCompra()
- ControlFechaLiquidacionCompra()
- ControlFechaVencimientoCompra()
- ControlAnioBaseCompra()
- End Sub
- Private Sub ControlPeriodosCompra()
- Dim valor As String
- If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
- If Me.cboPeriodosC.SelectedIndex = -1 Then
- valor = ""
- Else
- If (String.IsNullOrEmpty(Me.cboPeriodosC.SelectedValue)) Then
- valor = String.Empty
- Else
- valor = Me.cboPeriodosC.SelectedValue
- End If
- End If
- oCEPrincipal.PeriodicidadCompra = valor
- End If
- End Sub
- Function FechaTipo(ByVal ultimafecha As DateTime, ByVal frecuencia As Integer)
- Dim periodos As Integer = 0
- Dim Fecha As Date
- If frecuencia = 1 Then
- periodos = 12
- ElseIf frecuencia = 2 Then
- periodos = 6
- ElseIf frecuencia = 4 Then
- periodos = 3
- ElseIf frecuencia = 12 Then
- periodos = 1
- End If
- Fecha = ultimafecha.AddMonths(periodos)
- Return Fecha
- End Function
- Private Sub ControlUltimaFechaCuponCompra()
- If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
- Me.oCEPrincipal.UltimaFechaCuponCompra = dtpUltimaFechaCuponCompra.Value.Date
- End If
- End Sub
- Private Sub ControlSiguienteFechaCuponCompra()
- If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
- Me.oCEPrincipal.SiguienteFechaCuponCompra = dtpSiguienteFechaCuponCompra.Value.Date
- End If
- End Sub
- Private Sub ControlFechaLiquidacionCompra()
- If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
- Me.oCEPrincipal.FechaLiquidacionCompra = dtpFechaLiquidacionCompra.Value.Date
- End If
- End Sub
- Private Sub ControlFechaVencimientoCompra()
- If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
- Me.oCEPrincipal.FechaVencimientoCompra = dtpFechaVencimientoCompra.Value.Date
- End If
- End Sub
- Private Sub ControlAnioBaseCompra()
- Dim valor As Integer
- If Me.TipoTransaccion = "N" Or Me.TipoTransaccion = "A" Then
- valor = cboAnioBaseC.SelectedItem
- Me.oCEPrincipal.DiasBaseCompra = valor
- End If
- End Sub
- Private Sub txtValorNominalCompra_LostFocus(sender As Object, e As EventArgs) Handles txtValorNominalCompra.LostFocus
- End Sub
- Private Sub txtPorcentajeCuponCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.LostFocus
- End Sub
- Private Sub txtPrecioAlVencimientoCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.LostFocus
- End Sub
- Private Sub txtPrecioCompra_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioCompra.LostFocus
- End Sub
- Private Sub txtCostoTransferenciaCompra_LostFocus(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.LostFocus
- End Sub
- Private Sub dtpSiguienteFechaCuponVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpSiguienteFechaCuponVenta.ValueChanged
- Formato()
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtCostoTransferenciaVenta_TextChanged(sender As Object, e As EventArgs)
- End Sub
- Private Sub dgvImpuestosYComisiones_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs)
- End Sub
- Private Sub dgvImpuestosYComisiones_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellContentClick
- Formato()
- End Sub
- Private Sub dgvImpuestosYComisiones_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs)
- oCEPrincipal.ImpuestosYComisiones.AcceptChanges()
- End Sub
- Private Sub PrepararTablaIngresos()
- Dim CantidadColumnas As Integer = dgvIngresos.ColumnCount
- If CantidadColumnas = 0 Then
- Dim oDataGridViewTextBoxColumn As DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "CodInv"
- oDataGridViewTextBoxColumn.DataPropertyName = "CodInv"
- oDataGridViewTextBoxColumn.HeaderText = "Código Inversión"
- oDataGridViewTextBoxColumn.ValueType = GetType(String)
- oDataGridViewTextBoxColumn.Visible = False
- Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "NumCupon"
- oDataGridViewTextBoxColumn.DataPropertyName = "NumCupon"
- oDataGridViewTextBoxColumn.HeaderText = "No. Cupón"
- oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
- oDataGridViewTextBoxColumn.Visible = False
- Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "Correlativo"
- oDataGridViewTextBoxColumn.DataPropertyName = "Correlativo"
- oDataGridViewTextBoxColumn.HeaderText = "No. Cupón"
- oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
- Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "FechaCupon"
- oDataGridViewTextBoxColumn.DataPropertyName = "FechaCupon"
- oDataGridViewTextBoxColumn.HeaderText = "Fecha Cupón"
- oDataGridViewTextBoxColumn.ValueType = GetType(Date)
- Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "Dias"
- oDataGridViewTextBoxColumn.DataPropertyName = "Dias"
- oDataGridViewTextBoxColumn.HeaderText = "Dias "
- oDataGridViewTextBoxColumn.ValueType = GetType(Integer)
- Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "Ingreso"
- oDataGridViewTextBoxColumn.DataPropertyName = "Ingreso"
- oDataGridViewTextBoxColumn.HeaderText = "Ingreso"
- oDataGridViewTextBoxColumn.ValueType = GetType(Double)
- oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
- Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "PorcentajeImpuesto"
- oDataGridViewTextBoxColumn.DataPropertyName = "PorcImpuesto"
- oDataGridViewTextBoxColumn.HeaderText = "% Impuesto"
- oDataGridViewTextBoxColumn.ValueType = GetType(String)
- oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
- Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "MontoImpuesto"
- oDataGridViewTextBoxColumn.DataPropertyName = "MontoImpuesto"
- oDataGridViewTextBoxColumn.HeaderText = "Impuesto"
- oDataGridViewTextBoxColumn.ValueType = GetType(Double)
- oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
- Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
- oDataGridViewTextBoxColumn = New DataGridViewTextBoxColumn
- oDataGridViewTextBoxColumn.Name = "Liquido"
- oDataGridViewTextBoxColumn.DataPropertyName = "Liquido"
- oDataGridViewTextBoxColumn.HeaderText = "Liquido"
- oDataGridViewTextBoxColumn.ValueType = GetType(Double)
- oDataGridViewTextBoxColumn.DefaultCellStyle.Format = Configuraciones.CodigoTXTMontos
- Me.dgvIngresos.Columns.Add(oDataGridViewTextBoxColumn)
- End If
- End Sub
- Private Sub txtValorNominalVenta_LostFocus(sender As Object, e As EventArgs) Handles txtValorNominalVenta.LostFocus
- End Sub
- Private Sub txtPorcentajeCuponVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPorcentajeCuponVenta.LostFocus
- End Sub
- Private Sub txtPrecioAlVencimientoVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoVenta.LostFocus
- End Sub
- Private Sub txtPrecioVenta_LostFocus(sender As Object, e As EventArgs) Handles txtPrecioVenta.LostFocus
- End Sub
- Private Sub dgvIngresos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
- End Sub
- Private Sub dgvIngresos_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvIngresos.CellBeginEdit
- End Sub
- Private Sub dgvIngresos_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellEndEdit
- Dim Tabla As String = Instrumento()
- If Not Tabla = "TIT" Then
- CalculoIngresosBONO()
- End If
- End Sub
- Private Sub dgvIngresos_UserDeletedRow(sender As Object, e As DataGridViewRowEventArgs) Handles dgvIngresos.UserDeletedRow
- oCEPrincipal.Ingresos.AcceptChanges()
- End Sub
- Private Sub txtValorNominal_Op_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominal_Op.TextChanged
- End Sub
- Private Sub LLenarResultadosOperacion()
- Dim FechaCompra = dtpFechaLiquidacionCompra.Value
- Dim FechaVenta = dtpFechaLiquidacionVenta.Value
- Dim Dias As Integer = Operaciones.Dias(FechaCompra, FechaVenta, IndexBaseC)
- txtValorNominal_Op.Text = Operaciones.ConvertirDecimal(txtValorNominalCompra.Text.ToString)
- txtPlazo_Op.Text = Operaciones.ConvertirDecimal(PlazoOperacion().ToString)
- txtPrecioCompra_Op.Text = Operaciones.ConvertirDecimal(txtPrecioCompra.Text.ToString)
- txtPrecioVenta_Op.Text = Operaciones.ConvertirDecimal(txtPrecioVenta.Text.ToString)
- txtGananciaPerdidaCapital_Op.Text = Operaciones.ConvertirDecimal(GananciaPerdida().ToString)
- txtIngresosPorIntereses_Op.Text = Operaciones.ConvertirDecimal(IngresosInteres().ToString)
- txtCostosTotales_Op.Text = Operaciones.ConvertirDecimal(CostosTotales().ToString)
- txtGananciaPerdidaTotal_Op.Text = Operaciones.ConvertirDecimal(MontoGananciaPerdida().ToString)
- txtRendimientoGananciaPerdida_Op.Text = Operaciones.ConvertirDecimal(RendimientoGananciaPerdida(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
- txtRendimientoIntereses_Op.Text = Operaciones.ConvertirDecimal(RendimientoInteres(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
- txtRendimientoAntesISR_Op.Text = Operaciones.ConvertirDecimal(RendimientoNeto(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
- txtRendimientoDespuesISR_Op.Text = Operaciones.ConvertirDecimal(RendimientoNetoDespues(Dias, FechaCompra, FechaVenta, IndexBaseC).ToString)
- End Sub
- Private Function PlazoOperacion()
- Dim FechaVenta As Date = dtpFechaLiquidacionVenta.Value
- Dim FechaCompra As Date = dtpFechaLiquidacionCompra.Value
- Dim Dias = Operaciones.Dias(FechaCompra, FechaVenta, IndexBaseC)
- Return Dias
- End Function
- Private Function GananciaPerdida()
- Dim ValorTrasadoVenta = txtValorTransadoVenta.Text
- Dim ValorTrasadoCompra = txtValorTransadoCompra.Text
- Dim Total = ValorTrasadoVenta - ValorTrasadoCompra
- Return Total
- End Function
- Private Function IngresosInteres()
- Dim Registros = dgvIngresos.Rows.Count
- Dim Suma As Double = 0.0
- Registros = Registros - 2
- For i As Integer = 0 To Registros
- Suma = Suma + Double.Parse(dgvIngresos.Item(4, i).Value)
- Next
- Dim InteresAcumulado = txtInteresAcumuladoVenta.Text
- Return (Suma + InteresAcumulado)
- End Function
- Private Function CostosTotales()
- Dim ComisionCompraCasa = txtComisionCompraCasa.Text
- Dim ComisionVentaCasa = txtComisionVentaCasa.Text
- Dim ComisionCompraBolsa = txtComisionCompraBolsa.Text
- Dim ComisionVentaBolsa = txtComisionVentaBolsa.Text
- Dim CostoTransferenciaCompra = txtCostoTransferenciaCompra.Text
- 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
- Dim Total = (CDec(ComisionCompraCasa) + CDec(ComisionCompraBolsa) + CDec(CostoTransferenciaCompra) + CDec(ComisionVentaCasa) + CDec(ComisionVentaBolsa)) * -1
- Return Total
- End If
- Return "0"
- End Function
- Private Function MontoGananciaPerdida()
- Dim GananciaPerdida = txtGananciaPerdidaCapital_Op.Text
- Dim CostosTotales = txtCostosTotales_Op.Text
- Dim IngresoInteres = txtIngresosPorIntereses_Op.Text
- Dim Total = CDec(GananciaPerdida) + CDec(CostosTotales) + txtIngresosPorIntereses_Op.Text
- Return Total
- End Function
- Private Function RendimientoGananciaPerdida(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
- Dim GananciaCapital = txtGananciaPerdidaCapital_Op.Text
- Dim ValorNominal = txtValorNominal_Op.Text
- Dim Valor As Double = 0
- If (IndexBase = 0) Then
- Valor = GananciaCapital / ValorNominal * 360 / Dias
- Return (Valor * 100).ToString() + "%"
- ElseIf (IndexBase = 1) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
- PrOpc2 = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- ElseIf (IndexBase = 2) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
- PrOpc2 = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = GananciaCapital / ValorNominal * 365 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = GananciaCapital / ValorNominal * 366 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- Else
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = GananciaCapital / ValorNominal * 360 / DiasPrimeraFecha
- PrOpc2 = GananciaCapital / ValorNominal * 360 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = GananciaCapital / ValorNominal * 360 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = GananciaCapital / ValorNominal * 360 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- End If
- Return (Valor * 100).ToString() + "%"
- End Function
- Private Function RendimientoInteres(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
- Dim IngresosInteres = txtIngresosPorIntereses_Op.Text
- Dim ValorNominal = txtValorNominal_Op.Text
- Dim Valor As Double = 0
- If (IndexBase = 0) Then
- Valor = IngresosInteres / ValorNominal * 360 / Dias
- Return (Valor * 100).ToString() + "%"
- ElseIf (IndexBase = 1) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
- PrOpc2 = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- ElseIf (IndexBase = 2) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
- PrOpc2 = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = IngresosInteres / ValorNominal * 365 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = IngresosInteres / ValorNominal * 366 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- Else
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = IngresosInteres / ValorNominal * 360 / DiasPrimeraFecha
- PrOpc2 = IngresosInteres / ValorNominal * 360 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = IngresosInteres / ValorNominal * 360 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = IngresosInteres / ValorNominal * 360 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- End If
- End Function
- Private Function RendimientoNeto(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
- Dim MontoGananciaPerdidaTotal = txtGananciaPerdidaTotal_Op.Text
- Dim ValorNominal = txtValorNominal_Op.Text
- Dim Valor As Double = 0
- If (IndexBase = 0) Then
- Valor = MontoGananciaPerdidaTotal / ValorNominal * 360 / Dias
- Return (Valor * 100).ToString() + "%"
- ElseIf (IndexBase = 1) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
- PrOpc2 = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- ElseIf (IndexBase = 2) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
- PrOpc2 = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = MontoGananciaPerdidaTotal / ValorNominal * 365 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = MontoGananciaPerdidaTotal / ValorNominal * 366 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- Else
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasPrimeraFecha
- PrOpc2 = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = MontoGananciaPerdidaTotal / ValorNominal * 360 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- End If
- End Function
- Private Function Recibido()
- Dim Registros = dgvIngresos.Rows.Count
- Dim Suma As Double = 0.0
- Registros = Registros - 1
- For i As Integer = 0 To Registros
- If (Not String.IsNullOrEmpty(dgvIngresos.Rows(i).Cells("Ingreso").Value)) Then
- Suma = Suma + Double.Parse(dgvIngresos.Rows(i).Cells("Ingreso").Value)
- End If
- Next
- Return Suma
- End Function
- Private Function RendimientoNetoDespues(ByVal Dias As Integer, ByVal Fecha1 As Date, ByVal Fecha2 As Date, ByVal IndexBase As Integer)
- Dim Registros = dgvIngresos.Rows.Count
- Dim Suma As Double = 0.0
- Registros = Registros - 1
- For i As Integer = 0 To Registros
- If (Not String.IsNullOrEmpty(dgvIngresos.Rows(i).Cells("MontoImpuesto").Value)) Then
- Suma = Suma + Double.Parse(dgvIngresos.Rows(i).Cells("MontoImpuesto").Value)
- End If
- Next
- Dim MontoGananciaTotal = txtGananciaPerdidaTotal_Op.Text
- Dim Impuesto = Suma
- Dim ValorNominal = txtValorNominal_Op.Text
- Dim Valor As Double = 0
- If (IndexBase = 0) Then
- Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / Dias
- Return (Valor * 100).ToString() + "%"
- ElseIf (IndexBase = 1) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
- PrOpc2 = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- ElseIf (IndexBase = 2) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
- PrOpc2 = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 366 / DiasPrimeraFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 365 / DiasSegundaFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- Else
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasPrimeraFecha
- PrOpc2 = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasSegundaFecha
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasSegundaFecha
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = (MontoGananciaTotal - Impuesto) / ValorNominal * 360 / DiasPrimeraFecha
- Else
- Valor = 0
- End If
- Return (Valor * 100).ToString() + "%"
- End If
- End Function
- Private Sub TabPage4_Click(sender As Object, e As EventArgs) Handles TabPage4.Click
- End Sub
- Private Sub TabPage1_Click(sender As Object, e As EventArgs) Handles TabPage1.Click
- End Sub
- Private Sub TabPage2_Click(sender As Object, e As EventArgs) Handles TbIngresos.Click
- End Sub
- Private Sub navModificar_Click(sender As Object, e As EventArgs) Handles navModificar.Click
- TipoTransaccion = "M"
- btnAceptar.Text = "Modificar"
- 'btnAccionComisiones.Text = "Modificar"
- End Sub
- Private Sub navNuevo_Click(sender As Object, e As EventArgs) Handles navNuevo.Click
- TipoTransaccion = "N"
- btnAceptar.Text = "Nuevo"
- End Sub
- Private Sub navEliminar_Click(sender As Object, e As EventArgs) Handles navEliminar.Click
- TipoTransaccion = "B"
- btnAceptar.Text = "Eliminar"
- End Sub
- Private Sub txtYTMAlVencimientoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoCompra.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtPorcentajeInteresAcumuladoVenta_TextChanged(sender As Object, e As EventArgs)
- End Sub
- Private Sub txtYTMAlVencimientoComisionCompra_TextChanged(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoComisionCompra.TextChanged
- End Sub
- Private Sub txtValorNominalVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominalVenta.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtPorcentajeCuponVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeCuponVenta.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtPrecioAlVencimientoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoVenta.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtValorNominalCompra_TextChanged(sender As Object, e As EventArgs) Handles txtValorNominalCompra.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtPrecioSucioCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioCompra.TextChanged
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs)
- RefrescarValorControles()
- End Sub
- Private Sub txtPrecioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioVenta.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub btnAccionIngreso_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub TabControl1_TabIndexChanged(sender As Object, e As EventArgs) Handles TabCampos.TabIndexChanged
- Formato()
- Formato()
- End Sub
- Private Sub dgvIngresos_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellClick
- Index = e.RowIndex
- PrepararCalculos()
- Formato()
- End Sub
- Private Sub txtDiasAcumuladosCompra_TextChanged(sender As Object, e As EventArgs) Handles txtDiasAcumuladosCompra.TextChanged
- End Sub
- Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabCampos.SelectedIndexChanged
- ValidacionErrores()
- BotonQuitar()
- If (dgvIngresos.Rows.Count < 2) Then
- End If
- If (TabCampos.SelectedIndex = 2) Or (TabCampos.SelectedIndex = 1) Then
- LLenarResultadosOperacion()
- End If
- End Sub
- Private Sub dtpUltimaFechaCuponVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpUltimaFechaCuponVenta.ValueChanged
- Formato()
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub dtpFechaLiquidacionVenta_ValueChanged(sender As Object, e As EventArgs) Handles dtpFechaLiquidacionVenta.ValueChanged
- Formato()
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtYTMAlVencimientoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoVenta.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub btnAmortizacion_Click(sender As Object, e As EventArgs)
- frmResultadoTitularizacion.Show()
- End Sub
- Function ColeccionIngresos(ByRef index As Integer)
- Dim coleccion As New Collection
- Dim NoCupon, Fecha, Ingreso, PorcImpuesto, Impuesto, Dias, Liquido As String
- NoCupon = dgvIngresos.Rows(index).Cells("NumCupon").Value
- Fecha = dgvIngresos.Rows(index).Cells("FechaCupon").Value
- Dias = dgvIngresos.Rows(index).Cells("Dias").Value
- Ingreso = dgvIngresos.Rows(index).Cells("Ingreso").Value
- PorcImpuesto = dgvIngresos.Rows(index).Cells("PorcentajeImpuesto").Value
- If Not PorcImpuesto Is Nothing Then
- PorcImpuesto = CDec((PorcImpuesto.ToString().Trim("%")) / 100)
- End If
- Impuesto = dgvIngresos.Rows(index).Cells("MontoImpuesto").Value
- Liquido = dgvIngresos.Rows(index).Cells("Liquido").Value
- coleccion.Add(NoCupon)
- coleccion.Add(Fecha)
- coleccion.Add(Dias)
- coleccion.Add(Ingreso)
- coleccion.Add(PorcImpuesto)
- coleccion.Add(Impuesto)
- coleccion.Add(Liquido)
- Return coleccion
- End Function
- Function Instrumento()
- Dim codigo As String = Variables.Codigo
- Dim Tabla As String = String.Empty
- If codigo.IndexOf("TIT") > -1 Then
- Tabla = "TIT"
- ElseIf codigo.IndexOf("EURB") > -1 Then
- Tabla = "EURB"
- ElseIf codigo.IndexOf("BONO") > -1 Then
- Tabla = "BONO"
- ElseIf codigo.IndexOf("CINV") > -1 Then
- Tabla = "CINV"
- End If
- Return Tabla
- End Function
- Function ModificarIngreso()
- Dim i As Integer = 0
- Dim Cantidad As Integer = dgvIngresos.Rows.Count - 2
- Dim Diccionario As New Dictionary(Of Integer, Collection)
- While i <= Cantidad
- Dim coleccion = ColeccionIngresos(i)
- Diccionario.Add(i, coleccion)
- i += 1
- End While
- Return Diccionario
- End Function
- Sub CargarIngresos()
- Dim codigo As String = Variables.Codigo
- Dim dr = BonosConsulta.CargarIngreso(codigo, Instrumento)
- While dr.Read
- Dim Porc = dr("PorcImpuesto")
- If String.IsNullOrEmpty(Porc.ToString) Then
- Porc = "0.0%"
- Else
- Porc = (Porc * 100).ToString + "%"
- End If
- dgvIngresos.Rows.Add("", dr("NumCupon"), "", dr("FechaCupon"), dr("Dias"), dr("Ingreso"), Porc, dr("MontoImpuesto"), dr("Liquido"))
- End While
- End Sub
- Private Sub txtComisionPorCompraCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorCompraCasa.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtComisionPorBolsaCompra_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorBolsaCompra.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtComisionPorVentaCasa_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorVentaCasa.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtComisionPorBolsaVenta_TextChanged(sender As Object, e As EventArgs) Handles txtComisionPorBolsaVenta.TextChanged
- Calculos()
- ValidacionErrores()
- End Sub
- Private Sub txtMontoARecibir_TextChanged(sender As Object, e As EventArgs) Handles txtMontoARecibir.TextChanged
- Calculos()
- End Sub
- Private Sub txtCostosTotales_Op_TextChanged(sender As Object, e As EventArgs) Handles txtCostosTotales_Op.TextChanged
- End Sub
- Private Sub txtRendimientoDespuesISR_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoDespuesISR_Op.TextChanged
- End Sub
- Private Sub txtPrecioSucioVenta_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioSucioVenta.TextChanged
- End Sub
- Private Sub txtGananciaPerdidaCapital_Op_TextChanged(sender As Object, e As EventArgs) Handles txtGananciaPerdidaCapital_Op.TextChanged
- End Sub
- Private Sub txtValorNominalCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorNominalCompra.KeyPress
- If String.IsNullOrEmpty(txtValorNominalCompra.Text) Then
- If e.KeyChar = "." Then
- txtValorNominalCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtValorNominalCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtValorNominalVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtValorNominalVenta.KeyPress
- If String.IsNullOrEmpty(txtValorNominalVenta.Text) Then
- If e.KeyChar = "." Then
- txtValorNominalVenta.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtValorNominalVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtPorcentajeCuponCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeCuponCompra.KeyPress
- If String.IsNullOrEmpty(txtPorcentajeCuponCompra.Text) Then
- If e.KeyChar = "." Then
- txtPorcentajeCuponCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtPorcentajeCuponCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtPorcentajeCuponVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentajeCuponVenta.KeyPress
- If String.IsNullOrEmpty(txtPorcentajeCuponVenta.Text) Then
- If e.KeyChar = "." Then
- txtPorcentajeCuponVenta.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtPorcentajeCuponVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtYTMAlVencimientoCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtYTMAlVencimientoCompra.KeyPress
- If String.IsNullOrEmpty(txtYTMAlVencimientoCompra.Text) Then
- If e.KeyChar = "." Then
- txtYTMAlVencimientoCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtYTMAlVencimientoCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtYTMAlVencimientoVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtYTMAlVencimientoVenta.KeyPress
- If String.IsNullOrEmpty(txtYTMAlVencimientoVenta.Text) Then
- If e.KeyChar = "." Then
- txtYTMAlVencimientoVenta.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtYTMAlVencimientoVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtPrecioAlVencimientoCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioAlVencimientoCompra.KeyPress
- If String.IsNullOrEmpty(txtPrecioAlVencimientoCompra.Text) Then
- If e.KeyChar = "." Then
- txtPrecioAlVencimientoCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtPrecioAlVencimientoCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtPrecioAlVencimientoVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioAlVencimientoVenta.KeyPress
- If String.IsNullOrEmpty(txtPrecioAlVencimientoVenta.Text) Then
- If e.KeyChar = "." Then
- txtPrecioAlVencimientoVenta.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtPrecioAlVencimientoVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtPrecioCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioCompra.KeyPress
- If String.IsNullOrEmpty(txtPrecioCompra.Text) Then
- If e.KeyChar = "." Then
- txtPrecioCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtPrecioCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtPrecioVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecioVenta.KeyPress
- If String.IsNullOrEmpty(txtPrecioVenta.Text) Then
- If e.KeyChar = "." Then
- txtPrecioVenta.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtPrecioVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtComisionPorCompraCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorCompraCasa.KeyPress
- If String.IsNullOrEmpty(txtComisionPorCompraCasa.Text) Then
- If e.KeyChar = "." Then
- txtComisionPorCompraCasa.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtComisionPorCompraCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtComisionPorVentaCasa_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorVentaCasa.KeyPress
- If String.IsNullOrEmpty(txtComisionPorVentaCasa.Text) Then
- If e.KeyChar = "." Then
- txtComisionPorVentaCasa.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtComisionPorVentaCasa.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtComisionPorBolsaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorBolsaCompra.KeyPress
- If String.IsNullOrEmpty(txtComisionPorBolsaCompra.Text) Then
- If e.KeyChar = "." Then
- txtComisionPorBolsaCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtComisionPorBolsaCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtComisionPorBolsaVenta_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtComisionPorBolsaVenta.KeyPress
- If String.IsNullOrEmpty(txtComisionPorBolsaVenta.Text) Then
- If e.KeyChar = "." Then
- txtComisionPorBolsaVenta.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtComisionPorBolsaVenta.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtCostoTransferenciaCompra_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCostoTransferenciaCompra.KeyPress
- If String.IsNullOrEmpty(txtCostoTransferenciaCompra.Text) Then
- If e.KeyChar = "." Then
- txtCostoTransferenciaCompra.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtCostoTransferenciaCompra.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtMontoARecibir_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtMontoARecibir.KeyPress
- If String.IsNullOrEmpty(txtMontoARecibir.Text) Then
- If e.KeyChar = "." Then
- txtMontoARecibir.Text = "0"
- Exit Sub
- End If
- End If
- If (Not txtMontoARecibir.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
- Operaciones.ValidarEntrada(sender, e, True)
- Else
- Operaciones.ValidarEntrada(sender, e, False)
- End If
- End Sub
- Private Sub txtPrecioCompra_Op_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioCompra_Op.TextChanged
- End Sub
- Private Sub txtPrecioVenta_Op_TextChanged(sender As Object, e As EventArgs) Handles txtPrecioVenta_Op.TextChanged
- End Sub
- Private Sub txtInteresAcumuladoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtInteresAcumuladoCompra.TextChanged
- End Sub
- Sub AsignacionPeriodicidad()
- Dim Periodicidad As String = cboPeriodosC.SelectedValue
- If (Periodicidad = "M") Then
- TipoPeriodicidad = 1
- ElseIf (Periodicidad = "T") Then
- TipoPeriodicidad = 3
- ElseIf (Periodicidad = "S") Then
- TipoPeriodicidad = 6
- ElseIf (Periodicidad = "A") Then
- TipoPeriodicidad = 12
- End If
- End Sub
- Sub PrepararCalculos()
- AsignacionPeriodicidad()
- Dim Index = dgvIngresos.CurrentRow.Index
- Dim IndexAnterior = Index - 1
- Dim Respaldo As String = Format(dtpSiguienteFechaCuponCompra.Value, "dd/MM/yyyy")
- Dim FechaSig = CDate(Respaldo)
- Dim Fechaliq = dtpFechaLiquidacionCompra.Value
- Dim FechaCupon, Dias, Ingreso, PorcentajeImpuesto, MontoImpuesto, Liquido
- FechaCupon = dgvIngresos.Rows(Index).Cells("FechaCupon").Value
- Dias = dgvIngresos.Rows(Index).Cells("Dias").Value
- Ingreso = dgvIngresos.Rows(Index).Cells("Ingreso").Value
- PorcentajeImpuesto = dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value
- If (Not PorcentajeImpuesto Is Nothing) Then
- PorcentajeImpuesto = CDec(PorcentajeImpuesto.ToString.Trim("%")) / 100
- Else
- PorcentajeImpuesto = "0.0%"
- End If
- MontoImpuesto = dgvIngresos.Rows(Index).Cells("MontoImpuesto").Value
- Liquido = dgvIngresos.Rows(Index).Cells("Liquido").Value
- If (String.IsNullOrEmpty(FechaCupon)) Then
- If (Index = 0) Then
- FechaCupon = FechaSig
- Else
- Dim FechaAnterior As Date = dgvIngresos.Rows(IndexAnterior).Cells("FechaCupon").Value
- FechaCupon = Operaciones.Meses(TipoPeriodicidad, FechaAnterior, FechaSig)
- End If
- dgvIngresos.Rows(Index).Cells("FechaCupon").Value = FechaCupon
- End If
- If (String.IsNullOrEmpty(Dias)) Then
- Dim Dia As Integer = 0
- If (Index = 0) Then
- Dia = Operaciones.DiasAcumulados(Fechaliq, FechaSig, IndexBaseC)
- Else
- Dim DiaAnterior As Date = dgvIngresos.Rows(IndexAnterior).Cells("FechaCupon").Value
- Dim DiaActual = dgvIngresos.Rows(Index).Cells("FechaCupon").Value
- Dia = Operaciones.DiasAcumulados(DiaAnterior, DiaActual, IndexBaseC)
- End If
- dgvIngresos.Rows(Index).Cells("Dias").Value = Dia
- End If
- If (String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("NumCupon").Value)) Then
- dgvIngresos.Rows(Index).Cells("NumCupon").Value = Correlativo()
- End If
- If (String.IsNullOrEmpty(Ingreso)) Then
- dgvIngresos.Rows(Index).Cells("Ingreso").Value = 0
- End If
- If (Index = 0) Then
- If (String.IsNullOrEmpty(dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value)) Then
- dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value = "0.0%"
- End If
- Else
- dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value = dgvIngresos.Rows(IndexAnterior).Cells("PorcentajeImpuesto").Value
- End If
- If dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value.ToString.IndexOf("%") = -1 Then
- dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value = dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value.ToString + "%"
- End If
- If (String.IsNullOrEmpty(MontoImpuesto)) Then
- dgvIngresos.Rows(Index).Cells("MontoImpuesto").Value = 0
- End If
- If (String.IsNullOrEmpty(Liquido)) Then
- dgvIngresos.Rows(Index).Cells("Liquido").Value = 0
- End If
- CorrelativoSinBD()
- End Sub
- Function Correlativo()
- Dim Index As Integer = 0
- Dim IndexCantidad As Integer = dgvIngresos.Rows.Count - 2
- Dim NumeroMayor As Integer = 0
- While Index <= IndexCantidad
- Dim Numero As Integer = dgvIngresos.Rows(Index).Cells("NumCupon").Value
- If Numero > NumeroMayor Then
- NumeroMayor = Numero
- End If
- Index += 1
- End While
- Return NumeroMayor + 1
- End Function
- Sub CorrelativoSinBD()
- Dim Index As Integer = 0
- Dim IndexCantidad As Integer = dgvIngresos.Rows.Count - 2
- Dim NumeroMayor As Integer = 0
- While Index <= IndexCantidad
- dgvIngresos.Rows(Index).Cells("Correlativo").Value = Index + 1
- Index += 1
- End While
- End Sub
- Function PeriodoGracia()
- Dim FechaEmision As Date = Variables.FechaEmisionTIT
- Dim FechaPeriodoGracia As Date = FechaEmision
- Dim CantidadPeriodoGracia As Integer = 0
- Dim TipoPeriodoGracia As String = Variables.TipoPeriodoGracia
- Dim CantidadPeriodo As String = Variables.CantidadPeriodo
- If String.IsNullOrEmpty(CantidadPeriodo) Or CantidadPeriodo = "0" Then
- Return False
- Else
- CantidadPeriodoGracia = CantidadPeriodo
- End If
- If TipoPeriodoGracia = "D" Or TipoPeriodoGracia = "M" Or TipoPeriodoGracia = "A" Then
- If TipoPeriodoGracia = "D" Then
- FechaPeriodoGracia = FechaEmision.AddDays(CantidadPeriodoGracia)
- ElseIf TipoPeriodoGracia = "M" Then
- FechaPeriodoGracia = FechaEmision.AddMonths(CantidadPeriodoGracia)
- Else
- FechaPeriodoGracia = FechaEmision.AddYears(CantidadPeriodoGracia)
- End If
- Return FechaPeriodoGracia
- Else
- Return False
- End If
- End Function
- 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)
- Dim Valor As Double = 0
- If (IndexBase = 0) Then
- Valor = ValorNominal * PorcCupon * Dias / 360
- Return Valor
- ElseIf (IndexBase = 1) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
- PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 365
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = ValorNominal * PorcCupon * DiasSegundaFecha / 365
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
- Else
- Valor = 0
- End If
- Return Valor
- ElseIf (IndexBase = 2) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha360Bi(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha360(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
- PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 365
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = ValorNominal * PorcCupon * DiasSegundaFecha / 365
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = ValorNominal * PorcCupon * DiasPrimeraFecha / 366
- Else
- Valor = 0
- End If
- Return Valor
- Else
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = Operaciones.DiasDespuesCambioPrimeraFecha366Varios(Fecha1, Fecha2)
- DiasSegundaFecha = Operaciones.DiasDespuesCambioPrimeraFecha365Varios(Fecha1, Fecha2)
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = ValorNominal * PorcCupon * DiasPrimeraFecha / 360
- PrOpc2 = ValorNominal * PorcCupon * DiasSegundaFecha / 360
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = ValorNominal * PorcCupon * DiasSegundaFecha / 360
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = ValorNominal * PorcCupon * DiasPrimeraFecha / 360
- Else
- Valor = 0
- End If
- Return Valor
- End If
- Return Valor
- End Function
- 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)
- Dim Valor As Double = 0
- Dim DiasPrimeraFecha = 0, DiasSegundaFecha = 0
- DiasPrimeraFecha = PrimerosDias
- DiasSegundaFecha = RestantesDias
- If (IndexBase = 0) Then
- Valor = ValorSaldo * PorcCupon * Dias / 360
- Return Valor
- ElseIf (IndexBase = 1) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
- PrOpc2 = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
- Else
- Valor = 0
- End If
- Return Valor
- ElseIf (IndexBase = 2) Then
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
- PrOpc2 = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = ValorSaldo * PorcCupon * DiasSegundaFecha / 365
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = ValorSaldo * PorcCupon * DiasPrimeraFecha / 366
- Else
- Valor = 0
- End If
- Return Valor
- Else
- Dim PrOpc1 = 0.0, PrOpc2 = 0.0
- If (DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- PrOpc1 = ValorSaldo * PorcCupon * DiasPrimeraFecha / 360
- PrOpc2 = ValorSaldo * PorcCupon * DiasSegundaFecha / 360
- Valor = PrOpc1 + PrOpc2
- ElseIf (Not DiasPrimeraFecha > 0 And DiasSegundaFecha > 0) Then
- Valor = ValorSaldo * PorcCupon * DiasSegundaFecha / 360
- ElseIf (DiasPrimeraFecha > 0 And Not DiasSegundaFecha > 0) Then
- Valor = ValorSaldo * PorcCupon * DiasPrimeraFecha / 360
- Else
- Valor = 0
- End If
- Return Valor
- End If
- Return Valor
- End Function
- Function Impuestos(ByVal Ingresos As Double, PorcentajeRenta As Double)
- Dim Total As Double
- Total = Ingresos * PorcentajeRenta
- Return Total
- End Function
- Function Liquido(ByVal Ingreso As Double, ByVal Renta As Double)
- Dim Total As Double
- Total = Ingreso - Renta
- Return Total
- End Function
- Sub CalculoIngresosBONO()
- Dim Ingreso As Double = 0
- Dim ValorNominal = 0.0, PorcCupon = 0.0, Ingresos = 0.0, PorcentajeRenta = 0.0
- Dim IngresosInt = 0.0, Impuestos = 0.0, Liquido = 0.0
- ValorNominal = CDec(txtValorNominalCompra.Text)
- PorcCupon = CDec(txtPorcentajeCuponCompra.Text.ToString.Trim("%")) / 100
- Dim Index As Integer = dgvIngresos.CurrentRow.Index
- Dim Fecha1 As Date = Date.Now.Date
- Dim Fecha2 As Date = Date.Now.Date
- Dim Dias As Integer = dgvIngresos.Rows(Index).Cells("Dias").Value
- If (Index = 0) Then
- Dim RespaldoFecha As String = Format(dtpFechaLiquidacionCompra.Value, "yyyy/MM/dd")
- Fecha1 = RespaldoFecha
- Fecha2 = dgvIngresos.Rows(Index).Cells("FechaCupon").Value
- Else
- Fecha1 = dgvIngresos.Rows(Index - 1).Cells("FechaCupon").Value
- Fecha2 = dgvIngresos.Rows(Index).Cells("FechaCupon").Value
- End If
- If (Not dgvIngresos.CurrentRow.Cells("PorcentajeImpuesto").Value Is Nothing) Then
- PorcentajeRenta = CDec(dgvIngresos.Rows(Index).Cells("PorcentajeImpuesto").Value.ToString.Trim("%")) / 100
- Else
- PorcentajeRenta = 0
- End If
- IngresosInt = IngresosIntereses(ValorNominal, PorcCupon, Dias, Fecha1, Fecha2, IndexBaseC)
- Ingresos = Me.Impuestos(IngresosInt, PorcentajeRenta)
- Liquido = Me.Liquido(IngresosInt, Ingresos)
- dgvIngresos.CurrentRow.Cells("Ingreso").Value = IngresosInt
- dgvIngresos.CurrentRow.Cells("MontoImpuesto").Value = Ingresos
- dgvIngresos.CurrentRow.Cells("Liquido").Value = Liquido
- End Sub
- Sub PrepararIngresosTIT(ByVal Index As Integer, ByRef Amortizacion As DataGridView)
- AsignacionPeriodicidad()
- Dim IndexAnterior = Index - 1
- Dim Respaldo As String = Format(dtpSiguienteFechaCuponCompra.Value, "dd/MM/yyyy")
- Dim Dias, Ingreso, PorcentajeImpuesto, MontoImpuesto, Liquido, PorcentajeImpuestoAnterior
- Dias = dgvIngresos.Rows(Index).Cells("Dias").Value
- Ingreso = dgvIngresos.Rows(Index).Cells("Ingreso").Value
- PorcentajeImpuesto = 10
- If (Not PorcentajeImpuesto Is Nothing) Then
- PorcentajeImpuesto = CDec(PorcentajeImpuesto.ToString.Trim("%")) / 100
- Else
- PorcentajeImpuesto = "0.0%"
- End If
- MontoImpuesto = 0
- Liquido = 0
- If (Index = 0) Then
- PorcentajeImpuestoAnterior = "10.0%"
- Else
- PorcentajeImpuestoAnterior = dgvIngresos.Rows(IndexAnterior).Cells("PorcentajeImpuesto").Value
- End If
- Dim Dia As Integer = 0
- If Not String.IsNullOrEmpty(Amortizacion.Rows(Index).Cells("Dias").Value) Then
- Dia = Amortizacion.Rows(Index).Cells("Dias").Value
- End If
- Dim Fecha As Date = Date.Now.Date
- If Not String.IsNullOrEmpty(Amortizacion.Rows(Index).Cells("Fecha").Value) Then
- Fecha = Amortizacion.Rows(Index).Cells("Fecha").Value
- End If
- dgvIngresos.Rows.Add(0, 0, 0, Fecha, Dia, 0, PorcentajeImpuestoAnterior, 0, 0)
- End Sub
- Sub CalculoIngresosTIT()
- Dim FechaPeriodoGracia = PeriodoGracia()
- Dim CantidadAmortizacion As Integer = Variables.dgvAmortizacion.Rows.Count - 1
- Dim Amortizacion = Variables.dgvAmortizacion
- Dim Index As Integer = 0
- Dim j As Integer = 0
- While Index <= CantidadAmortizacion
- PrepararIngresosTIT(Index, Amortizacion)
- Index += 1
- End While
- While j <= CantidadAmortizacion
- Dim PrimerosDias As Double = Amortizacion.Rows(j).Cells("PrimerosDias").Value
- Dim RestantesDias As Double = Amortizacion.Rows(j).Cells("RestantesDias").Value
- Dim FechaActualCupon = dgvIngresos.Rows(j).Cells("FechaCupon").Value
- Dim Ingreso As Double = 0
- Dim ValorSaldo = 0.0, PorcCupon = 0.0, Ingresos = 0.0, PorcentajeRenta = 0.0
- Dim IngresosInt = 0.0, Impuestos = 0.0, Liquido = 0.0
- Dim SaldoPendiente As Double = 0
- 'If TypeOf FechaPeriodoGracia Is Boolean Then
- If j = 0 Then
- ValorSaldo = Variables.MontoCompraTIT
- Else
- ValorSaldo = Amortizacion.Rows(j - 1).Cells("Saldos").Value
- End If
- PorcCupon = CDec(txtPorcentajeCuponCompra.Text.ToString.Trim("%")) / 100
- Dim Fecha1 As Date = Date.Now.Date
- Dim Fecha2 As Date = Date.Now.Date
- Dim Dias As Integer = dgvIngresos.Rows(j).Cells("Dias").Value
- If (j = 0) Then
- Dim RespaldoFecha As String = Format(dtpFechaLiquidacionCompra.Value, "yyyy/MM/dd")
- Fecha1 = RespaldoFecha
- Fecha2 = dgvIngresos.Rows(j).Cells("FechaCupon").Value
- Else
- Fecha1 = dgvIngresos.Rows(j - 1).Cells("FechaCupon").Value
- Fecha2 = dgvIngresos.Rows(j).Cells("FechaCupon").Value
- End If
- If (Not dgvIngresos.Rows(j).Cells("PorcentajeImpuesto").Value Is Nothing) Then
- PorcentajeRenta = CDec(dgvIngresos.Rows(j).Cells("PorcentajeImpuesto").Value.ToString.Trim("%")) / 100
- Else
- PorcentajeRenta = 0
- End If
- IngresosInt = IngresosInteresesTIT(ValorSaldo, PorcCupon, Dias, PrimerosDias, RestantesDias, IndexBaseC)
- Ingresos = Me.Impuestos(IngresosInt, PorcentajeRenta)
- Liquido = Me.Liquido(IngresosInt, Ingresos)
- dgvIngresos.Rows(j).Cells("Ingreso").Value = IngresosInt
- dgvIngresos.Rows(j).Cells("MontoImpuesto").Value = Ingresos
- dgvIngresos.Rows(j).Cells("Liquido").Value = Liquido
- j += 1
- End While
- End Sub
- Private Sub txtPorcentajeInteresAcumuladoCompra_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentajeInteresAcumuladoCompra.TextChanged
- End Sub
- Private Sub btnQuitar_Click(sender As Object, e As EventArgs) Handles btnQuitar.Click
- QuitarFila()
- Calculos()
- End Sub
- Sub QuitarFila()
- Dim CantidadFilas As Integer = dgvIngresos.Rows.Count - 1
- If CantidadFilas > 0 Then
- Dim result As Integer = MsgBox("¿Está seguro que desea eliminar la fila?", MsgBoxStyle.OkCancel)
- ' Test result.
- Dim codigo As String = Variables.Codigo
- Dim Numero As Integer = dgvIngresos.CurrentRow.Cells("NumCupon").Value
- If result = MsgBoxResult.Ok Then
- Try
- dgvIngresos.Rows.Remove(dgvIngresos.CurrentRow)
- BonosConsulta.EliminarIngreso(codigo, Numero, Instrumento)
- Catch ex As Exception
- MsgBox("No ha seleccionado una fila")
- End Try
- End If
- Else
- MsgBox("Actualmente no tiene registros")
- End If
- End Sub
- Private Sub txtCuponesRecibidos_TextChanged(sender As Object, e As EventArgs) Handles txtCuponesRecibidos.TextChanged
- End Sub
- Private Sub txtIngresosPorIntereses_Op_TextChanged(sender As Object, e As EventArgs) Handles txtIngresosPorIntereses_Op.TextChanged
- End Sub
- Private Sub txtRendimientoGananciaPerdida_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoGananciaPerdida_Op.TextChanged
- End Sub
- Private Sub txtRendimientoIntereses_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoIntereses_Op.TextChanged
- End Sub
- Private Sub txtRendimientoAntesISR_Op_TextChanged(sender As Object, e As EventArgs) Handles txtRendimientoAntesISR_Op.TextChanged
- End Sub
- Private Sub txtPlazo_Op_TextChanged(sender As Object, e As EventArgs) Handles txtPlazo_Op.TextChanged
- End Sub
- Private Sub txtDiasAcumuladosVenta_TextChanged(sender As Object, e As EventArgs) Handles txtDiasAcumuladosVenta.TextChanged
- End Sub
- Private Sub pnlPie_Paint(sender As Object, e As PaintEventArgs) Handles pnlPie.Paint
- End Sub
- Private Sub txtValorNominalCompra_Leave(sender As Object, e As EventArgs) Handles txtValorNominalCompra.Leave
- Formato()
- End Sub
- Private Sub txtPorcentajeCuponCompra_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeCuponCompra.Leave
- Formato()
- End Sub
- Private Sub txtYTMAlVencimientoCompra_Leave(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoCompra.Leave
- Formato()
- End Sub
- Private Sub txtPrecioAlVencimientoCompra_Leave(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoCompra.Leave
- Formato()
- End Sub
- Private Sub txtPrecioCompra_Leave(sender As Object, e As EventArgs) Handles txtPrecioCompra.Leave
- Formato()
- End Sub
- Private Sub txtComisionPorCompraCasa_Leave(sender As Object, e As EventArgs) Handles txtComisionPorCompraCasa.Leave
- Formato()
- End Sub
- Private Sub txtComisionPorBolsaCompra_Leave(sender As Object, e As EventArgs) Handles txtComisionPorBolsaCompra.Leave
- Formato()
- End Sub
- Private Sub txtCostoTransferenciaCompra_Leave(sender As Object, e As EventArgs) Handles txtCostoTransferenciaCompra.Leave
- Formato()
- End Sub
- Private Sub txtValorNominalVenta_Leave(sender As Object, e As EventArgs) Handles txtValorNominalVenta.Leave
- Formato()
- End Sub
- Private Sub txtPorcentajeCuponVenta_Leave(sender As Object, e As EventArgs) Handles txtPorcentajeCuponVenta.Leave
- Formato()
- End Sub
- Private Sub txtYTMAlVencimientoVenta_Leave(sender As Object, e As EventArgs) Handles txtYTMAlVencimientoVenta.Leave
- Formato()
- End Sub
- Private Sub txtPrecioAlVencimientoVenta_Leave(sender As Object, e As EventArgs) Handles txtPrecioAlVencimientoVenta.Leave
- Formato()
- End Sub
- Private Sub txtPrecioVenta_Leave(sender As Object, e As EventArgs) Handles txtPrecioVenta.Leave
- Formato()
- End Sub
- Private Sub txtComisionPorVentaCasa_Leave(sender As Object, e As EventArgs) Handles txtComisionPorVentaCasa.Leave
- Formato()
- End Sub
- Private Sub txtComisionPorBolsaVenta_Leave(sender As Object, e As EventArgs) Handles txtComisionPorBolsaVenta.Leave
- Formato()
- End Sub
- Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles btnIngresos.Click
- CalculoIngresosTIT()
- End Sub
- Private Sub txtValorNominalCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorNominalCompra.KeyUp
- If txtValorNominalCompra.Text = "." Then
- txtValorNominalCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtPorcentajeCuponCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentajeCuponCompra.KeyUp
- If txtPorcentajeCuponCompra.Text = "." Then
- txtPorcentajeCuponCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtYTMAlVencimientoCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtYTMAlVencimientoCompra.KeyUp
- If txtYTMAlVencimientoCompra.Text = "." Then
- txtYTMAlVencimientoCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtPrecioAlVencimientoCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioAlVencimientoCompra.KeyUp
- If txtPrecioAlVencimientoCompra.Text = "." Then
- txtPrecioAlVencimientoCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtPrecioCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioCompra.KeyUp
- If txtPrecioCompra.Text = "." Then
- txtPrecioCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtComisionPorCompraCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorCompraCasa.KeyUp
- If txtComisionPorCompraCasa.Text = "." Then
- txtComisionPorCompraCasa.Text = ".0"
- End If
- End Sub
- Private Sub txtComisionPorBolsaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorBolsaCompra.KeyUp
- If txtComisionPorBolsaCompra.Text = "." Then
- txtComisionPorBolsaCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtCostoTransferenciaCompra_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCostoTransferenciaCompra.KeyUp
- If txtCostoTransferenciaCompra.Text = "." Then
- txtCostoTransferenciaCompra.Text = ".0"
- End If
- End Sub
- Private Sub txtValorNominalVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtValorNominalVenta.KeyUp
- If txtValorNominalVenta.Text = "." Then
- txtValorNominalVenta.Text = ".0"
- End If
- End Sub
- Private Sub txtPorcentajeCuponVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentajeCuponVenta.KeyUp
- If txtPorcentajeCuponVenta.Text = "." Then
- txtPorcentajeCuponVenta.Text = ".0"
- End If
- End Sub
- Private Sub txtYTMAlVencimientoVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtYTMAlVencimientoVenta.KeyUp
- If txtYTMAlVencimientoVenta.Text = "." Then
- txtYTMAlVencimientoVenta.Text = ".0"
- End If
- End Sub
- Private Sub txtPrecioAlVencimientoVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioAlVencimientoVenta.KeyUp
- If txtPrecioAlVencimientoVenta.Text = "." Then
- txtPrecioAlVencimientoVenta.Text = ".0"
- End If
- End Sub
- Private Sub txtPrecioVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPrecioVenta.KeyUp
- If txtPrecioVenta.Text = "." Then
- txtPrecioVenta.Text = ".0"
- End If
- End Sub
- Private Sub txtComisionPorVentaCasa_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorVentaCasa.KeyUp
- If txtComisionPorVentaCasa.Text = "." Then
- txtComisionPorVentaCasa.Text = ".0"
- End If
- End Sub
- Private Sub txtComisionPorBolsaVenta_KeyUp(sender As Object, e As KeyEventArgs) Handles txtComisionPorBolsaVenta.KeyUp
- If txtComisionPorBolsaVenta.Text = "." Then
- txtComisionPorBolsaVenta.Text = ".0"
- End If
- End Sub
- Private Sub dgvIngresos_KeyPress(sender As Object, e As KeyPressEventArgs) Handles dgvIngresos.KeyPress
- Formato()
- End Sub
- Private Sub dgvIngresos_Leave(sender As Object, e As EventArgs) Handles dgvIngresos.Leave
- End Sub
- Private Sub dgvIngresos_Click(sender As Object, e As EventArgs) Handles dgvIngresos.Click
- Formato()
- End Sub
- Private Sub dgvIngresos_CellLeave(sender As Object, e As DataGridViewCellEventArgs) Handles dgvIngresos.CellLeave
- Formato()
- End Sub
- Sub ValidacionErrores()
- If Not String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
- If Double.IsNaN(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
- txtPorcentajeInteresAcumuladoCompra.Text = "0.0%"
- End If
- If Double.IsInfinity(txtPorcentajeInteresAcumuladoCompra.Text.ToString.Trim("%")) Then
- txtPorcentajeInteresAcumuladoCompra.Text = "0.0%"
- End If
- End If
- If Not String.IsNullOrEmpty(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
- If Double.IsNaN(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
- txtPorcentajeInteresAcumuladoVenta.Text = "0.0%"
- End If
- If Double.IsInfinity(txtPorcentajeInteresAcumuladoVenta.Text.ToString.Trim("%")) Then
- txtPorcentajeInteresAcumuladoVenta.Text = "0.0%"
- End If
- End If
- If Not String.IsNullOrEmpty(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
- If Double.IsNaN(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
- txtPrecioSucioCompra.Text = "0.0%"
- End If
- If Double.IsInfinity(txtPrecioSucioCompra.Text.ToString.Trim("%")) Then
- txtPrecioSucioCompra.Text = "0.0%"
- End If
- End If
- If Not String.IsNullOrEmpty(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
- If Double.IsNaN(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
- txtPrecioSucioVenta.Text = "0.0%"
- End If
- If Double.IsInfinity(txtPrecioSucioVenta.Text.ToString.Trim("%")) Then
- txtPrecioSucioVenta.Text = "0.0%"
- End If
- End If
- End Sub
- Sub BotonQuitar()
- If TabCampos.SelectedIndex = 1 Then
- btnQuitar.Visible = True
- btnQuitar.Enabled = True
- Else
- btnQuitar.Visible = False
- btnQuitar.Enabled = False
- End If
- End Sub
- Private Sub lblRedencion_Click(sender As Object, e As EventArgs)
- End Sub
- Private Sub txtValorTransadoVenta_TextChanged(sender As Object, e As EventArgs) Handles txtValorTransadoVenta.TextChanged
- End Sub
- Private Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
- End Sub
- Private Sub Button1_Click_1(sender As Object, e As EventArgs)
- End Sub
- Sub CargarTransladoNuevo()
- Dim Existe As Boolean = ExisteInversion()
- If CantFormAbierto = False Then
- If Not RetCodigoInversionExiste And Not Existe Then
- Dim TipoTransaccionCompraVenta As String = Variables.TipoTransaccionCompraVenta
- If TipoTransaccionCompraVenta = "C" Then
- txtValorNominalCompra.Text = Variables.RetMonto
- txtPrecioCompra.Text = Variables.RetPrecio
- txtPorcentajeCuponCompra.Text = Variables.RetRendimiento
- ElseIf TipoTransaccionCompraVenta = "V" Then
- txtValorNominalVenta.Text = Variables.RetMonto
- txtPrecioVenta.Text = Variables.RetPrecio
- txtPorcentajeCuponVenta.Text = Variables.RetRendimiento
- End If
- End If
- End If
- End Sub
- Private Sub btnVenderTitulo_Click(sender As Object, e As EventArgs) Handles btnVenderTitulo.Click
- If Variables.InvocadorProInv = "frmINV" Then
- Dim TrasladarDatos As New TrasladarDatosCMVTA
- Dim General As New DAOGeneral
- Dim Codigo = Variables.Codigo
- Dim Tabla As String = "INV0"
- TrasladarDatos = RellenarDatosCMVTA()
- Dim Existe As Boolean = General.ExisteTitulo(Codigo, Tabla)
- If Existe Then
- Dim CodigoInversion As String = Variables.Codigo
- Dim frmPINVCMVTA As New frmPIN("V", CodigoInversion, TrasladarDatos)
- frmINV.Close()
- Me.Close()
- frmPINVCMVTA.ShowDialog()
- End If
- End If
- End Sub
- Function RellenarDatosCMVTA()
- Dim TrasladarDatos As New TrasladarDatosCMVTA
- TrasladarDatos.BaseCINV = Operaciones.ConvertirEntero(cboAnioBaseC.SelectedIndex.ToString)
- TrasladarDatos.CuponCINV = Operaciones.ConvertirDecimal(txtPorcentajeCuponCompra.Text.ToString)
- TrasladarDatos.FechaLiquidacionCINV = Operaciones.ConvertirFecha(dtpFechaLiquidacionCompra.Value.ToString)
- TrasladarDatos.FechaVencimientoCINV = Operaciones.ConvertirFecha(dtpFechaVencimientoCompra.Value.ToString)
- TrasladarDatos.PeriodicidadCINV = cboPeriodosC.SelectedValue.ToString
- TrasladarDatos.PorcentajeComisionBolsaCINV = Operaciones.ConvertirDecimal(txtComisionPorBolsaCompra.Text.ToString)
- TrasladarDatos.PorcentajeComisionCasaCINV = Operaciones.ConvertirDecimal(txtComisionPorCompraCasa.Text.ToString)
- TrasladarDatos.PrecioCompraCINV = Operaciones.ConvertirDecimal(txtPrecioCompra.Text.ToString)
- TrasladarDatos.PrecioVencimientoCINV = Operaciones.ConvertirDecimal(txtPrecioAlVencimientoCompra.Text.ToString)
- TrasladarDatos.UltimaFechaCuponCINV = Operaciones.ConvertirFecha(dtpUltimaFechaCuponCompra.Value)
- TrasladarDatos.ValorNominalCINV = Operaciones.ConvertirDecimal(txtValorNominalCompra.Text.ToString)
- TrasladarDatos.YTMVencimientoCINV = Operaciones.ConvertirDecimal(txtYTMAlVencimientoCompra.Text.ToString)
- TrasladarDatos.NombreInstrumento = "CINV"
- TrasladarDatos.AgregarCMVTA = True
- Return TrasladarDatos
- End Function
- End Class
|