VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form FrmCambiarFecDoc 
   Caption         =   "Cambiar Fecha de Factura"
   ClientHeight    =   2385
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4905
   LinkTopic       =   "Form1"
   ScaleHeight     =   2385
   ScaleWidth      =   4905
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton CmdBuscar 
      Caption         =   "..."
      Default         =   -1  'True
      BeginProperty Font 
         Name            =   "Arial Black"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4380
      TabIndex        =   10
      Top             =   360
      Width           =   375
   End
   Begin VB.TextBox TxtHora 
      BeginProperty DataFormat 
         Type            =   1
         Format          =   "hh:mm:ss AMPM"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   10250
         SubFormatType   =   4
      EndProperty
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   360
      Left            =   3540
      TabIndex        =   8
      Top             =   955
      Width           =   1215
   End
   Begin MSComCtl2.DTPicker DTP1 
      Height          =   375
      Left            =   2100
      TabIndex        =   7
      Top             =   960
      Width           =   1455
      _ExtentX        =   2566
      _ExtentY        =   661
      _Version        =   393216
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Format          =   22806529
      CurrentDate     =   39563
   End
   Begin VB.TextBox Txt_Num 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1920
      TabIndex        =   2
      Top             =   360
      Width           =   2415
   End
   Begin VB.CommandButton Cmd_Aceptar 
      Caption         =   "Aceptar"
      Height          =   375
      Left            =   540
      TabIndex        =   1
      Top             =   1860
      Width           =   1935
   End
   Begin VB.CommandButton Cmd_salir 
      Caption         =   "Cancelar"
      Height          =   375
      Left            =   2700
      TabIndex        =   0
      Top             =   1860
      Width           =   1935
   End
   Begin MSComCtl2.DTPicker DTP2 
      Height          =   375
      Left            =   2100
      TabIndex        =   9
      Top             =   1380
      Width           =   1455
      _ExtentX        =   2566
      _ExtentY        =   661
      _Version        =   393216
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Format          =   22806529
      CurrentDate     =   39563
   End
   Begin VB.Label Label5 
      Caption         =   "NO FUNCION!!!"
      Height          =   315
      Left            =   3660
      TabIndex        =   11
      Top             =   1440
      Width           =   1215
   End
   Begin VB.Label Label4 
      Caption         =   "Fecha Proceso:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   6
      Top             =   1440
      Width           =   2055
   End
   Begin VB.Line Line1 
      X1              =   0
      X2              =   5340
      Y1              =   840
      Y2              =   840
   End
   Begin VB.Label Label1 
      Caption         =   "Número Factura:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   5
      Top             =   420
      Width           =   1815
   End
   Begin VB.Label Label2 
      Caption         =   "Fecha Documento:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   4
      Top             =   1020
      Width           =   2055
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      Caption         =   "Nota: Revisar antes y después de un cambio de Fecha."
      ForeColor       =   &H000000C0&
      Height          =   255
      Left            =   0
      TabIndex        =   3
      Top             =   0
      Width           =   4575
   End
End
Attribute VB_Name = "FrmCambiarFecDoc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Cmd_Aceptar_Click()
On Error GoTo trataerror
    Dim cmd As ADODB.Command
    Dim strsql As String
    Dim con As ADODB.Connection
    Dim rs1 As ADODB.Recordset
     If IsNumeric(Txt_Num.Text) And Len(Txt_Num.Text) > 8 And IsDate(TxtHora.Text) Then
        '-------------------------------------------------------------
        strsql = "SELECT * FROM OP_SALES (NOLOCK) WHERE DOCTYPEID = '01' AND SITEID = '76' AND NBRDOCUMENT=" & Val(Txt_Num.Text) & ""
        Set rs1 = New ADODB.Recordset
        rs1.CursorLocation = adUseClient
        
        Set con = New ADODB.Connection
        con.ConnectionString = "FILEDSN=conexionsies"
        con.Open
        rs1.Open strsql, con, adOpenDynamic, adLockBatchOptimistic
        
        If rs1.RecordCount = 0 Or rs1.EOF Then
            MsgBox "Número de Factura No Existe, por favor verificar.", vbInformation, "Nro no Existe"
            Exit Sub
        End If
        '-------------------------------------------------------------
        Fecha1 = Format(DTP1, "yyyymmdd") & " " & Format(TxtHora.Text, "hh:mm:ss")
        Fecha2 = Format(DTP2, "yyyymmdd")
        strsql = "UPDATE OP_SALES SET DATEDOC= '" & Fecha2 & "' , DATEPROCESALES= '" & Fecha2 & "' WHERE DOCTYPEID = '01' AND SITEID = '76' AND NBRDOCUMENT=" & Val(Txt_Num.Text) & ""
        Set cmd = New ADODB.Command
        
        cmd.CommandText = strsql
        cmd.ActiveConnection = "FILEDSN=conexionsies"
        cmd.Execute
        
        MsgBox "Número de factura modificado, por favor verificar.", vbInformation, "Nro Modificado"
     Else
        MsgBox "Número ingresado es incorrecto", vbExclamation, "Número incorrecto"
     End If
     
Exit Sub
    
trataerror:
    If Not cmd Is Nothing Then
        Set cmd = Nothing
    End If
    If Not rs1 Is Nothing Then
        Set rs1 = Nothing
    End If
    MsgBox "No se pudo cambiar las fechas.", vbExclamation, "Error en Actualización"

End Sub

Private Sub CmdBuscar_Click()
    'Num = Txt_Num.Text
On Error GoTo trataerror
    Dim cmd As ADODB.Command
    Dim strsql As String
    Dim con As ADODB.Connection
    Dim rs1 As ADODB.Recordset

     If IsNumeric(Txt_Num.Text) And Len(Txt_Num.Text) > 8 Then
        '-------------------------------------------------------------
        strsql = "SELECT DATEDOC,DATEPROCESALES FROM OP_SALES (NOLOCK) WHERE DOCTYPEID = '01' AND SITEID = '76' AND NBRDOCUMENT=" & Val(Txt_Num.Text) & ""
        Set rs1 = New ADODB.Recordset
        rs1.CursorLocation = adUseClient
        
        Set con = New ADODB.Connection
        con.ConnectionString = "FILEDSN=conexionsies"
        con.Open
        rs1.Open strsql, con, adOpenDynamic, adLockBatchOptimistic
        
        If rs1.RecordCount = 0 Or rs1.EOF Then
            MsgBox "Número de Factura No Existe, por favor verificar.", vbInformation, "Nro no Existe"
            Exit Sub
        Else
            DTP1 = rs1.Fields("DATEDOC")
            TxtHora.Text = Format(rs1.Fields("DATEDOC"), "hh:mm:ss")
            DTP2 = rs1.Fields("DATEPROCESALES")
        End If
        '-------------------------------------------------------------
        
     Else
        MsgBox "Número ingresado es incorrecto", vbExclamation, "Número incorrecto"
     End If
     
Exit Sub
    
trataerror:
    If Not rs1 Is Nothing Then
        Set rs1 = Nothing
    End If
    MsgBox "Error inesperado en la busqueda del número.", vbExclamation, "Error en Busqueda"
'--------------------------------
End Sub

Private Sub cmd_salir_Click()
    Unload Me
End Sub

Public Sub salir_formulario()
    Salir
End Sub

Private Sub Salir()
    Unload Me
End Sub

