Skip to content
binodnp edited this page Sep 11, 2013 · 1 revision

Yet Another CRUD Tool! But Why?

Stay warned! MixERP invents its own wheels.

This just an opposite of ORM or CRUD frameworks that generate codes. The FormControl does not generate any code and is not an ORM tool. You will find a hundred free CRUD tools/frameworks available for the .net framework. Moreover, there are also some commercial products which do the job pretty well. But, none of the existing tools could be fit in our scenario.

The problem we found with the existing tools were:

  • Too much code generation.
  • Too much generalized and pre assumed.
  • Less control, too schema bound. This introduces a weird limitation to us by being forced to choose a single entity to work with. What if you wanted to display (Grid) the "X View" to the user and then present (Form) "Y Table" for insert, edit, or delete operation. MixERP solves this.
  • No provision to define the display fields of the foreign key on their base tables. This will be problematic in cases where your users would have to choose an arbitrary item id (ex 1345) or you would have to make the item name the primary key. What would users choose if the referenced primary key was a GUID column. MixERP again solves this without generating a single code.
  • No provision to exclude columns for insert. The tools fail to understand a simple concept that some columns could be either computed on the database level, updated by a trigger, or timestamp fields when manual manipulation should not be allowed.
  • No provision to add a policy for allowing and/or restricting the edit, insert, and/or delete operation based on application user or role.

What we call "FormControl" achieves its goal by automating the following major tasks, but without generating codes:

  • Displaying a paged database table
  • Adding a row to the database table
  • Editing the selected row
  • Deleting the selected row
  • Printing the displayed table
  • The source code can be found on the following directory:

Root/MixERP.Net.FrontEnd/UserControls/Forms/FormControl.ascx

The control exposes following properties

public bool DenyEdit { get; set; }
public bool DenyDelete { get; set; }
public bool DenyAdd { get; set; }
public string Description { get; set; }
public string DisplayFields { get; set; }
public string DisplayViews { get; set; }
public string Exclude { get; set; }
public string KeyColumn { get; set; }
public int PageSize { get; set; }
public string SelectedValues { get; set; }
public string Table { get; set; }
public string TableSchema { get; set; }
public string Text { get; set; }
public string View { get; set; }
public string ViewSchema { get; set; }
public int Width { get; set; }

More on Properties

DenyEdit

This property when set to true will restrict a user from editing the selected row. This property could be enabled at runtime depending upon the currently signed in user's role or authorization policy defined by the administrator.

DenyDelete

This property when set to true will restrict a user from deleting the selected row. This property could be enabled at runtime depending upon the currently signed in user's role or authorization policy defined by the administrator.

DenyAdd

This property when set to true will restrict a user from adding a new row to the view. This property could be enabled at runtime depending upon the currently signed in user's role or authorization policy defined by the administrator.

Description

This property's value, if set, will be displayed under the form title as an alert or information to the user. Refer to the following screenshot:

Description

DisplayFields

If the table has foreign keys, set this to a comma separated list of the name of the field or Column Expression to be displayed on the DropDownList control.

Column Expression

Expressions could be used instead of column name. Please refer to the following MSDN articles for more information on Expression Columns:

http://msdn.microsoft.com/en-us/library/zwxk25bd(v=vs.100).aspx http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression(v=vs.100).aspx

Syntax

Comma separated list of [Fully qualified column]-->[display_column or expression]

as in

DisplayFields="office.users.user_id-->user_name, core.accounts.account_id-->account_code + ' (' + account_name + ')'"

DisplayViews

This property when set a value will enable a popup selection of foreign keys by displaying the base tables. Set this to a comma separated list of the name of the Database View or Database Table to be displayed on the popup window.

Syntax

Comma separated list of [Fully qualified column]-->[fully qualified PostgreSQL view]

as in

DisplayViews="office.users.user_id-->office.user_view, core.accounts.account_id-->core.account_view"

Refer to the source code of BankAccount.aspx:

https://github.com/binodnp/mixerp/blob/master/MixERP.Net.FrontEnd/Finance/Setup/BankAccounts.aspx