Sunday, 21 June 2009

A more sophisticated way of importing a database

The current Wessex Premier has a very simple way of checking a database to import - if it's not called "V3.mdb" it won't be imported. Now this works at a very simple level, but it leaves two problems

The first is that all the backed up files have to be called "V3.mdb" (rather than anything more convenient like say "ShopBackup_16_6_09.mdb"). You can get round this by renaming the file after exporting and back again before importing, but this is an awkward and fiddly way of dodging the issue.

The second problem is that although the file might be called "V3.mdb" the internal structure of the database (called the "schema") could have been changed and this would make it incompatible with the program.

So, is there a way of checking the schema of each table against a master schema-file?
There is, of course, otherwise I wouldn't be writing this!
This first thing to do is to extract the schema from the file to be imported. The crucial line of code is this -

dstSchema.Tables("V3Schema").WriteXmlSchema(xmlWriter)
Which writes the schema to a temporary (xml file) to compare against master xml schema.

Then the temporary file is then run (byte by byte) with the master file and each byte is compared, if they don't match then the file to be imported is rejected. The heart of the code is this -

Do
MasterByte = MasterStream.ReadByte 'master table
CheckByte = CheckStream.ReadByte 'table to be imported
If MasterByte <> CheckByte Then
blnOk = False
Exit Do
End If
Loop While MasterByte <> -1

This is done for each of the four tables in the program's database, as long as the file-to-be-imported passes the test it can be imported (its name is changed to "V3" for internal use).
Obviously there is a lot more code to set up the above lines - checking that the files exist, that the user hasn't pressed "Cancel" as so on - but in testing I haven't yet come across any problems, so it looks like this feature will be in Wessex Premier II.

Sunday, 7 June 2009

Sneak preview


"So, what are you working on now?" is a question I've often been asked at the Spring Fair.
The answer is a completely rewritten Wessex Premier. The basic idea being 2 programs in 1 - a basic frame pricing version which uses just the mouldings part of the database, but no worktickets or customers list. This could be upgraded to the full version when the user needs to - using the same database that has been built up. In this way one could get use to using the program just to give prices, and because it works in exactly the same way as the full version it will be much more straightforward to upgrade - you wouldn't even need another disk.


Another aspect I'm working on is improving the handling of database records, particularly worktickets, in the full version. At the moment in WPP3 the lists of work to be done, low moulding stock etc. are separate from the records themselves (ie. you have to close down the list having made a note of the record, then go to the record itself. Not very efficient.) Now you will be able to look at the list, double-click on the line of interest and the individual record will come up. Also, visually, the workticket list is easier to read being in name order with the Overdue, For completion and Completed jobs in different colours.

The third big change is adding mountboards to the database. The idea behind this is to record the mountboard colour in the database and then print a spot of that colour on the workticket. This way mistakes can be minimised (for instance Aqadia 8643 in quite a different colour to 8043).
To make everything even more foolproof when the list of mount colours comes up each line is the colour of the mountboard. It was an interesting piece of programming as the lettering (normally black) has to change depending on the lightness/darkness of each colour.

Now I'm at the stage of "tweaking" the program, for instance - if when you click on a workticket, do you want all the other worktickets on that same invoice to appear, or does that just complicate the process? Is putting the mount colours on the workticket actually an advantage? Only by using the program for real do these thing emerge.

There is a technical price to be paid however. Whereas the current Wessex Premier (WPP3) uses VB2003 with the .Net Framework 1.1 (a quick install). This new program is written in VB2008 and uses the .Net Framework 2.0 ( a much longer install), which is needed because the program has to shut down and restart (when switching between versions) and also for the new menu controls.
Another reason for going with the new program is better integration with Windows Vista & Windows 7 (here at the end of October). While at the moment most people use XP, as computers get changed and upgraded those using XP will get less and less (in fact Microsoft plan to stop supporting XP completely in 2014).

Will the new program see the light of day? We'll have to see!

Sunday, 17 May 2009

Some history, - in the beginning - - -

Way back in the days of the ZX Spectrum (over 25 years ago now) I was shown the basics of programming by the teenage sons of a colleague. It occurred to me that this would be an ideal way of pricing picture frames. Upto that point we had used a 2 way table - add the horizontal and vertical measurements together, then go down a column adding in the various items. This, of course regularly produced mistakes in the addition and the customers, looking at the long list charges, often wanted to know what each item was. The new simple program for the Spectrum solved all this, after a few key presses the price appeared on the screen, and the customers said "Yes please". I think I must be one of the few people who used the Spectrum for business rather than games!

For those who don't know of the Sinclair ZX Spectrum it was about the size of today's tablet PCs. It plugged into a TV and stored its programs on a cassette tape. The weakness was its keyboard, the rubber membrane kept giving up. After I got through 3 we bit the bullet and bought a PC (about £1000 20 years ago). This meant the program was rewritten in GW Basic and then with the coming of Windows 3.1 -QBasic. With each rewrite extra features were added.
There was none of the pretty interface of today, and the mouse was superfluous. To change the parameters you edited the program code directly (not quite the problem it appears as QBasic was bundled with Windows 3.1). It did show the way, however, so when I got hold of VB6 it was a revelation - you could, with a bit of work, produce a program that looked professional, was reliable and could easily be packaged for other people's computers.

The result was what came to be the original Wessex Pricing Program (wpp1). I took the CD along to the Spring Fair to show Wessex Pictures, and the rest, as they say, was history (actually it was the start of a steep learning-curve which is still going on).
The proof of the pudding is that the program is still regularly sold by Wessex.
More recent history will be covered in another blog.

nb. There is an update for wpp1 to allow for the increase in moulding costs since the CDs were originally printed - go to www.wessexpictures.com.

Wednesday, 6 May 2009

Troubleshooting bulk update


Wessex Premier is able to perform a bulk update on Wessex & Frinton moulding records. It's very useful to, say, add all the mouldings from Wessex (as, after all, you can order just one length with your weekly delivery). But as the list consists of somewhere in the region of 1300 records this is where the update-from-file comes in.

The program has proved to be very reliable in this area (you download the update files from the www.wessex.com, tell the program whether you want to just update the existing records or to update and add everything else, then navigate to the downloaded files and press go).

One point to note is that Wessex & Frinton share some mouldings (actually over 200), these are the "WFxxx" and "PWxxx" ranges. So, if you already have them listed under (say) Wessex when you update the Frinton section the program will report that it cannot add duplicate records.

Any problems that have arisen have always been to do with the update file itself. These files are in "Excel" format and are prepared by hand at Wessex, so one problem has been where an expected value hasn't been entered (usually the price has been left blank). Now, whilst the program updates now have more code to cope with this, it can cause the bulk update to stop.
The answer is to open the file with Excel and look for the blank values and then either - delete the line, or - put in a sensible value, save the file and rerun the bulk update. 9 times out of 10 this fixes the problem.
However, we did have one brainteaser where there was a whole blank line at the end of the file!
So that blank line had to be deleted, very strange getting your head around deleting something that wasn't there!

Wednesday, 22 April 2009

Designing the Wessex Premier GUI

A program can be amazingly sophisticated but unless the user can easily operate it then it's pretty useless. This is where a well designed GUI (graphical user interface), or in other words a good looking, easy to understand main form comes in.

The Wessex Premier main form is that shape because it is logical to start entering data from the top and with each new type of data continue downwards, finishing with what we all want to know - the total price.
Also it is important to stop the operator accidentally entering data that the program does not expect. For instance the top two size boxes will only accept numbers or a decimal point. The moulding boxes will only allow upto 5 characters (the maximum allowed for a moulding ID.) plus lower case letters are converted to upper case.
Next to the total price button is shown the quantity. Which is a numeric up/down control, numbers are changed using the small arrows rather than allowing the operator to enter them directly.

Those Visual Basic aficionados amongst you will have noticed that the buttons have a non-standard appearance. This is achieved programmatically rather than using bitmaps - the same goes for the graded background. The total effect is (I think) one of good design which helps promote intuitive usage as well as looking right in a sophisticated retail environment.

Whilst the most used part of the program is designed to be as quick & simple to use as possible, other parts the GUI is used to slow down the operator and give them pause for thought. One example is saving of the Options form.
It is purposely meant to be slightly out of the ordinary so the operator has to pause to decide what's going on, and in doing so may save themselves from making a mistake.

Of course what is invaluable is being able to test the program in a real environment with operators who don't really care how it works, just as long as they don't get into a mess with it! Here, the most lowly member of staff is as important(if not more so) than any number of "experts", because they are the ones who will produce the combination of keystrokes and mouse clicks that these experts haven't even conceived of!

Monday, 20 April 2009

Optimizing for Vista

It's taken quite a long time to get my hands on a computer capable of running Vista, a couple of months ago I managed it.
The obvious thing to do was to check that all the Wessex Programs worked. They did - WPP1 & WPP2 (written in VB6) had no issues. WPP3 however threw up a couple of interesting things.
The first was the graded colour background to many of the forms which finished (in Vista) before the bottom border. This is because the Menu & border widths are smaller in Vista, so I had to find code that would allow for XP & Vista. This turned out to be (instead of hard-coding for the physical width of the menu & border) to use "Me.DisplayRectangle.Height".
The 2nd issue was when opening another program (PDF reader or Media player) an error message appeared saying no application was associated with the process - the application then went on to open correctly! Annoying or what?
After a bit of digging I found the answer in "VB 2008" published by Wrox (it also applied to VB 2003 that WPP3 is written in). It was to add 1 line of code -
" myProcess.StartInfo.Verb = "Open"" It works without this line in XP, why does it need it in Vista?
Along the way I also tried a preview of the upcoming Windows 7 (Vista as it should have been) and found the programs were fine with that too.
So - Wessex now have the modified WPP3 (version 3.2.1) and all's well ?!

Saturday, 18 April 2009

View of Programs

The original Wessex Pricing Program(WPP1)


Wessex Pricing Program Advanced (WPP2)



The main form of Wessex Premier (WPP3)


.