Sunteți pe pagina 1din 15

‘Formulario Barras

Private Const MinRow As Long = 2


Private CurrentRow As Long

Private Function MaxRow() As Long


With Cells(MinRow, 1).CurrentRegion
MaxRow = .Rows.Count - .Row + 1
End With
End Function
Private Sub AnteriorBtn_Click()
CurrentRow = IIf(CurrentRow - 1 < MinRow, MinRow, CurrentRow - 1)
UpdateTextBoxes
End Sub

Private Sub Bcerrar_Click()


Unload Me
Fmenu.Show
End Sub

Private Sub Beti_Click()


facturar
facturar2
'inserta_imagen
IMPRIMIR
End Sub

Private Sub CommandButton1_Click()


Unload Me
Fbuscador.Show
End Sub
Sub todos()
Lnom.Caption = Tnom.Text: Lcar.Caption = Tcar.Text: Lcur.Caption =
Tcur.Text
Lid.Caption = Tid.Text: Tid2.Text = Tid.Text: Lsex.Caption = Tsex.Text
Lfecha.Caption = Tfecha.Text: Lven.Caption = Tven.Text
End Sub

Private Sub PrimerBtn_Click()


CurrentRow = MinRow
UpdateTextBoxes
End Sub

Private Sub SiguienteBtn_Click()


CurrentRow = IIf(CurrentRow + 1 > MaxRow, MaxRow, CurrentRow + 1)
UpdateTextBoxes
End Sub

Private Sub Tcode_Change()


Cbcode.Text = Tcode.Text
End Sub

Private Sub Tid_Change()


Lid.Caption = Tid.Text
End Sub
Private Sub Truta3_Change()
If Truta3 <> "" Then
Image1.Picture = LoadPicture(Truta3)
Else
Image1.Picture = LoadPicture(Truta2)
End If
If Truta3 <> "" Then
Image3.Picture = LoadPicture(Truta3)
Else
Image3.Picture = LoadPicture(Truta2)
End If
End Sub
Private Sub UltimoBtn_Click()
CurrentRow = MaxRow
UpdateTextBoxes
End Sub

Private Sub UpdateTextBoxes()


Tcode = Sheet1.Cells(CurrentRow, 1).Text: Tnom = Sheet1.Cells(CurrentRow,
2).Text
Tcur = Sheet1.Cells(CurrentRow, 3).Text: Tcar = Sheet1.Cells(CurrentRow,
4).Text
Tfecha = Sheet1.Cells(CurrentRow, 5).Text: Truta3 =
Sheet1.Cells(CurrentRow, 6).Text
Tid = Sheet1.Cells(CurrentRow, 7).Text: Tsex = Sheet1.Cells(CurrentRow,
8).Text
Tven = Sheet1.Cells(CurrentRow, 9).Text ': Truta3 =
Sheet1.Cells(CurrentRow, 6).Text
End Sub

Private Sub Cbcode_Change()


Tcode.Text = Cbcode.Text
On Error Resume Next
If nprod(Cbcode.Text) <> 0 Then

Sheets("Alumnos").Activate
Cells(Cbcode.ListIndex + 2, 1).Select
Tnom = ActiveCell.Offset(0, 1): Tcur = ActiveCell.Offset(0, 2):
Tcar = ActiveCell.Offset(0, 3)
Tfecha = ActiveCell.Offset(0, 4): Truta3 = ActiveCell.Offset(0,
5): Tid = ActiveCell.Offset(0, 6)
Tsex = ActiveCell.Offset(0, 7): Tven = ActiveCell.Offset(0, 8)
todos
Else
Tnom = "": Tcar = "": Tfecha = Date: Tven = Date: Tcur = "":
Truta3 = Truta2.Text
Tsex = "Masculino": Che1.Value = True: Tid = ""
End If

End Sub

Private Sub UserForm_Initialize()


Tfecha = Date: Tfecha = Format(Tfecha, "dd/mm/yyyy")
Dim rango, celda As Range
Set rango = Worksheets("Alumnos").Range("Listado_prod")

