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

اتمنى المساعده في مشكله التي توجهني

في كود البحث وتعديل وحذف وحفظ بعد تعديل

هذا هو الكود :-
PHP كود :
Imports System.Data
Imports System
.Data.OleDb
Public Class act_search
    Dim Connectionstring 
As String _
    
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" _
    Application
.StartupPath "\Student.mdb"
    
Dim newconnection As New OleDbConnection(Connectionstring)
    
Dim DataSet1 As New DataSet
    Dim SQLstr 
As String
    Dim m 
As String
    
Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click

        
Static As Integer 0
        
' Static: Specifies that one or more declared local variables are to remain in existence and retain their
        ' 
latest values after termination of the procedure in which they are declared

        
If Text_1.Text Trim(""Then Exit Sub
        
' إذا كان مربع النص فارغ يتم انهاء هذا الاجراء

        If RadioButton8.Checked = True Then
            ExactSearch()

            '
ExactSearch()
            
' مطابق للكلمة
            ' 
يتم تنفيذ الدالة ExactSearch 

        
ElseIf RadioButton9.Checked True Then
            GeneralSearch
()
            
'  GeneralSearchيتم تنفيذ الدالة
            ' 
عام
        End 
If

        
newconnection.Open()
        
Dim DataAdapter1 As New OleDbDataAdapter(SQLstrnewconnection)
        
DataAdapter1.Fill(DataSet1"Student_data")
        
newconnection.Close()

        
' ملء مربعات النص بما يوافق ناتج كلمة البحث
        Text_2.DataBindings.Add("Text", DataSet1, "Student_data.Student_id")
        Text_3.DataBindings.Add("Text", DataSet1, "Student_data.Student_no")
        Text_4.DataBindings.Add("Text", DataSet1, "Student_data.Student_Name")
        Text_5.DataBindings.Add("Text", DataSet1, "Student_data.Student_Email")
        Text_6.DataBindings.Add("Text", DataSet1, "Student_data.Student_specialty")
        Text_7.DataBindings.Add("Text", DataSet1, "Student_data.Student_College")
        Text_8.DataBindings.Add("Text", DataSet1, "Student_data.Student_Mobile")

        ' 
ملء الداتاقريد بنتائج كلمة البحث
        DataGridView1
.DataSource DataSet1
        DataGridView1
.DataMember "Student_data"
        
DataGridView1.AllowDrop True

        
' عند الانتهاء من البحث يتم تعطيل زر البحث لتفادي الخطأ؟؟؟
        Button1.Enabled = False

        If Me.BindingContext(DataSet1, "Student_data").Count = 0 Then
            MsgBox("لاتوجد بيانات, الرجاء محاوله مره اخرى ")
            Exit Sub
        End If
    End Sub
    Public Sub ExactSearch()
        If RadioButton1.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_id = '" & Text_1.Text & "'"
        ElseIf RadioButton2.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_no = '" & Text_1.Text & "'"
        ElseIf RadioButton3.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_Name = '" & Text_1.Text & "'"
        ElseIf RadioButton4.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_Email = '" & Text_1.Text & "'"
        ElseIf RadioButton5.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_specialty = '" & Text_1.Text & "'"
        ElseIf RadioButton6.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_College = '" & Text_1.Text & "'"
        ElseIf RadioButton7.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_Mobile = '" & Text_1.Text & "'"
        End If
    End Sub
    Public Sub GeneralSearch()
        If RadioButton1.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_id LIKE '
%" & Text_1.Text & "%'"
        ElseIf RadioButton2.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_no LIKE '
%" & Text_1.Text & "%'"
        ElseIf RadioButton3.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_Name LIKE '
%" & Text_1.Text & "%'"
        ElseIf RadioButton4.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_Email LIKE '
%" & Text_1.Text & "%'"
        ElseIf RadioButton5.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_specialty LIKE '
%" & Text_1.Text & "%'"
        ElseIf RadioButton6.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_College LIKE '
%" & Text_1.Text & "%'"
        ElseIf RadioButton7.Checked = True Then
            SQLstr = "SELECT * FROM Student_data WHERE Student_Mobile LIKE '
%" & Text_1.Text & "%'"
        End If
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Me.Close()

    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ' 
اعادة تعيين
        
' لتمكين البحث مرة أخرى
        Text_1.DataBindings.Clear()
        Text_2.DataBindings.Clear()
        Text_3.DataBindings.Clear()
        Text_4.DataBindings.Clear()
        Text_5.DataBindings.Clear()
        Text_6.DataBindings.Clear()
        Text_7.DataBindings.Clear()
        Text_8.DataBindings.Clear()
        Text_1.Text = ""
        Text_2.Text = ""
        Text_3.Text = ""
        Text_4.Text = ""
        Text_5.Text = ""
        Text_6.Text = ""
        Text_7.Text = ""
        Text_8.Text = ""

        '
DataGridView1.DataBindings.Clear()
        
'DataGridView1.Refresh()
        '
DataGridView1.AllowUserToDeleteRows True
        
'DataGridView1.Update()
        Button1.Enabled = True
        SQLstr = ""
        DataSet1.Clear()
        Me.DataGridView1.DataSource = Nothing
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        '
Button4.Enabled False
        
'Button5.Enabled = False
        '
Button3.Enabled True
        
'Button2.Enabled = True
        '
Text_3.ReadOnly True
        
'Text_4.ReadOnly = True
        '
Text_5.ReadOnly True
        
'Text_6.ReadOnly = True
        '
Text_7.ReadOnly True
        
'Text_8.ReadOnly = True
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim SavInto As New OleDb.OleDbCommand
        Dim adapter2 As New OleDbDataAdapter(SQLstr, Connectionstring)
        SavInto.Connection = newconnection
        SavInto.CommandType = CommandType.Text
        '
,,,,,,,No_session
        SavInto
.CommandText "UPDATE Student_data SET Student_id = '" Trim(Text_2.Text) & "' , Student_no = '" Trim(Text_3.Text) & "' , Student_Name= '" Trim(Text_4.Text) & "' , Student_Email = '" Trim(Text_5.Text) & "' , Student_specialty = '" Trim(Text_6.Text) & "' , Student_College = '" Trim(Text_7.Text) & "'  , Student_Mobile = '" Trim(Text_8.Text) & "' WHERE No_session ='" "'"
        
newconnection.Open()
        
SavInto.ExecuteNonQuery()
        
newconnection.Close()
        
Button4.Enabled False
        Button5
.Enabled False
        Button3
.Enabled True
        Button2
.Enabled True
        Text_2
.ReadOnly True
        Text_3
.ReadOnly True
        Text_4
.ReadOnly True
        Text_5
.ReadOnly True
        Text_6
.ReadOnly True
        Text_7
.ReadOnly True
        Text_8
.ReadOnly True
    End Sub

    
Private Sub Button5_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button5.Click

        
If MsgBox("هل تريد حذف السجل الحالي"MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel Then
            
Exit Sub
        End 
If
        
Dim SavInto As New OleDb.OleDbCommand
        Dim DataAdapter1 
As New OleDbDataAdapter(SQLstrConnectionstring)
        
SavInto.Connection newconnection
        SavInto
.CommandType CommandType.Text
        SavInto
.CommandText "DELETE FROM Student_data WHERE Student_Mobile ='" Trim(Text_8.Text) & "'"
        
newconnection.Open()
        
SavInto.ExecuteNonQuery()
        
DataSet1.Clear()
        
DataAdapter1.Fill(DataSet1"Student_data")
        
newconnection.Close()
        
MsgBox("تمت عملية الحذف في قاعدة البيانات بنجاح")
    
End Sub

    
Private Sub Button7_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button7.Click
        cat_main
.Show()
        
Me.Hide()
    
End Sub

    
Private Sub searchform_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load
        RadioButton1
.Checked True
        RadioButton8
.Checked True

    End Sub
End 
Class 

تم ارفق الملف اتمنى مساعده في حل المشكله


الملفات المرفقة
.rar   test.rar (الحجم : 533.2 ك ب / التحميلات : 73)
الرد }}}
تم الشكر بواسطة:
#2
[COLOR="#800000"]السلام عليكم

اخي العزيز انظر هذا الموضوع http://vb4arb.com/vb/showthread.php?2774...ull-Sample وحمل المثال للاخ ابو ايهاب

بالتوفيق انشاءالله[/COLOR]
الرد }}}
تم الشكر بواسطة:
#3
sajad كتب :[COLOR="#800000"]السلام عليكم

اخي العزيز انظر هذا الموضوع http://vb4arb.com/vb/showthread.php?2774...ull-Sample وحمل المثال للاخ ابو ايهاب

بالتوفيق انشاءالله[/COLOR]

بارك الله فيك يا اخي
جاري تحميل ملف ان شاء الله استفيد منه
الرد }}}
تم الشكر بواسطة:
#4
يالغالي المشروع باصدار 9

انا استخدم 2010

توجد مشكله من ناحية الصور


http://upload.traidnt.net/upfiles/NmA39842.png
الرد }}}
تم الشكر بواسطة:
#5
السلام عليكم

اضغط على Ignore and continue
الرد }}}
تم الشكر بواسطة:
#6
بارك الله فيك ضبط

ياريت احل يحل مشكله الموجوده في الاكواد
الرد }}}
تم الشكر بواسطة:
#7
اشكر اخي الكريم
تم حل المشكله بفضل الله
اتمنى لك التوفيق
الرد }}}
تم الشكر بواسطة:



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


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