jj
This commit is contained in:
@@ -19,17 +19,17 @@ Public Class DB
|
||||
End Sub
|
||||
|
||||
#Region "=== HELPERS ==="
|
||||
Public Function formatTable(table As String) As String
|
||||
Public Function FormatTable(table As String) As String
|
||||
Return String.Format("[{0}].[dbo].[{1}]", _db, table)
|
||||
End Function
|
||||
|
||||
Public Function GetFormIdFor(entityName As String) As Integer
|
||||
Dim sql = String.Format("SELECT GUID FROM {0} WHERE NAME = '{1}'", Me.formatTable("TBPMO_FORM"), entityName)
|
||||
Dim sql = String.Format("SELECT GUID FROM {0} WHERE NAME = '{1}'", Me.FormatTable("TBPMO_FORM"), entityName)
|
||||
Return Me.Scalar(sql)
|
||||
End Function
|
||||
|
||||
Public Function GetControlId(formId As Integer, Optional name As String = "ApplicationNumber") As Integer
|
||||
Dim sql = String.Format("SELECT GUID FROM {0} WHERE NAME = '{1}' AND FORM_ID = {2}", Me.formatTable("TBPMO_CONTROL"), name, formId)
|
||||
Dim sql = String.Format("SELECT GUID FROM {0} WHERE NAME = '{1}' AND FORM_ID = {2}", Me.FormatTable("TBPMO_CONTROL"), name, formId)
|
||||
Return Me.Scalar(sql)
|
||||
End Function
|
||||
|
||||
@@ -54,7 +54,7 @@ Public Class DB
|
||||
End Function
|
||||
|
||||
Public Function IsEqual(controlId As Integer, recordId As Integer, valueToCompare As Object)
|
||||
Dim table = Me.formatTable("TBPMO_CONTROL_VALUE")
|
||||
Dim table = Me.FormatTable("TBPMO_CONTROL_VALUE")
|
||||
Dim sql = String.Format("SELECT VALUE FROM {0} WHERE CONTROL_ID = {1} AND RECORD_ID = {2}", table, controlId, recordId)
|
||||
Dim value = Me.Scalar(sql)
|
||||
|
||||
@@ -65,15 +65,15 @@ Public Class DB
|
||||
Return value = valueToCompare
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "=== RECORD ID ==="
|
||||
Public Function GetRecordId(controlId As Integer, applicationNumber As String) As Integer
|
||||
Dim sql = String.Format("SELECT RECORD_ID FROM {0} WHERE CONTROL_ID = {1} AND VALUE = '{2}'", Me.formatTable("TBPMO_CONTROL_VALUE"), controlId, applicationNumber)
|
||||
Dim sql = String.Format("SELECT RECORD_ID FROM {0} WHERE CONTROL_ID = {1} AND VALUE = '{2}'", Me.FormatTable("TBPMO_CONTROL_VALUE"), controlId, applicationNumber)
|
||||
Return Me.Scalar(sql)
|
||||
End Function
|
||||
|
||||
Public Function InsertRecord(formId As Integer)
|
||||
Dim sql = String.Format("INSERT INTO {0} (FORM_ID, ADDED_WHO, RECORD_ENTITY_ID, PARENT_RECORD) VALUES ({1}, '{2}', {1}, 0)", Me.formatTable("TBPMO_RECORD"), formId, Username)
|
||||
Dim sql = String.Format("INSERT INTO {0} (FORM_ID, ADDED_WHO, RECORD_ENTITY_ID, PARENT_RECORD) VALUES ({1}, '{2}', {1}, 0)", Me.FormatTable("TBPMO_RECORD"), formId, Username)
|
||||
Me.NonQuery(sql)
|
||||
Return Me.Scalar("SELECT MAX(GUID) FROM TBPMO_RECORD")
|
||||
End Function
|
||||
@@ -81,19 +81,19 @@ Public Class DB
|
||||
|
||||
#Region "=== VALUES ==="
|
||||
Public Function InsertValue(controlId As Integer, recordId As Integer, value As Object)
|
||||
Dim table = Me.formatTable("TBPMO_CONTROL_VALUE")
|
||||
Dim table = Me.FormatTable("TBPMO_CONTROL_VALUE")
|
||||
Dim sql = String.Format("INSERT INTO {0} (CONTROL_ID, RECORD_ID, VALUE, ADDED_WHO) VALUES ({1}, {2}, '{3}', '{4}')", table, controlId, recordId, value, Username)
|
||||
Me.NonQuery(sql)
|
||||
Return Me.Scalar(String.Format("SELECT MAX(GUID) FROM {0} WHERE CONTROL_ID = {1}", table, controlId))
|
||||
End Function
|
||||
|
||||
Public Sub UpdateValue(controlId As Integer, recordId As Integer, value As Object)
|
||||
Dim table = Me.formatTable("TBPMO_CONTROL_VALUE")
|
||||
Dim table = Me.FormatTable("TBPMO_CONTROL_VALUE")
|
||||
Dim sql = String.Format("UPDATE {0} SET VALUE = '{1}', CHANGED_WHO = '{4}' WHERE CONTROL_ID = {2} AND RECORD_ID = {3} ", table, value, controlId, recordId, Username)
|
||||
Me.NonQuery(sql)
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "=== DATABASE ==="
|
||||
Public Function Scalar(queryString As String)
|
||||
Dim conn As New SqlConnection(_connstring)
|
||||
@@ -152,7 +152,7 @@ Public Class DB
|
||||
|
||||
#Region "=== IMAGES ==="
|
||||
Public Sub InsertImage(bimage As Byte(), ControlId As Integer, RecordId As Integer)
|
||||
Dim table = Me.formatTable("TBPMO_CONTROL_IMAGE")
|
||||
Dim table = Me.FormatTable("TBPMO_CONTROL_IMAGE")
|
||||
Dim sql = String.Format("INSERT INTO {0} (CONTROL_ID, RECORD_ID, IMG) VALUES (@CONTROL_ID, @RECORD_ID, @IMG)", table)
|
||||
Dim conn As New SqlClient.SqlConnection(_connstring)
|
||||
Dim cmd As New SqlClient.SqlCommand(sql, conn)
|
||||
@@ -167,7 +167,7 @@ Public Class DB
|
||||
End Sub
|
||||
|
||||
Public Sub UpdateImage(bimage As Byte(), ControlId As Integer, RecordId As Integer)
|
||||
Dim table = Me.formatTable("TBPMO_CONTROL_IMAGE")
|
||||
Dim table = Me.FormatTable("TBPMO_CONTROL_IMAGE")
|
||||
Dim sql = String.Format("UPDATE {0} SET IMG = @IMG WHERE CONTROL_ID = @CONTROL_ID AND RECORD_ID = @RECORD_ID", table)
|
||||
Dim conn As New SqlClient.SqlConnection(_connstring)
|
||||
Dim cmd As New SqlClient.SqlCommand(sql, conn)
|
||||
|
||||
Reference in New Issue
Block a user