تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
كود البحث
#1
السلام عليكم ورحمة الله وبركاته 

الأخوة الأعزاء محتاج مساعدة منكم والسؤال كالتالي : - في عملية البحث أريد أن أبحث عن : أسعار المنتج برقم المنتج 

يوجد لدي فورم به : 

كود :
txtitemid.text
txtwholesaleone.Text
       txtcustomerone.Text
       txtsaleone.Text
       txtwholesaletwo.Text
       txtcustomertwo.Text
       txtsaletwo.Text
       txtwholesalethird.Text
       txtcustomerthird.Text
       txtsalethird.Text

ويوجد عندي كلاس إسمه : DatabaseManager يوجد به التالي : 

كود :
Imports System.Data.SqlClient
Imports System.Configuration
Public Class DatabaseManager
   Private _connection As SqlConnection
   Private _connectionString As String

   Public ReadOnly Property Connection() As SqlConnection
       Get
           If _connection Is Nothing Then _connection = New SqlConnection(_connectionString)
           Return _connection
       End Get
   End Property

   Public Sub New()
       Me._connectionString = ConfigurationManager.ConnectionStrings("connSQLServer").ConnectionString
   End Sub

   Public Sub New(ByVal ConnectionString As String)
       Me._connectionString = _connectionString
   End Sub

   Public Sub close()
       If _
           Not _connection Is Nothing AndAlso _
           _connection.State = ConnectionState.Open Then _
               _connection.Close()
   End Sub

   Public Function fillTable(ByRef cmd As SqlCommand, ByRef dt As DataTable) As Integer
       Dim retval As Integer = -1
       dt = New DataTable
       cmd.CommandType = CommandType.StoredProcedure
       cmd.Connection = Me.Connection
       Dim da As New SqlDataAdapter(cmd)
       da.Fill(dt)

       If (Not dt Is Nothing) Then retval = dt.Rows.Count
       Return retval
   End Function

   Public Function executeReader(ByRef cmd As SqlCommand, ByRef dr As SqlDataReader) As Integer
       cmd.CommandType = CommandType.StoredProcedure
       Return exeReader(cmd, dr)
   End Function

   Public Function executeReader(ByVal sql As String, ByRef dr As SqlDataReader) As Integer
       Dim cmd As New SqlCommand(sql)
       cmd.CommandType = CommandType.Text
       cmd.Connection = Me.Connection
       Dim retval As Integer = executeReader(cmd, dr)
       Return retval
   End Function

   Private Function exeReader(ByRef cmd As SqlCommand, ByRef dr As SqlDataReader) As Integer
       Dim retval As Integer = -1
       cmd.Connection = Me.Connection
       Try
           If cmd.CommandType = CommandType.StoredProcedure Then
               Dim pr As New SqlParameter("@retval", SqlDbType.Int)
               pr.Direction = ParameterDirection.ReturnValue
               cmd.Parameters.Add(pr)
           End If
           If cmd.Connection.State = ConnectionState.Closed Then cmd.Connection.Open()
           dr = cmd.ExecuteReader()

           If cmd.CommandType = CommandType.StoredProcedure Then retval = cmd.Parameters("@retval").Value
       Catch ex As Exception
           Throw New Exception(ex.Message)
       Finally
           Me.close()
       End Try

       Return retval
   End Function

   Public Function executeNonQuery(ByRef cmd As SqlCommand) As Integer
       cmd.CommandType = CommandType.StoredProcedure
       Return exeNonQuery(cmd)
   End Function

تم عمل استورد بروسيجر كالتالي : - 

كود :
ALTER PROCEDURE [dbo].[Get_Prices_Item_By_ID]

   @ItemID int

    
as

begin

Select ItemID,FirstUnitWholeSalePrice,FirstUnitShopperPrice,FirstUnitDemotionsPrice,FirstUnitPriceDefult,SecondUnitWholeSalePrice,SecondUnitShopperPrice,SecondUnitDemotionsPrice,SecondUnitPriceDefult,ThirdUnitWholeSalePrice,ThirdUnitShopperPrice,ThirdUnitDemotionsPrice,ThirdUnitPriceDefult,DefultPrice from ItemsPricesTbl Where ItemID=@ItemID
RETURN
End


وكلاس الداتا لير فيه : 

كود :
Friend Function Get_Prices_Item_By_ID(ByRef dr As SqlDataReader, ByVal ItemID As Integer)
           Dim cmd As New SqlCommand("Get_Prices_Item_By_ID")
           cmd.Parameters.Add("@ItemID", SqlDbType.Int).Value = CType(ItemID, Integer)

           Dim retval As Integer = dm.executeReader(cmd, dr)
           Return retval
       End Function

والبزنز لاير فيه : 

كود :
       Public Function Get_Prices_Item_By_ID(ByVal ItemID As Integer)
           p.Get_Prices_Item_By_ID(dr, ItemID)
           Return dr
       End Function

ما هو الكود الذي الذي سوف أضعه في زر البحث ؟؟؟

وشكــراً
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
كود البحث - بواسطة khalid475 - 04-05-17, 06:00 PM
RE: كود البحث - بواسطة khalid475 - 05-05-17, 09:04 AM
RE: كود البحث - بواسطة khalid475 - 05-05-17, 07:15 PM
RE: كود البحث - بواسطة سعود - 05-05-17, 09:05 PM
RE: كود البحث - بواسطة khalid475 - 05-05-17, 09:12 PM
RE: كود البحث - بواسطة Abdulaziz Hazazi - 06-05-17, 05:12 AM
RE: كود البحث - بواسطة khalid475 - 06-05-17, 08:48 AM
RE: كود البحث - بواسطة khalid475 - 06-05-17, 09:34 PM
RE: كود البحث - بواسطة mansoor - 06-05-17, 09:51 PM
RE: كود البحث - بواسطة khalid475 - 07-05-17, 05:37 PM
RE: كود البحث - بواسطة ابو ليلى - 07-05-17, 10:40 PM
RE: كود البحث - بواسطة khalid475 - 08-05-17, 06:45 PM
RE: كود البحث - بواسطة khalid475 - 09-05-17, 05:20 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [VB.NET] استفسار بخصوص البحث في RichTextBox SerialPort dubai.eig 2 667 18-06-25, 11:09 AM
آخر رد: dubai.eig
Rainbow [كود] البحث تلقائياً عند التبديل بين الـ RadioButton محمد مسافر 8 716 04-10-24, 02:33 AM
آخر رد: Taha Okla
Rainbow [كود] البحث وتحريك اسهم الداتا جريدفيو عند البحث محمد مسافر 2 587 19-09-24, 01:14 AM
آخر رد: محمد مسافر
  مساعدة البحث بين تاريخين أبووسم 3 553 16-08-24, 01:37 PM
آخر رد: أبووسم
  البحث بالأسم الأول فقط heem1986 6 650 03-08-24, 04:17 PM
آخر رد: heem1986
  [VB.NET] تجاهل التشكيل من الأسماء عند البحث في التيكست بوكس Khalil chiha 3 541 01-08-24, 10:28 PM
آخر رد: Khalil chiha
  يوجد خطاء فى كود البحث بواستطة الكمبوبوكس واجراء مخزن new_programer 4 418 06-07-24, 12:05 AM
آخر رد: Zuhare
  البحث بين تاريخين مع الوقت - من بداية اليوم - حتى اخر اليوم moh61 3 613 12-06-24, 08:00 PM
آخر رد: Taha Okla
  أريد البحث بإستخدام أي جزء من الكلمة و ليس أول جزء منها . CoderMM 3 623 17-04-24, 01:19 AM
آخر رد: Taha Okla
  [VB.NET] البحث باستخدام CheckedListBox لتكون نتيجة التحديد شرط لجملة الاستعلام ahmedramzyaish 0 449 19-02-24, 03:44 AM
آخر رد: ahmedramzyaish

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


يقوم بقرائة الموضوع: