Implementing Specialized Data Capture Applications with InVision Development Tools (Part 1)

Size: px
Start display at page:

Download "Implementing Specialized Data Capture Applications with InVision Development Tools (Part 1)"

Transcription

1 Implementing Specialized Data Capture Applicatins with InVisin Develpment Tls (Part 1) [This is the first f a series f white papers n implementing applicatins with special requirements fr data capture such as barcdes, signatures, and magnetic stripes. This white paper is fcuses n implementing scan-enabled applicatins.] There Are N Prblems, Just Opprtunities S, yur bss just called yu and tld yu that yur cmpany s manufacturing business has increased 10-fld due t successful advertising. He needs an applicatin t scan items as they are received at the warehuse receiving dck and update the cmpany s asset database prnt. Wrse, there are hundreds f items n the receiving platfrm and the warehuse guys are threatening t strike because f the wrklad. Yur ne ally is the receiving clerk, wh has been lgging in items by hand until nw. Being a seasned IT prfessinal, hw d yu handle the situatin? Well, yu culd jump in and vlunteer t pull all-nighters with the receiving clerk fr the rest f yur career, r yu culd finally mdify the inventry applicatin fr that scanning device yu bught a year ag. Scan-Enabling a Pcket PC Applicatin Let s assume yur cmpany has a simple MS-Access database. Yur challenge (pprtunity) is t get the item data frm the scanning device and update that database. We ll start with an embedded VB applicatin and InVisin s iscanit ActiveX cntrl. iscanit is an ActiveX Cntrl specifically designed t cntrl bar cde scanning n data cllectin devices. iscanit is fully scalable, and is available fr use n mst Windws-based platfrms. This custm cntrl prvides bar cde scanning capabilities fr inventry cntrl, warehuse management, pint f sale, identificatin and any ther data cllectin needs. Assuming yu have purchased a cpy f iscanit and installed and registered the cntrl n yur develpment desktp, let s fire up evb. We re ging t use a Symbl 2800 device with the Pcket PC O/S fr this prject. We ll make this very simple and create a frm with three fields: Item Number this will receive the Item barcde, r allw the user t enter the barcde manually Lcatin this will be a simple pick list f lcatins dwnladed frm the database Quantity this will be a text field fr manual entry, but will additinally increment every time the user scans an item with the same barcde as the last item scanned. Creating the Scan Frm First, we must make evb aware f ur cntrls by ppulating its tlbx with sme f the cntrls frm the InVisin iscanit install. We re ging t use tw cntrls: iscanit, the InVisin Scan cntrl itself 2004 InVisin Sftware, Inc. 1 Implementing Data Capture Apps-1.dc

2 ScanText, a simple scan-aware cmpnent. Scan-aware cntrls are similar in sme respects t their standard evb cunterparts and cntain additinal prperties and events that further enhance data capture such as filtering the scanned data and telling us whether a match was fund. In Figure 1, we have already added the ScanText and iscanit cntrls t the tlbx. We gt t this pint by right-clicking n the tlbx, chsing Cmpnents t display the evb Cmpnents dialg bx and then selecting the InVisin ScanText Type Library and InVisin ActiveX Scan Cntrl cntrls. Ntice the small filter and barcde icns in the tlbx. iscanit and ScanText Figure 1: Adding the iscanit and ScanText Cntrls 2004 InVisin Sftware, Inc. 2 Implementing Data Capture Apps-1.dc

3 Nw we ll click n each icn in the tlbx and then click n the Scan Item frm t place the cntrls n the frm. Dn t wrry abut the iscanit cntrl; althugh it lks like it s visible n the frm, it is intrinsically an invisible cntrl. We will just drag it ut the way f any ther cntrl s we can click n it and view its design time prperties. Additinally, we will drag the ScanText cntrl alngside the Item Number label. Figure 2: Scan Item with ScanText We have t take nte f sme prperties f the iscanit cntrl and change t suit: iscanit: ScannerEnabled, Scanner Open - If bth ScannerOpen and ScannerEnabled are set t True at design time, the scanner device will be pened and enabled autmatically when the frm is laded. This is the simplest set f ptins. ScanText: Text: ScanText we ll change that t blank BrderStyle we ll change t True ScanCntrl This tells the ScanText cntrl which cntrl we are using t handle scanning. In this case it is the iscanit cntrl. This is nt a design-time prperty, s we ll have t set this in the frm s lad event: Private Sub Frm_Lad() ScanTextCtl1.ScanCntrl = iscanit1 End Sub Befre we lk at sme f the mre interesting scan-aware prperties, let s get sme immediate feedback: In ther wrds, see if the scanner wrks! Befre we can d anything, we have t lad the ScanText cntrl nt the handheld. The evb IDE can help us with this. Ensure the handheld has an ActiveSync cnnectin with the desktp, and Select Tls Remte Tls Cntrl Manager frm the main menu. This displays the Cntrl Manager Windw in Figure InVisin Sftware, Inc. 3 Implementing Data Capture Apps-1.dc

4 Figure 3: Cntrl Manager We ll select the O/S we re using in the left pane: Pcket PC. This displays a list in the right pane that tells us what cntrls are installed and accessible at design time vs. which nes are installed n the handheld device. Ntice that the InVisin cntrls are nwhere t be fund n this list we have t add them. Right-click anywhere in the right pane and select Add New Cntrl. Navigate t C:\Prgram Files\InVisin Sftware\iScanIt\Device and select the flder that matches the prcessr f yur handheld device. Fr this sample, we are develping fr an ARMPPC, r Armstrng Pcket PC-based handheld, s we will navigate t C:\Prgram Files\InVisin Sftware\iScanIt\Device\ArmPPC. Select the ScanText.cx and iscanit.cx files and click Open. This autmatically installs and registers the cntrls n the handheld. We are nw ready t tell evb t run ur applicatin! Chse Run Execute. evb shuld lad dwnlad and run ur applicatin, and the frm shuld display. Press the scan trigger n the handheld and scan a barcde with ne f the symblgies that are enabled by default, say Cde 39, Full ASCII. Yu shuld see the cntent f the barcde appear in the ScanText cntrl. Vila! We are just a few steps away frm a really useful applicatin and yur ascent t White Knighthd f the Receiving Clerks! 2004 InVisin Sftware, Inc. 4 Implementing Data Capture Apps-1.dc

5 Database Access It s a gd thing Micrsft chse t supprt ActiveSync synchrnizatin between MS- Access and the CEDB frmat fr its Pcket PC architecture, because it s ne f the cmpelling reasns t adpt it fr small, simple envirnments like ur sample. Using MS-Access, create a database called Inventry.mdb and create tw tables: tblinventrytransactins TransactinNumber (number, primary key) ItemUPC field (text, size 50) Lcatin field (text, size 50) Quantity field (number) tbllcatins LcatinID field (number, primary key) LcatinDescriptin field (text, size 50) Open the tbllcatins table and type in sme lcatins and assign each a unique LcatinID number. Real simple; n database gurus need apply. Obviusly, the transactins we receive need t be applied t a real Master Inventry database, but that is beynd the scpe f this article. Synchrnize the Database with the Handheld Using ActiveSync with the device cnnected, click the Optins Icn and check Pcket Access in the list n the Sync Optins tab (Figure 4). Nw click the Settings buttn and then click Add. Figure 4: Sync Optins 2004 InVisin Sftware, Inc. 5 Implementing Data Capture Apps-1.dc

6 Select the Inventry.mdb database, and in the next dialg bx (Figure 5), be sure t enter the cmplete path f where the Pcket PC versin (Inventry.CDB) f the Inventry.mdb shuld reside. Fr simplicity, enter the path f the.vb executable yu created. Yu can find this in evb Prject Prperties, General tab under the Remte Settings, Remte Path designatins. Fr ur prject it is \Prgram Files\WhitePaper\Prject1.vb, s \Prgram Files\WhitePaper\ is where yu want the Inventry.CDB database t reside. Figure 5: ActiveSync Imprt Database Dialg When cmplete, yu shuld end up with a Database Synchrnizatin dialg that lks like Figure 6. The database shuld synchrnize immediately. Figure 6: Database Synchrnizatin Settings 2004 InVisin Sftware, Inc. 6 Implementing Data Capture Apps-1.dc

