VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Form2 
   BackColor       =   &H00FFFFFF&
   Caption         =   "Form2"
   ClientHeight    =   5760
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   14670
   LinkTopic       =   "Form2"
   ScaleHeight     =   5760
   ScaleWidth      =   14670
   StartUpPosition =   3  'Windows Default
   WindowState     =   2  'Maximized
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   465
      Left            =   2880
      TabIndex        =   18
      Top             =   120
      Width           =   1065
   End
   Begin VB.ComboBox Combo1 
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   465
      ItemData        =   "Form2-2.frx":0000
      Left            =   3960
      List            =   "Form2-2.frx":000A
      TabIndex        =   17
      Text            =   "CodBulto"
      Top             =   120
      Width           =   1575
   End
   Begin VB.CommandButton Command6 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Reporte"
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   7440
      Style           =   1  'Graphical
      TabIndex        =   16
      Top             =   600
      Width           =   1935
   End
   Begin VB.CommandButton Command9 
      BackColor       =   &H00FFFFFF&
      Height          =   975
      Left            =   12480
      Picture         =   "Form2-2.frx":0021
      Style           =   1  'Graphical
      TabIndex        =   15
      Top             =   120
      Width           =   1335
   End
   Begin VB.CommandButton Command10 
      BackColor       =   &H00FFFFFF&
      Height          =   975
      Left            =   11280
      Picture         =   "Form2-2.frx":067A
      Style           =   1  'Graphical
      TabIndex        =   14
      Top             =   120
      Width           =   1215
   End
   Begin VB.CommandButton Command5 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Anular"
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   9480
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   120
      Width           =   1695
   End
   Begin RichTextLib.RichTextBox RichTextBox1 
      Height          =   495
      Left            =   13680
      TabIndex        =   12
      Top             =   1200
      Visible         =   0   'False
      Width           =   615
      _ExtentX        =   1085
      _ExtentY        =   873
      _Version        =   393217
      TextRTF         =   $"Form2-2.frx":0D24
   End
   Begin VB.CommandButton Command4 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Imprimir"
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   7440
      Style           =   1  'Graphical
      TabIndex        =   11
      Top             =   120
      Width           =   1935
   End
   Begin MSComCtl2.DTPicker DTPicker1 
      Height          =   450
      Left            =   120
      TabIndex        =   9
      Top             =   600
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   794
      _Version        =   393216
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Format          =   121503745
      CurrentDate     =   45567
   End
   Begin VB.OptionButton Option1 
      Caption         =   "Mensual"
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   2
      Left            =   9480
      TabIndex        =   8
      Top             =   600
      Visible         =   0   'False
      Width           =   1575
   End
   Begin VB.OptionButton Option1 
      Caption         =   "Diario "
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   1
      Left            =   5640
      TabIndex        =   7
      Top             =   600
      Width           =   1695
   End
   Begin VB.OptionButton Option1 
      Caption         =   "Detallado"
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   0
      Left            =   5640
      TabIndex        =   6
      Top             =   120
      Value           =   -1  'True
      Width           =   1695
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   450
      Left            =   120
      TabIndex        =   3
      Top             =   120
      Width           =   2745
   End
   Begin VB.CommandButton Command1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Buscar"
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   15.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   450
      Left            =   3960
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   600
      Width           =   1580
   End
   Begin VB.CommandButton Command2 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Aceptar"
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   15.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   0
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   4680
      Width           =   1935
   End
   Begin VB.CommandButton Command3 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Cancelar"
      BeginProperty Font 
         Name            =   "Impact"
         Size            =   15.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   3120
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   4680
      Width           =   1935
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Height          =   3495
      Index           =   0
      Left            =   0
      TabIndex        =   4
      Top             =   1080
      Width           =   5055
      _ExtentX        =   8916
      _ExtentY        =   6165
      _Version        =   393216
      AllowUpdate     =   0   'False
      HeadLines       =   1
      RowHeight       =   30
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Impact"
         Size            =   15.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   3082
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   3082
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         MarqueeStyle    =   3
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin RichTextLib.RichTextBox RichTextBox_Dis 
      Height          =   255
      Left            =   10440
      TabIndex        =   5
      Top             =   0
      Visible         =   0   'False
      Width           =   255
      _ExtentX        =   450
      _ExtentY        =   450
      _Version        =   393217
      Enabled         =   -1  'True
      TextRTF         =   $"Form2-2.frx":0DAF
   End
   Begin MSComCtl2.DTPicker DTPicker2 
      Height          =   450
      Left            =   2040
      TabIndex        =   10
      Top             =   600
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   794
      _Version        =   393216
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Impact"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Format          =   121503745
      CurrentDate     =   45567
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Sub GuardarFormatoGrid()
Dim I_G As Integer
Dim V_Star As Integer
RichTextBox_Dis.Text = ""
vTabla = DataGrid1(dbindEx).Tag
    For I_G = 0 To DataGrid1(dbindEx).Columns.Count - 1
        RichTextBox_Dis.Text = RichTextBox_Dis.Text & Format(DataGrid1(dbindEx).Columns(I_G).Width, "00000")
        RichTextBox_Dis.Text = RichTextBox_Dis.Text & "-"
    Next I_G

    RichTextBox_Dis.SaveFile App.Path & "\" & vTabla & ".TXT", 1
