25-11-18, 08:32 PM
(25-11-18, 08:27 PM)عبد العزيز البسكري كتب :السّلام عليكم و رحمة الله و بركاتهتوجد العديد من الطرق و هذه إحداها أخي الكريم ..كود :
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Using Commandcheck As New OleDbCommand("SELECT MAX(ID) FROM FONCTIONNAIRE", Con)
If Con.State = ConnectionState.Closed Then Con.Open()
If Commandcheck.ExecuteScalar Is DBNull.Value Then
MsgBox("قاعدة البيانات فارغة .. لا توجد بيانات لتنفيذ الأمر ")
Con.Close()
Exit Sub
End If
End Using
If MsgBox(" هل أنت متأكّد من أنك تريد حذف بيانات هذا الموظّف : " & TxtEmpName.Text & " ؟ ", MsgBoxStyle.YesNo + MsgBoxStyle.Critical, "تحذير") = MsgBoxResult.No Then
Exit Sub
ElseIf TextBox1.Text = "" Then
MsgBox("الرجاء كتابة الرقم التسلسلي", MsgBoxStyle.MsgBoxRtlReading, "تنبيه")
Else
Using Command As New OleDbCommand("DELETE FROM FONCTIONNAIRE WHERE ID = @ID", Con)
Command.Parameters.Add("@ID", OleDbType.Numeric).Value = TextBox1.Text
If Con.State = ConnectionState.Closed Then Con.Open()
If Command.ExecuteNonQuery() = 1 Then
MsgBox("تمت عملية الحذف بنجاح", MsgBoxStyle.MsgBoxRtlReading, "تنفيذ اجراء الحذف")
Else
MsgBox("لم تتم عملية الحذف بنجاح", MsgBoxStyle.MsgBoxRtlReading, "تنفيذ اجراء الحذف")
Call SetState("View")
End If
Con.Close()
End Using
End If
End Sub
تحياتي
شكرا جدا اخي العزيز
المبرمج لا يفكر في المشكلة بل في الحل!!

