package reparto_mazapa.keymon.lat;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.B4AClass;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.debug.*;

public class c_noventa extends B4AClass.ImplB4AClass implements BA.SubDelegator{
    private static java.util.HashMap<String, java.lang.reflect.Method> htSubs;
    private void innerInitialize(BA _ba) throws Exception {
        if (ba == null) {
            ba = new BA(_ba, this, htSubs, "reparto_mazapa.keymon.lat.c_noventa");
            if (htSubs == null) {
                ba.loadHtSubs(this.getClass());
                htSubs = ba.htSubs;
            }
            
        }
        if (BA.isShellModeRuntimeCheck(ba)) 
			   this.getClass().getMethod("_class_globals", reparto_mazapa.keymon.lat.c_noventa.class).invoke(this, new Object[] {null});
        else
            ba.raiseEvent2(null, true, "class_globals", false);
    }

 public anywheresoftware.b4a.keywords.Common __c = null;
public anywheresoftware.b4a.objects.B4XViewWrapper _root = null;
public anywheresoftware.b4a.objects.B4XViewWrapper.XUI _xui = null;
public anywheresoftware.b4a.gps.GPS _g = null;
public anywheresoftware.b4a.sql.SQL.CursorWrapper _c = null;
public String _comentario = "";
public anywheresoftware.b4a.objects.ButtonWrapper _cancela = null;
public anywheresoftware.b4a.objects.ButtonWrapper _guarda = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _r_1 = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _r_2 = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _r_3 = null;
public anywheresoftware.b4a.objects.EditTextWrapper _e_comm = null;
public String _motivo = "";
public String _cuenta = "";
public String _usuario = "";
public String _sdate = "";
public String _stime = "";
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _r_4 = null;
public anywheresoftware.b4a.objects.PanelWrapper _p_principal = null;
public anywheresoftware.b4a.sql.SQL.CursorWrapper _d = null;
public reparto_mazapa.keymon.lat.dbrequestmanager _reqmanager = null;
public b4a.example.dateutils _dateutils = null;
public reparto_mazapa.keymon.lat.main _main = null;
public reparto_mazapa.keymon.lat.appupdater _appupdater = null;
public reparto_mazapa.keymon.lat.tracker _tracker = null;
public reparto_mazapa.keymon.lat.starter _starter = null;
public reparto_mazapa.keymon.lat.subs _subs = null;
public reparto_mazapa.keymon.lat.firebasemessaging _firebasemessaging = null;
public reparto_mazapa.keymon.lat.foto _foto = null;
public reparto_mazapa.keymon.lat.mapa_cliente _mapa_cliente = null;
public reparto_mazapa.keymon.lat.mapa_rutas _mapa_rutas = null;
public reparto_mazapa.keymon.lat.newinst2 _newinst2 = null;
public reparto_mazapa.keymon.lat.b4xpages _b4xpages = null;
public reparto_mazapa.keymon.lat.b4xcollections _b4xcollections = null;
public reparto_mazapa.keymon.lat.httputils2service _httputils2service = null;
public reparto_mazapa.keymon.lat.xuiviewsutils _xuiviewsutils = null;
public String  _b4xpage_appear() throws Exception{
 //BA.debugLineNum = 38;BA.debugLine="Sub B4XPage_Appear";
 //BA.debugLineNum = 39;BA.debugLine="reqManager.Initialize(Me, B4XPages.MainPage.SERVE";
_reqmanager._initialize /*String*/ (ba,this,_b4xpages._mainpage /*reparto_mazapa.keymon.lat.b4xmainpage*/ (ba)._server /*String*/ );
 //BA.debugLineNum = 40;BA.debugLine="e_comm.Text=\"\"";
_e_comm.setText(BA.ObjectToCharSequence(""));
 //BA.debugLineNum = 41;BA.debugLine="r_1.Checked = False";
_r_1.setChecked(__c.False);
 //BA.debugLineNum = 42;BA.debugLine="r_2.Checked = False";
_r_2.setChecked(__c.False);
 //BA.debugLineNum = 43;BA.debugLine="r_3.Checked = False";
_r_3.setChecked(__c.False);
 //BA.debugLineNum = 44;BA.debugLine="r_4.Checked = False";
_r_4.setChecked(__c.False);
 //BA.debugLineNum = 45;BA.debugLine="End Sub";
return "";
}
public String  _b4xpage_created(anywheresoftware.b4a.objects.B4XViewWrapper _root1) throws Exception{
 //BA.debugLineNum = 29;BA.debugLine="Private Sub B4XPage_Created (Root1 As B4XView)";
 //BA.debugLineNum = 30;BA.debugLine="Root = Root1";
_root = _root1;
 //BA.debugLineNum = 32;BA.debugLine="Root.LoadLayout(\"no_venta\")";
_root.LoadLayout("no_venta",ba);
 //BA.debugLineNum = 33;BA.debugLine="reqManager.Initialize(Me, B4XPages.MainPage.SERVE";
_reqmanager._initialize /*String*/ (ba,this,_b4xpages._mainpage /*reparto_mazapa.keymon.lat.b4xmainpage*/ (ba)._server /*String*/ );
 //BA.debugLineNum = 34;BA.debugLine="End Sub";
return "";
}
public String  _cancela_click() throws Exception{
 //BA.debugLineNum = 52;BA.debugLine="Sub CANCELA_Click";
 //BA.debugLineNum = 53;BA.debugLine="B4XPages.ShowPage(\"Cliente\")";
_b4xpages._showpage /*String*/ (ba,"Cliente");
 //BA.debugLineNum = 54;BA.debugLine="End Sub";
return "";
}
public String  _class_globals() throws Exception{
 //BA.debugLineNum = 1;BA.debugLine="Sub Class_Globals";
 //BA.debugLineNum = 2;BA.debugLine="Private Root As B4XView 'ignore";
_root = new anywheresoftware.b4a.objects.B4XViewWrapper();
 //BA.debugLineNum = 3;BA.debugLine="Private xui As XUI 'ignore";
_xui = new anywheresoftware.b4a.objects.B4XViewWrapper.XUI();
 //BA.debugLineNum = 4;BA.debugLine="Dim g As GPS";
_g = new anywheresoftware.b4a.gps.GPS();
 //BA.debugLineNum = 5;BA.debugLine="Dim c As Cursor";
_c = new anywheresoftware.b4a.sql.SQL.CursorWrapper();
 //BA.debugLineNum = 6;BA.debugLine="Dim COMENTARIO As String";
_comentario = "";
 //BA.debugLineNum = 7;BA.debugLine="Dim CANCELA As Button";
_cancela = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 8;BA.debugLine="Dim GUARDA As Button";
_guarda = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 9;BA.debugLine="Dim r_1 As RadioButton";
_r_1 = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 10;BA.debugLine="Dim r_2 As RadioButton";
_r_2 = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 11;BA.debugLine="Dim r_3 As RadioButton";
_r_3 = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 12;BA.debugLine="Dim e_comm As EditText";
_e_comm = new anywheresoftware.b4a.objects.EditTextWrapper();
 //BA.debugLineNum = 13;BA.debugLine="Dim motivo As String";
_motivo = "";
 //BA.debugLineNum = 14;BA.debugLine="Dim cuenta As String";
_cuenta = "";
 //BA.debugLineNum = 15;BA.debugLine="Dim usuario As String";
_usuario = "";
 //BA.debugLineNum = 16;BA.debugLine="Dim sDate,sTime As String";
_sdate = "";
_stime = "";
 //BA.debugLineNum = 17;BA.debugLine="Dim r_4 As RadioButton";
_r_4 = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 18;BA.debugLine="Private p_principal As Panel";
_p_principal = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 19;BA.debugLine="Dim d As Cursor";
_d = new anywheresoftware.b4a.sql.SQL.CursorWrapper();
 //BA.debugLineNum = 20;BA.debugLine="Dim reqManager As DBRequestManager";
_reqmanager = new reparto_mazapa.keymon.lat.dbrequestmanager();
 //BA.debugLineNum = 21;BA.debugLine="End Sub";
return "";
}
public String  _gps_locationchanged(anywheresoftware.b4a.gps.LocationWrapper _location1) throws Exception{
 //BA.debugLineNum = 47;BA.debugLine="Sub GPS_LocationChanged (Location1 As Location)";
 //BA.debugLineNum = 50;BA.debugLine="End Sub";
return "";
}
public void  _guarda_click() throws Exception{
ResumableSub_GUARDA_Click rsub = new ResumableSub_GUARDA_Click(this);
rsub.resume(ba, null);
}
public static class ResumableSub_GUARDA_Click extends BA.ResumableSub {
public ResumableSub_GUARDA_Click(reparto_mazapa.keymon.lat.c_noventa parent) {
this.parent = parent;
}
reparto_mazapa.keymon.lat.c_noventa parent;
String _rutaactualizar = "";
anywheresoftware.b4a.sql.SQL.CursorWrapper _rut = null;
String _estecliente = "";
anywheresoftware.b4a.sql.SQL.CursorWrapper _rv = null;
int _i2 = 0;
int _i = 0;
String _ruta = "";
String _rutapre = "";
String _fechaprev = "";
int _resultado = 0;
anywheresoftware.b4a.sql.SQL.CursorWrapper _mandamapa = null;
int step36;
int limit36;
int step43;
int limit43;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
 //BA.debugLineNum = 57;BA.debugLine="If r_1.Checked = False And r_2.Checked = False An";
if (true) break;

case 1:
//if
this.state = 51;
if (parent._r_1.getChecked()==parent.__c.False && parent._r_2.getChecked()==parent.__c.False && parent._r_3.getChecked()==parent.__c.False && parent._r_4.getChecked()==parent.__c.False) { 
this.state = 3;
}else {
this.state = 5;
}if (true) break;

case 3:
//C
this.state = 51;
 //BA.debugLineNum = 58;BA.debugLine="MsgboxAsync(\"Selecciona un motivo de rechazo\",\"A";
parent.__c.MsgboxAsync(BA.ObjectToCharSequence("Selecciona un motivo de rechazo"),BA.ObjectToCharSequence("Atención"),ba);
 if (true) break;

case 5:
//C
this.state = 6;
 //BA.debugLineNum = 61;BA.debugLine="If r_1.Checked Then";
if (true) break;

case 6:
//if
this.state = 15;
if (parent._r_1.getChecked()) { 
this.state = 8;
}else if(parent._r_2.getChecked()) { 
this.state = 10;
}else if(parent._r_3.getChecked()) { 
this.state = 12;
}else {
this.state = 14;
}if (true) break;

case 8:
//C
this.state = 15;
 //BA.debugLineNum = 62;BA.debugLine="motivo = \"CERRADO\"";
parent._motivo = "CERRADO";
 if (true) break;

case 10:
//C
this.state = 15;
 //BA.debugLineNum = 64;BA.debugLine="motivo = \"NO PIDIO\"";
parent._motivo = "NO PIDIO";
 if (true) break;

case 12:
//C
this.state = 15;
 //BA.debugLineNum = 66;BA.debugLine="motivo = \"CANCELA\"";
parent._motivo = "CANCELA";
 if (true) break;

case 14:
//C
this.state = 15;
 //BA.debugLineNum = 68;BA.debugLine="motivo = \"NO ESTA EL ENCARGADO\"";
parent._motivo = "NO ESTA EL ENCARGADO";
 if (true) break;
;
 //BA.debugLineNum = 71;BA.debugLine="If motivo <> \"CERRADO\"  Or motivo = \"CERRADO\" Th";

case 15:
//if
this.state = 50;
if ((parent._motivo).equals("CERRADO") == false || (parent._motivo).equals("CERRADO")) { 
this.state = 17;
}else {
this.state = 49;
}if (true) break;

case 17:
//C
this.state = 18;
 //BA.debugLineNum = 72;BA.debugLine="DateTime.DateFormat = \"MM/dd/yyyy\"";
parent.__c.DateTime.setDateFormat("MM/dd/yyyy");
 //BA.debugLineNum = 73;BA.debugLine="DateTime.TimeFormat=\"HHmmss\"";
parent.__c.DateTime.setTimeFormat("HHmmss");
 //BA.debugLineNum = 74;BA.debugLine="sDate=DateTime.Date(DateTime.Now)";
parent._sdate = parent.__c.DateTime.Date(parent.__c.DateTime.getNow());
 //BA.debugLineNum = 75;BA.debugLine="sTime=DateTime.Time(DateTime.Now)";
parent._stime = parent.__c.DateTime.Time(parent.__c.DateTime.getNow());
 //BA.debugLineNum = 76;BA.debugLine="c=Starter.skmt.ExecQuery(\"select CUENTA from cu";
parent._c = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("select CUENTA from cuentaa")));
 //BA.debugLineNum = 77;BA.debugLine="c.Position = 0";
parent._c.setPosition((int) (0));
 //BA.debugLineNum = 78;BA.debugLine="cuenta = c.GetString(\"CUENTA\")";
parent._cuenta = parent._c.GetString("CUENTA");
 //BA.debugLineNum = 79;BA.debugLine="c=Starter.skmt.ExecQuery(\"select usuario from u";
parent._c = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("select usuario from usuarioa")));
 //BA.debugLineNum = 80;BA.debugLine="c.Position = 0";
parent._c.setPosition((int) (0));
 //BA.debugLineNum = 81;BA.debugLine="usuario = c.GetString(\"USUARIO\")";
parent._usuario = parent._c.GetString("USUARIO");
 //BA.debugLineNum = 82;BA.debugLine="c.Close";
parent._c.Close();
 //BA.debugLineNum = 83;BA.debugLine="Dim rutaactualizar As String";
_rutaactualizar = "";
 //BA.debugLineNum = 84;BA.debugLine="Dim rut As Cursor = Starter.skmt.ExecQuery(\"SEL";
_rut = new anywheresoftware.b4a.sql.SQL.CursorWrapper();
_rut = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("SELECT CAT_CL_RUTA FROM kmt_info WHERE CAT_CL_CODIGO IN (SELECT CUENTA FROM CUENTAA)")));
 //BA.debugLineNum = 85;BA.debugLine="If rut.RowCount > 0 Then";
