(I apologize for missing files in the last zip file. If you downloaded this Application before March 1st 2006, please download again as this is the updated file. After downloading the file, please read readme.txt file and contact me at the article email if you have any questions.)
Introduction
Every programmer has a big dream "Programming without code". Practically a lot of database tools offer programming without code, the best two tools that I tried are Microsoft Access and PowerBuilder.
If you developed applications using Microsoft Access, you will realize that developing with Access is not as easy as you thought it would be at first sight. After you use the wizard and are happy with the generated application, you will realize that you do not have a menu or MDI forms. In addition, you cannot do many trivial things unless you change the normal flow of Access, for instance if you want to create a dropdown combo box and fill it with a certain value in filter form, you cannot do so and it is obvious that you cannot make a true .exe Application.
Rapid Application seems very powerful as long as it is driven in the normal way, and is hard to customize.
Power builder was another tool. It is much more powerful than Microsoft Access INMHO but, if you use a readymade library you have to understand it completely, because any customization means you need to override a function with a new one.
So the conclusion is, if you use a powerful programming tool (like ASP.NET, .NET Windows Forms, Delphi, C++ Builder (that is what I used)) with a powerful programming library to inherit and use, and you know how to enhance and override functions, it is the best solution.
Now here you are, that is .NET as a Rapid database tool.
I implemented this idea earlier in PowerBuilder with three levels of inheritance. It took three months to develop and once I finished it, it spread out very quickly and many companies used it.
So I can easily apply the same concept in .NET Application.
Just create the library and you will inherit and use it, and it automatically works fine and is more powerful and easy than Microsoft Access.
What we Expect from DNetlibrary?
Is exactly what you expect from a database tool that cover all of these areas:
- Build a form for each database table(s)/View(s).
- Lookup fields from other tables in case of foreign keys or any other relation.
- Navigate all records with nice customizable Navigator control.
- Build a menu to appear with each form with basic behavior (Last, Previous, Next, Last, Insert, Update, Save, Undo, Lock, Find, Sort,.. ) and with specific behavior.
- Bind shortcuts with user menu.
- Context menu with each Area (specially with Master detail forms) for navigation and basic actions.
- Filter screen with all searchable fields with friendly names (captions) with many combinations of criteria as possible.
- Sort screen with drag and drop facilities to put in order all the fields that you need to sort.
- Master Detail Form with all functionality of Automatic retrieving detail records and inserting Master Key in detail record with each Add or insertion.
- Find data screen with scrolling and highlighting data.
I PROMISE THAT YOU CAN DO ALL OF THAT WITHOUT ANY CODE, as long as you customize the library.
What is already Implemented in the DNetLibrary?
Actually I finished the navigation, and retrieving data, and programming all menus and shortcut functions.
I know you will be a little upset, but I will do my best to finish the rest of the functionalities as soon as possible.
But the good news is, if you understand how the library is created, you can very easily do the rest. And if you do, please email me to enhance the library.
What is the source of Information to let the library work?
Simply Typed Dataset is a copy of all tables and views in database with some meta data like Captions.
Does it mean that we will use a Great OOP Model to work as Data driven programming?
Absolutely not.
You still need the other tiers: Process Layer, Data Entity Layer, Business Object Layer, DALC Layer, Database Layer.
In many simple Applications, you need Just UI and DALC, and use Typed Dataset to represent Data Entity Layer.
In our case we will develop the UI Layer only, using a great feature of typed data set and data binding.
Structure of the library
The main classes in the library are:
DataHelper
class: that is the only class that will talk directly with the SQL database.
Utilities
classes: for formatting and other utilities, most of their methods are static
.
UC_DataWindow
: is the main class that applies all the UI features of the database tool including navigation, filtering, sorting, context menu, shortcut functions like menu, etc.
F_Single form
: is the basic simple form for database form of single object, like employee information, all database lookup tables, detail table if the master is already filtered to be 1 record,.. It also works in the master detail model that uses 2 forms, first form has the master record and other contains the detailed records.
Using the code
To use the code, you simply do two separate steps:
- Add new user control inherited from
UC_DataWindow
and add a typed dataset in this example DS_Pubs
, then add datagrid or bounded text(s) combobox(es) and list(s) as you wish, and configure the properties of the user object.
- Add a new form inherited from
F_Single
, then drag the userobject that you created and configure the properties of the form, then call this form from the main MDI form and you will enjoy all the functionalities.
Walkthrough create F_Job form
- Add a new inherited user control inherited from
UC_Datawindow
and name it UC_Job
Add a new dataset from toolbox and choose typed dataset and choose DS_PUBS
and name it ds_Pubs
. So you have now got the empty user control that has the typed dataset ds_Pubs
- Click properties of
UC_Job
, then set DS_Data
property as ds_Pubs
, set Table
as ds_pubs.jobs
and set retrieveAtOpening = true
.
- Add any data binding control(s). In this example add 4 text controls with 4 captions, add label and set the caption
job_id
then add textbox and set the name editjob_id
and in databinding select the text and set with ds_Pubs
- jobs.job_id
.
Actually you can generate all the data textbox controls automatically if you add a temporary form using DataForm wizard and choose dataset DS_Pubs
then choose Jobtable then choose single record / form.
Finally change the generated name of dataset to ds_Pubs
then copy all labels and controls and paste it in the UC_Jobs
, that is exactly what you achieved if you chose all labels and textboxes manually.
- Create the new Inherited form
F_Job
from F_Single
, then drag the UC_Job
from toolbox to the Form and then set these properties. Show the Form Property and set the UC_DataWindowObject
as uC_job1
. Show the uc_Nav
property and set UC_DataWindowMain
as uC_job1
- Run the form Add new menu item in
F_Main
. Form menu calls Jobs and onclick add this code:
private void m_Jobs_Click(object sender, System.EventArgs e)
{
F_Job form=new F_Job(); form.MdiParent=this; form.Show();
}
Now enjoy the F_Job
form and try to test all these options.
Navigate from the navigator until you reach the last record, then click next. It will roll and begin from the start again and the text box indicator will show the number of current record / number of records.
Points of Interest
The F_job
main menu will be embedded in the main menu, and still has its own context (pop up) menu.
If you tried with F9(First), F10(Next), F11(Prev), or F12(Last), you will realise the importance of inserting all the heavy code in the base class and inheriting all the functionality.
History
- V2 will include (God willing) Automatic Inserting, Updating, Saving, Sorting, Filtering
- V3 will include Master detail form
- V4 master record, details,... and Tree Support
I hope you enjoy the Application. If you have any comments and questions, mailto:wahib@iws-australasia.com