Spanish Agregar fila B4XTable (Solucionado)

benji

Active Member
Licensed User
Longtime User
Buenas...
quiero agregar una fila a un B4XTable, y no lo logro... cargo el primero, y cuando quiero agregar el segundo, o no lo agrega, o sobreescribo el primero, pero en ningun caso se agrega al listado.
este es el codigo que tengo, que me falta?

Insert b4xtable:
If txtDestino.Text.Length = 15 Then
            AuxCentroOrigen = txtUbi.Text.SubString2(0,3)
            AuxAlmacenOrigen = txtUbi.Text.SubString2(4,7)
            AuxCentroDestino = txtDestino.Text.SubString2(0,3)
            AuxAlmacenDestino = txtDestino.Text.SubString2(4,7)
            If AuxCentroOrigen = AuxCentroDestino Then
                If AuxAlmacenOrigen = AuxAlmacenDestino Then
                    i = 0
                    If CargaTabla = False Then
                        Dim headers As List
                        headers.Initialize 'the list is only used to skip the headers row
                        Dim Data As List
                        Data.Initialize
                        Dim row(5) As Object
                        row(0) = txtUbi.Text
                        row(1) = AuxMaterial
                        row(2) = txtCantidad.Text
                        row(3) = AuxLote
                        row(4) = txtDestino.Text

                        'Some of the values are Null. We need to convert them to empty strings:
                        If row(2) = Null Then row(2) = ""
                        'row(3) = rs.GetString("Address")
                        Data.Add(row)
                        CargaTabla = True
                        B4XTable1.SetData(Data)
                        B4XTable1.ClearDataView
                        B4XTable1.Refresh
                    Else
                        B4XTable1.sql1.ExecNonQuery2("INSERT INTO data VALUES(?,?,?,?,?)", Array As Object(txtUbi.Text,AuxMaterial,txtCantidad.Text,AuxLote,txtDestino.Text))
                        'B4XTable1.SQL1.ExecNonQuery2("UPDATE data SET c8 = ? WHERE c9 = ?", Array As String(5,AuxIdDetalle))
                    End If
                Else
                    Msgbox("Almacen Destino NO puede ser distinto de Origen","WMS")
                End If
            Else
                Msgbox("Centro Destino NO puede ser distinto a Origen","WMS")
            End If
        Else
            Msgbox("Error en la Ubicacion Destino","WMS")   
        End If

de antemano, muchas gracias.
 

benji

Active Member
Licensed User
Longtime User
Solucionado, me faltaba agregar
B4XTable1.ClearDataView
B4XTable1.Refresh

después del insert.... y después de varios cabezazos jajaja...
 

roerGarcia

Active Member
Licensed User
Longtime User
Era lo que te iba a señalar desde
Checa este codigo:
Private Sub ShowDialog(Item As Map, RowId As Long)
    Wait For (PrefDialog.ShowDialog(Item, "OK", "CANCEL")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Dim params As List
        params.Initialize
        params.AddAll(Array(Item.Get("Type"), Item.Get("Name"), Item.Get("Birth Date"), Item.Get("Sex"))) 'keys based on the template json file
        If RowId = 0 Then 'new row
            B4XTable1.sql1.ExecNonQuery2($"INSERT INTO data VALUES("", ?, ?, ?, ?)"$, params)
            B4XTable1.ClearDataView
        Else
            params.Add(RowId)
            'first column is c0. We skip it as this is the "edit" column
            B4XTable1.sql1.ExecNonQuery2("UPDATE data SET c1 = ?, c2 = ?, c3 = ?, c4 = ? WHERE rowid = ?", params)
            B4XTable1.Refresh
        End If
    End If
End Sub

Viene de https://www.b4x.com/android/forum/threads/b4x-cross-platform-editable-b4xtable-form-example.104766/
 
Top