if (true) break;

case 18:
//if
this.state = 21;
if (_rut.getRowCount()>0) { 
this.state = 20;
}if (true) break;

case 20:
//C
this.state = 21;
 //BA.debugLineNum = 86;BA.debugLine="rut.Position = 0";
_rut.setPosition((int) (0));
 //BA.debugLineNum = 87;BA.debugLine="rutaactualizar = rut.GetString(\"CAT_CL_RUTA\")";
_rutaactualizar = _rut.GetString("CAT_CL_RUTA");
 if (true) break;

case 21:
//C
this.state = 22;
;
 //BA.debugLineNum = 91;BA.debugLine="c=Starter.skmt.ExecQuery(\"select HVD_NUM_REGIST";
parent._c = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("select HVD_NUM_REGISTRO, HVD_CLIENTE, HVD_PRONOMBRE, HVD_CANT, HVD_COSTO_TOT, HVD_FECHA, HVD_PROID, CAT_GP_PRECIO from HIST_VENTAS2 join CAT_GUNAPROD on CAT_GP_ID = HVD_PROID WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_PRONOMBRE asc")));
 //BA.debugLineNum = 92;BA.debugLine="If c.RowCount > 0 Then 'Si  hay pedido en HIST_";
if (true) break;

case 22:
//if
this.state = 37;
if (parent._c.getRowCount()>0) { 
this.state = 24;
}if (true) break;

