منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[VB.NET] ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : [VB.NET] ممكن المساعدة في اجراء بحث كومبوبكس وتيكست (/showthread.php?tid=49574)

الصفحات: 1 2 3


RE: ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - تركي الحلواني - 15-07-24

لو ترفق مثال ليتم التعديل عليه.


RE: ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - raedre22 - 16-07-24

(15-07-24, 06:28 PM)تركي الحلواني كتب : لو ترفق مثال ليتم التعديل عليه.

سوف يتم تجهيز وارفاق ملف العمل

تم ارسال المشروع على الخاص


RE: ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - Zuhare - 16-07-24

PHP كود :
Sub LoadRecords()
    Dim i As Integer = 0
    Dim total As Double 
= 0
    DataGridView1
.Rows.Clear()

    cn.Open()

        Dim query As String = "SELECT * FROM tblProduct AS p " &
                          "INNER JOIN tblGeneric AS g ON p.ProductGeneric = GenericID " &
                          "INNER JOIN tblBrand AS b ON p.ProductBrand = BrandID " &
                          "INNER JOIN tblFromulation AS f ON p.ProductFromulation = FromulationID " &
                          "INNER JOIN tblClassification AS c ON p.ProductClassification = ClassificationID " &
                          "INNER JOIN tblType AS t ON p.ProductType = TypeID " &
                          "WHERE ProductQuantity > 0 AND " & cboFilter.Text & " LIKE @SearchText"

    dim cm as New SqlCommand(query, cn)
    cm.Parameters.AddWithValue("@SearchText", "%" & txtSearch.Text & "%")

    dim dr as sqldatareader = cm.ExecuteReader()

         While dr.Read()
        i += 1
        total 
+= CInt(dr.Item("ProductQuantity").ToString())
        DataGridView1.Rows.Add(i, 
                               dr
.Item("ProductID").ToString(), 
                               dr
.Item("ProductBarcode").ToString(), 
                               dr
.Item("GenericName").ToString(), 
                               dr
.Item("BrandName").ToString(), 
                               dr
.Item("FromulationName").ToString(), 
                               dr
.Item("ClassificationName").ToString(), 
                               dr
.Item("TypeName").ToString(), 
                               dr
.Item("ProductQuantity").ToString(), 
                               dr
.Item("ProductBuyPrice").ToString(), 
                               dr
.Item("ProductSalePrice").ToString(), 
                               Format
(CDate(dr.Item("ProductDate").ToString()), "yyyy/MM"), 
                               dr
.Item("ProductReorder").ToString())
    End While

       dr
.Close()
    cm = Nothing
        cn
.Close()

      lblCount.Text = "عدد المنتجات: " & Format(CLng(DataGridView1.Rows.Count), "#,##0") & Space(10) & " كمية المنتجات: " & Format(total, "#,##0")
End Sub  



RE: ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - raedre22 - 16-07-24

(16-07-24, 03:23 AM)Zuhare كتب :
PHP كود :
Sub LoadRecords()
    Dim i As Integer = 0
    Dim total As Double 
= 0
    DataGridView1
.Rows.Clear()

    cn.Open()

        Dim query As String = "SELECT * FROM tblProduct AS p " &
                          "INNER JOIN tblGeneric AS g ON p.ProductGeneric = GenericID " &
                          "INNER JOIN tblBrand AS b ON p.ProductBrand = BrandID " &
                          "INNER JOIN tblFromulation AS f ON p.ProductFromulation = FromulationID " &
                          "INNER JOIN tblClassification AS c ON p.ProductClassification = ClassificationID " &
                          "INNER JOIN tblType AS t ON p.ProductType = TypeID " &
                          "WHERE ProductQuantity > 0 AND " & cboFilter.Text & " LIKE @SearchText"

    dim cm as New SqlCommand(query, cn)
    cm.Parameters.AddWithValue("@SearchText", "%" & txtSearch.Text & "%")

    dim dr as sqldatareader = cm.ExecuteReader()

         While dr.Read()
        i += 1
        total 
