منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[سؤال] عايز كو للحذف - نسخة قابلة للطباعة

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



عايز كو للحذف - اسامه الهرماوي - 25-11-18

السلام عليك ممكن
كود للحذف من الاكسس


RE: عايز كو للحذف - عبد العزيز البسكري - 25-11-18

السّلام عليكم و رحمة الله و بركاته
توجد العديد من الطرق و هذه إحداها أخي الكريم ..
كود :
   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

تحياتي



RE: عايز كو للحذف - اسامه الهرماوي - 25-11-18

(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

تحياتي

شكرا جدا اخي العزيز