19-08-18, 02:31 PM
هذا كود الحفظ
Private Sub butsave_Click_1(sender As System.Object, e As System.EventArgs) Handles butsave.Click
If combocreditor_name.Text.Trim = "" Then
MsgBox("برجاء إدخال إسم الدائن", MsgBoxStyle.Critical, "خطأ")
combocreditor_name.Focus()
Else
Dim sql = " select * from tblcredit where creditor_name = '" & combocreditor_name.Text & "'"
Dim adp As New OleDb.OleDbDataAdapter(sql, conn)
Dim ds = New DataSet
adp.Fill(ds)
Dim dt = ds.Tables(0)
If dt.Rows.Count > 0 Then
MsgBox(" إسم الدائن المدخل موجود تحت رقم" & dt.Rows(0).Item("credit_code"), MsgBoxStyle.Information, "تنبيه")
Else
Dim dr = dt.NewRow
dr!credit_code = txtcredit_code.Text
dr!creditor_name = combocreditor_name.Text
dr!credit_date = dtp.Text
dr!credit_amount = txtamount.Text
dr!credit_notes = txtnotes.Text
dt.Rows.Add(dr)
Dim cmd As New OleDb.OleDbCommandBuilder(adp)
adp.Update(dt)
butnew_Click_1(sender, e)
MsgBox("تم حفظ البيانات بنجاح", MsgBoxStyle.Information, "تأكيد")
ReloadRecords()
DisplayRecords()
End If
End If
End Sub
وانا استخدم قاعدة بيانات اكسس بامتداد accdb
Private Sub butsave_Click_1(sender As System.Object, e As System.EventArgs) Handles butsave.Click
If combocreditor_name.Text.Trim = "" Then
MsgBox("برجاء إدخال إسم الدائن", MsgBoxStyle.Critical, "خطأ")
combocreditor_name.Focus()
Else
Dim sql = " select * from tblcredit where creditor_name = '" & combocreditor_name.Text & "'"
Dim adp As New OleDb.OleDbDataAdapter(sql, conn)
Dim ds = New DataSet
adp.Fill(ds)
Dim dt = ds.Tables(0)
If dt.Rows.Count > 0 Then
MsgBox(" إسم الدائن المدخل موجود تحت رقم" & dt.Rows(0).Item("credit_code"), MsgBoxStyle.Information, "تنبيه")
Else
Dim dr = dt.NewRow
dr!credit_code = txtcredit_code.Text
dr!creditor_name = combocreditor_name.Text
dr!credit_date = dtp.Text
dr!credit_amount = txtamount.Text
dr!credit_notes = txtnotes.Text
dt.Rows.Add(dr)
Dim cmd As New OleDb.OleDbCommandBuilder(adp)
adp.Update(dt)
butnew_Click_1(sender, e)
MsgBox("تم حفظ البيانات بنجاح", MsgBoxStyle.Information, "تأكيد")
ReloadRecords()
DisplayRecords()
End If
End If
End Sub
وانا استخدم قاعدة بيانات اكسس بامتداد accdb