End Sub

Sub FormatoGrid()
On Error Resume Next
RichTextBox_Dis.LoadFile (App.Path & "\" & vTabla & ".TXT")
DataGrid1(dbindEx).Tag = vTabla
If Err.Number = 75 Then
    For I_G = 0 To DataGrid1(dbindEx).Columns.Count - 1
        RichTextBox_Dis.Text = RichTextBox_Dis.Text & Format(DataGrid1(dbindEx).Columns(I_G).Width, "00000")
        RichTextBox_Dis.Text = RichTextBox_Dis.Text & "-"
    Next I_G

    RichTextBox_Dis.SaveFile App.Path & "\" & vTabla & ".TXT", 1
Else
    For I_G = 0 To DataGrid1(dbindEx).Columns.Count - 1
        
            If I_G = 0 Then
                V_Star = 1
                DataGrid1(dbindEx).Columns(I_G).Width = Mid(RichTextBox_Dis.Text, V_Star, 5)
            Else
                V_Star = V_Star + 6
                DataGrid1(dbindEx).Columns(I_G).Width = Mid(RichTextBox_Dis.Text, V_Star, 5)
            End If
        
    Next I_G
End If
End Sub




Private Sub Command1_Click()
Dim vFiltroFecha As String
Dim vGrupo As String
Dim vFiltro As String
Dim vFiltroNBulto As String
If IsNumeric(Text2.Text) = True Then
    vFiltroNBulto = " and nbulto=" & Text2.Text & " "
Else
    vFiltroNBulto = ""
End If
vFiltroFecha = " where convert(varchar,fecha,112)>=" & Format(DTPicker1.Value, "YYYYMMDD") & " AND convert(varchar,fecha,112)<=" & Format(DTPicker2.Value, "YYYYMMDD")

If Len(Text1.Text) >= 1 And Combo1.Text = "CodBulto" Then
    If IsNumeric(Text1.Text) = True Then
        vFiltroFecha = ""
        vFiltro = " where codbulto=" & Text1.Text & "  "
    End If
End If
If Combo1.Text = "Cliente" Then
    vFiltro = " AND TIPOFAC+NPRESUPUESTO IN(SELECT TIPOFAC+NUMEROD FROM SAFACT WHERE DESCRIP LIKE '%" & Text1.Text & "%') "
End If
If Option1(0).Value = True Then
    V_Vista = "SELECT     CONVERT(datetime, CONVERT(varchar, FECHA, 112)) AS Fecha, (SELECT TOP 1 DESCRIP FROM SAFACT WHERE TIPOFAC+NUMEROD =_TABLE_DESPACHO.TIPOFAC+_TABLE_DESPACHO.NPRESUPUESTO) AS CLIENTE, REPLACE(REPLACE(REPLACE(REPLACE(TIPOFAC,'A','FAC'),'B','DEV'),'O','CAR'),'P','DES') AS TIPOFAC, NPRESUPUESTO AS NDOC, NroLinea, CODIGO,  MAX(DESCRIPCION) AS DESCRIPCION,  SUM(CANTIDAD) AS CANTIDAD,  NBULTO, ULTBULTO, CODBULTO FROM _TABLE_DESPACHO " & _
    vFiltroFecha & vFiltro & vFiltroNBulto & " GROUP BY CONVERT(datetime, CONVERT(varchar, FECHA, 112)), TIPOFAC, NPRESUPUESTO, NroLinea, CODIGO, NBULTO, ULTBULTO, CODBULTO  order by codbulto"
    vTabla = "REPORTE_EMPAQUE"
ElseIf Option1(1).Value = True Then
    V_Vista = "SELECT     CONVERT(datetime, CONVERT(varchar, FECHA, 112)) AS Fecha,  CODIGO, MAX(DESCRIPCION) AS DESCRIPCION, SUM(CANTIDAD) AS CANTIDAD  FROM _TABLE_DESPACHO " & _
    vFiltroFecha & vFiltro & vFiltroNBulto & " GROUP BY CONVERT(datetime, CONVERT(varchar, FECHA, 112)),  CODIGO  "
    vTabla = "REPORTE_EMPAQUE2"
ElseIf Option1(2).Value = True Then
    V_Vista = "SELECT     left(CONVERT(varchar, FECHA, 112),6) AS PERIODO, CODIGO, MAX(DESCRIPCION) AS DESCRIPCION, SUM(CANTIDAD) AS CANTIDAD  FROM _TABLE_DESPACHO " & _
    vFiltroFecha & vFiltro & vFiltroNBulto & " GROUP BY   LEFT(CONVERT(varchar, FECHA, 112),6) ,  CODIGO  "
    vTabla = "REPORTE_EMPAQUE3"
End If
ActualizarRs8
'MEN123 = InputBox("", "", V_Vista)
'''''''''''''''''formato
dbindEx = 0
Set DataGrid1(dbindEx).DataSource = rs8

FormatoGrid

'''''''''''''''''fin formato
End Sub


Private Sub Command10_Click()
        If rs8.EOF = False Then
            rs8.MoveNext
        End If
        If rs8.EOF = True Then
            rs8.MoveLast
        End If
End Sub

Private Sub Command2_Click()
If rs3.BOF = True Or rs3.EOF = True Then
Else
'    DataGrid1(0).SetFocus
'    vVendedorSelec = True

    Form2.Visible = False
End If
End Sub

Private Sub Command3_Click()

'vVendedorSelec = False
Form2.Visible = False
End Sub

Private Sub Command4_Click()
If Option1(0).Value = True Then
    If rs8.BOF = True And rs8.EOF = True Then
    Else
        RichTextBox1.Text = App.Path & "\RESUMEN.rpt@" & vbCrLf & "@BULTOS@"
        RichTextBox1.SaveFile App.Path & "\REPORTE.INI", 1
        RichTextBox1.Text = " {_TABLE_DESPACHO.CODBULTO} = " & rs8.Fields("CODBULTO").Value & " "
        RichTextBox1.SaveFile App.Path & "\FILTRO.INI", 1
        RichTextBox1.Text = "NO"
        RichTextBox1.SaveFile App.Path & "\IMPRIMIR_DIRECTO.INI", 1
        MEN123 = Shell(App.Path & "\REPORTE.EXE", vbNormalFocus)
    End If
End If
End Sub

Private Sub Command5_Click()
If Option1(0).Value = True Then
    If rs8.BOF = True Or rs8.EOF = True Then
    Else
        FrmAutorizar.Show 1
        If vAutorizar = True Then
            CN.Execute " update _TABLE_DESPACHO set nbulto=0, codbulto=null, ultbulto=null where  NPRESUPUESTO='" & rs8.Fields("NDOC").Value & "' and NroLinea=" & rs8.Fields("NROLINEA").Value & " and CODIGO='" & rs8.Fields("CODIGO").Value & "'"
            Command1 = True
        End If
    End If
End If
End Sub

Private Sub Command6_Click()
If Option1(0).Value = True Then
    If rs8.BOF = True And rs8.EOF = True Then
    Else
        RichTextBox1.Text = App.Path & "\ReporteDespacho.rpt@" & vbCrLf & "@BULTOS@"
        RichTextBox1.SaveFile App.Path & "\REPORTE.INI", 1
        RichTextBox1.Text = " {_TABLE_DESPACHO.FECHA} >= DateTime (" & Format(DTPicker1.Value, "YYYY, MM, DD") & ", 0, 0, 0) and {_TABLE_DESPACHO.FECHA} <= DateTime (" & Format(DTPicker2.Value, "YYYY, MM, DD") & ", 23, 59, 59)"
        RichTextBox1.SaveFile App.Path & "\FILTRO.INI", 1
        RichTextBox1.Text = "NO"
        RichTextBox1.SaveFile App.Path & "\IMPRIMIR_DIRECTO.INI", 1
        MEN123 = Shell(App.Path & "\REPORTE.EXE", vbNormalFocus)
    End If
End If
End Sub

Private Sub Command9_Click()
        If rs8.BOF = False Then
            rs8.MovePrevious
        End If
        If rs8.BOF = True Then
            rs8.MoveFirst
        End If
End Sub

Private Sub DataGrid1_ColResize(Index As Integer, ByVal ColIndex As Integer, Cancel As Integer)
dbindEx = Index
GuardarFormatoGrid
End Sub
Private Sub DataGrid1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
    Command2 = True
End If

End Sub

Private Sub Form_Activate()
Command1 = True
End Sub

Private Sub Form_Load()
DTPicker1.Value = "01/" & Format(Date, "MM/YYYY")
DTPicker2.Value = "01/" & Format(Date + 30, "MM/YYYY")
DTPicker2.Value = DTPicker2.Value - 1
End Sub

Private Sub Form_Resize()
If Form2.Height > 1200 Then
    DataGrid1(0).Height = Form2.Height - DataGrid1(0).Top - 1200
    DataGrid1(0).Width = Form2.Width - DataGrid1(0).Left - 200
    Command2.Top = DataGrid1(0).Top + DataGrid1(0).Height
    Command3.Top = Command2.Top
End If
End Sub

Private Sub Option1_Click(Index As Integer)
If Option1(0).Value = True Then
    Command4.Enabled = True
Else
    Command4.Enabled = False
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    KeyAscii = 0
    Command1 = True
End If
End Sub

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then
    Me.DataGrid1(0).SetFocus
End If
End Sub






Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then
Else
    KeyAscii = 0
End If
End Sub
