Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System
- Imports System.Collections.Generic
- Imports System.Text
- Imports System.Data
- Imports System.Data.OleDb
- Imports System.Windows.Forms
- Imports System.Collections
- Imports Pos.Pos.BLL
- Namespace Pos.DAL
- Public Class daUser
- Private CnnStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data " + "Source= " + Application.StartupPath + "\pos.accdb;Jet OLEDB:Database Password=pos"
- 'Public menu As List(Of String)
- 'Public menu As String
- Public menu As ArrayList
- Private cnn As New OleDbConnection()
- Public role As String
- Public Sub New()
- cnn.ConnectionString = CnnStr
- cnn.Open()
- End Sub
- Public Sub add(ByVal user As User)
- If cnn.State = ConnectionState.Open Then
- cnn.Close()
- End If
- Try
- Dim strCom As String = "Insert into tblUser(Username,Password,Jabatan) values ('" & Convert.ToString(user.Username) & "'," & Convert.ToString(user.Password) & "'," & Convert.ToString(user.Jabatan) & "')"
- cnn.ConnectionString = CnnStr
- cnn.Open()
- Dim Comm As New OleDbCommand(strCom, cnn)
- Comm.Dispose()
- cnn.Close()
- Catch ex As OleDbException
- Throw ex
- Catch ex As Exception
- Throw New Exception(ex.Message.ToString())
- End Try
- End Sub
- Public Function Login(ByVal username As String, ByVal password As String) As String
- 'Dim role As String
- If cnn.State = ConnectionState.Open Then
- cnn.Close()
- End If
- Try
- Dim strCom As String = "select Jabatan from tblUser where Username='" + username + "' and Password='" + password + "'"
- cnn.ConnectionString = CnnStr
- cnn.Open()
- Dim Comm As New OleDbCommand(strCom, cnn)
- Dim dr As OleDbDataReader = Comm.ExecuteReader
- While dr.Read
- role = dr(0).ToString
- End While
- cnn.Close()
- Catch ex As Exception
- Return ex.ToString
- Finally
- End Try
- Return role
- End Function
- Public Function getMenu(ByVal jabatan As String) As List(Of String)
- 'Public Function getMenu(ByVal jabatan As String) As Boolean
- If cnn.State = ConnectionState.Open Then
- cnn.Close()
- End If
- Try
- 'Dim strCommand As String = "select Menu from tblJabatan where JabatanName='" + jabatan + "'"
- Dim strCommand As String = "select Menu from tblJabatan where JabatanName='tes'"
- cnn.ConnectionString = CnnStr
- cnn.Open()
- Dim Comm As New OleDbCommand(strCommand, cnn)
- Dim dr As OleDbDataReader = Comm.ExecuteReader
- If dr.HasRows Then
- Do While dr.Read
- menu.Add(dr(0).ToString)
- Loop
- End If
- cnn.Close()
- Catch er As OleDb.OleDbException
- Catch ex As Exception
- Finally
- End Try
- Return menu
- End Function
- End Class
- End Namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement