Visual Studio 2015 - POS System Project

Create User Registration/Login Form

Posted by P.O.S System on July, 2019

Remember, you are creating this application for someone else "Client", "User" or Customer". You need to measure and calculate all possible risk and consider all possible bugs due to running your application on different OS than yours. your client will be the owner of your project and the "Admin". You have already Pre-defined "Admin" credentials "{Username, Password, UserRole}" for him in your MS-Access 2007 Database "mydb.accdb" table "usrs" in the Prev. chapter "P.O.S System Project Planning".

I will provide a source code for each part I finish separately. In the end of the parts there will be a source code for the whole project in one file. You may find the source code for this part ("VS2015-User Registration/Login Form") in the end of this part. All the source codes are under GPL lisence.

What does User Registration/Login Form simply do ?

In a small P.O.S Sytem Project like this, it won't do much but its existance is neccessary for multi-users (User1, User2) in stores or shops or multi-shifts (Day & night).

It limits the users from accessing certain Forms (i.e: Stock, Cash)
It shows each user process or trasactions (i.e: User1 sold an item, User2 sold 5 items ..... etc)
It makes it easier for "Admin" to calculate the amount of cash in the cash drawer, and determind any loss and the responsible.

User Registration/Login Form Design.

It needs to be so simple and efficient, easy to use and secure, user-friendly and powerful. You only get to acchieve this by a well-coded database in your project. We already secured the Database "mydb.accdb" with a password. We will use OleDBParameters to avoid Sql Injections.

Free POS Project Source Code VB.Net Download P.O.S System Project User Registration/Login Form Design.

As you can see above it consists of some common Visual Studio Tools from the Toolbox Textboxes, Labels, Buttons, Picturebox ErrorProvider, Timer, ToolStrip. There are also some Modules in the Project Solution that I've created to manage this stage of the main P.O.S System Project.

User Registration/Login Form Modules.

Connections.vb : Contains the General Declaration, Functions and Sub to work with the Database
This module will have more codes as I go, and each section will be mentioned in its part.
I pre-defined the Database path, name, ConnectionString for OleDb.
Function LoggedInAs Returns a String value {"Admin","User"} indicating which UserRole is in use now.
Function OpenCN Returns a String value {"Open","Close"} indicating the Database State.
Sub ExecuteCmd Connects the OleDbCommand to OleDbConnection without executing Sql Statement.
Function ChkDupl Returns a Boolean value {"True","False"} indicating any Duplications in {"Admin"} username record.
Function GetUserRole Returns a String value {"Admin","User"} indicating the UserRole from Database Table.
Sub LoadMyReport Connects the Crystal Report to the CrystalReportViewer.
Sub DGFromTbl Populate the DataGridView with any table using any Sql Statement.

User Registration/Login Form Coding.

When the P.O.S application runs, the Login Form appears and asks the User/Admin to enter credentials {"Username","Password"}, now we only have a pre-defined credentials for "Admin".

Admin creates Users, Admin/Users username is Unique. We set it in the database table 'usrs' and we coded it in the Connections.vb Module by Function ChlDupl.

When specifying the correct credentials for the "Admin", you get to Create "Users" from another Form called ("CreateUsrs.vb"). The Form ("CreateUsrs.vb") enables the "Admin" to create as many users, it also has a DataGridView populated with Users/Admin Credentials, and it has the ability to Edit/Delete/Search.

Admin can Edit his credentials, but not to delete it. Admin can Add/Edit/Delete/Search Users. Admin Can not Add new "Admin"

Create-Users Form Design

This form is only accessible by "Admin". This form can only be accessed from Main Form. CreateUsrs.vb Form also has a common tools from Visual Studio 2015 Toolbox Textboxes, Labels, Picturebox, DataGridView, MenuStrip, Timer

download free POS System Project Visual Basic 2015 P.O.S System Project CreateUsers Form Design.

Create-Users Form Coding.

Admin Navigate to CreateUsrs.vb Form to create new {"UserRole : User, Username: User1, Password: User1Password, UserPic"} and hit Save, if no Error with Database and Table and no duplication with Admin credentials the process pass successfully and you find a new record in the table "usrs", and The DataGridView adds new DataGridViewRow contains the new User credentials and Photo.

I used OleDbParameters with Add/Edit/Search/Delete commands to avoid Sql Injections to my MS-Access2007 Database table 'usrs' in "mydb.accdb". You will find the source code with comments to explain each process.

Be careful with Populating MS-Access 2007 with Photo with big size, because it will take much space in your application folder and make it hard to save/retrieve photos to the DataGridView. The DataGridView is also populated with user credentials and user photo as well. Choosing large photos wil cause the application to wait and hang alot.

Navigating through DataGridView will populate the Textbox with credentials from DataGridViewRows Entered and populates the Picturebox with photo from DataGridViewRow. Admin may edit his own dredentials and photo, but not to delete it. Admin may choose or search for a user in the DataGridView and Edit his/her credentials and photo then hit Edit/Delete From MenuStrip tool or using ShortCut Keys pre-defined in the project (I.e: Edit: Ctrl+E, Save: Ctrl+S, Delete: Del).

User Registration/Login Form Testing.

Now, I will create two users to test with {"DayShiftUser, user1password, user, photo1","NightShiftUser, user2password, photo2"}. If everything goes fine so far, I will see DataGridView populated with three rows {"Admin","DayShiftUser","NightShiftUser"} and three photos.

POS 2019 Free Download Source Code in P.O.S System Project - User Registration/Login Form Test.

Now that we successfully built the User Registration/Login Form for our Small P.O.S System Project in Visual Studio 2015, we will then continue to create some tables (I.e : Purchase, Sell, Stock, ..... etc) and Visual Studio 2015 Forms (I.e: PurchaseForm.vb, SellForm.vb, ... etc) in the next chapters.

We have so far

Visual Studio 2015 Project
Microsoft Access Database 2007 with one table called "usrs"
Pre-defined "Admin" credentials {"POS_Admin",""}
MainFrm.vb Form for Users/Admin Login
CreateUsrs.vb Form for Admin to create/Edit/Delete users.
Admin created two users {"DayShift","NightShift"} with credentials and photos.
Populate MS-Access2007 with Photos from Picturebox
Populate DataGridView with photos from MS-Access2007 Database table 'usrs'
Save/retrieve photo from/to Picturebox/DataGridView from/to MS-Access2007 Database table 'usrs'

Download Source Code →