Advertisement
arielgatti444

decoracion

May 5th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub btnGrabar_Click()
  2. Dim rsMue As Recordset
  3.  
  4. If txtMueble.Text = "" Then
  5.     MsgBox "El detalle del mueble no puede ser vacio"
  6.     Exit Sub
  7. End If
  8.  
  9. If cboAmbiente.ItemData(cboAmbiente.ListIndex) = -1 Then
  10.     MsgBox "Debe elegir un ambiente"
  11.     Exit Sub
  12. End If
  13.  
  14. If txtPrecio.Text = "" Then
  15.     MsgBox "Debe ingresar precio"
  16.     Exit Sub
  17.     ElseIf CSng(txtPrecio.Text) < 0 Then
  18.         MsgBox "El precio ingresado es invalido"
  19.         Exit Sub
  20. End If
  21.  
  22.  
  23. Set rsMue = goDb.OpenRecordset("Mueble", dbOpenDynaset)
  24. rsMue.AddNew
  25. rsMue("aCodigo") = cboAmbiente.ItemData(cboAmbiente.ListIndex)
  26. rsMue("nombre") = txtMueble.Text
  27. rsMue("precio") = CSng(txtPrecio.Text)
  28. rsMue.Update
  29.  
  30. rsMue.Close
  31.  
  32. Set rsMue = Nothing
  33.  
  34. actualizarAmbientes
  35. actualizarMueblesPorAmbiente
  36.  
  37. End Sub
  38.  
  39. Private Sub actualizarAmbientes()
  40.  
  41. Dim rsMue As Recordset
  42. Dim rsAmb As Recordset
  43. Dim siAux As Single
  44. Dim inCont As Integer
  45.  
  46. Set rsAmb = goDb.OpenRecordset("Ambiente", dbOpenDynaset)
  47. Set rsMue = goDb.OpenRecordset("Mueble", dbOpenDynaset)
  48.  
  49. If rsAmb.BOF And rsAmb.EOF Then
  50.     rsAmb.MoveFirst
  51. End If
  52.  
  53. If rsMue.BOF And rsMue.EOF Then
  54.     rsMue.MoveFirst
  55. End If
  56.  
  57. lstAmbiente.Clear
  58.  
  59. Do While Not rsAmb.EOF
  60.     siAux = 0
  61.     inCont = 0
  62.     rsMue.MoveFirst
  63.     Do While Not rsMue.EOF
  64.     If rsMue("aCodigo") = rsAmb("aCodigo") Then
  65.         siAux = siAux + rsMue("Precio")
  66.         inCont = inCont + 1
  67.     End If
  68.     rsMue.MoveNext
  69.     Loop
  70. lstAmbiente.AddItem rsAmb("descripcion") & " - " & inCont & " - " & Format(siAux, "$0.00")
  71. lstAmbiente.ItemData(lstAmbiente.NewIndex) = rsAmb("aCodigo")
  72. rsAmb.MoveNext
  73. Loop
  74.  
  75. rsAmb.Close
  76. rsMue.Close
  77.  
  78. Set rsAmb = Nothing
  79. Set rsMue = Nothing
  80.  
  81. End Sub
  82.  
  83. Private Sub actualizarMueblesPorAmbiente()
  84. Dim rsMue As Recordset
  85. Set rsMue = goDb.OpenRecordset("Mueble", dbOpenDynaset)
  86.  
  87. rsMue.MoveFirst
  88. lstMueble.Clear
  89.  
  90. If lstAmbiente.ListIndex = -1 Then
  91.     lstMueble.Clear
  92.     Exit Sub
  93. End If
  94.  
  95. Do While Not rsMue.EOF
  96.     If rsMue("aCodigo") = lstAmbiente.ItemData(lstAmbiente.ListIndex) Then
  97.         lstMueble.AddItem rsMue("nombre")
  98.         lstMueble.ItemData(lstMueble.NewIndex) = rsMue("mCodigo")
  99.     End If
  100.     rsMue.MoveNext
  101. Loop
  102.  
  103. rsMue.Close
  104. Set rsMue = Nothing
  105.  
  106. End Sub
  107.  
  108. '-----------------------------------------------------------------------------------------------------'
  109.  
  110. Private Sub lstAmbiente_Click()
  111. actualizarMueblesPorAmbiente
  112. End Sub
  113.  
  114. '-----------------------------------------------------------------------------------------------------'
  115.  
  116. Private Sub btnBorrar_Click()
  117.  
  118. Dim rsMue As Recordset
  119. Set rsMue = goDb.OpenRecordset("Mueble", dbOpenDynaset)
  120.  
  121. If rsMue.BOF And rsMue.EOF Then
  122.     rsMue.MoveFirst
  123. End If
  124.  
  125. Do While Not rsMue.EOF
  126.     If rsMue("mCodigo") = lstMueble.ItemData(lstMueble.ListIndex) Then
  127.         rsMue.Delete
  128.     End If
  129.     rsMue.MoveNext
  130. Loop
  131.  
  132. actualizarAmbientes
  133. actualizarMueblesPorAmbiente
  134.  
  135. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement