29-11-17, 07:06 PM
(آخر تعديل لهذه المشاركة : 29-11-17, 07:38 PM {2} بواسطة Amir_Alzubidy.
تعديل السبب: تعديل العنوان
)
دي بعض الاكواد مهمه ولذيذه و هتساعد البعض
للعمليات الاربعة واكثر
( اضافة ،حفظ ، تعديل ، بحث ، حذف)
بالاضافة الى كود استدعاء الصور
دعواتكم ليا
البحث بالرقم :
PHP كود :
Dim cn As New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"
cn.Open()
Dim s As String
s = "select * from doctor where dr_jopno= " & TextBox9.Text
Dim CmdReader As New OleDbCommand(s, cn)
Dim DeptReader As OleDbDataReader
DeptReader = CmdReader.ExecuteReader
If DeptReader.Read() Then
TextBox1.Text = DeptReader("dr_name")
TextBox2.Text = DeptReader("dr_address")
TextBox3.Text = DeptReader("dr_qualification")
TextBox4.Text = DeptReader("dr_specialization")
TextBox5.Text = DeptReader("dr_jopno")
TextBox6.Text = DeptReader("dr_dateof")
TextBox7.Text = DeptReader("dr_telephone")
Else
MsgBox("الرقم غير موجود الرجاء التاكد من الرقم الصحيح", MsgBoxStyle.Information)
End If
هذا كود جديد ( افراغ الحقول ) :
كود :
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
هذا الكود لفتح الصور بجميع الصيغ :
PHP كود :
OpenFileDialog1.Filter = "images (*.jpg,*.jpeg,*.bmp,*.gif,*.png)|*.BMP;*.PNG;*.JPG;*.JPEG;*.GIF"
OpenFileDialog1.Title = "open image "
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName = Nothing Then Exit Sub
هل يمكن أظهار رسالة في سطرين؟
نعم :
PHP كود :
MsgBox("hairan" & vbCr & "felnas")
or
MsgBox("any text here" & vbNewLine & "any text here")
كود خاص بالاضافة :
PHP كود :
Dim cn As New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"
cn.Open()
Dim s As String
s = "insert into doctor values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "'," & TextBox5.Text & ",'" & TextBox6.Text & "'," & TextBox7.Text & ")"
Dim CmdReader As New OleDbCommand(s, cn)
Dim res As Integer
res = CmdReader.ExecuteNonQuery
MsgBox("تمت إضافة سجل بنجاح")
كود خاص بالتعديل :
PHP كود :
Dim cn As New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"
cn.Open()
Dim s As String
s = "update doctor set dr_name='" & TextBox1.Text & "',dr_address='" & TextBox2.Text & "',dr_qualification='" & TextBox3.Text & "',dr_specialization='" & TextBox4.Text & "',dr_dateof='" & TextBox6.Text & "',dr_telephone=" & TextBox7.Text & " where dr_jopno= " & TextBox5.Text
Dim CmdReader As New OleDbCommand(s, cn)
Dim res As Integer
res = CmdReader.ExecuteNonQuery
MsgBox("تمت عملية التعديل بنجاح")
كود الحذف :
PHP كود :
Dim cn As New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"
cn.Open()
Dim s As String
s = "delete from doctor where dr_jopno= " & TextBox5.Text
Dim CmdReader As New OleDbCommand(s, cn)
Dim res As Integer
res = CmdReader.ExecuteNonQuery
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
MsgBox("تمت عملية الحذف")
كود التحديث لقاعدة البيانات :
PHP كود :
Dim cn As New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"
cn.Open()
Dim s As String
s = "select * from doctor "
Dim da As New OleDbDataAdapter(s, cn)
Dim ds As New DataSet
da.Fill(ds, "doctor")
DataGridView1.DataSource = ds.Tables(0)
كود التحميل :
PHP كود :
Dim cn As New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"
cn.Open()
Dim s As String
s = "select * from doctor"
Dim CmdReader As New OleDbCommand(s, cn)
Dim DeptReader As OleDbDataReader
DeptReader = CmdReader.ExecuteReader
DeptReader.Read()
TextBox1.Text = DeptReader("dr_name")
TextBox2.Text = DeptReader("dr_address")
TextBox3.Text = DeptReader("dr_qualification")
TextBox4.Text = DeptReader("dr_specialization")
TextBox5.Text = DeptReader("dr_jopno")
TextBox6.Text = DeptReader("dr_dateof")
TextBox7.Text = DeptReader("dr_telephone")
اذا كنت عاوز دخول البرنامج حسب الصلاحيات في قاعدة البيانات :
PHP كود :
If username.Text = u.Text And password.Text = p.Text Then
Form1.Show()
Me.Hide()
Else
MsgBox("يوجد خطأ في إسم المستخدم أو كلمة المرور", MsgBoxStyle.Information, "عذراً")
username.Clear()
password.Clear()
دام الله لكم البشر والخير
سبحان الله وبحمده