case 24:
//C
this.state = 25;
 //BA.debugLineNum = 95;BA.debugLine="Private esteCliente As String = Subs.traeClien";
_estecliente = parent._subs._traecliente /*String*/ (ba);
 //BA.debugLineNum = 96;BA.debugLine="Private rv As Cursor = Starter.skmt.ExecQuery(";
_rv = new anywheresoftware.b4a.sql.SQL.CursorWrapper();
_rv = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery(("select * from REPARTO where REP_CLIENTE = '"+parent.__c.SmartStringFormatter("",(Object)(_estecliente))+"' and REP_CLI_ORIG <> '"+parent.__c.SmartStringFormatter("",(Object)(_estecliente))+"' and REP_RECHAZO = 0"))));
 //BA.debugLineNum = 97;BA.debugLine="If rv.RowCount > 0 Then 'Si tenemos venta en e";
if (true) break;

case 25:
//if
this.state = 32;
if (_rv.getRowCount()>0) { 
this.state = 27;
}if (true) break;

case 27:
//C
this.state = 28;
 //BA.debugLineNum = 98;BA.debugLine="For i2=0 To rv.RowCount - 1";
if (true) break;

case 28:
//for
this.state = 31;
step36 = 1;
limit36 = (int) (_rv.getRowCount()-1);
_i2 = (int) (0) ;
this.state = 52;
if (true) break;

case 52:
//C
this.state = 31;
if ((step36 > 0 && _i2 <= limit36) || (step36 < 0 && _i2 >= limit36)) this.state = 30;
if (true) break;

case 53:
//C
this.state = 52;
_i2 = ((int)(0 + _i2 + step36)) ;
if (true) break;

case 30:
//C
this.state = 53;
 //BA.debugLineNum = 99;BA.debugLine="rv.Position = i2";
_rv.setPosition(_i2);
 //BA.debugLineNum = 100;BA.debugLine="Log($\"Actualizamos REPARTO - cliente=${rv.Ge";
parent.__c.LogImpl("316449580",("Actualizamos REPARTO - cliente="+parent.__c.SmartStringFormatter("",(Object)(_rv.GetString("REP_CLIENTE")))+", cliente orignal="+parent.__c.SmartStringFormatter("",(Object)(_rv.GetString("REP_CLI_ORIG")))+", le agregamos "+parent.__c.SmartStringFormatter("",(Object)(_rv.GetString("REP_CANT")))+""),0);
 //BA.debugLineNum = 101;BA.debugLine="Starter.skmt.ExecNonQuery($\"update REPARTO s";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery(("update REPARTO set REP_CANT = REP_CANT + "+parent.__c.SmartStringFormatter("",(Object)(_rv.GetString("REP_CANT")))+" where REP_RECHAZO = '1' and REP_CLIENTE = '"+parent.__c.SmartStringFormatter("",(Object)(_rv.GetString("REP_CLI_ORIG")))+"' and REP_CLI_ORIG = '"+parent.__c.SmartStringFormatter("",(Object)(_rv.GetString("REP_CLI_ORIG")))+"'"));
 if (true) break;
if (true) break;

case 31:
//C
this.state = 32;
;
 if (true) break;

case 32:
//C
this.state = 33;
;
 //BA.debugLineNum = 105;BA.debugLine="Starter.skmt.ExecNonQuery(\"delete from reparto";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery("delete from reparto where REP_CLIENTE IN (Select CUENTA from cuentaa)");
 //BA.debugLineNum = 106;BA.debugLine="For i=0 To c.RowCount - 1 'Insertamos los prod";
if (true) break;

case 33:
//for
this.state = 36;
step43 = 1;
limit43 = (int) (parent._c.getRowCount()-1);
_i = (int) (0) ;
this.state = 54;
if (true) break;

case 54:
//C
this.state = 36;
if ((step43 > 0 && _i <= limit43) || (step43 < 0 && _i >= limit43)) this.state = 35;
if (true) break;

case 55:
//C
this.state = 54;
_i = ((int)(0 + _i + step43)) ;
if (true) break;

case 35:
//C
this.state = 55;
 //BA.debugLineNum = 107;BA.debugLine="c.Position=i";
parent._c.setPosition(_i);
 //BA.debugLineNum = 108;BA.debugLine="Log($\"REGISTRO= ${c.GetString(\"HVD_NUM_REGIST";
parent.__c.LogImpl("316449588",("REGISTRO= "+parent.__c.SmartStringFormatter("",(Object)(parent._c.GetString("HVD_NUM_REGISTRO")))+""),0);
 //BA.debugLineNum = 109;BA.debugLine="Starter.skmt.ExecNonQuery2(\"insert into repar";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT, REP_FECHA, REP_RECHAZO, REP_PRODID, REP_PRECIO, REP_PRODREGISTRO, REP_CLI_ORIG) VALUES (?,?,?,?,?,1,?,?,?,?) ",anywheresoftware.b4a.keywords.Common.ArrayToList(new String[]{parent._c.GetString("HVD_CLIENTE"),parent._c.GetString("HVD_PRONOMBRE"),parent._c.GetString("HVD_CANT"),parent._c.GetString("HVD_COSTO_TOT"),parent._c.GetString("HVD_FECHA"),parent._c.GetString("HVD_PROID"),parent._c.GetString("CAT_GP_PRECIO"),parent._c.GetString("HVD_NUM_REGISTRO"),parent._c.GetString("HVD_CLIENTE")}));
 //BA.debugLineNum = 110;BA.debugLine="Starter.skmt.ExecNonQuery2(\"insert into repar";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT, REP_FECHA, REP_RECHAZO, REP_PRODID, REP_PRECIO, REP_PRODREGISTRO, REP_CLI_ORIG) VALUES (?,?,?,?,?,0,?,?,?,?) ",anywheresoftware.b4a.keywords.Common.ArrayToList(new String[]{parent._c.GetString("HVD_CLIENTE"),parent._c.GetString("HVD_PRONOMBRE"),BA.NumberToString(0),parent._c.GetString("HVD_COSTO_TOT"),parent._c.GetString("HVD_FECHA"),parent._c.GetString("HVD_PROID"),parent._c.GetString("CAT_GP_PRECIO"),parent._c.GetString("HVD_NUM_REGISTRO"),parent._c.GetString("HVD_CLIENTE")}));
 //BA.debugLineNum = 111;BA.debugLine="Starter.skmt.ExecNonQuery2(\"update cat_gunapr";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_nombre = ?",anywheresoftware.b4a.keywords.Common.ArrayToList(new Object[]{(Object)(parent._c.GetString("HVD_CANT")),(Object)(parent._c.GetString("HVD_PRONOMBRE"))}));
 if (true) break;
if (true) break;

case 36:
//C
this.state = 37;
;
 if (true) break;

case 37:
//C
this.state = 38;
;
 //BA.debugLineNum = 116;BA.debugLine="Starter.skmt.ExecNonQuery2(\"INSERT INTO NOVENTA";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("INSERT INTO NOVENTA (NV_CLIENTE,NV_FECHA,NV_USER,NV_MOTIVO,NV_COMM,NV_LAT,NV_LON,NV_FOTO) VALUES(?,?,?,?,?,?,?,?) ",anywheresoftware.b4a.keywords.Common.ArrayToList(new Object[]{(Object)(parent._cuenta),(Object)(parent._sdate+parent._stime),(Object)(parent._usuario),(Object)(parent._motivo),(Object)(parent._e_comm.getText()),(Object)(parent._b4xpages._mainpage /*reparto_mazapa.keymon.lat.b4xmainpage*/ (ba)._lat_gps /*String*/ ),(Object)(parent._b4xpages._mainpage /*reparto_mazapa.keymon.lat.b4xmainpage*/ (ba)._lon_gps /*String*/ ),(Object)(_rutaactualizar)}));
 //BA.debugLineNum = 117;BA.debugLine="Starter.skmt.ExecNonQuery($\"UPDATE kmt_info set";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery(("UPDATE kmt_info set gestion = 3, HORAENT = '"+parent.__c.SmartStringFormatter("",(Object)(parent._sdate+" "+parent._stime))+"' where CAT_CL_CODIGO In (select cuenta from cuentaa) and CAT_CL_RUTA = '"+parent.__c.SmartStringFormatter("",(Object)(_rutaactualizar))+"'"));
 //BA.debugLineNum = 118;BA.debugLine="Starter.skmt.ExecNonQuery(\"update HIST_VENTAS S";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery("update HIST_VENTAS SET HVD_RECHAZO = 1, HVD_RECHAZOCANT = HVD_CANT, HVD_RECHAZOCANTC = CANTC, BCAJAS = 0 , CANTC = 0 WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)");
 //BA.debugLineNum = 119;BA.debugLine="Starter.skmt.ExecNonQuery($\"update HIST_VENTAS";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery(("update HIST_VENTAS set HVD_RECHAZO = 2,  HVD_RECHAZOCANT = HVD_RECHAZOCANT  WHERE HVD_PROID = HVD_CODPROMO and HVD_CLIENTE in (Select CUENTA from cuentaa)"));
 //BA.debugLineNum = 120;BA.debugLine="Starter.skmt.ExecNonQuery(\"DELETE FROM PEDIDO W";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery("DELETE FROM PEDIDO WHERE PE_CLIENTE IN (SELECT CUENTA FROM CUENTAA)");
 //BA.debugLineNum = 121;BA.debugLine="d = Starter.skmt.ExecQuery(\"SELECT RUTAA FROM R";
parent._d = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("SELECT RUTAA FROM RUTAA")));
 //BA.debugLineNum = 122;BA.debugLine="d.Position = 0";
parent._d.setPosition((int) (0));
 //BA.debugLineNum = 123;BA.debugLine="Dim ruta As String = d.GetString(\"RUTAA\")";
_ruta = parent._d.GetString("RUTAA");
 //BA.debugLineNum = 124;BA.debugLine="d.Close";
parent._d.Close();
 //BA.debugLineNum = 125;BA.debugLine="d = Starter.skmt.ExecQuery(\"SELECT CAT_CL_RUTA";
parent._d = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("SELECT CAT_CL_RUTA FROM kmt_info WHERE CAT_CL_CODIGO IN (SELECT CUENTA FROM CUENTAA)")));
 //BA.debugLineNum = 126;BA.debugLine="d.Position = 0";
parent._d.setPosition((int) (0));
 //BA.debugLineNum = 127;BA.debugLine="Dim rutapre As String = d.GetString(\"CAT_CL_RUT";
_rutapre = parent._d.GetString("CAT_CL_RUTA");
 //BA.debugLineNum = 128;BA.debugLine="d.Close";
parent._d.Close();
 //BA.debugLineNum = 129;BA.debugLine="d = Starter.skmt.ExecQuery(\"SELECT HVD_FECHA FR";
parent._d = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("SELECT HVD_FECHA FROM HIST_VENTAS WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)")));
 //BA.debugLineNum = 130;BA.debugLine="d.Position = 0";
parent._d.setPosition((int) (0));
 //BA.debugLineNum = 131;BA.debugLine="Dim fechaprev As String = Subs.traefECHAPREV";
_fechaprev = parent._subs._traefechaprev /*String*/ (ba);
 //BA.debugLineNum = 132;BA.debugLine="d.Close";
parent._d.Close();
 //BA.debugLineNum = 133;BA.debugLine="d = Starter.skmt.ExecQuery(\"SELECT CUENTA FROM";
parent._d = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("SELECT CUENTA FROM CUENTAA")));
 //BA.debugLineNum = 134;BA.debugLine="d.Position = 0";
parent._d.setPosition((int) (0));
 //BA.debugLineNum = 135;BA.debugLine="Starter.skmt.ExecNonQuery2(\"INSERT INTO REPARTO";
parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("INSERT INTO REPARTO_GEO (CLIENTE, USUARIO, FECHA_PUNTEO, LATITUD, LONGITUD, ALMACEN, RUTA_REPARTO, RUTA_PREV, FECHA_PREVENTA, MOTIVO, COMENTARIO,TIPO,ENVIO) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,0)",anywheresoftware.b4a.keywords.Common.ArrayToList(new String[]{parent._cuenta,parent._usuario,parent._sdate+" "+parent._stime,parent._b4xpages._mainpage /*reparto_mazapa.keymon.lat.b4xmainpage*/ (ba)._lat_gps /*String*/ ,parent._b4xpages._mainpage /*reparto_mazapa.keymon.lat.b4xmainpage*/ (ba)._lon_gps /*String*/ ,parent._b4xpages._mainpage /*reparto_mazapa.keymon.lat.b4xmainpage*/ (ba)._almacen /*String*/ ,_ruta,_rutapre,_fechaprev,parent._motivo,parent._e_comm.getText(),"NO ENTREGADO"}));
 //BA.debugLineNum = 137;BA.debugLine="Msgbox2Async(\"Pedido rechazado\",\"Atención\",\"Ok\"";
parent.__c.Msgbox2Async(BA.ObjectToCharSequence("Pedido rechazado"),BA.ObjectToCharSequence("Atención"),"Ok","","",parent.__c.LoadBitmap(parent.__c.File.getDirAssets(),"alert2.png"),ba,parent.__c.False);
 //BA.debugLineNum = 138;BA.debugLine="Wait For Msgbox_Result (resultado As Int)";
parent.__c.WaitFor("msgbox_result", ba, this, null);
this.state = 56;
return;
case 56:
//C
this.state = 38;
_resultado = (Integer) result[0];
;
 //BA.debugLineNum = 139;BA.debugLine="If resultado = DialogResponse.POSITIVE Then";
if (true) break;

case 38:
//if
this.state = 47;
if (_resultado==parent.__c.DialogResponse.POSITIVE) { 
this.state = 40;
}if (true) break;

case 40:
//C
this.state = 41;
 //BA.debugLineNum = 140;BA.debugLine="Dim mandamapa As Cursor = Starter.skmt.ExecQue";
_mandamapa = new anywheresoftware.b4a.sql.SQL.CursorWrapper();
_mandamapa = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(parent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("SELECT * FROM kmt_info WHERE gestion = 0 and CAT_CL_CODIGO <> 63403")));
 //BA.debugLineNum = 141;BA.debugLine="If mandamapa.RowCount > 0 Then";
if (true) break;

case 41:
//if
this.state = 46;
if (_mandamapa.getRowCount()>0) { 
this.state = 43;
}else if(_mandamapa.getRowCount()==0) { 
this.state = 45;
}if (true) break;

