تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] ممكن المساعدة في اجراء بحث كومبوبكس وتيكست
#21
(17-07-24, 11:53 PM)Zuhare كتب : لازم يكون اسم العمود موجود في مكان 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

احسنت لم اجرب لحد الان لكن يشهد الله اني هذه الفكرة لدي من الامس واليوم اريد تطبيقها
جزاك الله خير وافضل الجزاء

(18-07-24, 10:43 AM)تركي الحلواني كتب : كم اخبرك الاخ (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 

بكم البركة انتم اساذة ومنكم نتعلم
جزيل الشكر والامتنان
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  ممكن ايضاح اكثر لـ continu for justforit 6 314 05-11-25, 12:10 AM
آخر رد: justforit
  [VB.NET] اذا ممكن مشروع ادارة مدرسة بدر إشتية 4 8,531 08-02-25, 02:05 AM
آخر رد: الورد2
  ارجو تعديل الكود جلب البيانات عن طريق اجراء مخزن - مرفق مثال new_programer 0 619 05-02-25, 01:51 AM
آخر رد: new_programer
  ممكن اعرف معنى مفهومي HLD ,LLD bassant 0 312 30-01-25, 02:07 PM
آخر رد: bassant
  [سؤال] اجراء المسح الضوئي وتصوير المستندات من خلال المستعرض ابوعبدالملك 3 359 24-01-25, 06:37 AM
آخر رد: ابوعبدالملك
  شيء غريب ممكن تفسير justforit 2 356 03-12-24, 11:44 PM
آخر رد: justforit
Exclamation [VB.NET] ممكن كود تشغيل ملف صوت MP3 الورد الصناعي 10 910 20-10-24, 03:08 PM
آخر رد: salamandal
Exclamation [VB.NET] ممكن عمل كود لحفظ المكتوب داخل اداة TextBox الورد الصناعي 9 783 17-10-24, 11:43 PM
آخر رد: salamandal
  ممكن طريقة عمل الصورة بشكل دائري بوحمد 3 484 14-10-24, 04:01 PM
آخر رد: بوحمد
  السلام عليكم ممكن كود بحث فى برنامج مصمم بالفيجوال بيسك وقاعدة بيانات اكسس خالد كامل1 1 457 08-10-24, 02:37 PM
آخر رد: salamandal

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


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