Вы находитесь на странице: 1из 10

SENTENCIAS

Option Explicit

Sub main()
With base
.CursorLocation = adUseClient
.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\taller002.mdb;Persist Security Info=False"
FrmLogin.Show
End With
With base1
.CursorLocation = adUseClient
.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\MOTOR.mdb;Persist Security Info=False"
End With

End Sub

Sub Usuarios()
With RsUsuarios
If .State = 1 Then .Close
.Open "select * from TablaUsuarios", base, adOpenStatic, adLockOptimistic
End With
End Sub
'' TABLA BOMBA DE AGUA
Sub BombaA()
With RsBombaA
If .State = 1 Then .Close
.Open "select * from Bomba_A WHERE Num= " & N & " ORDER BY ID DESC", base1,
adOpenStatic, adLockOptimistic
'Rs.Open "nombre de la tabla", cn, adOpenDynamic, adLockPessimistic

End With
End Sub
'' TABLA CORREA DE TIEMPO
Sub CorreaT()
With RsCorreaT
If .State = 1 Then .Close
.Open "select * from Correa_T ORDER BY ID DESC", base1, adOpenStatic,
adLockOptimistic
End With
End Sub

Sub CorreaU()
With RsCorreaU
If .State = 1 Then .Close
.Open "select * from Correa_U ORDER BY ID DESC", base1, adOpenStatic,
adLockOptimistic

End With
End Sub

Sub TensorCU()
With RsTensorCU
If .State = 1 Then .Close
.Open "select * from Tensor_CU ORDER BY ID DESC", base1, adOpenStatic,
adLockOptimistic

End With
End Sub

Sub BombaAC()
With RsBombaAC
If .State = 1 Then .Close
.Open "select * from Bomba_AC ORDER BY ID DESC", base1, adOpenStatic,
adLockOptimistic

End With
End Sub

Sub CambioAF()
With RsCambioAF
If .State = 1 Then .Close
.Open "select * from Cambio_A_F ORDER BY ID DESC", base1, adOpenStatic,
adLockOptimistic

End With
End Sub

Sub Bujias()
With RsBujias
If .State = 1 Then .Close
.Open "select * from Bujias ORDER BY ID DESC", base1, adOpenStatic,
adLockOptimistic

End With
End Sub

Sub CablesB()
With RsCablesB
If .State = 1 Then .Close
.Open "select * from Cables_B ORDER BY ID DESC", base1, adOpenStatic,
adLockOptimistic

End With
End Sub

Sub Bobinas()
With RsBobinas
If .State = 1 Then .Close
.Open "select * from Bobinas ORDER BY ID DESC", base1, adOpenStatic,
adLockOptimistic

End With
End Sub

Sub Inyectores()
With RsInyectores
If .State = 1 Then .Close
.Open "select * from Inyectores ORDER BY ID DESC", base1, adOpenStatic,
adLockOptimistic

End With
End Sub

Sub EmpacaduraTV()
With RsEmpacaduraTV
If .State = 1 Then .Close
.Open "select * from Empacadura_TV ORDER BY ID DESC", base1, adOpenStatic,
adLockOptimistic

End With
End Sub

Sub PLACAS()
With RsPlaca
If .State = 1 Then .Close
.Open "select * from PLACAS", base1, adOpenStatic, adLockOptimistic

End With
End Sub

MOTOR
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS.Show 1
Case 1
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS.Show 1
Case 2
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS.Show 1
Case 3
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS.Show 1
Case 4
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS.Show 1
Case 5
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS5.Show 1
Case 6
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS67.Show 1
Case 7
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS67.Show 1
Case 8
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS.Show 1
Case 9
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS.Show 1
Case 10
j = Index: msg1 = Command1(Index).Caption
FrmTABLAS.Show 1
End Select
End Sub

Private Sub Command3_Click()


Unload Me
End Sub

Private Sub Form_Load()


If color <> "" Then Command1(j).BackColor = color
End Sub

TABLAS

Private Sub habilitarcajas(estado As Boolean)


