Önceki Bakiye Kuralı (Site takipçimden)
sub ProcessEvent(App)
strDBUser = ".." ' SQL Server kullanıcı adı
strDBPass = "..*" ' SQL Server kullanıcısının şifresi
strDBServer = ".." ' SQL Server
strDBName = ".." ' Veritabanı adı
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" + strDBUser + ";Password=" + strDBPass + ";Initial Catalog=" + strDBName+ ";Data Source=" + strDBServer
conn.Open
Set rs = CreateObject("adodb.recordset")
rs.ActiveConnection = conn
ST_CariId = App.Doc.FieldAsString("ARP_LOGICALREF")
ST_DocNumber = App.Doc.FieldAsString("NUMBER")
ST_strQuery = "SELECT (SELECT SUM(DEBIT)-SUM(CREDIT) FROM LV_022_01_GNTOTCL WITH(NOLOCK) WHERE (CARDREF =" + ST_CariId + "AND TOTTYP = 1)) - NETTOTAL FROM LG_022_01_INVOICE WHERE FICHENO='" + ST_DocNumber+ "'"
rs.Open ST_strQuery, conn
oncekibakiye = rs.Fields(0).value
App.Doc.WriteStartElement "ADDITIONALDOCUMENTS/ADDITIONALDOCUMENT"
App.Doc.WriteElementString "ID",Replace(cstr(oncekibakiye),",",".")
App.Doc.WriteElementString "ISSUEDATE", Year(Date) & "-" & Right("0" & Month(Date),2) & "-" & Right("0" & Day(Date), 2)
App.Doc.WriteElementString "DOCUMENTTYPE", "ONCEKIBAKIYE"
App.Doc.WriteEndElement
rs.close
conn.close
App.Doc.SaveData
end sub