DÜZELTME

Katılım
1 Ağustos 2006
Mesajlar
179
Altın Üyelik Bitiş Tarihi
22-08-2024
Merhabalar sql de 2 tablom var 1 tabloyadan verileri çekiyorum 2 ci tabloya yazdırıyorum
ama söyle sorum var TRCODE göre ayırıp onun bilgilerini nasıl alabilirim

Ekli dosyayı görüntüle 232543

C:
    Sub add_order()



        Dim sql As String = ("Select * from LG_991_01_ORFLINE_TABLO")
        Dim cmd As New SqlCommand(sql, conn)
        Dim sa As New SqlDataAdapter(cmd)

        sa.Fill(ds)
        DataGridView2.DataSource = ds.Tables(0)


        Dim order = uapp.NewDataObject(UnityObjects.DataObjectType.doSalesOrderSlip)
        order.New()


        order.DataFields.FieldByName("NUMBER").Value = "~"
            order.DataFields.FieldByName("DATE").Value = "24.11.2021"
            order.DataFields.FieldByName("DOC_NUMBER").Value = "WEB"
            order.DataFields.FieldByName("AUXIL_CODE").Value = "WEB"
            order.DataFields.FieldByName("ARP_CODE").Value = CLIENTREF
            order.DataFields.FieldByName("ORDER_STATUS").Value = 4
            order.DataFields.FieldByName("CURRSEL_TOTAL").Value = 1

            Dim transactions_lines = order.DataFields.FieldByName("TRANSACTIONS").Lines



        For i = 0 To ds.Tables(0).Rows.Count - 1
            Dim CLIENTREF = Replace(ds.Tables(0).Rows(i).Item("CLIENTREF"), " ", "")
            Dim STOCKREF = Replace(ds.Tables(0).Rows(i).Item("STOCKREF"), " ", "")
            Dim PRICE = ds.Tables(0).Rows(i).Item("PRICE")

            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 = 1
            transactions_lines((transactions_lines.Count - 1)).FieldByName("PRICE").Value = PRICE
            transactions_lines((transactions_lines.Count - 1)).FieldByName("VAT_RATE").Value = 18
            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 = "24.11.2021 "
            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 = "24.11.2021"
            transactions_lines((transactions_lines.Count - 1)).FieldByName("ORG_QUANTITY").Value = 1
            transactions_lines((transactions_lines.Count - 1)).FieldByName("ORG_PRICE").Value = PRICE

            order.DataFields.FieldByName("AFFECT_RISK").Value = 0
            order.DataFields.FieldByName("DEDUCTIONPART1").Value = 2
            order.DataFields.FieldByName("DEDUCTIONPART2").Value = 3

            order.DataFields.FieldByName("AFFECT_RISK").Value = 0
            order.DataFields.FieldByName("DEDUCTIONPART1").Value = 2
            order.DataFields.FieldByName("DEDUCTIONPART2").Value = 3
        Next

        If (order.Post() = True) Then
            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 i = 0 To order.ValidateErrors.Count - 1
                    MsgBox("XML Error :(" + CStr(order.ValidateErrors.Item(i).ID) + ")-" + order.ValidateErrors.Item(i).Error)
                Next i
            End If
        End If



    End Sub
 

Haluk

Özel Üye
Katılım
7 Temmuz 2004
Mesajlar
12,406
Excel Vers. ve Dili
64 Bit 2010 - İngilizce
+
Google Sheets
+
JScript
Altın Üyelik Bitiş Tarihi
SQL sorgusunu aşağıdaki gibi birşey yapınca oluyor mu?

Tabii, TRCODE alanının nümerik olması gerekir....

C#:
"Select * from LG_991_01_ORFLINE_TABLO Where TRCODE = 88"
.
 
Katılım
1 Ağustos 2006
Mesajlar
179
Altın Üyelik Bitiş Tarihi
22-08-2024
evet oluyor bende söyle çözdüm ançak doğru bilemedim veriler doğru kayıt ediyor ançak sistemi zorlar mı bilmiyorum

Kod:
Sub add_order()



        Dim sql As String = ("Select * from LG_991_01_ORFLINE_TABLO")
        Dim cmd As New SqlCommand(sql, conn)
        Dim sa As New SqlDataAdapter(cmd)
        sa.Fill(ds)
        DataGridView2.DataSource = ds.Tables(0)


        Dim gs As New DataSet
        Dim sql2 As String = ("Select  TRCODE,CLIENTREF from LG_991_01_ORFLINE_TABLO GROUP BY  TRCODE,CLIENTREF")
        Dim cmd2 As New SqlCommand(sql2, conn)
        Dim ea As New SqlDataAdapter(cmd2)
        ea.Fill(gs)


        For ia = 0 To gs.Tables(0).Rows.Count - 1
            Dim order = uapp.NewDataObject(UnityObjects.DataObjectType.doSalesOrderSlip)
            order.New()


            Dim CLIENTREF2 = Replace(gs.Tables(0).Rows(ia).Item("CLIENTREF"), " ", "")

            order.DataFields.FieldByName("NUMBER").Value = "~"
            order.DataFields.FieldByName("DATE").Value = "24.11.2021"
            order.DataFields.FieldByName("DOC_NUMBER").Value = "WEB"
            order.DataFields.FieldByName("AUXIL_CODE").Value = "WEB"
            order.DataFields.FieldByName("ARP_CODE").Value = CLIENTREF2
            order.DataFields.FieldByName("ORDER_STATUS").Value = 4
            order.DataFields.FieldByName("CURRSEL_TOTAL").Value = 1


            Dim transactions_lines = order.DataFields.FieldByName("TRANSACTIONS").Lines

            For i = 0 To ds.Tables(0).Rows.Count - 1
                Dim CLIENTREF = Replace(ds.Tables(0).Rows(i).Item("CLIENTREF"), " ", "")
                If (CLIENTREF = CLIENTREF2) Then


                    Dim STOCKREF = Replace(ds.Tables(0).Rows(i).Item("STOCKREF"), " ", "")
                    Dim PRICE = ds.Tables(0).Rows(i).Item("PRICE")
                    Dim AMOUNT = ds.Tables(0).Rows(i).Item("AMOUNT")

                    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 = 18
                    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 = "24.11.2021 "
                    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 = "24.11.2021"
                    transactions_lines((transactions_lines.Count - 1)).FieldByName("ORG_QUANTITY").Value = 1
                    transactions_lines((transactions_lines.Count - 1)).FieldByName("ORG_PRICE").Value = PRICE

                    order.DataFields.FieldByName("AFFECT_RISK").Value = 0
                    order.DataFields.FieldByName("DEDUCTIONPART1").Value = 2
                    order.DataFields.FieldByName("DEDUCTIONPART2").Value = 3

                    order.DataFields.FieldByName("AFFECT_RISK").Value = 0
                    order.DataFields.FieldByName("DEDUCTIONPART1").Value = 2
                    order.DataFields.FieldByName("DEDUCTIONPART2").Value = 3

                End If

            Next

            If (order.Post() = True) Then
                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 i = 0 To order.ValidateErrors.Count - 1
                        MsgBox("XML Error :(" + CStr(order.ValidateErrors.Item(i).ID) + ")-" + order.ValidateErrors.Item(i).Error)
                    Next i
                End If



            End If

        Next

    End Sub
SQL sorgusunu aşağıdaki gibi birşey yapınca oluyor mu?

Tabii, TRCODE alanının nümerik olması gerekir....

C#:
"Select * from LG_991_01_ORFLINE_TABLO Where TRCODE = 88"
.
 
Üst