TxtFecha.Locked = estado
TxtKilo.Locked = estado
TxtFactu.Locked = estado
TxtProve.Locked = estado
TxtTaller.Locked = estado
TxtMonto1.Locked = estado
TxtMonto2.Locked = estado
End Sub
Private Sub limpiar()
TxtFecha.Text = ""
TxtKilo.Text = ""
TxtFactu.Text = ""
TxtProve.Text = ""
TxtTaller.Text = ""
TxtMonto1.Text = ""
TxtMonto2.Text = ""
End Sub
Private Sub habilitarbotones(estado1 As Boolean, estado2 As BookmarkEnum)
CmdModi.Enabled = estado1
CmdNuevo.Enabled = estado1
CmdGuardar.Enabled = estado2
CmdCancelar.Enabled = estado2
CmdEliminar.Enabled = estado1
CmdBuscar.Enabled = estado1
End Sub

Private Sub cerrargrid()


DataGrid1.Columns(0).Locked = True
DataGrid1.Columns(1).Locked = True
DataGrid1.Columns(2).Locked = True
DataGrid1.Columns(3).Locked = True
DataGrid1.Columns(4).Locked = True
DataGrid1.Columns(5).Locked = True
DataGrid1.Columns(6).Locked = True
DataGrid1.Columns(7).Locked = True
End Sub

Private Sub CmdBuscar_Click()


busca = InputBox("Ingrese nombre del Proveedor ", "Busqueda", "ingrese")
If busca = "" Then
MsgBox "No se ingreso texto ", vbInformation
Exit Sub
Else ''S ingres data
With Recor
.Requery
.Filter = "Proveedor LIKE '*" & busca & "*' or Taller_Instalacion LIKE
'*" & busca & "*'"
If .EOF Then LlenarGrid: ActualizaCol: MsgBox "no se encontr el
Proveedor " & busca: limpiar: Exit Sub
End With
End If
ActualizaCol
End Sub

Private Sub CmdCancelar_Click()


habilitarbotones True, False
habilitarcajas True
limpiar

End Sub

Private Sub CmdEliminar_Click()


If codigo = 0 Then
MsgBox "Elija un registro", vbInformation
Exit Sub
Else
With Recor
.Find "ID='" & Trim(codigo) & "'"
If .EOF Then
MsgBox "No se encontr el registro", vbInformation
Exit Sub
Else
If MsgBox("Desea eliminar el registro " & DataGrid1.Columns(4).Text,
vbInformation + vbYesNo) = vbYes Then
.Delete
.Requery
codigo = 0
limpiar
End If
End If
End With
End If

ActualizaCol
End Sub

Private Sub CmdGuardar_Click()


'Validar cajas de texto
If TxtFecha.Text = "" Then MsgBox "campo fecha est vacio", vbInformation, "Aviso":
TxtFecha.SetFocus: Exit Sub
If TxtKilo.Text = "" Then MsgBox "campo fecha est vacio", vbInformation, "Aviso":
TxtKilo.SetFocus: Exit Sub
If TxtFactu.Text = "" Then MsgBox "campo fecha est vacio", vbInformation, "Aviso":
TxtFactu.SetFocus: Exit Sub
If TxtProve.Text = "" Then MsgBox "campo fecha est vacio", vbInformation, "Aviso":
TxtProve.SetFocus: Exit Sub
If TxtTaller.Text = "" Then MsgBox "campo fecha est vacio", vbInformation,
"Aviso": TxtTaller.SetFocus: Exit Sub
If TxtMonto1.Text = "" Then MsgBox "campo fecha est vacio", vbInformation,
"Aviso": TxtMonto1.SetFocus: Exit Sub
If TxtMonto2.Text = "" Then MsgBox "campo fecha est vacio", vbInformation,
"Aviso": TxtMonto2.SetFocus: Exit Sub

If Modi = False Then ''CREAR NUEVO REGISTRO


With Recor
.Requery
.AddNew
!Fecha = TxtFecha.Text
!Kilometros = TxtKilo.Text
!Factura = TxtFactu.Text
!Proveedor = TxtProve.Text
!Taller_Instalacion = TxtTaller.Text
!Monto_M_O = TxtMonto1.Text
!Monto_Repuesto = TxtMonto2.Text
''' cambiar el nombre del num por su cdigo real
Dim cambio
With RsPlaca
.Requery
.Find "Placa='" & Trim(PLACA) & "'"
cambio = !Num
End With
!Num = cambio
.Update
.Requery
End With
Else ''' MODIFICAR UN REGISTRO
With Recor
.Requery
.Find "ID='" & Trim(codigo) & "'"
!Fecha = TxtFecha.Text
!Kilometros = TxtKilo.Text
!Factura = TxtFactu.Text
!Proveedor = TxtProve.Text
!Taller_Instalacion = TxtTaller.Text
!Monto_M_O = TxtMonto1.Text
!Monto_Repuesto = TxtMonto2.Text
Dim clave1 ''cambiar nombre al ID
.Find "ID='" & Trim(codigo) & "'"
clave1 = !id
.UpdateBatch
.Requery
End With
End If
habilitarcajas True
habilitarbotones True, False
cerrargrid: ActualizaCol
End Sub

Private Sub CmdModi_Click()


TxtFecha.SetFocus
habilitarcajas False
Modi = True
habilitarbotones False, True

End Sub

Private Sub CmdNuevo_Click()


TxtFecha.SetFocus
habilitarcajas False
limpiar
Modi = False
habilitarbotones False, True

End Sub
Private Sub CmdSalir_Click()
If Recor.RecordCount >= 1 Then Motor!Command1(j).BackColor = &H80000003: Principal!
CmdBoton(z).BackColor = &H80000003: color = &H80000003
' If RsBombaA.RecordCount >= 1 Then CmdBoton(z).BackColor = &H80000003:
Command1(j).BackColor = &H80000003

' Cierro
Recor.Close
' Libero la memoria
Set Recor = Nothing
Unload Me
End Sub

Private Sub DataGrid1_Click()


With Recor
If .BOF Or .EOF Then Exit Sub
' Else
codigo = DataGrid1.Columns(0).Text
'End If
TxtFecha = !Fecha
TxtKilo = !Kilometros
TxtFactu = !Factura
TxtProve = !Proveedor
TxtTaller = !Taller_Instalacion
TxtMonto1 = !Monto_M_O
TxtMonto2 = !Monto_Repuesto
End With
End Sub

Private Sub Form_Load()


If j = 0 Then BombaA: Set Recor = RsBombaA: Set DataGrid1.DataSource = RsBombaA: _
Label8.Caption = "Tabla del Histrico de la " + msg1
If j = 1 Then CorreaT: Set Recor = RsCorreaT: Set DataGrid1.DataSource = RsCorreaT:
_
Label8.Caption = "Tabla del Histrico de la " + msg1
If j = 2 Then CorreaU: Set Recor = RsCorreaU: Set DataGrid1.DataSource = RsCorreaU:
_
Label8.Caption = "Tabla del Histrico de la " + msg1
If j = 3 Then TensorCU: Set Recor = RsTensorCU: Set DataGrid1.DataSource =
RsTensorCU: _
Label8.Caption = "Tabla del Histrico del " + msg1
If j = 4 Then BombaAC: Set Recor = RsBombaAC: Set DataGrid1.DataSource = RsBombaAC:
_
Label8.Caption = "Tabla del Histrico de la " + msg1
If j = 8 Then Bobinas: Set Recor = RsBobinas: Set DataGrid1.DataSource = RsBobinas:
_
Label8.Caption = "Tabla del Histrico de las " + msg1
If j = 9 Then Inyectores: Set Recor = RsInyectores: Set DataGrid1.DataSource =
RsInyectores: _
Label8.Caption = "Tabla del Histrico de los " + msg1
If j = 10 Then EmpacaduraTV: Set Recor = RsEmpacaduraTV: Set DataGrid1.DataSource =
RsEmpacaduraTV: _
Label8.Caption = "Tabla del Histrico de la " + msg1
cerrargrid: ActualizaCol
habilitarcajas True
habilitarbotones True, True
End Sub
Private Sub ActualizaCol()
DataGrid1.Columns(0).Width = 0
DataGrid1.Columns(1).Width = 1100
DataGrid1.Columns(2).Width = 1200
DataGrid1.Columns(3).Width = 1050
DataGrid1.Columns(4).Width = 2000
DataGrid1.Columns(5).Width = 2000
DataGrid1.Columns(6).Width = 1500
DataGrid1.Columns(7).Width = 1600

End Sub

Private Sub LlenarGrid() ' Sub para quitar el fitro y visualizar todos los datos en
el dataGRid
' Comprueba que el recordset est instanciado
If Not Recor Is Nothing Then
' Comprueba que est abierto
If Recor.State = adStateOpen Then
' Elimina el filtro
Recor.Filter = ""
' Carga el Datagrid
Set DataGrid1.DataSource = Recor
' se posiciona en el primer registro
Recor.MoveFirst
End If
End If
End Sub

PRINCIPAL

Private Sub CmdAgregar_Click()


'Validar cajas de texto
If TxtCarros.Text = RsPlaca.RecordCount Then MsgBox "ALCANZ EL LIMITE DE VEHICULOS
REGISTRADOS", vbInformation, "Aviso": TxtPlaca.Enabled = False: CmdAgregar.Enabled
= False: Exit Sub
If TxtPlaca.Text = "" Then MsgBox "campo Placa est vacio", vbInformation, "Aviso":
TxtPlaca.SetFocus: Exit Sub
With RsPlaca
.Requery
.AddNew
!PLACA = TxtPlaca.Text
CmbPlacas.AddItem (TxtPlaca.Text)
.Update
.Requery
End With
TxtPlaca.Text = ""
End Sub

Private Sub CmdBoton_Click(Index As Integer)


If CmbPlacas.Text = "" Then CmbPlacas.SetFocus: CmbPlacas.BackColor = vbYellow:
MsgBox "SELECCIONE UNA PLACA DE VEHICULO", vbInformation, "Aviso": Exit Sub
' If RsBombaA.RecordCount >= 1 Then CmdBoton(z).BackColor = &H80000003
PLACA = CmbPlacas.Text
With RsPlaca
.Requery
.Find "Placa='" & Trim(PLACA) & "'"
N = !Num
End With
Select Case Index
Case 0
z = Index '': msg1 = Command1(Index).Caption
Motor.Show 1
Case 1
'j = Index: msg1 = Command1(Index).Caption
Frenos.Show 1
Case 2
'j = Index: msg1 = Command1(Index).Caption
Enfria.Show 1
Case 3
'j = Index: msg1 = Command1(Index).Caption
Tren.Show 1
Case 4
'j = Index: msg1 = Command1(Index).Caption
Amorti.Show 1
Case 5
'j = Index: msg1 = Command1(Index).Caption
Caja.Show 1
Case 6
'j = Index: msg1 = Command1(Index).Caption
Cauchos.Show 1
Case 7
'j = Index: msg1 = Command1(Index).Caption
Bateria.Show 1
Case 8
'j = Index: msg1 = Command1(Index).Caption
Luces.Show 1
Case 9
'j = Index: msg1 = Command1(Index).Caption
Filtro.Show 1
Case 10
'j = Index: msg1 = Command1(Index).Caption
Correa.Show 1
Case 11
'j = Index: msg1 = Command1(Index).Caption
Alternador.Show 1
Case 12
'j = Index: msg1 = Command1(Index).Caption
Aire.Show 1
Case 13
'j = Index: msg1 = Command1(Index).Caption
SistemaDC.Show 1
Case 14
'j = Index: msg1 = Command1(Index).Caption
Soportes.Show 1
Case 15
'z = Index: msg1 = Command1(Index).Caption
Clutch.Show 1
End Select

End Sub

Private Sub Command2_Click()


Unload Me
End Sub
Private Sub Form_Load()
PLACAS
TxtCarros.Text = carros
While RsPlaca.EOF = False
CmbPlacas.AddItem RsPlaca!PLACA
RsPlaca.MoveNext
Wend
If carros = RsPlaca.RecordCount Then TxtPlaca.Enabled = False: CmdAgregar.Enabled =
False
End Sub

Private Sub Command1_Click()


Dim nombre As String
Dim telefono As String
nombre = Text1
telefono = Text2
Open App.Path & "\sysdata.txt" For Append As #1
Write #1, nombre, telefono
Close #1
Text1 = Empty
Text2 = Empty
MsgBox "Registro exitoso", vbInformation, "REGISTRO EXITOSO"

End Sub

Private Sub Command2_Click()


Dim nombre As String
nombre = Text1

Open App.Path & "\sysdata.txt" For Input As #1

Do While Not EOF(1)


Input #1, a, b

If nombre = a Then
Text2 = b
End If
Loop
Close #1
End Sub

Вам также может понравиться