7 Finish the Applicatin Add Database Cde Nw we ll g back t evb and add a cuple f fields we will need n the Inventry Frm: A drpdwn list named drplcatins t display the lcatins fr selectin A textbx named txtquantity t enter the quantity The frm shuld nw lk like Figure 7. Let s add the reference that ScanText requires s that it can receive scans frm iscanit. We als need t ppulate ur Lcatins drpdwn list with the chices frm the database. We ll d that in the main frm s lad event: Figure 7: Cmpleted Frm Private Sub Frm_Lad() scnitemnum.scancntrl = iscanit Reference t iscanit scnitemnum.text = "" stractivecnnectin = "\Prgram Files\WhitePaper\Inventry.cdb" 'Cnnect t database Set cnndata = CreateObject("ADOCE.Cnnectin.3.0") cnndata.cnnectinstring = "prvider=cedb;data surce=" & stractivecnnectin cnndata.open Dim rsdata As ADOCE.Recrdset On Errr Resume Next 'retrieve recrds frm database Set rsdata = CreateObject("ADOCE.Recrdset.3.0") rsdata.open "SELECT * FROM tbllcatins ", stractivecnnectin If Nt rsdata.bof And Nt rsdata.eof Then 'Add t list rsdata.mvefirst D While Nt rsdata.eof drplcatin.additem rsdata.fields("lcatindescriptin") drplcatin.itemdata(drplcatin.newindex) = rsdata.fields("lcatinindex") rsdata.mvenext Lp 2004 InVisin Sftware, Inc. 7 Implementing Data Capture Apps-1.dc

8 End Sub End If Set rsdata = Nthing rsdata.clse Als, we must add the cde that inserts the scanned item s barcde, it s lcatinid, and the quantity fund. We ll d that in the Save buttn s click event: Private Sub cmdsave_click() Dim lkey As Lng Dim currentnw As Variant ' will hld a date currentnw = Nw ' fixes the date and time at a pint in time lkey = CLng(CStr(CInt(Mnth(currentNw))) _ & CStr(CInt(Day(currentNw))) _ & CStr(CInt(Hur(currentNw))) _ & CStr(CInt(Minute(currentNw))) _ & CStr(CInt(Secnd(currentNw)))) cnndata.execute ("INSERT INTO tbltransactins (TransactinNumber, ItemUPC, LcatinID, Quantity) VALUES(" & lkey & ",'" & scnitemnum.text & "'," & drplcatin.itemdata(drplcatin.listindex) & "," & txtquantity.text & ") ") End Sub Sme Nice Additins We will need sme glbal definitins t handle database, etc.: Dim cnndata As ADOCE.Cnnectin Dim stractivecnnectin As String Dim strolditemnum As String A nice tuch t add is the ability t recgnize the last barcde scanned and autmatically increase the quantity by 1. We ll have t handle the Scan_Cmplete event frm the iscanit cntrl t d that. Just duble-click n the iscanit cntrl t generate the skeletn cde fr that default event, and fill it like s: Private Sub iscanit1_scancmplete(byval lstatus As Lng, ByVal strdata As String, ByVal llength As Lng, ByVal straimcde As String, ByVal lsymblgy As Lng) If (strdata = strolditemnum And IsNumeric(txtQuantity.Text)) Then txtquantity.text = CStr(CInt(txtQuantity.Text) + 1) Else strolditemnum = strdata txtquantity.text = "1" End If End Sub 2004 InVisin Sftware, Inc. 8 Implementing Data Capture Apps-1.dc

9 And finally, we clse the database cnnectin and disable and clse the scanner. If this is nt dne, the applicatin will never prperly clse, and the device may have t be warm-bted: Private Sub cmdquit_click() cnndata.clse iscanit1.scanneropen = False iscanit1.scannerenabled = False App.End End Sub Nw GO PLAY! Fire up the applicatin either with the RUN EXECUTE technique frm evb r just click n the.vb executable. Scan a barcde, select a lcatin. When yu scan a new item, the quantity shuld start at 1 and increment fr every barcde that matches the last ne. When yu are dne with an Item(s), click the SAVE buttn. G n t the next item and d the same thing. When dne, use ActiveSync t synchrnize the device. Then pen the Inventry database n the desktp and pen the tbltransactins. Yu shuld see the transactin recrds reflecting the items scanned, their lcatins, and the quantities fund. Next Installment In the next part f this series, we will use iscanit s symblgy selectin functins and filtering t deal with thse pesky barcde check digits! In additin, we will intrduce a very unique feature: Web-enabled scanning InVisin Sftware, Inc. 9 Implementing Data Capture Apps-1.dc