Skip to content

Instantly share code, notes, and snippets.

@jbagaresgaray
Created February 8, 2017 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbagaresgaray/b361217016b09b1c737860ffd908796c to your computer and use it in GitHub Desktop.
Save jbagaresgaray/b361217016b09b1c737860ffd908796c to your computer and use it in GitHub Desktop.
HRIS Job Title Grouping
Option Explicit On
Imports MySql.Data.MySqlClient
Module modPositionGroup
Public Structure Group_Position
Dim GroupID As Integer
Dim GroupCode As String
Dim GroupName As String
Dim Description As String
Dim Inactive As Short
Dim CreatedBy As Integer
Dim DateCreated As Date
Dim ModifiedBy As Integer
Dim DateModified As Date
End Structure
Public Function Add_Group_Position(ByVal GP As Group_Position) As Boolean
Dim sSQL As String = "INSERT INTO `group_position`(`GroupCode`,`GroupName`,`Description`,`Inactive`,`CreatedBy`,`DateCreated`)VALUES('" & GP.GroupCode & _
"','" & GP.GroupName & "','" & GP.Description & "','" & GP.Inactive & "','" & CURRENT_USER.UserID & "',CURDATE());"
If ExecuteQry(sSQL) Then
Add_Group_Position = True
Else
Add_Group_Position = False
End If
End Function
Public Function Update_Group_Position(ByVal GroupID As Integer, ByVal GP As Group_Position) As Boolean
Dim sSQL As String = "UPDATE `group_position` SET `GroupCode` ='" & GP.GroupCode & "',`GroupName` ='" & GP.GroupName & "',`Description` ='" & GP.Description & "',`Inactive` ='" & GP.Inactive & "',`ModifiedBy` ='" & CURRENT_USER.UserID & "',`DateModified` = CURDATE() WHERE GroupID='" & GroupID & "';"
If ExecuteQry(sSQL) Then
Update_Group_Position = True
Else
Update_Group_Position = False
End If
End Function
Public Function Delete_Group_Position(ByVal GroupID As Integer) As Boolean
If ExecuteQry("DELETE FROM group_position WHERE GroupID='" & GroupID & "'") Then
Delete_Group_Position = True
Else
Delete_Group_Position = False
End If
End Function
Public Function GetGroupPositionByID(ByVal GroupID As Integer, ByRef GP As Group_Position) As Boolean
Dim con As New MySqlConnection(DB_CONNECTION_STRING)
con.Open()
Dim com As New MySqlCommand("SELECT * FROM group_position WHERE GroupID='" & GroupID & "' LIMIT 1", con)
Dim vRS As MySqlDataReader = com.ExecuteReader()
vRS.Read()
If vRS.HasRows Then
GetGroupPositionByID = True
Else
GetGroupPositionByID = 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