Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Capture Signatures Remotely from Your Pocket PC : Page 2

You don't have to work for Federal Express to outfit your delivery or salesforce with a remote signature capture and transmission feature. With just a Pocket PC and the simple instructions herein, you'll soon be sending John Hancocks to and from your server with accuracy and grace.


advertisement
Testing the Signature Control
You can now test the signature control. Back in Form1, double-click on it to reveal the code-behind. Code the following:

Public Class Form1 Private sig As New Signature Private Sub Form1_Load( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles MyBase.Load With sig .Location = New Point(3, 180) .Size = New Size(233, 73) .Enable = True .InitSignature() End With Me.Controls.Add(sig) Me.Refresh() End Sub End Class

Essentially, you are programmatically adding the signature control to the form. Press F5 to deploy it to an emulator (or a real device) and you should now be able to write on the signature control (see Figure 6).




Figure 6. Testing the signature control on an emulator or a real device is now possible.
 
Figure 7. Populate Form1 with the various controls as shown here.

Sending Signatures to Backend Server
Now that you have the signature control ready, it is time to code the logic to send the signature to a backend server. For this, you will use sockets communication.

Add a new class to the current project and name it Sync.vb. Populate it as follows:

Imports System.Net Imports System.Net.Sockets Public Class Sync Const portNo As Integer = 3456 Private client As Socket Public Sub PerformSync( _ ByVal HostIP As String, _ ByVal txtData As String) Try Dim RemoteAdd As System.Net.IPAddress = _ System.Net.IPAddress.Parse(HostIP) Dim endPoint As New IPEndPoint(RemoteAdd, portNo) client = New Socket(endPoint.AddressFamily, _ SocketType.Stream, ProtocolType.Tcp) client.Connect(endPoint) '---send a message to the server Dim data As Byte() = _ System.Text.Encoding.ASCII.GetBytes(txtData & "*") '---send the text--- client.Send(data) MsgBox("Data sent!") client.Close() Catch ex As Exception MsgBox(ex.ToString) End Try End Sub End Class

Author's Note: Most of the code for socket communication is similar to that used in my previous article, "Take Your Apps Far and Wide with a GPS Tracking System."

Back in the code-behind for Form1, add the following member variables:

Public Class Form1 Private sig As New Signature '---use for synchronization--- Private sync As New Sync '---IP address of the server--- Private ServerIP As String = "10.0.1.2" '---the ID of the user--- Private ID As String = "1"

Author's Note: Substitute "10.0.1.2" with the IP address of your own server. More on this in the next section.

Using the data-binding feature of Visual Studio 2005, bind the SQL Mobile database Northwind.sdf to a DataGrid control (see Figure 7) and add a Send menu item.

Author's note: You can refer to this screen cast to understand how to bind a table in a database to a DataGrid control.

Code the Send menu button as follows:

Private Sub MenuItem1_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles MenuItem1.Click '---send to the server--- Dim OrderID As String = _ OrdersDataGrid.Item( _ OrdersDataGrid.CurrentCell.RowNumber, 0). _ ToString() sync.PerformSync(ServerIP, ID & "#" & OrderID & _ "#" & Now & "#" & sig.Signature) '---clear the signature--- sig.InitSignature() End Sub

Essentially, you are sending the following information to the server:
  • ID of the person making the delivery
  • Order ID
  • Date and time of delivery
  • Signature of the recipient


Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap