Android Question How to Insert any rows from XcustomListView to mysql table

Dear All, please helm me for this case..
I have already displaying data from MySQL table into xcustomlistview panel,
next on the Xcustomlistview will be added data (the number of order items) and will be inserted in to the other MySQL table (table name "salesorder")
please help me... :)
 

Attachments

Sub carinama(Nama As String) ' This The first Source that show table in custom list view
Dim req As DBRequestManager=CreateRequest
Dim cmd As DBCommand=CreateCommand("getbarangnamalengkap", Array(spngroup.SelectedItem, Nama&"%"))
Wait for (req.ExecuteQuery(cmd,0,Null)) JobDone(j As HttpJob)
If j.Success Then
clv1.Clear
req.HandleJobAsync(j,"req")
wait for (req) req_result(res As DBResult)
req.PrintTable(res)
Log(res.Columns)

For Each row() As Object In res.Rows
Dim TD As TestData
TD.Initialize
TD.txtnama= row(2) & " " & ":" & " "& row(8)
TD.txtorder= ""
Dim Pnl As B4XView = XUI.CreatePanel(Null)
Pnl.Color = XUI.Color_Gray
Pnl.SetLayoutAnimated(0, 0, 0, clv1.AsView.Width, 50dip)
clv1.Add(Pnl,TD)
Next
If Status="OB" Then
Else
getGroup
End If
Else
Log("ERROR: " &j.ErrorMessage)
End If
j.Release
End Sub

Sub InsertOrder(id_sales As Int, nosalesorder As Int, kodepelanggan As String, namapelanggan As String, kodebarang As String, namabarang As String, hargabarang As Double, jumlahbarang As Int) ' This for Insert To Table Mysql
Dim req As DBRequestManager=CreateRequest
Dim cmd As DBCommand=CreateCommand("insertorder", Array(id_sales,nosalesorder,kodepelanggan,namapelanggan,kodebarang,namabarang,hargabarang,jumlahbarang))
Wait for (req.ExecuteQuery(cmd,0,Null)) JobDone(j As HttpJob)
If j.Success Then
ToastMessageShow("Orderan sudah dikirim.... !", False)
End If
j.Release
End Sub

Sub btnorder_Click
InsertOrder(.......... ???? ) ' Where I can get the all the data that shown in panel xcustomlist view ???
End sub
 
B4X:
Sub carinama(Nama As String) ' This The first Source that show table in custom list view
Dim req As DBRequestManager=CreateRequest
Dim cmd As DBCommand=CreateCommand("getbarangnamalengkap", Array(spngroup.SelectedItem, Nama&"%"))
Wait for (req.ExecuteQuery(cmd,0,Null)) JobDone(j As HttpJob)
If j.Success Then
clv1.Clear
req.HandleJobAsync(j,"req")
wait for (req) req_result(res As DBResult)
req.PrintTable(res)
Log(res.Columns)

For Each row() As Object In res.Rows
Dim TD As TestData
TD.Initialize
TD.txtnama= row(2) & " " & ":" & " "& row(8)
TD.txtorder= ""
Dim Pnl As B4XView = XUI.CreatePanel(Null)
Pnl.Color = XUI.Color_Gray
Pnl.SetLayoutAnimated(0, 0, 0, clv1.AsView.Width, 50dip)
clv1.Add(Pnl,TD)
Next
If Status="OB" Then
Else
getGroup
End If
Else
Log("ERROR: " &j.ErrorMessage)
End If
j.Release
End Sub

Sub InsertOrder(id_sales As Int, nosalesorder As Int, kodepelanggan As String, namapelanggan As String, kodebarang As String, namabarang As String, hargabarang As Double, jumlahbarang As Int) ' This for Insert To Table Mysql
Dim req As DBRequestManager=CreateRequest
Dim cmd As DBCommand=CreateCommand("insertorder", Array(id_sales,nosalesorder,kodepelanggan,namapelanggan,kodebarang,namabarang,hargabarang,jumlahbarang))
Wait for (req.ExecuteQuery(cmd,0,Null)) JobDone(j As HttpJob)
If j.Success Then
ToastMessageShow("Orderan sudah dikirim.... !", False)
End If
j.Release
End Sub

Sub btnorder_Click
InsertOrder(.......... ???? ) ' Where I can get the all the data that shown in panel xcustomlist view ???
End sub
 
i have tried using this :
But jutst the last can be inserted...
please help ...
B4X:
Sub btnorder_Click
    ceknosalesorder
        Dim now As Long=DateTime.Now
        DateTime.DateFormat= "yyyy-MM-dd"
        
    If txtnosales.Text ="" Then
        For i = 0 To clv1.Size - 1
            Dim TD As TestData=clv1.GetValue(i)
            TD.txtorder =txtorder.Text
            Log(TD)
            InsertOrder("1000000", DateTime.Date(now), txtkodetoko.Text, txtnamatoko.Text, TD.txtnamasaja, TD.txtorder)
        Next
        ToastMessageShow("Orderan sudah dikirim.... !", False)
    Else

        For i = 0 To clv1.Size - 1
            Dim TD As TestData=clv1.GetValue(i)
            TD.txtorder =txtorder.Text
            Log(TD)
            InsertOrder(txtnosales.Text, DateTime.Date(now), txtkodetoko.Text, txtnamatoko.Text, TD.txtnamasaja, TD.txtorder)
        Next        
        ToastMessageShow("Orderan sudah dikirim.... !", False)
    End If
    txtnosales.Text=""
End Sub
 

Attachments

B4X:
Sub InsertOrder(nosalesorder As String, tglso As String, kodepelanggan As String, namapelanggan As String, namabarang As String, jumlahbarang As String)

    Dim cmd As DBCommand=CreateCommand("insertpesanan", Array(nosalesorder, tglso,kodepelanggan,namapelanggan,namabarang,jumlahbarang))
    Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd),Null)
    Wait for (j) jobDone(j As HttpJob)
    ProgressDialogShow(" Mohon Tunggu... ")
    ProgressDialogHide
    j.Release
End Sub
 

Sub btnorder_Click
    ceknosalesorder
        Dim now As Long=DateTime.Now
        DateTime.DateFormat= "yyyy-MM-dd"
        
    If txtnosales.Text ="" Then
        For i = 0 To clv1.Size - 1
            Dim TD As TestData=clv1.GetValue(i)
            TD.txtorder =txtorder.Text ' I use this to Insert value but just the last text that can be inserted to database, just " 7 " for all the list
            Log(TD)
            InsertOrder("1000000", DateTime.Date(now), txtkodetoko.Text, txtnamatoko.Text, TD.txtnamasaja, TD.txtorder)
        Next
        ToastMessageShow("Orderan sudah dikirim.... !", False)
    Else

        For i = 0 To clv1.Size - 1
            Dim TD As TestData=clv1.GetValue(i)
            TD.txtorder =txtorder.Text
            Log(TD)
            InsertOrder(txtnosales.Text, DateTime.Date(now), txtkodetoko.Text, txtnamatoko.Text, TD.txtnamasaja, TD.txtorder)
        Next        
        ToastMessageShow("Orderan sudah dikirim.... !", False)
    End If
    txtnosales.Text=""
End Sub

Sub Button1_Click
    Activity.LoadLayout("mainlayout")
    kodetoko= txtuser.Text
    txtkodetoko.Text=kodetoko
    Button1.Visible=False
    Button2.Visible=False
    getGroup
    getnamapln
    Status="LG"
End Sub
Sub Button2_Click
    Activity.LoadLayout("ceknota")
    Button1.Visible=False
    Button2.Visible=False
    getlistnota
End Sub
 

Attachments

I got it sir..... problem solved ;)
thankx you in advanced
B4X:
Sub btnorder_Click
         ceknosalesorder
        Sleep(500)
        Dim now As Long=DateTime.Now
        DateTime.DateFormat= "yyyy-MM-dd"
        For i = 0 To Clv1.Size - 1
            Dim TD As TestData = Clv1.GetValue(i)
            Dim pnl As B4XView = Clv1.GetPanel(i)
            pnl.IsInitialized
            Dim txtorder As B4XView = Clv1.GetPanel(i).GetView(1)
            If txtorder.Text.Length>0 Then
            TD.txtorder= txtorder.Text
            Log(TD)
            InsertOrder(nosalesordernew, DateTime.Date(now), txtkodetoko.Text, txtnamatoko.Text, TD.txtnamasaja, TD.txtorder)
            End If
        Next
        ToastMessageShow("Orderan sudah dikirim.... !", False)
End Sub
 

Attachments

Top