تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
محتاج الكود بحث عن اخر فاتورة مبيعات (مستعجل يا اخواني)
#2
جرب هذه الطريقة
PHP كود :
Private Sub btnSearch_Click(sender As ObjectAs EventArgsHandles btnSearch.Click
        Dim connectionString 
As String "connection"
 
       Using connection As New SqlConnection(connectionString)
 
                    Dim query As String "SELECT TOP 10 * FROM Invoices WHERE 1=1"

 
           If Not String.IsNullOrEmpty(txtDate.TextThen
                query 
&= " AND InvoiceDate = @InvoiceDate"
 
           End If
 
           If Not String.IsNullOrEmpty(txtInvoiceNumber.TextThen
                query 
&= " AND InvoiceNumber = @InvoiceNumber"
 
           End If
 
           If Not String.IsNullOrEmpty(txtCustomerName.TextThen
                query 
&= " AND CustomerName LIKE @CustomerName"
 
           End If

 
           query &= " ORDER BY CreatedDate DESC"

 
           Using command As New SqlCommand(queryconnection)
 
                             If Not String.IsNullOrEmpty(txtDate.TextThen
                    command
.Parameters.AddWithValue("@InvoiceDate"txtDate.Text)
 
               End If
 
               If Not String.IsNullOrEmpty(txtInvoiceNumber.TextThen
                    command
.Parameters.AddWithValue("@InvoiceNumber"txtInvoiceNumber.Text)
 
               End If
 
               If Not String.IsNullOrEmpty(txtCustomerName.TextThen
                    command
.Parameters.AddWithValue("@CustomerName""%" txtCustomerName.Text "%")
 
               End If

 
               Dim adapter As New SqlDataAdapter(command)
 
               Dim table As New DataTable()
 
               adapter.Fill(table)
 
               dataGridViewResults.DataSource table
            End Using
        End Using
    End Sub 
[صورة مرفقة: images?q=tbn:ANd9GcT72OLJW7D1E5QW-HUeWeJ...TGoNeg2jnQ]
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
RE: محتاج الكود بحث عن اخر فاتورة مبيعات (مستعجل يا اخواني) - بواسطة تركي الحلواني - 25-07-24, 11:20 AM


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم