Created
February 8, 2017 09:53
-
-
Save jbagaresgaray/f5b0e15fe5cc0aaa0bb3b991173b43d4 to your computer and use it in GitHub Desktop.
HRIS Division API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit On | |
Imports MySql.Data.MySqlClient | |
Module modDivision | |
Public Structure Divisions | |
Dim div_id As Integer | |
Dim div_code As String | |
Dim div_name As String | |
Dim div_desc As String | |
Dim inactive As Short | |
End Structure | |
Public Function Add_Divisions(ByVal D As Divisions) As Boolean | |
Dim sSQL As String = "INSERT INTO `divisions`(`div_code`,`div_name`,`div_desc`,`inactive`)VALUES('" & _ | |
D.div_code & "','" & D.div_name & "','" & D.div_desc & "','" & D.inactive & "')" | |
If ExecuteQry(sSQL) Then | |
Add_Divisions = True | |
Else | |
Add_Divisions = False | |
End If | |
End Function | |
Public Function Update_Divisions(ByVal div_id As Integer, ByVal D As Divisions) As Boolean | |
Dim sSQL As String = "UPDATE `divisions` SET `div_code` ='" & D.div_code & "',`div_name` ='" & _ | |
D.div_name & "',`div_desc` = '" & D.div_desc & "',`inactive` ='" & D.inactive & "' WHERE div_id='" & div_id & "';" | |
If ExecuteQry(sSQL) Then | |
Update_Divisions = True | |
Else | |
Update_Divisions = False | |
End If | |
End Function | |
Public Function Delete_Division(ByVal div_id As Integer) As Boolean | |
If ExecuteQry("DELETE FROM divisions WHERE div_id='" & div_id & "'") Then | |
Delete_Division = True | |
Else | |
Delete_Division = False | |
End If | |
End Function | |
Public Function GetDivisionsByID(ByVal div_id As String, ByRef D As Divisions) As Boolean | |
Dim con As New MySqlConnection(DB_CONNECTION_STRING) | |
con.Open() | |
Dim com As New MySqlCommand("SELECT * FROM divisions WHERE div_id='" & div_id & "' LIMIT 1", con) | |
Dim vRS As MySqlDataReader = com.ExecuteReader | |
vRS.Read() | |
If vRS.HasRows Then | |
With D | |
.div_code = vRS("div_code").ToString() | |
.div_desc = vRS("div_desc").ToString() | |
.div_name = vRS("div_name").ToString() | |
.inactive = BooleanToInt(vRS("inactive").ToString()) | |
.div_id = vRS("div_id").ToString() | |
End With | |
GetDivisionsByID = True | |
Else | |
GetDivisionsByID = False | |
End If | |
vRS.Close() | |
con.Close() | |
End Function | |
End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment