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

Formulario Principal

Private Sub B1_Click()


Unload Me
FEmpleados.Show
End Sub

Private Sub B2_Click()


Unload Me
Marcaje.Show
End Sub

Private Sub B3_Click()


Unload Me
Comprobantes.Show
End Sub

Private Sub B4_Click()


Unload Me
End
End Sub

Formulario de Empleados
Private Sub Bcerrar_Click()
Unload Me
Principal.Show
End Sub

Private Sub Beliminar_Click()


Dim x As Integer
x = MsgBox("Seguro que desea Eliminar este Item?", vbQuestion + vbYesNo, "Eliminar Item")
If x <> vbYes Then Exit Sub
Selection.EntireRow.Delete
ActiveWorkbook.Save

End Sub

Private Sub Bfoto_Click()


On Error Resume Next
archivoimg = Application.GetOpenFilename("Imágenes jpg,*.jpg,Imágenes bmp,*.bmp,Imágenes jpeg,*.jpeg", 0,
"Seleccionar Imágen")
Image1.Picture = LoadPicture("")
Image1.Picture = LoadPicture(archivoimg)
Truta = (archivoimg)
If Truta.Text = "FALSO" Then
Truta = Truta2.Text
End If

End Sub

Private Sub bguardar_Click()


Sheets("Empleados").Activate

Dim fCode As Integer


fCode = nCode(Cbcode.Text)

If fCode = 0 Then '1


Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate ' si el registro no existe, se va al final.
Loop

With ActiveCell.EntireRow.Font
.Name = "Calibri"
.Size = 9

End With

Dim x As Integer
x = MsgBox("Seguro que Desea Ingresar este Empleado? ", vbYesNo, "Ingresar Empleado")
If x <> vbYes Then Exit Sub
'Aqui es cuando agregamos o modificamos el registro
Application.ScreenUpdating = False
ActiveCell = Cbcode
ActiveCell.Offset(0, 1) = Tnom: ActiveCell.Offset(0, 2) = The: ActiveCell.Offset(0, 3) = Thsa
ActiveCell.Offset(0, 4) = Val(Tsud.Value): ActiveCell.Offset(0, 5) = Tfecha
ActiveCell.Offset(0, 6) = Truta

Application.ScreenUpdating = True

ActiveWorkbook.Save
Cbcode.Text = Worksheets("Empleados").Range("A2")

Exit Sub
Else
Cells(fCode, 2).Select ' cuando ya existe el registro, cumple esta condición.

End If '1

With ActiveCell.EntireRow.Font
.Name = "Calibri"
.Size = 9

End With
Dim Y As Integer
Y = MsgBox("Seguro que Desea Modificar este Empleado? ", vbYesNo, "Ingresar Empleados")
If Y <> vbYes Then Exit Sub '1
'Aqui es cuando agregamos o modificamos el registro
Application.ScreenUpdating = False
ActiveCell = Cbcode
ActiveCell.Offset(0, 0) = Tnom: ActiveCell.Offset(0, 1) = The: ActiveCell.Offset(0, 2) = Thsa
ActiveCell.Offset(0, 3) = Val(Tsud.Value): ActiveCell.Offset(0, 4) = Tfecha:
ActiveCell.Offset(0, 5) = Truta

Application.ScreenUpdating = True

ActiveWorkbook.Save
Cbcode.Text = Worksheets("Empleados").Range("A2")

End Sub

Private Sub Cbcode_Change()


Tcod.Text = Cbcode.Text
On Error Resume Next
If nCode(Cbcode.Text) <> 0 Then

Sheets("Empleados").Activate

Cells(Cbcode.ListIndex + 2, 1).Select
Tnom = ActiveCell.Offset(0, 1): The = ActiveCell.Offset(0, 2): Thsa = ActiveCell.Offset(0, 3)
Tsud = ActiveCell.Offset(0, 4): Tfecha = ActiveCell.Offset(0, 5)
Truta3 = ActiveCell.Offset(0, 6)

Else
Tnom = "": The = "": Thsa = "": Tsal = 0: Tsud = 0: Tfecha = Date: Truta3 = Truta2.Text

End If

End Sub

Private Sub Tcod_Change()


If IsNumeric(Tcod.Text) Then

Else
Tcod = ""
End If

Cbcode = Tcod
End Sub

Private Sub Tnom_Change()


If Tnom = "" Then
bguardar.Caption = "Guardar"
Else
bguardar.Caption = "Actualizar"
End If
End Sub

Private Sub Truta3_Change()


If Truta3 <> "" Then
Image1.Picture = LoadPicture(Truta3)
Else
Image1.Picture = LoadPicture(Truta2)
End If

End Sub

Private Sub Tsud_Change()


If IsNumeric(Tsud.Text) Then

Else
Tsud = ""
End If

End Sub

Private Sub UserForm_Initialize()


Dim rango, celda As Range
Set rango = Worksheets("Empleados").Range("Listado_emp")

For Each celda In rango


Cbcode.AddItem celda.Value

Next celda
Cbcode.Text = Worksheets("Empleados").Range("A2")
Tfecha = Date

End Sub
Formulario de Marcajes
Sub TEMPORAL()
CreateObject("wscript.shell").Popup _
"MARCAJE INCORRECTO!: " & vbCr & _
"INTENTE DE NUEVO !", 1, "INCORRECTO"
End Sub
'---------------------------------------------------------------------------------------------------
Private Sub Bcerrar_Click()
Unload Me: Principal.Show
End Sub
'---------------------------------------------------------------------------------------------------

Private Sub Cbcode_Change()


Tcod.Text = Cbcode.Text
On Error Resume Next
If nCode(Cbcode.Text) <> 0 Then
Sheets("Empleados").Activate
Cells(Cbcode.ListIndex + 2, 1).Select
Tnom = ActiveCell.Offset(0, 1):

Else
Tnom = ""
End If
End Sub
'---------------------------------------------------------------------------------------------------

Private Sub Cbcode2_Change()


On Error Resume Next
If nCode2(Cbcode2.Text) <> 0 Then
Sheets("Control").Activate
Cells(Cbcode2.ListIndex + 2, 1).Select
Tnom = ActiveCell.Offset(0, 1): 'the = ActiveCell.Offset(0, 2):
Tcod3 = ActiveCell.Offset(0, 5):

Else
Tnom = "": The = "": Tcod3 = ""
Tcod3 = ""
End If
End Sub
'---------------------------------------------------------------------------------------------------

Private Sub Cbcode3_Change()


On Error Resume Next
If nCode3(Cbcode3.Text) <> 0 Then
Sheets("Marcajes").Activate
Cells(Cbcode3.ListIndex + 2, 1).Select
The = ActiveCell.Offset(0, 2):

Else

The = ""
End If
End Sub
'---------------------------------------------------------------------------------------------------

Private Sub CommandButton1_Click()

If Tnom = "" Then


Exit Sub
End If
Sheets("Marcajes").Activate

Dim fCode3 As Integer


fCode3 = nCode3(Tcod2.Text)

If fCode3 = 0 Then
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate ' si el registro no existe, se va al final.
Loop
With ActiveCell.EntireRow.Font '--------------*
.Name = "Calibri"
.Size = 9
End With '------------------------------------*

'Aqui es cuando agregamos o modificamos el registro


Application.ScreenUpdating = False
ActiveCell = Tcod2
'ActiveCell.Offset(0, 0) = Tcod
ActiveCell.Offset(0, 1) = Tnom: ActiveCell.Offset(0, 2) = Lhora: ' ActiveCell.Offset(5, 3) = Thos
ActiveCell.Offset(0, 4) = Tfecha:
ActiveCell.Offset(0, 5) = Tcod: ActiveCell.Offset(0, 6) = Tpla
ActiveCell.Offset(0, 7) = Lti: ActiveCell.Offset(0, 8) = tcp

Application.ScreenUpdating = True
ActiveWorkbook.Save: ' Unload Me: Marcaje.Show:

Else
'If fCode2 <> 0 Then
Thsa = Lhora
CommandButton2_Click

Cells(fCode3, 1).Select
'Aqui es cuando agregamos o modificamos el registro
Application.ScreenUpdating = False
ActiveCell = Tcod2
ActiveCell.Offset(0, 3) = Lhora: ActiveCell.Offset(0, 4) = Tfecha
ActiveCell.Offset(0, 6) = Tpla: ActiveCell.Offset(0, 7) = Tti
ActiveCell.Offset(0, 8) = tcp

Application.ScreenUpdating = True
ActiveWorkbook.Save
End If
End Sub
'---------------------------------------------------------------------------------------------------

Private Sub CommandButton2_Click()


Dim t0, t1 As Variant
t0 = Format(The, "hh:mm:ss")
t1 = Format(Thsa, "hh:mm:ss")

Tti = Format(TimeValue(t1) - TimeValue(t0), "hh:mm:ss")

End Sub
'---------------------------------------------------------------------------------------------------

Private Sub Tcod_Change()


If IsNumeric(Tcod.Text) Then

Else
Tcod = ""
End If
Tcod2 = Tcod + Tfecha: Cbcode2 = Tcod.Text
Cbcode.Text = Tcod.Text
End Sub
'---------------------------------------------------------------------------------------------------

Private Sub Tcod_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

If KeyCode = 13 Then '-------------------------- 1


tcp = Tcod + Tpla
'***********************
If Tnom = "" Then '---------------2
TEMPORAL
Unload Me: Marcaje.Show
Exit Sub

End If '--------------------------2

Lhora.Caption = Time

Sheets("Control").Activate

Dim fCode2 As Integer


fCode2 = nCode2(Cbcode.Text)

If fCode2 = 0 Then '1


Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate ' si el registro no existe, se va al final.
Loop
With ActiveCell.EntireRow.Font '--------------*
.Name = "Calibri"
.Size = 9
End With '------------------------------------*

'Aqui es cuando agregamos o modificamos el registro


Application.ScreenUpdating = False
ActiveCell = Cbcode
ActiveCell.Offset(0, 1) = Tnom: ActiveCell.Offset(0, 2) = Lhora:
ActiveCell.Offset(0, 4) = Tfecha: ActiveCell.Offset(0, 5) = Tcod2
ActiveCell.Offset(0, 6) = Tpla: ' ActiveCell.Offset(0, 7) = Tti

Application.ScreenUpdating = True
CommandButton1_Click
ActiveWorkbook.Save: Unload Me: Marcaje.Show:

Else

Cells(fCode2, 2).Select
'Aqui es cuando agregamos o modificamos el registro
Application.ScreenUpdating = False
ActiveCell = Cbcode
ActiveCell.Offset(0, 0) = Tnom: ActiveCell.Offset(0, 2) = Lhora
ActiveCell.Offset(0, 3) = Tfecha: ActiveCell.Offset(0, 4) = Tcod2
ActiveCell.Offset(0, 5) = Tpla

Application.ScreenUpdating = True
CommandButton1_Click
ActiveWorkbook.Save: Unload Me: Marcaje.Show:
End If
End If
End Sub
'---------------------------------------------------------------------------------------------------

Private Sub Tcod2_Change()


Cbcode3 = Tcod2
End Sub

Private Sub Tcod3_Change()

End Sub
'---------------------------------------------------------------------------------------------------

Private Sub UserForm_Activate()


Lhora = Time: Tpla = weeknum(Tfecha):
Tcod2 = Tcod + Tfecha '+ Tpla
Lti.Caption = "0:00:00"
End Sub
'---------------------------------------------------------------------------------------------------

Private Sub UserForm_Initialize()

Dim rango, celda As Range


Set rango = Worksheets("Empleados").Range("Listado_emp")

For Each celda In rango


Cbcode.AddItem celda.Value

Next celda
Cbcode.Text = Worksheets("Empleados").Range("A2")

Dim rango1, celda1 As Range


Set rango1 = Worksheets("Control").Range("Listado_mar")

For Each celda1 In rango1


Cbcode2.AddItem celda1.Value

Next celda1
Cbcode2.Text = Worksheets("Control").Range("A2")

'***********************************************************

Dim rango2, celda2 As Range


Set rango2 = Worksheets("Marcajes").Range("Listado_cod")

For Each celda2 In rango2


Cbcode3.AddItem celda2.Value

Next celda2
Cbcode3.Text = Worksheets("Marcajes").Range("A2")

Tfecha = Date
Cbcode2.Text = Cbcode.Text
Tcod = ""
End Sub
Formulario de Comprobantes
Private Sub Bcerrar_Click()
Unload Me: Principal.Show
End Sub

Private Sub Cbcode_Change()


On Error Resume Next
If nCode(Cbcode.Text) <> 0 Then
Sheets("Empleados").Activate
Cells(Cbcode.ListIndex + 2, 1).Select
Tnom = ActiveCell.Offset(0, 1): Tsud = ActiveCell.Offset(0, 4)
Tfecha2 = ActiveCell.Offset(0, 5)

Else
Tnom = "": Tsud = "": Tfecha2 = ""
End If
End Sub

Private Sub CommandButton1_Click()


Dim x, Y As Variant
x = CDate(Ttotal) * 24
Y = x * Tsuh.Value
Tpago = Y
Dim nuevos As String
If InStr(Tpago, ",") > 0 Then
nuevos = Replace(Tpago.Value, ",", ".")
Tpago.Value = nuevos
End If
Tpago.Value = FormatNumber(Tpago.Value, 2)
Tpagar = Tpago
End Sub

Private Sub CommandButton2_Click()

If ListBox1.Text = "" Then


Tcod.SetFocus
Exit Sub
End If
limpiar
Sheets("Voucher").Activate

Sheets("Voucher").Cells(5, 1) = Tcod.Text: Sheets("Voucher").Cells(32, 1) = Tcod.Text


Sheets("Voucher").Cells(5, 2) = Tnom.Text: Sheets("Voucher").Cells(32, 2) = Tnom.Text
Sheets("Voucher").Cells(5, 7) = Tfecha2.Text: Sheets("Voucher").Cells(32, 7) = Tfecha2.Text
Sheets("Voucher").Cells(7, 1) = Tsud.Value: Sheets("Voucher").Cells(34, 1) = Tsud.Value
Sheets("Voucher").Cells(7, 2) = Tpla.Text: Sheets("Voucher").Cells(34, 2) = Tpla.Text
Sheets("Voucher").Cells(7, 3) = Tfecha.Text: Sheets("Voucher").Cells(34, 3) = Tfecha.Text
Sheets("Voucher").Cells(9, 1) = Label15.Caption: Sheets("Voucher").Cells(9, 4) = Tiem.Value
Sheets("Voucher").Cells(9, 5) = Tpago.Value: Sheets("Voucher").Cells(36, 5) = Tpago.Value
Sheets("Voucher").Cells(36, 1) = Label15.Caption: Sheets("Voucher").Cells(36, 4) = Tiem.Value
Sheets("Voucher").Cells(16, 5) = Tpago.Value: Sheets("Voucher").Cells(16, 9) = Tdeduc.Value
Sheets("Voucher").Cells(17, 8) = Tpagar.Value

Sheets("Voucher").Cells(43, 5) = Tpago.Value: Sheets("Voucher").Cells(43, 9) = Tdeduc.Value


Sheets("Voucher").Cells(44, 8) = Tpagar.Value

With Sheets("voucher")
.Visible = xlSheetVisible
.PageSetup.Orientation = xlPortrait:
.PrintOut
End With

Application.ScreenUpdating = True

MsgBox ("Comprobante Impreso con exito!"), vbInformation, "Impresion Realizada"


End Sub

Private Sub Sumar_Click()


Dim i As Integer
Dim Total As Variant

Total = CDate("00:00:00")
For i = 0 To ListBox1.ListCount - 1
Total = Total + CDate(ListBox1.List(i, 4))

Next i
Ttotal = Total
Tiem = CDate(Ttotal) * 24
Tiem.Value = FormatNumber(Tiem.Value, 2)

End Sub

Private Sub Tcod_Change()


If IsNumeric(Tcod.Text) Then

Else
Tcod = ""
End If
End Sub

Private Sub Tcod_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)


If KeyCode = 13 Then
Cbcode = ""
Cbcode.Text = Tcod.Text
Tcod2 = Tcod + Tpla

Me.ListBox1.Clear
Hoja3.Activate
items = Range("listas_mar").CurrentRegion.Rows.Count
For i = 2 To items

If LCase(Cells(i, 9).Value) Like "*" & LCase(Me.Tcod2.Value) & "*" Then


Me.ListBox1.AddItem Cells(i, 6)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Cells(i, 2): Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = Cells(i,
3)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = Cells(i, 4): Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = Cells(i,
8)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = Cells(i, 5)

End If
Next i
Sumar_Click
CommandButton1_Click
End If
End Sub

Private Sub Tiem_Change()


Dim nuevos As String
If InStr(Tiem, ",") > 0 Then
nuevos = Replace(Tiem.Value, ",", ".")
Tiem.Value = nuevos
End If
End Sub

Private Sub Tsud_Change()


If Tsud <> "" Then
Tsuh = Val(Tsud.Value) / 8
Tsuh.Value = FormatNumber(Tsuh.Value, 2)
Tsus = Tsud * 7: Tsum = Tsud * 30
End If
End Sub

Private Sub Tsuh_Change()


Dim nuevos As String
If InStr(Tsuh, ",") > 0 Then
nuevos = Replace(Tsuh.Value, ",", ".")
Tsuh.Value = nuevos
End If
End Sub

Private Sub UserForm_Activate()


Tfecha = Date
Tnom = "": Tsud = "": Tsus = "": Tsum = "": Tsuh = "": Tdeduc = 0: Tpagar = 0
Tpla = weeknum(Tfecha)
End Sub

Private Sub UserForm_Initialize()


Dim rango, celda As Range
Set rango = Worksheets("Empleados").Range("Listado_emp")

For Each celda In rango


Cbcode.AddItem celda.Value

Next celda
Cbcode.Text = Worksheets("Empleados").Range("A2")

'***********************************************************

Dim rango1, celda1 As Range


Set rango1 = Worksheets("Control").Range("Listado_mar")

For Each celda1 In rango1


Cbcode2.AddItem celda1.Value

Next celda1
Cbcode2.Text = Worksheets("Control").Range("A2")
End Sub

Sub limpiar()
Sheets("Voucher").Activate

Sheets("Voucher").Cells(5, 1).ClearContents: Sheets("Voucher").Cells(32, 1).ClearContents


Sheets("Voucher").Range("B5:F5").ClearContents: Sheets("Voucher").Range("G5:J5").ClearContents
Sheets("Voucher").Range("C7:E7").ClearContents: Sheets("Voucher").Range("A9:C15").ClearContents
Sheets("Voucher").Range("F9:H15").ClearContents: Sheets("Voucher").Range("I16:J16").ClearContents
Sheets("Voucher").Range("D9:E15").ClearContents
Sheets("Voucher").Range("B32:F32").ClearContents: Sheets("Voucher").Range("G32:J32").ClearContents
Sheets("Voucher").Range("C34:E34").ClearContents: Sheets("Voucher").Range("A36:C42").ClearContents
Sheets("Voucher").Range("F36:H42").ClearContents: Sheets("Voucher").Range("I43:J43").ClearContents
Sheets("Voucher").Range("D36:E42").ClearContents
Sheets("Voucher").Cells(16, 5).ClearContents: Sheets("Voucher").Cells(43, 5).ClearContents
Sheets("Voucher").Cells(17, 8).ClearContents: Sheets("Voucher").Cells(44, 8).ClearContents
Sheets("Voucher").Cells(7, 1).ClearContents: Sheets("Voucher").Cells(34, 1).ClearContents
Sheets("Voucher").Cells(7, 2).ClearContents: Sheets("Voucher").Cells(34, 2).ClearContents
End Sub

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