Professional Documents
Culture Documents
K Aung Yar Zar DiscAccounting YAccessLo - Bluephoenix
K Aung Yar Zar DiscAccounting YAccessLo - Bluephoenix
K Aung Yar Zar DiscAccounting YAccessLo - Bluephoenix
vb 1
Imports System
Imports System.Windows.Forms
Imports System.Data.OleDb
Imports System.IO
DtFile = DataFilePath
' If username = "" Then
'username = "Admin"
' End If
End Sub
#End Region
Private Sub AllCall(ByVal TbName As String)
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
DT.Clear()
Try
Dim DA As New OleDb.OleDbDataAdapter("select * from " & TbName, conn)
DA.Fill(DS)
DT = DS.Tables(0)
DBS.DataSource = DT
Catch ex As SystemException
MsgBox(ex.ToString)
End Try
End Sub
Call AllCall(TbName)
If Not IsNothing(DT) Then
DGV.DataSource = DT
Else
MsgBox("Some Errors Occured")
End If
End Sub
#End Region
#Region "Saving user input code here"
' Public Sub DataBaseSaver(ByVal datafilepath As String, ByVal username As String,
ByVal password As String, ByVal tablename As String, ByVal datagrid As Windows.
Forms.DataGridView)
Private Sub SaverForAll(ByVal DT As DataTable)
' If username = "" Then
'username = "Admin"
' End If
DT.GetChanges()
If Not IsNothing(DT) Then
Try
'Dim conn_str As String = "Provider = Microsoft.jet.OleDB.4.0;Data
Source = " & datafilepath & ";User ID = " & username & ";Password = " & password &
";"
Dim conn_str As String = "Provider = Microsoft.jet.OleDB.4.0;Data
Source = " & DtFile
If Not File.Exists(DtFile) Then
MsgBox("Required File was not found ! ", MsgBoxStyle.Information)
Exit Sub
End If
da.Fill(DT)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
conn.Close()
End If
End Sub
Public Sub yDataBaseSaver()
Call SaverForAll(DT)
Call DV(DGV)
End Sub
#End Region
Property yDBLoaderDataSet(ByVal TableName As String) As DataSet
Get
TbName = TableName
Call AllCall(TbName)
Return DS
End Get
Set(ByVal value As DataSet)
DS = value
K:\Aung Yar Zar\DiscAccounting\yAccessLoader\AccLoader.vb 3
End Set
End Property
Property yDBLoaderDataTable(ByVal TableName As String) As DataTable
Get
TbName = TableName
Call AllCall(TbName)
Return DT
End Get
Set(ByVal value As DataTable)
DT = value
End Set
End Property
Property yDBLoaderBindingSource(ByVal TableName As String) As Windows.Forms.
BindingSource
Get
TbName = TableName
Call AllCall(TbName)
Return DBS
End Get
Set(ByVal value As Windows.Forms.BindingSource)
DBS = value
End Set
End Property
Public Sub yBindindSourceSaver(ByVal DataTable As DataTable)
Call SaverForAll(DataTable)
End Sub
Public Sub yQueryViewer(ByVal Command As String, ByVal DGV As System.Windows.Forms.
DataGridView)
cmd = Command
If Command = "" Then
MsgBox("You must Discribe specific SQL Command String")
Exit Sub
End If
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
'DT.Clear()
qDT.Clear()
Try
Dim qDA As New OleDb.OleDbDataAdapter(Command, conn)
qDA.Fill(qDT)
'DT = qDT
DGV.DataSource = qDT
Catch ex As SystemException
MsgBox(ex.ToString)
End Try
End Sub
Public Function yQueryDataTable(ByVal Command As String) As DataTable
Dim qDT As New DataTable
cmd = Command
If Command = "" Then
MsgBox("You must Discribe specific SQL Command String")
Return Nothing
Exit Function
End If
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
'DT.Clear()
qDT.Clear()
Try
Dim qDA As New OleDb.OleDbDataAdapter(Command, conn)
qDA.Fill(qDT)
'DT = qDT
Catch ex As SystemException
K:\Aung Yar Zar\DiscAccounting\yAccessLoader\AccLoader.vb 4
MsgBox(ex.ToString)
End Try
Return qDT
End Function
Public Function yQueryDataSet(ByVal Command As String) As DataSet
Dim qDS As New DataSet
cmd = Command
If Command = "" Then
MsgBox("You must Discribe specific SQL Command String")
Return Nothing
Exit Function
End If
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
'DT.Clear()
qDS.Clear()
Try
Dim qDA As New OleDb.OleDbDataAdapter(Command, conn)
qDA.Fill(qDS)
Catch ex As SystemException
MsgBox(ex.ToString)
End Try
Return qDS
End Function
Public Function yQueryDataSet(ByVal tlbName As String, ByVal Command As String) As
DataSet
Dim qDS As New DataSet
cmd = Command
If Command = "" Then
MsgBox("You must Discribe specific SQL Command String")
Return Nothing
Exit Function
End If
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
'DT.Clear()
qDS.Clear()
Try
Dim qDA As New OleDb.OleDbDataAdapter(Command, conn)
qDA.Fill(qDS)
Catch ex As SystemException
MsgBox(ex.ToString)
End Try
Return qDS
End Function
Public Sub yQuerySaver()
Call SaverForQuery(qDT)
yQueryViewer(cmd, DGV)
'DGV.DataSource = qDT
'Call DV(DGV)
End Sub
Private Sub SaverForQuery(ByVal qDT As DataTable)
' If username = "" Then
'username = "Admin"
' End If
qDT.GetChanges()
If Not IsNothing(qDT) Then
Try
'
'Dim conn_str As String = "Provider = Microsoft.jet.OleDB.4.0;Data
Source = " & datafilepath & ";User ID = " & username & ";Password = " & password &
";"
Dim conn_str As String = "Provider = Microsoft.jet.OleDB.4.0;Data
K:\Aung Yar Zar\DiscAccounting\yAccessLoader\AccLoader.vb 5
Source = " & DtFile
If Not File.Exists(DtFile) Then
MsgBox("Required File was not found ! ", MsgBoxStyle.Information)
Exit Sub
End If
qDA.Fill(qDT)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
conn.Close()
End If
End Sub
Sub yDbDeleteAllFromTable(ByVal tblName As String)
'MsgBox(findstr) CurrentQuantity
Try
'Call formClear()
' MessageBox.Show(findstr & " + " & tblName)