frmSeleccionTitulosReportos.vb 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. Public Class frmSeleccionTitulosReportos
  2. Dim DAOGeneral As New DAOGeneral
  3. Dim Operaciones As New Operaciones
  4. Dim NombreTrasladar As String = String.Empty
  5. Dim ObtenerInstanciaObjetotexto As New TextBox
  6. Dim ObtenerInstanciaObjetocheque As New CheckBox
  7. Dim SeleccionDAO As New SeleccionTitulosReportosDAO
  8. Dim General As New DAOGeneral
  9. Dim CodigoAsociado As String = String.Empty
  10. Dim MontoUsado As Double = 0
  11. Dim Empresa As String = String.Empty
  12. Dim NombreEm As String = String.Empty
  13. Dim CodigoReporto As String = String.Empty
  14. Dim IdFlujo As Integer = 0
  15. Private Sub frmSeleccionTitulosReportos_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  16. Formato()
  17. DefinirValoresIniciales()
  18. CargarTitulos()
  19. SaldoGarantia()
  20. Controladores(0)
  21. End Sub
  22. Sub DefinirValoresIniciales()
  23. txtCodigoAsociado.Text = CodigoAsociado
  24. txtMonto.Text = MontoUsado
  25. End Sub
  26. Sub New()
  27. ' Esta llamada es exigida por el diseñador.
  28. InitializeComponent()
  29. ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
  30. End Sub
  31. Sub New(DicDatos As Dictionary(Of String, Object))
  32. Me.New
  33. If DicDatos.ContainsKey("MontoUsado") Then
  34. Me.MontoUsado = DicDatos.Item("MontoUsado")
  35. End If
  36. If DicDatos.ContainsKey("CodigoAsociado") Then
  37. Me.CodigoAsociado = DicDatos.Item("CodigoAsociado")
  38. End If
  39. If DicDatos.ContainsKey("Empresa") Then
  40. Me.Empresa = DicDatos.Item("Empresa")
  41. End If
  42. If DicDatos.ContainsKey("NombreEmpresa") Then
  43. Me.NombreEm = DicDatos.Item("NombreEmpresa")
  44. End If
  45. If DicDatos.ContainsKey("CodigoReporto") Then
  46. Me.CodigoReporto = DicDatos.Item("CodigoReporto")
  47. End If
  48. If DicDatos.ContainsKey("IdFlujo") Then
  49. Me.IdFlujo = DicDatos.Item("IdFlujo")
  50. End If
  51. End Sub
  52. Sub CargarTitulos()
  53. Dim dt As New DataTable
  54. dt = DAOGeneral.ListaInstrumentos("Propuesta")
  55. For Each Item As DataRow In dt.Rows
  56. ''GeneracionCheques
  57. Dim cheque As New CheckBox
  58. cheque.Width = 215
  59. cheque.Margin = New Padding(90, 10, 0, 10)
  60. cheque.Name = Item("Codigo").ToString
  61. cheque.Text = Item("Descripcion").ToString
  62. flpTitulos.AutoScroll = True
  63. ''GeneracionTexto
  64. Dim texto As New TextBox
  65. Dim Label As New Label
  66. Label.Text = " "
  67. Label.ForeColor = Color.Maroon
  68. Label.Name = Item("Codigo").ToString
  69. texto.Width = 150
  70. texto.Margin = New Padding(0, 10, 0, 10)
  71. Label.Margin = New Padding(50, 10, 0, 10)
  72. texto.Name = Item("Codigo").ToString
  73. texto.Text = 0
  74. flpValor.AutoScroll = True
  75. texto.ReadOnly = True
  76. texto.BorderStyle = BorderStyle.FixedSingle
  77. texto.BackColor = SystemColors.Control
  78. AddHandler cheque.CheckedChanged, AddressOf ObtenerNombre
  79. AddHandler cheque.MouseMove, AddressOf Focuss
  80. flpTitulos.Controls.Add(cheque)
  81. flpValor.Controls.Add(Label)
  82. flpValor.Controls.Add(texto)
  83. Next
  84. End Sub
  85. Sub Focuss()
  86. flpValor.VerticalScroll.Value = flpTitulos.VerticalScroll.Value
  87. End Sub
  88. Sub ObtenerNombre(sender As Object, e As EventArgs)
  89. Controladores(1)
  90. NombreTrasladar = sender.name.ToString
  91. For Each Item In flpValor.Controls
  92. If TypeOf Item Is TextBox Then
  93. If Item.Name = NombreTrasladar Then
  94. If sender.checked Then
  95. ObtenerInstanciaObjetotexto = Item
  96. ObtenerInstanciaObjetocheque = sender
  97. Seleccionado()
  98. Else
  99. ObtenerInstanciaObjetotexto = Item
  100. NombreTrasladar = sender.name.ToString
  101. Item.Text = 0
  102. ObtenerInstanciaObjetotexto.BackColor = SystemColors.Control
  103. ObtenerInstanciaObjetotexto.ForeColor = Color.Black
  104. ObtenerInstanciaObjetotexto = Nothing
  105. NombreTrasladar = String.Empty
  106. ObtenerInstanciaObjetocheque = Nothing
  107. End If
  108. End If
  109. ElseIf TypeOf Item Is Label Then
  110. If Item.Name = NombreTrasladar Then
  111. Item.text = "------>"
  112. Else
  113. Item.text = " "
  114. End If
  115. End If
  116. Next
  117. flpValor.VerticalScroll.Value = flpTitulos.VerticalScroll.Value
  118. End Sub
  119. Function TrasladarMonto()
  120. Dim MoverLimpio As Double = Operaciones.ConvertirDecimal(txtMover.Text.ToString)
  121. Dim PorcRest As Double = Operaciones.ConvertirDecimal(lblPorcentajeRestanteValor.Text.ToString)
  122. Dim MontoDisponible As Double = Operaciones.ConvertirDecimal(lblMontoDisponible.Text.ToString)
  123. Dim MontoTotal As Double = Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text.ToString)
  124. If rdbMonto.Checked Then
  125. If (MoverLimpio <= 0) Then
  126. MsgBox("Ingrese un numero mayor a 0")
  127. Return 0
  128. ElseIf MoverLimpio > MontoTotal Then
  129. MsgBox("El Monto Máximo es de " + MontoTotal.ToString)
  130. Return 0
  131. ElseIf MoverLimpio > MontoDisponible Then
  132. MsgBox("Monto Fuera de Rango")
  133. Return 0
  134. Else
  135. If Not String.IsNullOrEmpty(NombreTrasladar) And Not ObtenerInstanciaObjetotexto Is Nothing Then
  136. If Not lblMontoDisponible.Text = 0 Then
  137. ObtenerInstanciaObjetotexto.BackColor = Color.Brown
  138. ObtenerInstanciaObjetotexto.ForeColor = Color.White
  139. End If
  140. End If
  141. CalculoSaldoUsado()
  142. Return 1
  143. End If
  144. Else
  145. If (MoverLimpio <= 0) Then
  146. MsgBox("Ingrese un numero mayor a 0")
  147. Return 0
  148. ElseIf MoverLimpio > 100 Then
  149. MsgBox("El Porcentaje máximo es de 100 %")
  150. Return 0
  151. ElseIf MoverLimpio > PorcRest Then
  152. MsgBox("Porcentaje Fuera de Rango")
  153. Return 0
  154. Else
  155. If Not String.IsNullOrEmpty(NombreTrasladar) And Not ObtenerInstanciaObjetotexto Is Nothing Then
  156. If Not lblMontoDisponible.Text = 0 Then
  157. ObtenerInstanciaObjetotexto.BackColor = Color.Brown
  158. ObtenerInstanciaObjetotexto.ForeColor = Color.White
  159. End If
  160. End If
  161. CalculoSaldoUsado()
  162. Return 1
  163. End If
  164. End If
  165. End Function
  166. Sub CalculoSaldoUsado()
  167. Dim TipoValor As String = String.Empty
  168. If rdbMonto.Checked Then
  169. TipoValor = "Monto"
  170. Else
  171. TipoValor = "Porc"
  172. End If
  173. ''Es Positivo
  174. If TipoValor = "Monto" Then
  175. ObtenerInstanciaObjetotexto.Text = txtMover.Text
  176. txtMover.Text = 0
  177. Else
  178. If Not lblMontoDisponible.Text = 0 Then
  179. ObtenerInstanciaObjetotexto.Text = (Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text) * (Operaciones.ConvertirDecimal(txtMover.Text) / 100))
  180. Else
  181. MsgBox("No cuenta con suficientes fondos")
  182. End If
  183. End If
  184. End Sub
  185. Private Sub tlpValor_Paint(sender As Object, e As PaintEventArgs)
  186. End Sub
  187. Private Sub flpTitulos_Scroll(sender As Object, e As ScrollEventArgs) Handles flpTitulos.Scroll
  188. flpValor.VerticalScroll.Value = flpTitulos.VerticalScroll.Value
  189. End Sub
  190. Private Sub btnMover_Click(sender As Object, e As EventArgs) Handles btnMover.Click
  191. Dim Continuar As Integer = TrasladarMonto()
  192. If Continuar = 1 Then
  193. Controladores(2)
  194. End If
  195. End Sub
  196. Function ConteoSaldoUsado()
  197. Dim Monto As Double = 0
  198. Dim CantidadFilas = dgvDetalles.Rows.Count - 1
  199. Dim Index As Integer = 0
  200. While (CantidadFilas >= Index)
  201. Monto += Operaciones.ConvertirDecimal(dgvDetalles.Rows(Index).Cells("Monto").Value.ToString)
  202. Index += 1
  203. End While
  204. Return Monto
  205. End Function
  206. Function CalculoSaldo()
  207. Dim MontoActualPorcentaje As Double = 0
  208. Dim MontoUsado As Double = 0
  209. Dim MontoDisponible As Double = 0
  210. Dim Positivo As Boolean = False
  211. MontoActualPorcentaje = Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text.ToString)
  212. MontoUsado = Operaciones.ConvertirDecimal(ConteoSaldoUsado.ToString)
  213. lblMontoUsado.Text = MontoUsado
  214. MontoDisponible = MontoActualPorcentaje - MontoUsado
  215. If MontoDisponible >= 0 Then
  216. lblMontoDisponible.Text = MontoDisponible
  217. Positivo = True
  218. Else
  219. Positivo = False
  220. End If
  221. Return Positivo
  222. End Function
  223. Private Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles btnCancelar.Click
  224. txtMover.Text = 0
  225. If Not ObtenerInstanciaObjetocheque Is Nothing Then
  226. ObtenerInstanciaObjetocheque.Checked = False
  227. ObtenerInstanciaObjetocheque = Nothing
  228. End If
  229. Controladores(0)
  230. End Sub
  231. Private Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles btnAgregar.Click
  232. End Sub
  233. Sub Seleccionado()
  234. End Sub
  235. Private Sub flpTitulos_CursorChanged(sender As Object, e As EventArgs) Handles flpTitulos.CursorChanged
  236. End Sub
  237. Sub SaldoGarantia()
  238. Dim PorcentajeIngresado As Double = Operaciones.ConvertirDecimal(txtPorcentaje.Text.ToString)
  239. If PorcentajeIngresado > 100 Then
  240. txtPorcentaje.Text = "100 %"
  241. MsgBox("Porcentaje Demasiado Alto,Ingrese uno menor")
  242. End If
  243. Dim Porcentaje As Double = 0
  244. Dim ValorTitulo As Double = 0
  245. If Not String.IsNullOrEmpty(txtPorcentaje.Text) Then
  246. Porcentaje = (Operaciones.ConvertirDecimal(txtPorcentaje.Text.ToString) / 100)
  247. End If
  248. Dim Monto As Double = Operaciones.ConvertirDecimal(txtMonto.Text.ToString)
  249. Dim MontoDisponible As Double = Monto * Porcentaje
  250. ValorTitulo = Monto - MontoDisponible
  251. txtValorTitulo.Text = ValorTitulo
  252. lblMontoDisponible.Text = MontoDisponible
  253. lblMontoPorcentaje.Text = MontoDisponible
  254. End Sub
  255. Private Sub lblMontoDisponible_Click(sender As Object, e As EventArgs) Handles lblMontoDisponible.Click
  256. End Sub
  257. Private Sub txtPorcentaje_TextChanged(sender As Object, e As EventArgs) Handles txtPorcentaje.TextChanged
  258. SaldoGarantia()
  259. End Sub
  260. Sub Guardar()
  261. Dim Valores As New Collection
  262. Valores = GuardarValores()
  263. SeleccionDAO.ProcesoDatos(Valores)
  264. End Sub
  265. Function GuardarValores() As Collection
  266. Dim ColRegistros As New Collection
  267. Dim Tipo As String = String.Empty
  268. If rdbMonto.Checked Then
  269. Tipo = "Monto"
  270. Else
  271. Tipo = "Porcentaje"
  272. End If
  273. Dim CantidadFilas = dgvDetalles.Rows.Count - 1
  274. Dim Index As Integer = 0
  275. While (CantidadFilas >= Index)
  276. Dim DicRegistrosInstrumentos As New Dictionary(Of String, Object)
  277. Dim CodigoAso As String = Me.CodigoAsociado
  278. Dim CodigoReporto As String = Me.CodigoReporto
  279. Dim IdFlujo As Integer = Operaciones.ConvertirEntero(Me.IdFlujo.ToString)
  280. Dim NombreInstrumento As String = dgvDetalles.Rows(Index).Cells("NombreInstrumento").Value.ToString
  281. Dim NombreEmpresa As String = dgvDetalles.Rows(Index).Cells("NombreEmpresa").Value.ToString
  282. Dim TipoAsignacion As String = Tipo
  283. Dim MontoInicial As Double = Operaciones.ConvertirDecimal(txtMonto.Text.ToString)
  284. Dim MontoTotalUsado As Double = Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text.ToString)
  285. Dim PorcentajeRestante As Double = Operaciones.ConvertirDecimal(dgvDetalles.Rows(Index).Cells("PorcentajeRestantes").Value.ToString)
  286. Dim PorcentajeMontoUsado As Double = Operaciones.ConvertirDecimal(txtPorcentaje.Text.ToString)
  287. Dim MontoDisponible As Double = Operaciones.ConvertirDecimal(dgvDetalles.Rows(Index).Cells("SaldoDisponible").Value.ToString)
  288. Dim MontoUsado As Double = Operaciones.ConvertirDecimal(dgvDetalles.Rows(Index).Cells("SaldoUsado").Value.ToString)
  289. Dim MontoTitulo As Double = Operaciones.ConvertirDecimal(dgvDetalles.Rows(Index).Cells("Monto").Value.ToString)
  290. Dim MontoNoUsado As Double = Operaciones.ConvertirDecimal(txtValorTitulo.Text.ToString)
  291. Dim FechaCreado As Date = Date.Now.Date
  292. Dim EstadoProceso As String = "P"
  293. Dim Asociado As String = "No"
  294. ''AgregarCampos al Dicionario
  295. DicRegistrosInstrumentos.Add("CodigoAsociado", CodigoAso)
  296. DicRegistrosInstrumentos.Add("NombreInstrumento", NombreInstrumento)
  297. DicRegistrosInstrumentos.Add("NombreEmpresa", NombreEmpresa)
  298. DicRegistrosInstrumentos.Add("TipoAsignacion", TipoAsignacion)
  299. DicRegistrosInstrumentos.Add("MontoInicial", MontoInicial)
  300. DicRegistrosInstrumentos.Add("MontoTotalUsado", MontoTotalUsado)
  301. DicRegistrosInstrumentos.Add("PorcentajeRestante", PorcentajeRestante)
  302. DicRegistrosInstrumentos.Add("PorcentajeMontoUsado", PorcentajeMontoUsado)
  303. DicRegistrosInstrumentos.Add("MontoDisponible", MontoDisponible)
  304. DicRegistrosInstrumentos.Add("MontoUsado", MontoUsado)
  305. DicRegistrosInstrumentos.Add("MontoTitulo", MontoTitulo)
  306. DicRegistrosInstrumentos.Add("MontoNoUsado", MontoNoUsado)
  307. DicRegistrosInstrumentos.Add("FechaCreado", FechaCreado)
  308. DicRegistrosInstrumentos.Add("EstadoProceso", EstadoProceso)
  309. DicRegistrosInstrumentos.Add("Asociado", Asociado)
  310. DicRegistrosInstrumentos.Add("CodigoReporto", CodigoReporto)
  311. DicRegistrosInstrumentos.Add("IdFlujo", IdFlujo)
  312. ColRegistros.Add(DicRegistrosInstrumentos)
  313. Index += 1
  314. End While
  315. Return ColRegistros
  316. End Function
  317. Private Sub btnGenerar_Click(sender As Object, e As EventArgs) Handles btnGenerar.Click
  318. Guardar()
  319. frmColaTitulos.Inicializacion()
  320. frmColaTitulos.dgvDetalles.DataSource = Nothing
  321. Me.Close()
  322. End Sub
  323. Private Sub btnAgregarSiguiente_Click(sender As Object, e As EventArgs) Handles btnAgregarSiguiente.Click
  324. Dim Estado As String = String.Empty
  325. AgregarSiguiente()
  326. CalculoSaldo()
  327. PorcentajeRestante()
  328. Limpiar()
  329. Controladores(3)
  330. End Sub
  331. Sub AgregarSiguiente()
  332. Dim Nombre As String = String.Empty
  333. Dim NombreInstrumento As String = String.Empty
  334. Dim Monto As Double = 0
  335. Dim SaldoDisponible As Double = 0
  336. Dim SaldoUsado As Double = 0
  337. Dim PorcentajeRestante As Double = 0
  338. Dim Codigo As String = Variables.Codigo
  339. Dim Empresa As String = Me.Empresa
  340. Dim NombreEmpresa As String = Me.NombreEm
  341. For Each Item In flpValor.Controls
  342. If TypeOf Item Is TextBox Then
  343. If Item.BackColor = Color.Brown Then
  344. Nombre = Item.name.ToString
  345. Monto = Operaciones.ConvertirDecimal(Item.text.ToString)
  346. SaldoDisponible = Operaciones.ConvertirDecimal(lblMontoDisponible.Text.ToString) - Monto
  347. SaldoUsado = Operaciones.ConvertirDecimal(lblMontoUsado.Text.ToString) + Monto
  348. PorcentajeRestante = (SaldoDisponible / Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text.ToString)) * 100
  349. End If
  350. End If
  351. Next
  352. For Each Item In flpTitulos.Controls
  353. If TypeOf Item Is CheckBox Then
  354. If Item.checked Then
  355. NombreInstrumento = Item.text.ToString
  356. If Not String.IsNullOrEmpty(NombreInstrumento) Then
  357. Exit For
  358. End If
  359. End If
  360. End If
  361. Next
  362. If String.IsNullOrEmpty(Nombre) And String.IsNullOrEmpty(Monto.ToString) Or
  363. String.IsNullOrEmpty(SaldoDisponible.ToString) Or String.IsNullOrEmpty(SaldoUsado.ToString) Or
  364. String.IsNullOrEmpty(PorcentajeRestante.ToString) Or String.IsNullOrEmpty(Empresa.ToString) Or
  365. String.IsNullOrEmpty(NombreInstrumento.ToString) Or String.IsNullOrEmpty(NombreEm.ToString) Then
  366. MsgBox("Error en Traspaso")
  367. Else
  368. dgvDetalles.Rows.Add(Nombre, NombreInstrumento, Empresa, NombreEm, Monto.ToString, SaldoDisponible.ToString, SaldoUsado.ToString, PorcentajeRestante.ToString + " %".ToString)
  369. End If
  370. End Sub
  371. Private Sub btnAgregarMismoIns_Click(sender As Object, e As EventArgs)
  372. End Sub
  373. Sub Limpiar()
  374. For Each Item In flpValor.Controls
  375. If TypeOf Item Is TextBox Then
  376. Item.text = 0
  377. Item.backcolor = SystemColors.Control
  378. End If
  379. If TypeOf Item Is Label Then
  380. Item.text = " "
  381. End If
  382. Next
  383. For Each Item In flpTitulos.Controls
  384. If TypeOf Item Is CheckBox Then
  385. Item.checked = False
  386. End If
  387. Next
  388. End Sub
  389. Public Function SoloNumeros(ByVal strCadena As String) As String
  390. Dim SoloNumero As String = ""
  391. strCadena = Replace(strCadena, " ", "")
  392. Dim index As Integer
  393. For index = 1 To Len(strCadena)
  394. If (Mid$(strCadena, index, 1) Like "#") _
  395. Or Mid$(strCadena, index, 1) = "." Then
  396. SoloNumero = SoloNumero & Mid$(strCadena, index, 1)
  397. End If
  398. Next
  399. Return SoloNumero
  400. End Function
  401. Private Sub lblMontoUsado_Click(sender As Object, e As EventArgs) Handles lblMontoUsado.Click
  402. End Sub
  403. Sub PorcentajeRestante()
  404. Dim PorcentajeCompleto As Integer = 0
  405. Dim MontoCompleto As Double = 0
  406. Dim MontoUsado As Double = 0
  407. Dim Porcentaje As Double = 0
  408. MontoCompleto = Operaciones.ConvertirDecimal(lblMontoPorcentaje.Text.ToString)
  409. MontoUsado = Operaciones.ConvertirDecimal(lblMontoUsado.Text.ToString)
  410. Porcentaje = 100 - ((MontoUsado / MontoCompleto) * 100)
  411. lblPorcentajeRestanteValor.Text = Porcentaje.ToString + " %"
  412. End Sub
  413. Sub Controladores(ByRef PasoDatos As Integer)
  414. If PasoDatos = 0 Then
  415. btnAgregarSiguiente.Enabled = False
  416. pnlControladores.Enabled = False
  417. btnCancelar.Enabled = False
  418. btnAgregar.Enabled = False
  419. flpTitulos.Enabled = True
  420. ElseIf PasoDatos = 1 Then
  421. flpTitulos.Enabled = False
  422. pnlControladores.Enabled = True
  423. btnCancelar.Enabled = True
  424. ElseIf PasoDatos = 2 Then
  425. btnAgregarSiguiente.Enabled = True
  426. pnlControladores.Enabled = False
  427. ElseIf PasoDatos = 3 Then
  428. btnAgregar.Enabled = False
  429. flpTitulos.Enabled = True
  430. pnlControladores.Enabled = False
  431. btnCancelar.Enabled = False
  432. btnAgregarSiguiente.Enabled = False
  433. If rdbMonto.Checked Then
  434. txtMover.Text = "1 "
  435. Else
  436. txtMover.Text = "1 %"
  437. End If
  438. End If
  439. End Sub
  440. Private Sub txtPorcentaje_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentaje.KeyPress
  441. If String.IsNullOrEmpty(sender.Text) Then
  442. If e.KeyChar = "." Then
  443. sender.Text = "0"
  444. Exit Sub
  445. End If
  446. End If
  447. If (Not sender.Text.ToString.IndexOf(".") = -1 And e.KeyChar = ".") Then
  448. Operaciones.ValidarEntrada(sender, e, True)
  449. Else
  450. Operaciones.ValidarEntrada(sender, e, False)
  451. End If
  452. End Sub
  453. Sub Formato()
  454. If rdbPorcentaje.Checked Then
  455. Dim Porcentaje As String = txtPorcentaje.Text.Trim(" ").Trim("%")
  456. Dim PorcentajeNumero As Double = 0
  457. PorcentajeNumero = Operaciones.ConvertirDecimal(Porcentaje)
  458. If PorcentajeNumero = 0 Then
  459. PorcentajeNumero = 1
  460. End If
  461. Porcentaje = PorcentajeNumero.ToString + " %"
  462. txtPorcentaje.Text = Porcentaje
  463. End If
  464. End Sub
  465. Private Sub txtPorcentaje_Leave(sender As Object, e As EventArgs) Handles txtPorcentaje.Leave
  466. Formato()
  467. End Sub
  468. Private Sub rdbMonto_CheckedChanged(sender As Object, e As EventArgs) Handles rdbMonto.CheckedChanged
  469. CambioCalculo()
  470. Formato()
  471. End Sub
  472. Private Sub rdbPorcentaje_CheckedChanged(sender As Object, e As EventArgs) Handles rdbPorcentaje.CheckedChanged
  473. CambioCalculo()
  474. Formato()
  475. End Sub
  476. Sub CambioCalculo()
  477. If rdbPorcentaje.Checked Then
  478. txtPorcentaje.Text = "100 %"
  479. txtMover.Text = "1 %"
  480. Else
  481. txtPorcentaje.Text = "100 %"
  482. txtMover.Text = "1"
  483. End If
  484. End Sub
  485. Private Sub lblPorcentajeRestanteValor_Click(sender As Object, e As EventArgs) Handles lblPorcentajeRestanteValor.Click
  486. End Sub
  487. Private Sub txtMover_Leave(sender As Object, e As EventArgs) Handles txtMover.Leave
  488. If rdbPorcentaje.Checked Then
  489. txtMover.Text = Operaciones.ConvertirDecimal(txtMover.Text.ToString).ToString + " %"
  490. End If
  491. End Sub
  492. Private Sub dgvDetalles_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDetalles.CellContentClick
  493. End Sub
  494. End Class