Merhaba vb ile bir form yapıyprum mysqlden veri çekiyorum
ikitane DataGridView var
DataGridView2 cektiğim veriyi
DataGridView3 mysql sorgusuyla döndürüyorum buraya kadar sorunum yap
butona tekrar yenileyince DataGridView2 de mysql sorgusu boş olunca DataGridView3 için boş oluyor
nasıl DataGridView3 veriyi temizleye bilirim.
ikitane DataGridView var
DataGridView2 cektiğim veriyi
DataGridView3 mysql sorgusuyla döndürüyorum buraya kadar sorunum yap
butona tekrar yenileyince DataGridView2 de mysql sorgusu boş olunca DataGridView3 için boş oluyor
nasıl DataGridView3 veriyi temizleye bilirim.
C#:
Sub add_order()
Dim connection As String = ConfigurationManager.ConnectionStrings("mysql").ConnectionString
Dim ds As New DataSet
Dim sa As New MySqlDataAdapter("SELECT * FROM order where aktarma =0 ", connection)
sa.Fill(ds)
DataGridView2.DataSource = ds.Tables(0)
DataGridView2.Refresh()
DataGridView3.Refresh()
For i = 0 To ds.Tables(0).Rows.Count - 1
Dim order = uapp.NewDataObject(UnityObjects.DataObjectType.doSalesOrderSlip)
order.New()
Dim order_id = Replace(ds.Tables(0).Rows(i).Item("order_id"), " ", "")
Dim CUSTEM = Replace(ds.Tables(0).Rows(i).Item("CUSTEM"), " ", "")
Dim currency_code = Replace(ds.Tables(0).Rows(i).Item("currency_code"), " ", "")
Dim date_added = (ds.Tables(0).Rows(i).Item("date_added"))
Dim gelen = order_id
Dim dt As DateTime = Convert.ToDateTime(date_added)
Dim format As String = "dd.MM.yyyy"
Dim TARIH As String = dt.ToString(format)
order.DataFields.FieldByName("NUMBER").Value = "~"
order.DataFields.FieldByName("DATE").Value = TARIH
order.DataFields.FieldByName("DOC_NUMBER").Value = "WEB"
order.DataFields.FieldByName("AUXIL_CODE").Value = "WEB"
order.DataFields.FieldByName("ARP_CODE").Value = CUSTEM
order.DataFields.FieldByName("ORDER_STATUS").Value = 1
order.DataFields.FieldByName("CURRSEL_TOTAL").Value = 2
order.DataFields.FieldByName("CURRSEL_DETAILS").Value = 2
order.DataFields.FieldByName("RC_RATE").Value = 1
order.DataFields.FieldByName("DATA_SITEID").Value = 1
Dim connection2 As String = ConfigurationManager.ConnectionStrings("mysql").ConnectionString
Dim gs As New DataSet
Dim ea As New MySqlDataAdapter("SELECT * FROM product where order_id = '" & gelen & "' ", connection2)
ea.Fill(gs)
DataGridView3.DataSource = gs.Tables(0).DefaultView
DataGridView3.Refresh()
Dim transactions_lines = order.DataFields.FieldByName("TRANSACTIONS").Lines
For ia = 0 To gs.Tables(0).Rows.Count - 1
Dim order_id2 = Replace(gs.Tables(0).Rows(ia).Item("order_id"), " ", "")
If (order_id = order_id2) Then
Dim STOCKREF = Replace(gs.Tables(0).Rows(ia).Item("model"), " ", "")
Dim PRICE = gs.Tables(0).Rows(ia).Item("price")
Dim AMOUNT = gs.Tables(0).Rows(ia).Item("quantity")
transactions_lines.AppendLine()
transactions_lines((0)).FieldByName("TYPE").Value = 0
transactions_lines((transactions_lines.Count - 1)).FieldByName("MASTER_CODE").Value = STOCKREF
transactions_lines((transactions_lines.Count - 1)).FieldByName("QUANTITY").Value = AMOUNT
transactions_lines((transactions_lines.Count - 1)).FieldByName("PRICE").Value = PRICE
transactions_lines((transactions_lines.Count - 1)).FieldByName("VAT_RATE").Value = ""
transactions_lines((transactions_lines.Count - 1)).FieldByName("UNIT_CODE").Value = "ADET"
transactions_lines((transactions_lines.Count - 1)).FieldByName("UNIT_CONV1").Value = 1
transactions_lines((transactions_lines.Count - 1)).FieldByName("UNIT_CONV2").Value = 1
transactions_lines((transactions_lines.Count - 1)).FieldByName("DUE_DATE").Value = TARIH
transactions_lines((transactions_lines.Count - 1)).FieldByName("MULTI_ADD_TAX").Value = 0
transactions_lines((transactions_lines.Count - 1)).FieldByName("EDT_CURR").Value = 1
transactions_lines((transactions_lines.Count - 1)).FieldByName("ORG_DUE_DATE").Value = TARIH
transactions_lines((transactions_lines.Count - 1)).FieldByName("ORG_QUANTITY").Value = 1
transactions_lines((transactions_lines.Count - 1)).FieldByName("ORG_PRICE").Value = PRICE
If (currency_code = "USD") Then
order.DataFields.FieldByName("CURR_TRANSACTIN").Value = 1
Else
order.DataFields.FieldByName("CURR_TRANSACTIN").Value = 20
End If
End If
Next
If (order.Post() = True) Then
Dim connection3 As MySqlConnection
connection3 = New MySqlConnection
connection3.ConnectionString = ConfigurationManager.ConnectionStrings("mysql").ConnectionString
connection3.Open()
Dim SQLCOMMANDSTRING As String = "UPDATE order SET aktarma='1' WHERE order_id='" & order_id & "' "
Dim SqlCommand As New MySqlCommand(SQLCOMMANDSTRING, connection3)
Dim Count As Integer
Count = SqlCommand.ExecuteNonQuery
connection3.Close()
' MsgBox("POST OK !")
End If
If order.ErrorCode <> 0 Then
MsgBox("DB Error:(" + CStr(order.ErrorCode) + ") - " + order.ErrorDesc)
Else
If order.ValidateErrors.Count > 0 Then
For ai = 0 To order.ValidateErrors.Count - 1
MsgBox("XML Error :(" + CStr(order.ValidateErrors.Item(i).ID) + ")-" + order.ValidateErrors.Item(ai).Error)
Next ai
End If
End If
Next
conn.Close()
End Sub
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
' Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
' connect()
' add_order()
'End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim timer = New Timer
timer.Interval = 60 * 1000
AddHandler timer.Tick, AddressOf timer_Tick
timer.Start()
connect()
add_order()
End Sub