+= CInt(dr.Item("ProductQuantity").ToString())
        DataGridView1.Rows.Add(i, 
                               dr
.Item("ProductID").ToString(), 
                               dr
.Item("ProductBarcode").ToString(), 
                               dr
.Item("GenericName").ToString(), 
                               dr
.Item("BrandName").ToString(), 
                               dr
.Item("FromulationName").ToString(), 
                               dr
.Item("ClassificationName").ToString(), 
                               dr
.Item("TypeName").ToString(), 
                               dr
.Item("ProductQuantity").ToString(), 
                               dr
.Item("ProductBuyPrice").ToString(), 
                               dr
.Item("ProductSalePrice").ToString(), 
                               Format
(CDate(dr.Item("ProductDate").ToString()), "yyyy/MM"), 
                               dr
.Item("ProductReorder").ToString())
    End While

       dr
.Close()
    cm = Nothing
        cn
.Close()

      lblCount.Text = "عدد المنتجات: " & Format(CLng(DataGridView1.Rows.Count), "#,##0") & Space(10) & " كمية المنتجات: " & Format(total, "#,##0")
End Sub  

شكر جزيلا ولكن نفس الخطأ في Like


RE: ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - Zuhare - 17-07-24

PHP كود :
Sub LoadRecords()
    Dim i As Integer = 0
    Dim total As Double 
= 0
    DataGridView1
.Rows.Clear()

    cn.Open()

        Dim query As String = "SELECT * FROM tblProduct AS p " &
                          "INNER JOIN tblGeneric AS g ON p.ProductGeneric = GenericID " &
                          "INNER JOIN tblBrand AS b ON p.ProductBrand = BrandID " &
                          "INNER JOIN tblFromulation AS f ON p.ProductFromulation = FromulationID " &
                          "INNER JOIN tblClassification AS c ON p.ProductClassification = ClassificationID " &
                          "INNER JOIN tblType AS t ON p.ProductType = TypeID " &
                          "WHERE ProductQuantity > 0 AND " & cboFilter.Text & " LIKE '%'+@SearchText+'%'"

    dim cm as New SqlCommand(query, cn)
    cm.Parameters.AddWithValue("@SearchText",  txtSearch.Text )

    dim dr as sqldatareader = cm.ExecuteReader()

         While dr.Read()
        i += 1
        total 
+= CInt(dr.Item("ProductQuantity").ToString())
        DataGridView1.Rows.Add(i, 
                               dr
.Item("ProductID").ToString(), 
                               dr
.Item("ProductBarcode").ToString(), 
                               dr
.Item("GenericName").ToString(), 
                               dr
.Item("BrandName").ToString(), 
                               dr
.Item("FromulationName").ToString(), 
                               dr
.Item("ClassificationName").ToString(), 
                               dr
.Item("TypeName").ToString(), 
                               dr
.Item("ProductQuantity").ToString(), 
                               dr
.Item("ProductBuyPrice").ToString(), 
                               dr
.Item("ProductSalePrice").ToString(), 
                               Format
(CDate(dr.Item("ProductDate").ToString()), "yyyy/MM"), 
                               dr
.Item("ProductReorder").ToString())
    End While

       dr
.Close()
    cm = Nothing
        cn
.Close()

      lblCount.Text = "عدد المنتجات: " & Format(CLng(DataGridView1.Rows.Count), "#,##0") & Space(10) & " كمية المنتجات: " & Format(total, "#,##0")
End Sub  



RE: ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - raedre22 - 17-07-24

(17-07-24, 07:39 AM)Zuhare كتب :
PHP كود :
Sub LoadRecords()
    Dim i As Integer = 0
    Dim total As Double 
= 0
    DataGridView1
.Rows.Clear()

    cn.Open()

        Dim query As String = "SELECT * FROM tblProduct AS p " &
                          "INNER JOIN tblGeneric AS g ON p.ProductGeneric = GenericID " &
                          "INNER JOIN tblBrand AS b ON p.ProductBrand = BrandID " &
                          "INNER JOIN tblFromulation AS f ON p.ProductFromulation = FromulationID " &
                          "INNER JOIN tblClassification AS c ON p.ProductClassification = ClassificationID " &
                          "INNER JOIN tblType AS t ON p.ProductType = TypeID " &
                          "WHERE ProductQuantity > 0 AND " & cboFilter.Text & " LIKE '%'+@SearchText+'%'"

    dim cm as New SqlCommand(query, cn)
    cm.Parameters.AddWithValue("@SearchText",  txtSearch.Text )

    dim dr as sqldatareader = cm.ExecuteReader()

         While dr.Read()
        i += 1
        total 
+= CInt(dr.Item("ProductQuantity").ToString())
        DataGridView1.Rows.Add(i, 
                               dr
.Item("ProductID").ToString(), 
                               dr
.Item("ProductBarcode").ToString(), 
                               dr
.Item("GenericName").ToString(), 
                               dr
.Item("BrandName").ToString(), 
                               dr
.Item("FromulationName").ToString(), 
                               dr
.Item("ClassificationName").ToString(), 
                               dr
.Item("TypeName").ToString(), 
                               dr
.Item("ProductQuantity").ToString(), 
                               dr
.Item("ProductBuyPrice").ToString(), 
                               dr
.Item("ProductSalePrice").ToString(), 
                               Format
(CDate(dr.Item("ProductDate").ToString()), "yyyy/MM"), 
                               dr
.Item("ProductReorder").ToString())
    End While

       dr
.Close()
    cm = Nothing
        cn
.Close()

      lblCount.Text = "عدد المنتجات: " & Format(CLng(DataGridView1.Rows.Count), "#,##0") & Space(10) & " كمية المنتجات: " & Format(total, "#,##0")
End Sub  
 اعتذر اتعبتكم معي جزيتم خيرا من الله



RE: ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - Zuhare - 17-07-24

المشكله في محتوى cboFilter.Text فماذا يوجد بيها؟

المفروض يكون في cboFilter.Text اسم عمود صحيح بدون مسافات


RE: ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - raedre22 - 17-07-24

(17-07-24, 10:11 AM)Zuhare كتب : المشكله في محتوى cboFilter.Text فماذا يوجد بيها؟

المفروض يكون في cboFilter.Text اسم عمود صحيح بدون مسافات
cbofilter كومبوبوكس يحتوي على طريقة البحث





RE: ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - Zuhare - 17-07-24

لازم يكون اسم العمود موجود في مكان cboFilter.Text
PHP كود :
Sub LoadRecords()

dim filter as string=""

if cboFilter.Text="بالباركود" then
  filter
="tblProduct.barcode"
elseif cboFilter.Text="بالمنتج" then
  filter
="tblProduct.product"
elseif cboFilter.Text="بالشركة" then
  filter
="tblBrand.BrandID"
elseif cboFilter.Text="بالدولة" then
  filter
="tblProduct.country"
elseif cboFilter.Text="بالصنف" then
  filter
="tblClassification.ClassificationID"
elseif cboFilter.Text="بالنوع" then
  filter
="tblType.TypeID"
elseif cboFilter.Text="بالعدد" then
  filter
="tblProduct.dddddddd"
elseif cboFilter.Text="بسعر الشراء" then
  filter
="tblProduct.ssssssss"
elseif cboFilter.Text="بسعر البيع" then
  filter
="tblProduct.bbbbbb"
elseif cboFilter.Text="بالنفاذ" then
  filter
="tblProduct.nnnnnnn"
else
 
 exit sub
end 
if

    Dim i As Integer = 0
    Dim total As Double 
= 0
    DataGridView1
.Rows.Clear()

    cn.Open()

        Dim query As String = "SELECT * FROM tblProduct AS p " &
                          "INNER JOIN tblGeneric AS g ON p.ProductGeneric = GenericID " &
                          "INNER JOIN tblBrand AS b ON p.ProductBrand = BrandID " &
                          "INNER JOIN tblFromulation AS f ON p.ProductFromulation = FromulationID " &
                          "INNER JOIN tblClassification AS c ON p.ProductClassification = ClassificationID " &
                          "INNER JOIN tblType AS t ON p.ProductType = TypeID " &
                          "WHERE ProductQuantity > 0 AND " & filter & " LIKE '%'+@SearchText+'%'"

    dim cm as New SqlCommand(query, cn)
    cm.Parameters.AddWithValue("@SearchText",  txtSearch.Text )

    dim dr as sqldatareader = cm.ExecuteReader()

         While dr.Read()
        i += 1
        total 
+= CInt(dr.Item("ProductQuantity").ToString())
        DataGridView1.Rows.Add(i, 
                               dr
.Item("ProductID").ToString(), 
                               dr
.Item("ProductBarcode").ToString(), 
                               dr
.Item("GenericName").ToString(), 
                               dr
.Item("BrandName").ToString(), 
                               dr
.Item("FromulationName").ToString(), 
                               dr
.Item("ClassificationName").ToString(), 
                               dr
.Item("TypeName").ToString(), 
                               dr
.Item("ProductQuantity").ToString(), 
                               dr
.Item("ProductBuyPrice").ToString(), 
                               dr
.Item("ProductSalePrice").ToString(), 
                               Format
(CDate(dr.Item("ProductDate").ToString()), "yyyy/MM"), 
                               dr
.Item("ProductReorder").ToString())
    End While

       dr
.Close()
    cm = Nothing
        cn
.Close()

      lblCount.Text = "عدد المنتجات: " & Format(CLng(DataGridView1.Rows.Count), "#,##0") & Space(10) & " كمية المنتجات: " & Format(total, "#,##0")
End Sub  
وضعت متغير جديد اسمه filter وضعته بدل cboFilter.Tex في الاستعلام لكن راجع اسماء الاعمده ويكون يبدا باسم الجدول ثم نقطه ثم اسم العمود مثل tblBrand.ProductBrand


RE: ممكن المساعدة في اجراء بحث كومبوبكس وتيكست - تركي الحلواني - 18-07-24

كم اخبرك الاخ (Zuhare)
مع وجود بعض التعديل على الكود الخاص به
PHP كود :
Sub LoadRecords()

 
    Dim filter As String ""

 
    If cboFilter.Text "بالباركود" Then
         filter 
"p.ProductBarcode"
 
    ElseIf cboFilter.Text "بالمنتج" Then
         filter 
"g.GenericName"
 
    ElseIf cboFilter.Text "بالشركة" Then
         filter 
"b.BrandName"
 
    ElseIf cboFilter.Text "بالدولة" Then
         filter 
"f.FromulationName"
 
    ElseIf cboFilter.Text "بالصنف" Then
         filter 
"c.ClassificationName"
 
    ElseIf cboFilter.Text "بالنوع" Then
         filter 
"t.TypeName"
 
    ElseIf cboFilter.Text "بالعدد" Then
         filter 
"p.ProductQuantity"
 
    ElseIf cboFilter.Text "بسعر الشراء" Then
         filter 
"p.ProductBuyPrice"
 
    ElseIf cboFilter.Text "بسعر البيع" Then
         filter 
"p.ProductSalePrice"
 
    ElseIf cboFilter.Text "بالنفاذ" Then
         filter 
"p.ProductQuantity"
 
    Else
 
        Exit Sub
     End 
If

 
    Dim i As Integer 0
     Dim total 
As Double 0
     DataGridView1
.Rows.Clear()

 
    cn.Open()

 
    Dim query As String "SELECT * FROM tblProduct AS p " &
 
                      "INNER JOIN tblGeneric AS g ON p.ProductGeneric = GenericID " &
 
                      "INNER JOIN tblBrand AS b ON p.ProductBrand = BrandID " &
 
                      "INNER JOIN tblFromulation AS f ON p.ProductFromulation = FromulationID " &
 
                      "INNER JOIN tblClassification AS c ON p.ProductClassification = ClassificationID " &
 
                      "INNER JOIN tblType AS t ON p.ProductType = TypeID " &
 
                      "WHERE ProductQuantity > 0 AND " filter " LIKE '%'+@SearchText+'%'"

 
    Dim cm As New SqlCommand(querycn)
 
    cm.Parameters.AddWithValue("@SearchText"txtSearch.Text)

 
    Dim dr As SqlDataReader cm.ExecuteReader()

 
    While dr.Read()
 
        i += 1
         total 
+= CInt(dr.Item("ProductQuantity").ToString())
 
        DataGridView1.Rows.Add(i,
 
                           dr.Item("ProductID").ToString(),
 
                           dr.Item("ProductBarcode").ToString(),
 
                           dr.Item("GenericName").ToString(),
 
                           dr.Item("BrandName").ToString(),
 
                           dr.Item("FromulationName").ToString(),
 
                           dr.Item("ClassificationName").ToString(),
 
                           dr.Item("TypeName").ToString(),
 
                           dr.Item("ProductQuantity").ToString(),
 
                           dr.Item("ProductBuyPrice").ToString(),
 
                           dr.Item("ProductSalePrice").ToString(),
 
                           Format(CDate(dr.Item("ProductDate").ToString()), "yyyy/MM"),
 
                           dr.Item("ProductReorder").ToString())
 
    End While

 
    dr.Close()
 
    cm Nothing
     cn
.Close()

 
    lblCount.Text "عدد المنتجات: " Format(CLng(DataGridView1.Rows.Count), "#,##0") & Space(10) & " كمية المنتجات: " Format(total"#,##0")
 
End Sub