Android Question Error al grabar

caparicio

Member
Licensed User
Longtime User
java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteStatement android.database.sqlite.SQLiteDatabase.compileStatement(java.lang.String)' on a null object reference
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:78)
at prismatec.prismatec.koeventas.detallepedido._grabapedido(detallepedido.java:3772)
at prismatec.prismatec.koeventas.detallepedido._btngrabarpedido_click(detallepedido.java:557)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:5210)
at android.view.View$PerformClick.run(View.java:21294)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5530)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
 

caparicio

Member
Licensed User
Longtime User
Sub BtnGrabarPedido_Click

If lblTP.Text <> "0" Then

BtnGrabarPedido.Visible=False

ProgressDialogShow("Grabando pedido...")

DoEvents

DoEvents

GrabaPedido

Else

Msgbox("Pedido vacío","")

EndIf

EndSub
 
Upvote 0

caparicio

Member
Licensed User
Longtime User
Última fecha informada

7 minutos atrás

Informes de esta semana

1

Total de informes

1

Versión de la aplicación


  1. 491
Versión de Android


  1. Android 6.01
Dispositivo


  1. LG K10 LTE (m253)
 
Upvote 0

caparicio

Member
Licensed User
Longtime User
B4X:
Sub BtnGrabarPedido_Click
If lblTP.Text <> "0" Then
     BtnGrabarPedido.Visible=False
     ProgressDialogShow("Grabando pedido...")
     DoEvents
     DoEvents
     GrabaPedido
Else
     Msgbox("Pedido vacío","")
EndIf
EndSub
 
Upvote 0

caparicio

Member
Licensed User
Longtime User
B4X:
Private Sub GrabaPedido
Dim FechaEntregaMostrar As String = ""
If Starter.NroPedido<>"" Then
VolverLimite(Starter.ISALD)
EndIf
FechaHoraLocal =  DateTime.GetYear(DateTime.Now) & RightStr("00" & DateTime.GetMonth(DateTime.Now), 2) & _
RightStr("00" & DateTime.GetDayOfMonth(DateTime.Now), 2) & RightStr("00" & DateTime.GetHour(DateTime.Now), 2) & _
RightStr("00" & DateTime.GetMinute(DateTime.Now), 2) & RightStr("00" & DateTime.GetSecond(DateTime.Now), 2)
Dim Ahora As String = RightStr("00" & DateTime.GetHour(DateTime.Now), 2) & RightStr("00" & DateTime.GetMinute(DateTime.Now), 2) & _
    RightStr("00" & DateTime.GetSecond(DateTime.Now), 2)
Dim HoraCierre As String= Mid(Starter.Cierre, 1, 2) & Mid(Starter.Cierre, 4, 2) & Mid(Starter.Cierre, 7, 2)
If CDbl(Ahora) > CDbl(HoraCierre) Then
Msgbox("Horario de atención por este sistema es hasta las " & Starter.Cierre & ", el pedido será programado para la próxima entrega.", "")
EndIf
Dim arr(14) As String
arr = Starter.ListaECABECERA.Get(0)
    If CDbl(arr(5)) > 99999999 Then
        Msgbox("Pedido excede el máximo permitido. (99.999.999)", "")
Else
        If RevisaLimite(CDbl(arr(5)), Starter.ISALD) = True Then
