Function InsertToDRMTest (sidClient As String) As Integer
Dim Ret%
Dim sData$
Dim s$
Dim screa$
Dim sa$
InsertToDRMTest = False
sData = "SELECT tpe_name,raisonsociale,identifiant,designation,matricule,type FROM client WHERE codeclient.xxkey=" + sidClient
Ret = pExecute(sData)
If Ret = True Then
TabSQLValue(1, 0) = OnSQLGetItem(0)
TabSQLValue(1, 1) = OnSQLGetItem(1)
TabSQLValue(1, 2) = OnSQLGetItem(2)
TabSQLValue(1, 3) = OnSQLGetItem(3)
TabSQLValue(1, 4) = OnSQLGetItem(4)
TabSQLValue(1, 9) = OnSQLGetItem(5)
s = "xxx" + TabSQLValue(1, 0)
sData = "SELECT codeclient FROM DRMTEST.dbo.client WHERE tpe_name.string='" + s + "'"
Ret = pExecute(sData)
If Ret = True Then
XasTrace "Client Déja dans DRMTEST!"
Exit Function
End If
sData = "SELECT codeenseigne,codeprogramme,codesite,codeclient FROM drmtest.dbo.client "
sData = sData + "WHERE type.integer IN (1, 8, 10) AND tpe_name.string LIKE '*xxx*'"
Ret = pExecute(sData)
If Ret = True Then
TabSQLValue(1, 5) = OnSQLGetItem(0)
TabSQLValue(1, 6) = OnSQLGetItem(1)
TabSQLValue(1, 7) = OnSQLGetItem(2)
TabSQLValue(1, 8) = OnSQLGetItem(3)
screa = Date$
Ret = pExecute("CLEAR")
sData = "INSERT INTO DRMTEST.dbo.client (codeenseigne,codeprogramme,codesite,creation,maj,type,raisonsociale,"
sData = sData + "tpe_name,identifiant,designation,matricule,tpe_statut,enabled) VALUES( "
sData = sData + "'" + TabSQLValue(1, 5) + "',"
sData = sData + "'" + TabSQLValue(1, 6) + "',"
sData = sData + "'" + TabSQLValue(1, 7) + "',"
sData = sData + "'" + screa + "',"
sData = sData + "'" + screa + "',"
sData = sData + "'" + TabSQLValue(1, 9) + "',"
sData = sData + "'" + TabSQLValue(1, 1) + "',"
sData = sData + "'xxx" + TabSQLValue(1, 0) + "',"
sData = sData + "'" + TabSQLValue(1, 2) + "',"
sData = sData + "'" + TabSQLValue(1, 3) + "',"
sData = sData + "'" + TabSQLValue(1, 4) + "',"
sData = sData + "'6','1')"
Ret = pExecute(sData)
If Ret = True Then
sData = "SELECT codesite FROM DRMTEST.dbo.linksite WHERE codeclient.xxkey=" + TabSQLValue(1, 8)
Ret = pExecute(sData)
While (Ret = True)
Ret = pTmpExecute("SELECT codeclient FROM DRMTEST.dbo.client WHERE tpe_name.string='xxx" + TabSQLValue(1, 0) + "'")
If Ret = True Then
s = OnSQLGetItem(0)
sa = pTmpGetItem(0)
sData = "INSERT INTO DRMTEST.dbo.client.linksite (codeclient,codesite) VALUES ('" + sa + "','" + s + "')"
Ret = pTmpExecute(sData)
End If
Ret = pMoveNext(0)
Wend
Ret = pExecute("SELECT codesite FROM DRMTEST.dbo.site WHERE codesite.xxkey=" + TabSQLValue(1, 7))
If Ret = True Then
If Val(TabSQLValue(1, 9)) = 1 Then
s = "6"
Else
s = "7"
End If
sData = "INSERT INTO DRMTEST.dbo.site.hardware (type,creation,maj,name,onprog,onpv) VALUES ( "
sData = sData + "'" + s + "',"
sData = sData + "'" + screa + "',"
sData = sData + "'" + screa + "',"
sData = sData + "'xxx" + TabSQLValue(1, 0) + "',"
sData = sData + "'" + TabSQLValue(1, 6) + "',"
sData = sData + "'" + TabSQLValue(1, 7) + "')"
Ret = pExecute(sData)
InsertToDRMTest = Ret
End If
End If
End If
End If
End Function
|