اخي الكريم
حتى تتضح الروؤيه قمت بتحميل سورس كود برنامج جمعية الايتام من هذا الموقع
وعملت برنامج فقط من فورم واحد وموديل واحد
وهو مااحتاجه
وهذه اكواد الفورم والموديم
ولكن تطلع لي الرسالة السابقة
في الفورم:
Public Class frmaddkafeal
Inherits System.Windows.Forms.Form
Dim WithEvents ama As BindingManagerBase
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
numf = TextBox1.Text
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Me.TextBox2.Text.Trim.Length = 0 Then
Me.TextBox2.Focus()
MsgBox(" الرجاء ادخال اسم الكفيل ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
End If
If Me.TextBox3.Text.Trim.Length = 0 Then
Me.TextBox3.Focus()
MsgBox(" الرجاء ادخال رقم السجل المدني للكفيل ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
End If
If Me.TextBox4.Text.Trim.Length = 0 Then
Me.TextBox4.Focus()
MsgBox(" الرجاء ادخال جوال الكفيل ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
End If
If Me.ComboBox1.Text.Trim.Length = 0 Then
Me.ComboBox1.Focus()
MsgBox(" الرجاء اختر نوع الكفيل ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
End If
If Me.TextBox5.Text.Trim.Length = 0 Then
Me.TextBox5.Focus()
MsgBox(" الرجاء ادخال تاريخ بداية الكفالة ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
End If
If Me.TextBox6.Text.Trim.Length = 0 Then
Me.TextBox6.Focus()
MsgBox(" الرجاء ادخال تاريخ نهاية الكفالة ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
End If
If Me.TextBox7.Text.Trim.Length = 0 Then
Me.TextBox7.Focus()
MsgBox(" الرجاء ادخال عدد الأيتام المكفلين ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
End If
If Me.TextBox8.Text.Trim.Length = 0 Then
Me.TextBox8.Focus()
MsgBox(" الرجاء ادخال مبلغ الكفالة ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
End If
If Not Val(TextBox3.Text) < 9999999999 Or Not Val(TextBox3.Text) > 1000000000 Then
MsgBox(" أعد كتابة رقم السجل المدني للكفيل، هذه الصيغة لرقم السجل غير صالحة")
TextBox3.Focus()
TextBox3.Text = ""
Exit Sub
End If
If Not Val(TextBox4.Text) > 500000000 Or Not Val(TextBox4.Text) < 600000000 Then
MsgBox(" أعد كتابة رقم الجوال للكفيل، هذه الصيغة لرقم الجوال غير صالحة")
TextBox4.Focus()
TextBox4.Text = ""
Exit Sub
End If
''''''''''''''''''''''''''''''''''''''''''''''''الاستعلام عن رقم السجل هل تم تسجيله من قبل
Dim sql As String
sql = "select * from kafeal where سجل_الكفيل=" & (Me.TextBox3.Text.Trim) & " "
cmd = New OleDb.OleDbCommand(sql, conn)
Dim dr As OleDb.OleDbDataReader
If conn.State = ConnectionState.Closed Then conn.Open()
dr = cmd.ExecuteReader
If dr.Read Then
Me.TextBox3.Clear()
Me.TextBox3.Focus()
MsgBox(" عفواً هذا الكفيل سبق تسجيله ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
Else
dr.Close()
conn.Close()
End If
''''''''''''''''''''''''''''''''''''''''''''''''
Try
connec()
cmd.CommandText = "insert into kafeal (رقم_الكفيل,اسم_الكفيل,سجل_الكفيل,جوال_الكفيل,نوع_الكفيل,تاريخ_بداية_الكفالة,تاريخ_نهاية_الكفالة,عدد_المكفلين,مبلغ_الكفالة)values( " & TextBox1.Text.Trim & " , '" & Me.TextBox2.Text.Trim & "' , " & Me.TextBox3.Text.Trim & " , " & Me.TextBox4.Text.Trim & " ,'" & Me.ComboBox1.Text.Trim & "' , '" & Me.TextBox5.Text.Trim & "' , '" & Me.TextBox6.Text.Trim & "' , " & Me.TextBox7.Text.Trim & " , " & Me.TextBox8.Text.Trim & " )"
cmd.ExecuteNonQuery()
MessageBox.Show("لقد تمت عملية إضافة الكفيل بنجاح", "ادخال ناجح", MessageBoxButtons.OK, MessageBoxIcon.Information)
cnn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'''''''''''''''''''''''''''''''''''
ComboBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
''''''''''''''''''''''''''''''''''''''''''''إضافة رقم أخر سجل
TextBox1.Text = numf + 1
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
TextBox2.Focus()
''''''''''''''''''''''''''''''''''''''''''''''
End Sub
Private Sub addnum()
''''''''''''''''''''''''''''''''''''''''''''إضافة رقم أخر سجل
adapt = New OleDb.OleDbDataAdapter("select * from kafeal where kafeal.[رقم_الكفيل] order by val(kafeal.[رقم_الكفيل])", conn)
dset.Clear()
adapt.Fill(dset, "kafeal")
ama = Me.BindingContext(dset, "kafeal")
ama.Position = ama.Count - 1
Try
TextBox9.DataBindings.Add("Text", dset, "kafeal.رقم_الكفيل")
TextBox1.Text = Val(TextBox9.Text.Trim) + 1
Catch ex As Exception
Finally
adapt.Dispose()
conn.Close()
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
addnum()
End Sub
Private Sub TextBox3_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox3.KeyDown
If e.KeyValue = Keys.Enter Then
If Me.TextBox3.Text.Trim.Length = 0 Then
Me.TextBox3.Focus()
MsgBox(" الرجاء ادخال رقم السجل المدني للكفيل ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
End If
''''''''''''''''''''''''''''''''''''''''''''''''الاستعلام عن رقم السجل هل تم تسجيله من قبل
Dim sql As String
sql = "select * from kafeal where سجل_الكفيل=" & (Me.TextBox3.Text.Trim) & " "
cmd = New OleDb.OleDbCommand(sql, conn)
Dim dr As OleDb.OleDbDataReader
If conn.State = ConnectionState.Closed Then conn.Open()
dr = cmd.ExecuteReader
If dr.Read Then
Me.TextBox3.Text = ""
Me.TextBox3.Focus()
MsgBox(" عفواً هذا الكفيل سبق تسجيلها ", MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxRight, " خطاء في الاتصال ")
Exit Sub
Else
dr.Close()
conn.Close()
End If
''''''''''''''''''''''''''''''''''''''''''''''''
If Not Val(TextBox3.Text) < 9999999999 Or Not Val(TextBox3.Text) > 1000000000 Then
MsgBox(" أعد كتابة رقم السجل، هذه الصيغة لرقم السجل غير صالحة")
TextBox3.Focus()
TextBox3.Text = ""
Exit Sub
Else
TextBox4.Focus()
End If
End If
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
End Sub
Private Sub TextBox4_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox4.KeyDown
If e.KeyValue = Keys.Enter Then
If Not Val(TextBox4.Text) > 500000000 Or Not Val(TextBox4.Text) < 600000000 Then
MsgBox(" أعد كتابة رقم الجوال، هذه الصيغة لرقم الجوال غير صالحة")
TextBox4.Focus()
TextBox4.Text = ""
Exit Sub
Else
ComboBox1.Focus()
End If
End If
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
End Class
وهذه اكواد الموديل:
Imports System.Data.OleDb
Module Module1
Public UserName As String
Public passWord As String
Public cnn As New OleDbConnection
Public cmd, bmd, dmd As New OleDbCommand
Public da, db, dc, de, df, dk, dg, dj, di, dm, dn, ds, dv As OleDbDataReader
Public dbval As Integer
Public sel As New OleDbCommand 'SQL لتنفيذ أحد أوامر
Public dl, adapt, adapt1, adapt2 As New OleDbDataAdapter 'dset وسيط بين قاعدة البيانات والكائن
Public dset, dset1, dset2 As New DataSet 'قاعدة بيانات مؤقتة مخزنة في الذاكرة
Public conn As New OleDbConnection 'للاتصال بمصدر قاعدة بيانات
Public dr As DataRow
Public strconn As String = ""
Public Vflag As Boolean = False
Public searchtype As String ' this is to decide the search type selected to print report
Public Gadd, Gedit, Gdel, Gadduser, Gedituser, Gdeluser, Gbakup, Gcopy As String
Public textf, numf As String ' this use to take textbox val
Public Sub connec()
cnn.ConnectionString = ("provider=microsoft.jet.oledb.4.0;data source= aytamdata.mdb;Jet OLEDB
atabase Password=2;")
cnn.Open()
cmd.Connection = cnn
End Sub
Sub Connection()
Try
strconn = "provider=microsoft.jet.oledb.4.0;data source= " & Application.StartupPath & "\aytamdata.mdb;Jet OLEDB
atabase Password=2;"
conn.ConnectionString = strconn
sel.Connection = conn
Catch ex As Exception
MsgBox("تم الاتصال بقاعدة البيانات ")
End Try
End Sub
End Module