Page 1
Page 2
GUI Design
As you can see in the screenshots I
designed the GUI using a Tab Control. Don't be surprised
if the Tab Control in the Designer looks different then
in the emulator or on the device; this is known Beta Issue.
All the other buttons and dropdown lists are used the same
way as in a common Windows Forms Application.
One thing I truly missed for data representation
was a datagrid (Microsoft says it will be in the release
product) so I decided to use the ListView control. When
playing with that control be aware you might get some "unhelpful"
errors. For example when I didn't have the right classification
of ListView Items and SubItems I only got an Error - nothing
else, no Error Number, no Error Message. Some further advice
concerning the ListView: Don't forget to set the ListView
Item and Subitem to NULL after every sequence.

The general layout consists of three
Tabs. On the first Page the user can get the user names
and passwords after selecting company and application. This
page also offers the option of entering a new password for
a particular user.

The second page allows a user to enter
new companies, applications and users (and their credentials).
The third Page allows to do some tasks that I have not yet
implemented.

Function coding
If you have a look at the source code
of the application, you will see that I had to add a lot
of functions to populate the DropDown Lists and to insert
data into the database. The following snippet points out
how I retrieve Data out of the SQL CE Database and bind
it to the Control.
Sub bindfirma()
Dim dr As SqlCeDataReader
Dim command As New SqlServerCe.SqlCeCommand
&_
("select company from company",
cn)
'Connection is defined ouside snippet
!
cn.Open()
dr = command.ExecuteReader()
auswahl_firma.Items.Clear()
Do While dr.Read
auswahl_firma.Items.Add(dr.Item(0).ToString)
Loop
cn.Close()
DR = Nothing
End Sub
I preferred to use the SQLCEDataReader
for this task because it allocates less memory than the
DataSet and is easily destroyed after the population of
the control.
The last snippet shows how to insert
data into the SQL CE Database. After the Insert-Statement
is created it is used as a parameter in a command object
that is executed as a "non query". All Insert
Statements are encapsulated by a try-catch construction
so that any problems are reported to the user.
Private Sub firma_eintragen_Click(ByVal
sender &_
As System.Object, ByVal e As &_
System.EventArgs) Handles firma_eintragen.Click
If firma.Text <> ""
Then
Dim command As New SqlCeCommand("insert
&_
into company (company) values
('" & &_
firma.Text & "')",
cn)
Try
'Connection is
created outside that snippet !
cn.Open()
command.ExecuteNonQuery()
StatusBar1.Text
= "Company successfully &_
created"
StatusBar1.ForeColor
= Color.Black
Catch err As SqlCeException
StatusBar1.Text
= "Company already exists"
StatusBar1.ForeColor
= Color.Red
Catch err As Exception
StatusBar1.Text
= err.Message
Finally
firma.Text = ""
cn.Close()
End Try
Else
StatusBar1.Text = "supply a
Company"
StatusBar1.ForeColor = Color.Red
End If
End Sub
The next enhancements
As you can see in the last panel, there
are some functions I haven't coded yet, due to a lot of
project work that has to be done (and that of course puts
the bread on the table), so in the next month I´ll
code the following functions
- Encryption/Decryption of the Database
- Replication with a Desktop SQL Server
- Compact the atabase file
- Clean the database of useless records
- Deletion of unused companies/applications/users
That's all for my first showcase
of a CF and SQL CE 2.0 application, I hope you enjoyed it
and I´ll be back soon with some enhancements soon.
Previous Page