Access (“MS-Access”) is a popular desktop database for Microsoft Windows. It ranks among the top-10 databases on DB-Engines, and widely used in many Fortune-500 companies. Vendors, such as Hallam-ICS and QNE (Malaysia, Philippines) create business applications that use back-end Microsoft Access.
Winsoft Adonis is a component library for accessing databases which support the ADO programming model. All mainstream databases, such as MySQL, Embarcadero Interbase and FileMaker provide either ODBC or ADO connectivity drivers for Windows.
- Works with: Delphi, C++ Builder, VCL
- Works on: Windows 32-bit, Windows 64-bit
In this article, I created a small demonstration using Winsoft’s Adonis component library for connecting with Access.
Windows EXEs cannot run on Android, iOS, macOS or Linux. For that, you will have to use Delphi’s cross-platform FMX to target iOS, Android, macOS and Linux.
Table of Contents
Clinic ER (Entity Relation) Diagram
In this demo, I am going to create a Delphi VCL application that connects to an Access Database for a small clinic. The basis of the VCL application for this demo is the simple CRM demo included with Delphi 10.4 and C++Builder 10.4. The source code for the demo is linked at the end of the post.
In a clinic, there are three kinds of appointments: walk-in appointments, booked appointments (“I’ll be coming at 4pm on Thursday”), and ER. A booked appointment is only for one clinic. A patient cannot be in two clinics at the same time. At the time of the appointment, the patient sees one (or more) doctors at any one time, and tells his problems. The one (or more) doctors seeing the patients diagnoses and writes a prescription, gives it to the patient.
For brevity, hospital bedside visitations, doctor’s house-calls, pharmacy, dispensary, clinical health-education and consultation fees are left out.
Database Design
In this Clinic database, each table uses GUID for the primary key. This ensures that if you use the same database on two different computers and want to merge records, each row is unique and can easily be merged using JRO.
If you use auto-number or auto-increment, be aware you may end-up with the same primary keys and different data, making replication and de-duplication harder.
Clinic CRM
I converted Delphi Clinic CRM to use Winsoft’s Adonis. In this tutorial, I used Delphi 10.4 Update Patch 3.
The Patient Tab was re-factored to use Winsoft’s Adonis. The code-behind is minimal. It uses a TDataGrid connected to TWADODataSet.
In order to ensure unique names, the names field is split into four fields – First Name, Middle Name, Last Name and Suffix. This ensures, when you enter a name, you won’t address your letter to the senior person, when you refer to the junior person.
The Clinic section shows the process of patients
- coming to the clinic,
- in-clinic waiting to see the doctor,
- who have seen the doctor, and
- who left.
Code Highlights
The GUID for the each new record is initialized in the NewRecord event.
1 2 3 4 5 6 7 8 9 10 |
procedure TDM.dbPrescriptionsMasterNewRecord(DataSet: TDataSet); var uid: TGuid; res: HResult; begin res := CreateGuid(Uid); if res = S_OK then begin dbPrescriptionsMasterID.AsString := GuidToString(Uid); end; end; |
Before loading data, the grid redraw operation is temporarily paused using BeginUpdate and resumed using EndUpdate.
1 2 3 4 5 6 |
procedure TMainForm.PrescriptionsSearchBoxInvokeSearch(Sender: TObject); begin dgPrescriptions.BeginUpdate; DM.SearchPrescriptions(PrescriptionsSearchBox.Text); dgPrescriptions.EndUpdate; end; |
After a page-control update, such as a tab-change, I use the PageIndex property to ensure initial settings are fired in the PageControlUpdate event.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
procedure TMainForm.PageControlChange(Sender: TObject); begin if PageControl.ActivePageIndex = PatientsTab.PageIndex then begin PatientsButton.SetFocus; end else if PageControl.ActivePageIndex = CalendarTab.PageIndex then begin CalendarButton.SetFocus; end else if PageControl.ActivePageIndex = StaffTab.PageIndex then begin UsersButton.SetFocus; end else //... end; |
The code for this Clinic CRM demo can be downloaded here.
Head over and check out the full WINSOFT Adonis library for Access in Delphi and C++Builder.
Like what you see? You can get Adonis and over 100 other fantastic WinSoft components with our Enterprise Component Pack. For a limited time, when you purchase RAD Studio Enterprise or Architect Edition at special Upgrade Pricing, you will also get this package of third-party software worth over $13,000, including the full WinSoft Component Library, at NO EXTRA COST! Step up to RAD Studio 10.4 today!
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition