1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| Public class SQLDM
Public Function Insert_TItem(ByVal path As String, ByVal sfileName As String, ByVal inspectionID As String, _
ByVal sComment As String, ByVal sFileExtention As String, ByVal arrayOfID As ArrayList) As Boolean
Dim transaction As IDbTransaction
Try
Dim NewDMSD_ID As Long = GetNextDMSD_ID()
' Insert data Into DMSD_T
Dim sqlCommand As String = "INSERT INTO DM_T (DM_ID,DM_DOCUMENT_PATH,DM_DOCUMENT_NAME,DM_COMMENT," & _
"DM_INSERTED, DM_FILE_EXTENTION) VALUES ( " & NewDMSD_ID & ",'" & path & "','" & sfileName & "','" & _
sComment & "','" & Date.Now.ToString & "','" & sFileExtention & "') ;"
Dim dbCommandWrapper As clsDBCommandWrapper = Me.objDataBase.GetSqlStringCommandWrapper(sqlCommand)
'transaction = Me.objDataBase.GetConnection.BeginTransaction(IsolationLevel.Serializable)
Me.objDataBase.ExecuteNonQuery(dbCommandWrapper) ', transaction)
' Insert Data Into R_DMSD_T (Relation's table) fk fk
For i As Integer = 0 To arrayOfID.Count - 1
sqlCommand = "INSERT INTO R_DM_CAT_T (DM_T_DM_ID,CAT_CAT_ID) VALUES (" & NewDMSD_ID.ToString & "," & CStr(arrayOfID.Item(i)) & ");"
dbCommandWrapper = Me.objDataBase.GetSqlStringCommandWrapper(sqlCommand)
Me.objDataBase.ExecuteNonQuery(dbCommandWrapper) ', transaction)
Next
sqlCommand = "INSERT INTO R_SI_T_DM_T (SI_T_SI_ID, DMSD_T_DMSD_ID) VALUES ('" & inspectionID.ToString & "'," & NewDMSD_ID.ToString & ");"
dbCommandWrapper = Me.objDataBase.GetSqlStringCommandWrapper(sqlCommand)
Me.objDataBase.ExecuteNonQuery(dbCommandWrapper) ', transaction)
'transaction.Commit()
Catch ex As Exception
Debug.WriteLine(ex.ToString)
clsLogFile.SetData("Transaction Rollback ! " & ex.Message)
'transaction.Rollback()
End Try
End Function |
Partager