case 43:
//C
this.state = 46;
 //BA.debugLineNum = 142;BA.debugLine="StartActivity(MAPA_RUTAS)";
parent.__c.StartActivity(ba,(Object)(parent._mapa_rutas.getObject()));
 if (true) break;

case 45:
//C
this.state = 46;
 //BA.debugLineNum = 144;BA.debugLine="B4XPages.ShowPage(\"Principal\")";
parent._b4xpages._showpage /*String*/ (ba,"Principal");
 if (true) break;

case 46:
//C
this.state = 47;
;
 if (true) break;

case 47:
//C
this.state = 50;
;
 if (true) break;

case 49:
//C
this.state = 50;
 //BA.debugLineNum = 148;BA.debugLine="COMENTARIO = e_comm.Text";
parent._comentario = parent._e_comm.getText();
 if (true) break;

case 50:
//C
this.state = 51;
;
 if (true) break;

case 51:
//C
this.state = -1;
;
 //BA.debugLineNum = 153;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public void  _msgbox_result(int _resultado) throws Exception{
}
public Object  _initialize(anywheresoftware.b4a.BA _ba) throws Exception{
innerInitialize(_ba);
 //BA.debugLineNum = 24;BA.debugLine="Public Sub Initialize As Object";
 //BA.debugLineNum = 25;BA.debugLine="Return Me";
if (true) return this;
 //BA.debugLineNum = 26;BA.debugLine="End Sub";
return null;
}
public String  _jobdone(reparto_mazapa.keymon.lat.httpjob _job) throws Exception{
reparto_mazapa.keymon.lat.dbrequestmanager._dbresult _resultado = null;
String _cliente = "";
Object[] _records = null;
String _k = "";
 //BA.debugLineNum = 176;BA.debugLine="Sub JobDone(Job As HttpJob)";
 //BA.debugLineNum = 177;BA.debugLine="Log(Job.Success)";
__c.LogImpl("316580609",BA.ObjectToString(_job._success /*boolean*/ ),0);
 //BA.debugLineNum = 178;BA.debugLine="If Job.Success = False Then";
if (_job._success /*boolean*/ ==__c.False) { 
 }else {
 //BA.debugLineNum = 181;BA.debugLine="LogColor(\"JobDone: '\" & reqManager.HandleJob(Job";
__c.LogImpl("316580613","JobDone: '"+BA.ObjectToString(_reqmanager._handlejob /*reparto_mazapa.keymon.lat.dbrequestmanager._dbresult*/ (_job).Tag /*Object*/ )+"' - Registros: "+BA.NumberToString(_reqmanager._handlejob /*reparto_mazapa.keymon.lat.dbrequestmanager._dbresult*/ (_job).Rows /*anywheresoftware.b4a.objects.collections.List*/ .getSize()),__c.Colors.Green);
 //BA.debugLineNum = 182;BA.debugLine="If Job.JobName = \"DBRequest\" Then";
if ((_job._jobname /*String*/ ).equals("DBRequest")) { 
 //BA.debugLineNum = 183;BA.debugLine="Dim resultado As DBResult = reqManager.HandleJo";
_resultado = _reqmanager._handlejob /*reparto_mazapa.keymon.lat.dbrequestmanager._dbresult*/ (_job);
 //BA.debugLineNum = 184;BA.debugLine="If resultado.Tag.As(String).IndexOf(\"ins_REPART";
if ((BA.ObjectToString(_resultado.Tag /*Object*/ )).indexOf("ins_REPARTOPendientes_head_")>-1) { 
 //BA.debugLineNum = 185;BA.debugLine="Private cliente As String= resultado.Tag";
_cliente = BA.ObjectToString(_resultado.Tag /*Object*/ );
 //BA.debugLineNum = 186;BA.debugLine="cliente = cliente.SubString(cliente.IndexOf(\"_";
_cliente = _cliente.substring((int) (_cliente.indexOf("_")+24));
 //BA.debugLineNum = 187;BA.debugLine="Log($\"Cliente1:${cliente}\"$)";
__c.LogImpl("316580619",("Cliente1:"+__c.SmartStringFormatter("",(Object)(_cliente))+""),0);
 //BA.debugLineNum = 188;BA.debugLine="Starter.skmt.ExecNonQuery2(\"update REPARTO_GEO";
_starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("update REPARTO_GEO SET ENVIO = ? WHERE CLIENTE = ? AND ENVIO <> ?",anywheresoftware.b4a.keywords.Common.ArrayToList(new String[]{"1",_cliente,"1"}));
 //BA.debugLineNum = 189;BA.debugLine="For Each records() As Object In resultado.Rows";
{
final anywheresoftware.b4a.BA.IterableList group12 = _resultado.Rows /*anywheresoftware.b4a.objects.collections.List*/ ;
final int groupLen12 = group12.getSize()
;int index12 = 0;
;
for (; index12 < groupLen12;index12++){
_records = (Object[])(group12.Get(index12));
 //BA.debugLineNum = 190;BA.debugLine="For Each k As String In resultado.Columns.Key";
{
final anywheresoftware.b4a.BA.IterableList group13 = _resultado.Columns /*anywheresoftware.b4a.objects.collections.Map*/ .Keys();
final int groupLen13 = group13.getSize()
;int index13 = 0;
;
for (; index13 < groupLen13;index13++){
_k = BA.ObjectToString(group13.Get(index13));
 //BA.debugLineNum = 191;BA.debugLine="Log(resultado.Tag & \": \" & k & \": \" & record";
__c.LogImpl("316580623",BA.ObjectToString(_resultado.Tag /*Object*/ )+": "+_k+": "+BA.ObjectToString(_records[(int)(BA.ObjectToNumber(_resultado.Columns /*anywheresoftware.b4a.objects.collections.Map*/ .Get((Object)(_k))))]),0);
 }
};
 }
};
 };
 };
 //BA.debugLineNum = 196;BA.debugLine="Job.Release";
_job._release /*String*/ ();
 };
 //BA.debugLineNum = 199;BA.debugLine="End Sub";
return "";
}
public String  _mandapendientesreparto() throws Exception{
int _i = 0;
reparto_mazapa.keymon.lat.dbrequestmanager._dbcommand _cmd = null;
 //BA.debugLineNum = 156;BA.debugLine="Sub mandaPendientesreparto";
 //BA.debugLineNum = 157;BA.debugLine="c=Starter.skmt.ExecQuery(\"SELECT  CLIENTE, USUARI";
_c = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(_starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("SELECT  CLIENTE, USUARIO, FECHA_PUNTEO, LATITUD, LONGITUD, ALMACEN, RUTA_REPARTO, RUTA_PREV, FECHA_PREVENTA, MOTIVO, COMENTARIO,TIPO FROM REPARTO_GEO where ENVIO <> 1")));
 //BA.debugLineNum = 158;BA.debugLine="Log($\"REPARTO_Cliente PENDIENTE: ${c.RowCount}\"$)";
__c.LogImpl("316515074",("REPARTO_Cliente PENDIENTE: "+__c.SmartStringFormatter("",(Object)(_c.getRowCount()))+""),0);
 //BA.debugLineNum = 159;BA.debugLine="If c.RowCount>0 Then";
if (_c.getRowCount()>0) { 
 //BA.debugLineNum = 160;BA.debugLine="For i=0 To c.RowCount -1";
{
final int step4 = 1;
final int limit4 = (int) (_c.getRowCount()-1);
_i = (int) (0) ;
for (;_i <= limit4 ;_i = _i + step4 ) {
 //BA.debugLineNum = 161;BA.debugLine="c.Position=i";
_c.setPosition(_i);
 //BA.debugLineNum = 163;BA.debugLine="Dim cmd As DBCommand";
_cmd = new reparto_mazapa.keymon.lat.dbrequestmanager._dbcommand();
 //BA.debugLineNum = 164;BA.debugLine="cmd.Initialize";
_cmd.Initialize();
 //BA.debugLineNum = 165;BA.debugLine="cmd.Name = \"insert_REPARTO_MAZAPA\"";
_cmd.Name /*String*/  = "insert_REPARTO_MAZAPA";
 //BA.debugLineNum = 166;BA.debugLine="cmd.Parameters = Array As Object(c.GetString(\"C";
_cmd.Parameters /*Object[]*/  = new Object[]{(Object)(_c.GetString("CLIENTE")),(Object)(_c.GetString("USUARIO")),(Object)(_c.GetString("FECHA_PUNTEO")),(Object)(_c.GetString("LATITUD")),(Object)(_c.GetString("LONGITUD")),(Object)(_c.GetString("ALMACEN")),(Object)(_c.GetString("RUTA_REPARTO")),(Object)(_c.GetString("RUTA_PREV")),(Object)(_c.GetString("FECHA_PREVENTA")),(Object)(_c.GetString("MOTIVO")),(Object)(_c.GetString("COMENTARIO")),(Object)(_c.GetString("TIPO"))};
 //BA.debugLineNum = 167;BA.debugLine="reqManager.ExecuteCommand(cmd , $\"ins_REPARTOPe";
_reqmanager._executecommand /*String*/ (_cmd,(Object)(("ins_REPARTOPendientes_head_"+__c.SmartStringFormatter("",(Object)(_c.GetString("CLIENTE")))+"")));
 }
};
 };
 //BA.debugLineNum = 171;BA.debugLine="c.Close";
_c.Close();
 //BA.debugLineNum = 172;BA.debugLine="End Sub";
return "";
}
public Object callSub(String sub, Object sender, Object[] args) throws Exception {
BA.senderHolder.set(sender);
if (BA.fastSubCompare(sub, "B4XPAGE_CREATED"))
	return _b4xpage_created((anywheresoftware.b4a.objects.B4XViewWrapper) args[0]);
if (BA.fastSubCompare(sub, "GPS_LOCATIONCHANGED"))
	return _gps_locationchanged((anywheresoftware.b4a.gps.LocationWrapper) args[0]);
if (BA.fastSubCompare(sub, "JOBDONE"))
	return _jobdone((reparto_mazapa.keymon.lat.httpjob) args[0]);
return BA.SubDelegator.SubNotFound;
}
}
