Toybox A4 Code

As promised, more code! This time for the Toybox A4 canvas demo page I created.

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Toybox A4</title>
 
	<script language="javascript" type="application/javascript">
 
		var example;
		var context;
		var b =0;
 
		function init() {
			example = document.getElementById('canvas1');
			context = example.getContext('2d');
			b=0;
			draw();
		} // end init
 
		function draw() {
 
			context.fillStyle = "rgb(255,255,255)";
			context.fillRect(0, 0, 800, 800);
 
			var icCount = 16;
			var number = Math.PI * 2 / icCount;
 
			for (n=1; n<= icCount; n++) {
 
				x = 200 + ((Math.sin(number * (17-(n/ Math.PI)) * b)) * (20+(n*8)));
				y = (n * 30) + 20;
				c = (17-n) * 16;
 
				// Draw background circle
				context.beginPath(); 
				context.fillStyle = 'rgb(255,255,255)';
				context.arc(x, y, 22, 0, Math.PI*2, true); 
				context.closePath();
				context.fill();
 
				// Draw Foreground circle
				context.beginPath(); 
				context.fillStyle = 'rgb(' + c + ',' + c + ',90)';
				context.arc(x, y, 20, 0, Math.PI*2, true); 
				context.closePath();
				context.fill(); 
 
			} // end for
 
			b += 0.04;
 
			setTimeout("draw()",33);
 
		} // end draw function
 
</script>
 
</head>
 
<body onload="init();" align="center" bgcolor="#FFFFFF">
	<canvas id="canvas1" width="400" height="800"></canvas>
</body>
 
</html>

SAP Business One Connection

SAPbobsCOM Company

In the first of (hopefully) many (providing I keep the momentum going) posts regarding coding, I have documented the VB.NET code required to connect and return a SAP Business One Company. So here we go.

    Private Function Company(server As String, userName As String, SecurePW As Security.SecureString, _
                             companyDB As String, dbUsername As String, dbPassword As String, _
                             ByRef errorMsg As String) As SAPbobsCOM.Company
 
        Company = New SAPbobsCOM.Company
 
        ' Get the secure password 
        Dim ptr As IntPtr = Runtime.InteropServices.Marshal.SecureStringToBSTR(SecurePW)
 
        ' Set up the connection to SAP 
        Dim returnCode, errorCode As Integer
        With Company
            .Server = server
            .CompanyDB = companyDB
            .UserName = userName
            .Password = Runtime.InteropServices.Marshal.PtrToStringBSTR(ptr)
            .language = SAPbobsCOM.BoSuppLangs.ln_English
            .DbUserName = dbUsername
            .DbPassword = dbPassword
            .UseTrusted = False
            .DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008
 
        End With
 
        ' Try and connect to the database 
 
        returnCode = Company.Connect
        If returnCode = 0 AndAlso Company.Connected = True Then
            ' Success! 
        Else
            Company.GetLastError(errorCode, errorMsg)
            If Company.Connected Then Company.Disconnect()
            Company = Nothing
        End If
 
    End Function

We’re assuming that we are connecting to a SQL Server 2008 instance. Also, the SAP User password is passed in via a SecureString for maximum security. I’ll post the code for a login form that exposes the SecureString password at a later date.

1 6 7 8 9