Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Ericsson.accdb")
Dim da As New OleDbDataAdapter("SELECT * FROM [ERC_Cascaded_Sites] ", con) ' جدول مصدر المعلومات Dim dt As New DataTable ' مكان التخزين Dim binding As New BindingSource
'=========================================================================================================================== Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load binding.DataSource = dt da.Fill(dt)
Me.DataGridView1.DataSource = binding Me.DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect Me.DataGridView1.MultiSelect = False Me.DataGridView1.AllowUserToAddRows = False Me.DataGridView1.ReadOnly = True Me.DataGridView1.EnableHeadersVisualStyles = False End Sub
'==================================================================================================================== ' مفتاح الاضافة ----Add Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Using frm As New ERC_Cascaded_Sites_Add If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
'==================================================================================================================== ' مفتاح التعديل ----Update or save Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Me.DataGridView1.Rows.Count > 0 Then Using frm As New ERC_Cascaded_Sites_Add
Dim rowIndex As Integer = DataGridView1.CurrentRow.Index frm.id = Val(DataGridView1.CurrentRow.Cells(0).Value)
If frm.ShowDialog = Windows.Forms.DialogResult.OK Then
'==================================================================================================================== ' مفتاح الحذف -------Delete Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If binding.Position < 0 Then Return If MsgBox("هل تريد فعلاً حذف هذا السجل", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "تنبيه") = MsgBoxResult.Yes Then binding.RemoveCurrent() Dim builder As New OleDbCommandBuilder(da) With {.QuotePrefix = "[", .QuoteSuffix = "]"} da.Update(dt) End If End Sub
'==================================================================================================================== ' تكست البحث Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged binding.Filter = "Site_Region LIKE '%" & TextBox1.Text & "%' " End Sub
'==================================================================================================================== ' السجل الاول Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click binding.MoveFirst() End Sub
' السجل السابق Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click binding.MovePrevious() End Sub
' السجل التالي Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click binding.MoveNext() End Sub
' السجل الاخير Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click binding.MoveLast() End Sub
'==================================================================================================================== ' مفتاح الاغلاق ----Close Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() End Sub
End Class
ERC_Cascaded_Sites_Add
PHP كود :
Imports System.Data.OleDb
Public Class ERC_Cascaded_Sites_Add
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Ericsson.accdb")
Public id As Integer = 0 Dim da As OleDbDataAdapter ' جدول مصدر المعلومات Dim dt As New DataTable ' مكان التخزين Dim binding As New BindingSource
'=========================================================================================================================== Private Sub ERC_Cascaded_Sites_Add_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
binding.DataSource = dt
Dim sql As String = "SELECT * FROM [ERC_Cascaded_Sites] WHERE [ID]=" & id da = New OleDbDataAdapter(sql, con) ' جدول مصدر المعلومات da.Fill(dt)
'=========================================================================================================================== ' مفتاح التخزين Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
binding.EndEdit()
Dim builder As New OleDbCommandBuilder(da) With {.QuotePrefix = "[", .QuoteSuffix = "]"} da.Update(dt)
If id = 0 Then MsgBox("تم حفظ البيانات بنجاح", MsgBoxStyle.Information, "ألف مبروك")
Else MsgBox("تم تحديث البيانات بنجاح", MsgBoxStyle.Information, "ألف مبروك")
End If
Me.DialogResult = DialogResult.OK
End Sub
'=========================================================================================================================== ' اغلاق الشاسة Private Sub Button18_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button3.Click Me.DialogResult = DialogResult.Cancel End Sub
(22-11-17, 01:32 AM)a.ahmed كتب : ERC_Cascaded_Sites
PHP كود :
Imports System.Data.OleDb
Public Class ERC_Cascaded_Sites
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Ericsson.accdb")
Dim da As New OleDbDataAdapter("SELECT * FROM [ERC_Cascaded_Sites] ", con) ' جدول مصدر المعلومات Dim dt As New DataTable ' مكان التخزين Dim binding As New BindingSource
'=========================================================================================================================== Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load binding.DataSource = dt da.Fill(dt)
Me.DataGridView1.DataSource = binding Me.DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect Me.DataGridView1.MultiSelect = False Me.DataGridView1.AllowUserToAddRows = False Me.DataGridView1.ReadOnly = True Me.DataGridView1.EnableHeadersVisualStyles = False End Sub
'==================================================================================================================== ' مفتاح الاضافة ----Add Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Using frm As New ERC_Cascaded_Sites_Add If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
'==================================================================================================================== ' مفتاح التعديل ----Update or save Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Me.DataGridView1.Rows.Count > 0 Then Using frm As New ERC_Cascaded_Sites_Add
Dim rowIndex As Integer = DataGridView1.CurrentRow.Index frm.id = Val(DataGridView1.CurrentRow.Cells(0).Value)
If frm.ShowDialog = Windows.Forms.DialogResult.OK Then
'==================================================================================================================== ' مفتاح الحذف -------Delete Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If binding.Position < 0 Then Return If MsgBox("هل تريد فعلاً حذف هذا السجل", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "تنبيه") = MsgBoxResult.Yes Then binding.RemoveCurrent() Dim builder As New OleDbCommandBuilder(da) With {.QuotePrefix = "[", .QuoteSuffix = "]"} da.Update(dt) End If End Sub
'==================================================================================================================== ' تكست البحث Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged binding.Filter = "Site_Region LIKE '%" & TextBox1.Text & "%' " End Sub
'==================================================================================================================== ' السجل الاول Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click binding.MoveFirst() End Sub
' السجل السابق Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click binding.MovePrevious() End Sub
' السجل التالي Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click binding.MoveNext() End Sub
' السجل الاخير Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click binding.MoveLast() End Sub
'==================================================================================================================== ' مفتاح الاغلاق ----Close Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() End Sub
End Class
ERC_Cascaded_Sites_Add
PHP كود :
Imports System.Data.OleDb
Public Class ERC_Cascaded_Sites_Add
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Ericsson.accdb")
Public id As Integer = 0 Dim da As OleDbDataAdapter ' جدول مصدر المعلومات Dim dt As New DataTable ' مكان التخزين Dim binding As New BindingSource
'=========================================================================================================================== Private Sub ERC_Cascaded_Sites_Add_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
binding.DataSource = dt
Dim sql As String = "SELECT * FROM [ERC_Cascaded_Sites] WHERE [ID]=" & id da = New OleDbDataAdapter(sql, con) ' جدول مصدر المعلومات da.Fill(dt)
'=========================================================================================================================== ' مفتاح التخزين Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
binding.EndEdit()
Dim builder As New OleDbCommandBuilder(da) With {.QuotePrefix = "[", .QuoteSuffix = "]"} da.Update(dt)
If id = 0 Then MsgBox("تم حفظ البيانات بنجاح", MsgBoxStyle.Information, "ألف مبروك")
Else MsgBox("تم تحديث البيانات بنجاح", MsgBoxStyle.Information, "ألف مبروك")
End If
Me.DialogResult = DialogResult.OK
End Sub
'=========================================================================================================================== ' اغلاق الشاسة Private Sub Button18_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button3.Click Me.DialogResult = DialogResult.Cancel End Sub