Three-layer structure: logic layer

zhaozj2021-02-16  52

Logical layer:

Imports system.data.sqlclientimports workvision.dj0211e

Public Class Logictract Private ObjDatabaseOperate As DatabaseOperate

Public Sub New () 'Constructor MyBase.new () ObjDatabaseOperate = New DatabaseOperate End Sub

Public Function Read_DJ31 () AS dataView 'Specifies the table name DIM STRTABLENAME AS STRING STRTABLENAME = "DJ31" Return ObjDATABASEOPERATE.READ (STRTABLENAME, "1", "1") End Function

Public Function IU_DateBase (ByVal Ds As DataSet, ByVal Op As String) As String 'will record the DataSet into the appropriate database, or updates the corresponding database data using DataSet' transaction Dim DbConn As SqlConnection DbConn = ObjDataBaseOperate.GetConnection 'from the physical layer Get database connections

DIM TX AS SQLTRANSACTION DIM I, J AS INTEGER DIM STRWRON AS STRING = "" "

TRY dbconn.open () tx = dbconn.begintransaction

For i = 0 to ds.tables.count () - 1 'Call the INSERT function of the entity layer Insert all the data of all Table in the DS into the database for j = 0 to ds.tables (i) .Rows.count ( ) - 1 if op = "add" Then ObjdatabaseOperate.Insert (dbconn, tx, ds.tables (i) .rows (j)) elseif op = "edit" Then ObjDATABASEOPERATE.UPDATE (DBCONN, TX, DS.TABLES (i .Rows (j)) end if next Next

Tx.commit ()

Catch e as exception tx.rollback () strwrong = e.tostring beep () finally dbconn.close () end try

Return Strwrong End Function

Public Function Delete_DJ32DJ33 (ByVal StrID As String, ByVal StrFileID As String) As String Dim DbConn As SqlConnection = ObjDataBaseOperate.GetConnection Dim Tx As SqlTransaction Dim StrTableName, StrField, StrParameter, StrField2, StrParameter2 As String Dim StrWrong As StringDbConn.Open () Try Tx = DbConn.BeginTransaction strTableName = "DJ32" StrField = "DJ32_000" StrParameter = strID StrField2 = "DJ32_001" StrParameter2 = StrFileID ObjDataBaseOperate.Delete (dbConn, Tx, strTableName, StrField, StrParameter, StrField2, StrParameter2)

StrTableName = "DJ33" StrField = "DJ33_000" StrParameter = StrID StrField2 = "DJ33_001" StrParameter2 = StrFileID ObjDataBaseOperate.Delete (DbConn, Tx, StrTableName, StrField, StrParameter, StrField2, StrParameter2)

ObjdatabaseOperate.Update_dj32dj33 (dbconn, tx, strid, strfileid)

TX.com Exception TX.Rollback () beep () strwrong = ex.toString Finally dbconn.close () end TRY

Return Strwrong End Function

Public Function Insert_Row (Byval DR As DataRow) AS String ObjDatabaseOperate.Insert (DR) End Function

END CLASS

转载请注明原文地址:https://www.9cbs.com/read-21121.html

New Post(0)