For Each celda In rango


Cbcode.AddItem celda.Value

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

CurrentRow = MinRow
UpdateTextBoxes

End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)


Dim qq As String
If CloseMode = 0 Then
qq = Chr(34): Cancel = 1
End If
End Sub
Sub facturar()
Sheets("listado").Activate
Application.ScreenUpdating = False
Sheets("listado").Cells(2, 1) = Tcode.Text: Sheets("listado").Cells(2, 2)
= Tnom.Text
Sheets("listado").Cells(2, 3) = Tcur.Value: Sheets("listado").Cells(2, 4)
= Tcar.Text
Sheets("listado").Cells(2, 5) = Tfecha.Value: Sheets("listado").Cells(2,
6) = Tid.Text
Sheets("listado").Cells(2, 7) = Tsex.Value: Sheets("listado").Cells(2, 8)
= Tven.Text
Sheets("listado").Cells(2, 9) = Truta3.Value
Application.ScreenUpdating = True
End Sub
Sub facturar2()
Sheets("ETIQUETADO").Activate
Application.ScreenUpdating = False
Sheets("ETIQUETADO").Cells(2, 14) = Truta3.Text:
Application.ScreenUpdating = True
End Sub
Sub IMPRIMIR()
Sheets("etiquetado").Activate
Application.ScreenUpdating = False
With Sheets("etiquetado")
.Visible = xlSheetVisible
'''MsgBox "Se imprimiran los datos!", vbInformation, "Imprimir..."
.PageSetup.Orientation = xlPortrait
.PrintOut
End With
Application.ScreenUpdating = True

MsgBox ("Carnet Impreso con exito!"), vbInformation, "Impresion


Realizada"

End Sub
Sub inserta_imagen()
Sheets("ETIQUETADO").Select
ActiveSheet.Pictures.Insert(Truta3.Text).Select
With Selection.ShapeRange
'.Cells = Range("D1").Delete
.Top = Range("D1").Top
.Left = Range("D1").Left
.Height = 2000
.Width = 80

End With
End Sub
‘Formulario Fbuscador
Private Sub bmostrar_Click()
If Me.txt_Buscar.Value = Empty Then
MsgBox "Escriba un registro para buscar"
Me.ListBox1.Clear
Me.txt_Buscar.SetFocus
Me.TextBox1 = ""
Label15.Caption = ListBox1.ListCount
Exit Sub
End If

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

If LCase(Cells(i, 2).Value) Like "*" &


LCase(Me.txt_Buscar.Value) & "*" Then
Me.ListBox1.AddItem Cells(i, 1)
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,
15)

ElseIf LCase(Cells(i, 1).Value) Like "*" &


LCase(Me.txt_Buscar.Value) & "*" Then
Me.ListBox1.AddItem Cells(i, 1)
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,
15)

ElseIf LCase(Cells(i, 4).Value) Like "*" &


LCase(Me.txt_Buscar.Value) & "*" Then
Me.ListBox1.AddItem Cells(i, 1)
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,
15)

ElseIf LCase(Cells(i, 3).Value) Like "*" &


LCase(Me.txt_Buscar.Value) & "*" Then
Me.ListBox1.AddItem Cells(i, 1)
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,
15)

ElseIf LCase(Cells(i, 8).Value) Like "*" &


LCase(Me.txt_Buscar.Value) & "*" Then
Me.ListBox1.AddItem Cells(i, 1)
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,
15)

End If

Next i

Me.txt_Buscar.SetFocus
Me.txt_Buscar.SelStart = 0
Me.txt_Buscar.SelLength = Len(Me.txt_Buscar.Text)
Me.TextBox1 = ""
Label15.Caption = ListBox1.ListCount
Exit Sub

End Sub

Private Sub Cbcode_Change()


On Error Resume Next
If nprod(Cbcode.Text) <> 0 Then

Sheets("Productos").Activate

Cells(Cbcode.ListIndex + 2, 1).Select
'Tdes = ActiveCell.Offset(0, 1): Tpre = ActiveCell.Offset(0, 2):
Tubi = ActiveCell.Offset(0, 3)
' Tfecha = ActiveCell.Offset(0, 4):
Truta3 = ActiveCell.Offset(0, 5)
Else
'Tdes = "": Tpre = 0: Tfecha = Date: Tubi = "":
Truta3 = Truta2.Text
End If
End Sub

Private Sub cmd_Cerrar_Click()


Unload Me
Fmenu.Show
End Sub

Private Sub CommandButton2_Click()


If TextBox1.Text <> "" Then
FPro.Cbcode.Text = TextBox1.Text

Unload Fbuscador
FPro.Show
Else
Me.txt_Buscar.SetFocus
Exit Sub
End If
End Sub
Private Sub CommandButton3_Click()
If TextBox1.Text <> "" Then
Barras.Cbcode.Text = TextBox1.Text

Unload Fbuscador
Barras.Show
Else
Me.txt_Buscar.SetFocus
Exit Sub
End If
End Sub

Private Sub ListBox1_Click()


If ListBox1.Text = "" Then
MsgBox "Debe de seleccionar un valor en el Listbox"
Exit Sub
End If
TextBox1.Text = ListBox1.Column(0)
Cbcode.Text = ListBox1.Column(0)

Me.TextBox1.SelStart = 0
Me.TextBox1.SelLength = Len(Me.TextBox1.Text)
Me.TextBox1.Copy
End Sub

Private Sub Truta3_Change()


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

Private Sub txt_Buscar_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,


ByVal Shift As Integer)
If KeyCode = 13 Then
bmostrar_Click
End If
End Sub

Private Sub UserForm_Initialize()


Dim rango, celda As Range
Set rango = Worksheets("Alumnos").Range("Listado_prod")

For Each celda In rango


Cbcode.AddItem celda.Value

Next celda
Cbcode.Text = Worksheets("Alumnos").Range("A2")
Truta3 = Truta2.Text
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)


Dim qq As String
If CloseMode = 0 Then
qq = Chr(34)
Cancel = 1
End If
End Sub

‘Formulario FMenú
Private Sub B1_Click()
Unload Me
FPro.Show
End Sub

Private Sub CommandButton1_Click()


Unload Me
Fbuscador.Show
End Sub

Private Sub CommandButton2_Click()


Unload Me
Barras.Show
End Sub

Private Sub CommandButton3_Click()


Unload Me
End
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)


Dim qq As String
If CloseMode = 0 Then
qq = Chr(34)
Cancel = 1
End If
End Sub
‘Formulario FPRO
Private Const MinRow As Long = 2
Private CurrentRow As Long

Private Function MaxRow() As Long


With Cells(MinRow, 1).CurrentRegion
MaxRow = .Rows.Count - .Row + 1
End With
End Function
Private Sub AnteriorBtn_Click()
CurrentRow = IIf(CurrentRow - 1 < MinRow, MinRow, CurrentRow - 1)
UpdateTextBoxes
End Sub

Private Sub Bcerrar_Click()


Unload Me
Fmenu.Show
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 Cbcarrera_Change()


Tcar.Text = Cbcarrera.Text
End Sub

Private Sub Cbcurso_Change()


Tcur.Text = Cbcurso.Text
End Sub

Private Sub Che1_Click()


If Che1.Value = True Then
Che2.Value = False
Tsex.Text = "Masculino"
End If
End Sub

Private Sub Che2_Click()


If Che2.Value = True Then
Che1.Value = False
Tsex.Text = "Femenino"
End If
End Sub

Private Sub CommandButton1_Click()


Unload Me
Fbuscador.Show
End Sub

Private Sub PrimerBtn_Click()


CurrentRow = MinRow
UpdateTextBoxes
End Sub

Private Sub SiguienteBtn_Click()


CurrentRow = IIf(CurrentRow + 1 > MaxRow, MaxRow, CurrentRow + 1)
UpdateTextBoxes
End Sub

Private Sub Tcar_Change()


Cbcarrera.Text = Tcar.Text
End Sub

Private Sub Tcode_Change()


Cbcode.Text = Tcode.Text
End Sub

Private Sub Tcur_Change()


Cbcurso.Text = Tcur.Text
End Sub

Private Sub Truta3_Change()


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

Private Sub Tsex_Change()


If Tsex.Text = "Femenino" Then
Che1.Value = False
Che2.Value = True
Else
Che1.Value = True
Che2.Value = False
End If
End Sub

Private Sub UltimoBtn_Click()


CurrentRow = MaxRow
UpdateTextBoxes
End Sub

Private Sub UpdateTextBoxes()


Tcode = Sheet1.Cells(CurrentRow, 1).Text: Tdes = Sheet1.Cells(CurrentRow,
2).Text
Tpre = Sheet1.Cells(CurrentRow, 3).Text: Tubi = Sheet1.Cells(CurrentRow,
4).Text
Tfecha = Sheet1.Cells(CurrentRow, 5).Text: Truta3 =
Sheet1.Cells(CurrentRow, 6).Text
End Sub
Private Sub BEliminar_Click()
Dim x As Integer
x = MsgBox("Seguro que desea Eliminar este Registro?", vbQuestion +
vbYesNo, "Eliminar Registro")
If x <> vbYes Then Exit Sub
Selection.EntireRow.Delete
Unload Me
FPro.Show
ActiveWorkbook.Save
End Sub

Private Sub Bguardar_Click()


Sheets("Alumnos").Activate

Dim fCode As Integer


fCode = nprod(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

If Tnom = "" Then


MsgBox ("Coloque el nombre del Alumno!"), vbExclamation, "Nombre del
Alumno": Tnom.SetFocus
Exit Sub
End If

If Tcur = "" Then


MsgBox ("Seleccione el Curso de Matricula!"), vbExclamation, "Curso de
Matricula": Cbcurso.SetFocus
Exit Sub
End If
If Tcar = "" Then
MsgBox ("Seleccione la Carrera de Matricula!"), vbExclamation, "Carrera
de Matricula": Cbcarrera.SetFocus
Exit Sub
End If

If Tid = "" Then


MsgBox ("Ingrese el numero de Identidad del Alumno!"), vbExclamation,
"Identidad del Alumno": Tid.SetFocus
Exit Sub
End If

If Tven = "" Then


MsgBox ("Ingrese la Fecha de vencimineto del Carnet!"), vbExclamation,
"Fecha de Vencimiento": Tven.SetFocus
Exit Sub
End If

Tfecha = Format(Tfecha, "dd/mm/yyyy"): Tven = Format(Tven, "dd/mm/yyyy")

If Truta = "" Then


Truta = Truta2.Text
End If

Dim x As Integer
x = MsgBox("Seguro que Desea Ingresar este Registro? ", vbYesNo,
"Ingresar Registro")
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) = Tcur:
ActiveCell.Offset(0, 3) = Tcar
ActiveCell.Offset(0, 4) = Tfecha: ActiveCell.Offset(0, 5) = Truta:
ActiveCell.Offset(0, 6) = Tid
ActiveCell.Offset(0, 7) = Tsex: ActiveCell.Offset(0, 8) = Tven

Application.ScreenUpdating = True

ActiveWorkbook.Save
Unload Me
FPro.Show
'Cbcode.Text = Worksheets("Productos").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

If Tnom = "" Then


MsgBox ("Coloque el nombre del Alumno!"), vbExclamation, "Nombre del
Alumno": Tnom.SetFocus
Exit Sub
End If

If Tcur = "" Then


MsgBox ("Seleccione el Curso de Matricula!"), vbExclamation, "Curso de
Matricula": Cbcurso.SetFocus
Exit Sub
End If
If Tcar = "" Then
MsgBox ("Seleccione la Carrera de Matricula!"), vbExclamation, "Carrera
de Matricula": Cbcarrera.SetFocus
Exit Sub
End If

If Tid = "" Then


MsgBox ("Ingrese el numero de Identidad del Alumno!"), vbExclamation,
"Identidad del Alumno": Tid.SetFocus
Exit Sub
End If

If Tven = "" Then


MsgBox ("Ingrese la Fecha de vencimineto del Carnet!"), vbExclamation,
"Fecha de Vencimiento": Tven.SetFocus
Exit Sub
End If

Tfecha = Format(Tfecha, "dd/mm/yyyy"): Tven = Format(Tven, "dd/mm/yyyy")

If Truta = "" Then


Truta = Truta2.Text
End If

Dim y As Integer
y = MsgBox("Seguro que Desea Modificar este Registro? ", vbYesNo,
"Modificar Registro")
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) = Tcur:
ActiveCell.Offset(0, 2) = Tcar
ActiveCell.Offset(0, 3) = Tfecha: ActiveCell.Offset(0, 4) = Truta:
ActiveCell.Offset(0, 5) = Tid
ActiveCell.Offset(0, 6) = Tsex: ActiveCell.Offset(0, 7) = Tven
Application.ScreenUpdating = True

ActiveWorkbook.Save
Unload Me
FPro.Show
' Cbcode.Text = Worksheets("Productos").Range("A2")
'Truta3 = Truta2.Text
End Sub

Private Sub Cbcode_Change()


Tcode.Text = Cbcode.Text
On Error Resume Next
If nprod(Cbcode.Text) <> 0 Then

Sheets("Alumnos").Activate
Cells(Cbcode.ListIndex + 2, 1).Select
Tnom = ActiveCell.Offset(0, 1): Tcur = ActiveCell.Offset(0, 2):
Tcar = ActiveCell.Offset(0, 3)
Tfecha = ActiveCell.Offset(0, 4): Truta3 = ActiveCell.Offset(0,
5): Tid = ActiveCell.Offset(0, 6)
Tsex = ActiveCell.Offset(0, 7): Tven = ActiveCell.Offset(0, 8)
Else
Tnom = "": Tcar = 0: Tfecha = Date: Tven = Date: Tcur = "": Truta3
= Truta2.Text
Tsex = "Masculino": Che1.Value = True:
Tid = ""
End If
End Sub

Private Sub UserForm_Initialize()


Che1.Value = True
Tsex.Text = "Masculino"
Tfecha = Date: Tfecha = Format(Tfecha, "dd/mm/yyyy")
Tven = Date: Tven = Format(Tven, "dd/mm/yyyy")
Dim rango, celda As Range
Set rango = Worksheets("Alumnos").Range("Listado_prod")

For Each celda In rango


Cbcode.AddItem celda.Value

Next celda
Cbcode.Text = Worksheets("Alumnos").Range("A2")
'***************************************************************
Dim rango1, celda1 As Range
Set rango1 = Worksheets("Listado").Range("Lis_cur")

For Each celda1 In rango1


Cbcurso.AddItem celda1.Value

Next celda1
Cbcurso.Text = Worksheets("Listado").Range("K2")

'***************************************************************
Dim rango2, celda2 As Range
Set rango2 = Worksheets("Listado").Range("Lis_car")

For Each celda2 In rango2


Cbcarrera.AddItem celda2.Value

Next celda2
Cbcarrera.Text = Worksheets("Listado").Range("L2")

CurrentRow = MinRow
UpdateTextBoxes

End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)


Dim qq As String
If CloseMode = 0 Then
qq = Chr(34): Cancel = 1
End If
End Sub
‘Modulo
Function nprod(Codigo As String) As Integer
Application.ScreenUpdating = False
Sheets("Alumnos").Activate
Range("A2").Activate
nprod = 0
Do While Not IsEmpty(ActiveCell)
If Codigo = ActiveCell Then
nprod = ActiveCell.Row
End If
ActiveCell.Offset(1, 0).Select
Loop
Application.ScreenUpdating = True

End Function

Sub terminar()
If Application.Workbooks.Count = 1 Then
Application.Quit
Else
ThisWorkbook.Close True
End If

End Sub

‘Thisworkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)


terminar
End Sub

Private Sub Workbook_Open()


Fmenu.Show
End Sub

S-ar putea să vă placă și