Dim FechaLog As String =  DateTime.GetYear(DateTime.Now) & RightStr("00" & DateTime.GetMonth(DateTime.Now), 2) & _
RightStr("00" & DateTime.GetDayOfMonth(DateTime.Now), 2) & RightStr("00" & DateTime.GetHour(DateTime.Now), 2) & _
RightStr("00" & DateTime.GetMinute(DateTime.Now), 2) & RightStr("00" & DateTime.GetSecond(DateTime.Now), 2)
If Starter.NroPedido = "" Then
Dim rs As Cursor
rs = Starter.SQL1.ExecQuery("SELECT COALESCE(MAX(ECAPED), 0) AS ECAPED FROM ECABECERA WHERE RECLIE=" & Starter.Codigo & "")
If rs.RowCount > 0 Then
rs.Position = 0
Pedido = rs.GetString("ECAPED").Trim + 1
End If
rs.Close
Dim Values1 As List
Values1.Initialize
Values1.Clear
Values1.Add(Starter.VENCOD)
Values1.Add(Starter.Codigo)
Values1.Add(FechaHoraLocal)
Values1.Add(Pedido)
Values1.Add("1")
Values1.Add(FechaLog)
Starter.SQL3.ExecNonQuery2("INSERT INTO logpedidos VALUES (?, ?, ?, ?, ?, ?)", Values1)
Else
FechaHoraLocal = Starter.FechaPedido
Pedido = Starter.NroPedido
Starter.SQL1.ExecNonQuery("DELETE FROM ECABECERA WHERE ECAPED=" & Pedido & " AND ECAFEC='" & Starter.FechaPedido & "' AND RECLIE=" & Starter.Codigo)
Starter.SQL1.ExecNonQuery("DELETE FROM EDETALLE WHERE ECAPED=" & Pedido & " AND ECAFEC='" & Starter.FechaPedido & "' AND RECLIE=" & Starter.Codigo)
Starter.SQL1.ExecNonQuery("DELETE FROM EDCTOS WHERE ECAPED=" & Pedido & " AND ECAFEC='" & Starter.FechaPedido & "' AND RECLIE=" & Starter.Codigo)
Starter.SQL1.ExecNonQuery("DELETE FROM EDETBEN WHERE ECAPED=" & Pedido & " AND ECAFEC='" & Starter.FechaPedido & "' AND RECLIE=" & Starter.Codigo)
Dim Values2 As List
Values2.Initialize
Values2.Clear
Values2.Add(Starter.VENCOD)
Values2.Add(Starter.Codigo)
Values2.Add(Starter.FechaPedido)
Values2.Add(Pedido)
Values2.Add("2")
Values2.Add(FechaLog)
Starter.SQL3.ExecNonQuery2("INSERT INTO logpedidos VALUES (?, ?, ?, ?, ?, ?)", Values2)
EndIf
Dim Values3 As List
Values3.Initialize
Values3.Clear
Values3.Add(Starter.Codigo) 'RECLIE
Values3.Add(FechaHoraLocal) 'ECAFEC
Values3.Add(Pedido) 'ECAPED
Values3.Add(arr(3)) 'ECATNE
Values3.Add(arr(4)) 'ECATFL
Values3.Add(arr(5)) 'ECATBR
Values3.Add(arr(6)) 'ECATDE
Values3.Add(arr(7)) 'ECATIV
Values3.Add(arr(8)) 'ECATIA
Values3.Add(arr(9)) 'ECATIL
Values3.Add(arr(10)) 'ECATCI
Values3.Add(arr(11)) 'ECATIP1
Values3.Add(arr(12)) 'ECATIP2
Values3.Add("")'ECAFHD
Values3.Add("")'ECAFHR
Values3.Add("0")'ECANPE
Values3.Add("")'ECAFHE
Values3.Add("")'ECAFHF
Values3.Add(arr(13))'ECAFEP
If arr(13)<>"" Then
FechaEntregaMostrar = "Fecha de entrega pedido: " & Mid(arr(13), 7, 2) & "/" & Mid(arr(13), 5, 2) & "/" & Mid(arr(13), 1, 4)
Else
FechaEntregaMostrar = ""
EndIf
Values3.Add("")'ECAFRE
Values3.Add("X")'ECAEST
Values3.Add("")'ECAOBS
Values3.Add("")'ECAEVA
Values3.Add(Starter.Regimen)'ECAIDO
Starter.SQL1.ExecNonQuery2("INSERT INTO ECABECERA VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Values3)
For i = 0 To Starter.ListaEDETALLE.Size -1
Dim arr(27) As String
arr = Starter.ListaEDETALLE.Get(i)
Dim Values4 As List
Values4.Initialize
Values4.Clear
Values4.Add(Starter.Codigo) 'RECLIE
Values4.Add(FechaHoraLocal) 'ECAFEC
Values4.Add(Pedido) 'ECAPED
Values4.Add(arr(3)) 'EDEART
Values4.Add(arr(4)) 'EDEFEV
Values4.Add(arr(5)) 'EDECOR
Values4.Add(arr(6)) 'EDENAR
Values4.Add(arr(7)) 'EDECMO
Values4.Add(arr(8)) 'EDECAN
Values4.Add(arr(9)) 'EDECBO
Values4.Add(arr(10)) 'EDETIV
Values4.Add(arr(11)) 'EDETIA
Values4.Add(arr(12)) 'EDETIL
Values4.Add(arr(13)) 'EDETCI
Values4.Add(arr(14)) 'EDETNE
Values4.Add(arr(15)) 'EDETUN
Values4.Add(arr(16)) 'EDETDE
Values4.Add(arr(17)) 'EDETFL
Values4.Add(arr(18)) 'EDETBR
Values4.Add(arr(19)) 'EDEAD1
Values4.Add(arr(20)) 'EDEAD2
Values4.Add(arr(21)) 'AM01_ARTTAXCOD1
Values4.Add(arr(22)) 'AM01_ARTTAXCOD2
Values4.Add(arr(23)) 'AM01_ARTTAXCOD3
Values4.Add(arr(24)) 'AM01_ARTTAXCOD4
Values4.Add(arr(25)) 'AM01_ARTTAXCOD5
Values4.Add(arr(26)) 'AM01_NUMSUU
Starter.SQL1.ExecNonQuery2("INSERT INTO EDETALLE VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Values4)
Next
For i = 0 To Starter.ListaEDCTOS.Size -1
Dim arr(10) As String
arr = Starter.ListaEDCTOS.Get(i)
Dim Values5 As List
Values5.Initialize
Values5.Clear
Values5.Add(Starter.Codigo) 'RECLIE
Values5.Add(FechaHoraLocal) 'ECAFEC
Values5.Add(Pedido) 'ECAPED
Values5.Add(arr(3)) 'DCTART
Values5.Add(arr(4)) 'DCTFEV
Values5.Add(arr(5)) 'DCTCOR
Values5.Add(arr(6)) 'DCTTDE
Values5.Add(arr(7)) 'DCTPOR
Values5.Add(arr(8)) 'DCTVNE
Values5.Add(arr(9)) 'DCTVCA
Starter.SQL1.ExecNonQuery2("INSERT INTO EDCTOS VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Values5)
Next
For i = 0 To Starter.ListaEDETBEN.Size -1
Dim arr(8) As String
arr = Starter.ListaEDETBEN.Get(i)
Dim Values6 As List
Values6.Initialize
Values6.Clear
Values6.Add(Starter.Codigo) 'RECLIE
Values6.Add(FechaHoraLocal) 'ECAFEC
Values6.Add(Pedido) 'ECAPED
Values6.Add(arr(3)) 'BENCTP
Values6.Add(arr(4)) 'BENEAR
Values6.Add(arr(5)) 'BENECO
Values6.Add(arr(6)) 'BENEPO
Values6.Add(arr(7)) 'BENEVA
Try
Starter.SQL1.ExecNonQuery2("INSERT INTO EDETBEN VALUES (?, ?, ?, ?, ?, ?, ?, ?)", Values6)
Catch
Log(LastException)
EndTry
Next
Starter.SQL1.ExecNonQuery("Update ECABECERA Set ECAEST='Z' Where RECLIE=" & Starter.Codigo & " AND ECAFEC='" & FechaHoraLocal & "' AND ECAPED=" & Pedido & "")
Starter.SQL1.ExecNonQuery("Update Clientes Set Atendido='A' Where Codigo=" & Starter.Codigo & "")
If FechaEntregaMostrar<>"" Then
Msgbox(FechaEntregaMostrar, "")
EndIf
Try
Starter.Operacion = "I"
Starter.ListaPedido.Clear
If Starter.DeDonde = "Trazabilidad" Then
Activity.RemoveAllViews
Activity.Finish
StartActivity(Trazabilidad)
Else
If Starter.Regimen = "V" Then
Activity.RemoveAllViews
Activity.Finish
StartActivity(IngresoPedido)
Else
If Starter.Regimen = "Z" Then
Activity.RemoveAllViews
Activity.Finish
StartActivity(IngresoPedidoZ)
End If
End If
End If
Activity.Finish
Catch
Log(LastException)
EndTry
        End If
ProgressDialogHide
    End If
EndSub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…