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

  • all the data from custom list view + text want to insert to mysql table.jpg
    all the data from custom list view + text want to insert to mysql table.jpg
    250.6 KB · Views: 342
  • mysqltable SALESORDER.jpg
    mysqltable SALESORDER.jpg
    62.2 KB · Views: 341
  • showdatabase to customlisview.jpg
    showdatabase to customlisview.jpg
    80.7 KB · Views: 349
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
 
Upvote 0
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
 
Upvote 0
i have tried using
B4X:
Dim TD As TestData = clv1.GetValue(index)  '<---- This is row index... showing in customlistview index number
InsertOrder(txtnamatoko.text, DateTime.Date(now), kodetoko,txtnamatoko.text,txtnamatoko.text,TD.txtnama, TD.txtorder)

in clv there are many rows.. how to insert all of the rows that just has add by edit text ?
 

Attachments

  • all the data from custom list view + text want to insert to mysql table.jpg
    all the data from custom list view + text want to insert to mysql table.jpg
    250.6 KB · Views: 338
Upvote 0
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

  • import result.jpg
    import result.jpg
    53.9 KB · Views: 275
  • just the last record can be inserted to mysql.jpg
    just the last record can be inserted to mysql.jpg
    94.2 KB · Views: 292
Upvote 0
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

  • just the last record can be inserted to mysql.jpg
    just the last record can be inserted to mysql.jpg
    94.2 KB · Views: 246
  • import result.jpg
    import result.jpg
    53.9 KB · Views: 267
Upvote 0
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

  • solved oke.jpg
    solved oke.jpg
    105.2 KB · Views: 265
  • solved.jpg
    solved.jpg
    67 KB · Views: 266
Upvote 0
Top