Developing in AppFrame
Before you can start developing forms using the AppFrameR3 framework you need to prepare your computer first. The following downloads that you have to install before starting are:
- Visual Basic 2008 Express edition (http://www.microsoft.com/express/download/)
- DevExpress Control package (http://www.devexpress.com/Downloads/NET/)
- CR3 Client
If you are running Vista you can either turn off the User Access Control in Vista or run the client with Administrative priveleges. The easiest way to do this is right click command prompt and select “Run as Administrator” and then type in the following: “C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Omega AS\MarketMaker R3.appref-ms”. Replace MarketMaker R3.appref-ms with the name of your application (in this case: CoP Training.appref-ms)
When you have logged in to the CR3 client, go to the Development Menu and set the Design Time ConnectionString. Also tick of the enable visual inheritance checkbox (required to have get full design-time access to DevExpress controls).
SourceControl, creating new projects.
To create a new form using AppFrameR3 framework, you need to get familiar with the new Source Control tool that is part of the CR3 Main Client. Here you can create your projects, upload and deploy them. You have versioning control, possibility to compare files with previous versions etc. If you like to change the source control folder, that can be done in under Tools->preferences in the file menu. Remeber to set this when you are doing first time installation.
After you have created a new project using the Create New in CR3 Projects, Visual Studio is automatically started and, based on what template you have chosen, a blank form is created for you. The connection to the database is already set up, so you don't have to think about that. In your toolbox you should have components from DevExpress available. In addition to these you need to include the AppFrame controls.
- Right click in the toolbox and press choose items.
- In the dialog that appears, browse and find the AppFrame3.Win.dll within the Sys.WinClient.ClientRuntime folder that is located under your CR3 source control folder.
AppFrame Controls
In addition to the control package from DevExpress and the built in controls in Visual Studio, we have developed a set of controls that gives the necessary functionality that is required to meet our client’s needs. We have derived from the DevExpress controls and added extended functionality so that we could achieve full server side interaction.
But the key object when developing in AppFrame is the afDataObject. This object takes care of the interaction with the database. Inserts, updates and deletes of records are automatically taken care of by the afDataobject.
afControls
afGrid
- Grid that is derived from the GridControl.
- Supports server side filtering and sorting
- Closely connected to afDataObject
- Support both standard GridView and Banded View
- Right context menu with events like filter by selection, sorting etc
- Copy/paste of rows and cells both from/to excel and within the grid
afGridLookup
- Supports server side filtering and sorting
- Own designer for building the record source and setting UI
- Support use in afGrid
afTextEdit
afWebBrowser
- Supports connecting to Teamdocuments applications by use of the credentials to the person logged in
afComboBox
- In addition to adding standard text items, it's also possible to create a RecordSource using the designer
afRichTextBox
afDataObject
- The keystone object when developing in CR3.
- Gives you possibility to create RecordSources to use in AppFrame/DevExpress/Windows controls.
- Supports connecting to other dataobject (master/child link)
- Own designer for building the RecordSources.
- Can only use views as RecordSources.
- Web Enabled (Supports Remoting )
- SQL Injection proof
afDataNavigator
- Navigation and data manipulation within the afDataObject.
In addition, there are a set of objects and functions that you can utilize in your code. For an overview, please visit this page: CR3 objects and functions
Deployment
To deploy your applications to test/production you have to build the application in release mode(right click on project and press the build button). Go to CR3Projects and press the upload and publish button. You have to be sure that the application is set to test/production mode in CR3Projects. If not the application won’t be published.
To add the application to the menu you need to use the menu admin tool. Basically it is the same behavior as the old on in access. Add the object to group and add permissions to it. Based on what you have read so far, you can take a look on this video that will demonstrate how you create a new master/detail form in CR3.
Video – “Create Master Details Forms”
Some AppFrame3 Coding Tips
When developing CR3 forms there is a lot that can be done without needing to write much code. Generally we advise you using the designer in Visual Studio as much as possible. When it comes to coding, less is better.
In the list of AppFrame controls there is one control that founds the keystone in the framework, the afDataobject. By having focus on this as the keyobject in database interaction, it will give you many advantages both when it comes to time and quality. For example you should try as much as possible to avoid doing updates through controls. In many cases it will give you lot of headache.
By studying the afDataObject and knowing the features of it, you will save yourself from a lot of unnecessary coding. There are a set of other objects and functions that is reachable through code that will, in most cases, meet your needs when it comes to interaction with the database. The following overview will show a more detailed view: legg til link
Snippets
Visual Studio has a utility that is called Code Snippets. Basically it is a block of reusable code that is packed into the framework. In the AppFrame framework we have added a set of snippets that might be of great use. Right click inside a vb file and click Insert Snippet-> My Code Snippets -> AppFrame.
Best Practices
- Keep it simple
- Keep the business logic on the server
- Less code gives less bugs
- Use AppFrame code snippets
- Follow standard naming conventions
- Keep the end user in mind when designing and make sure you have an intuitive application.
Tips
- Remember to format data in the controls when having numeric values by setting the DisplayFormat and EditFormat on the controls.
- In order to ensure sql safe dateformat, use vDateTime.toString("s") when getting value from control(s)
Best Practices designing forms
- Dock a panel to the top in the master section
- Dock a tab control to center for the detail viewing (this will then grow when re-sizing)
- When adding control to the master section, avoid using TableLayout control (difficult to maintain). You can add controls (Textboxes, Lookups, etc) directly to the panel.
- Remember to set the appropiate tab order
- In order to get proper styling, use DevExpress components (including AppFrame controls) as much as possible
- Standard designing rules applies.
- Use recommended naming convention when giving name to controls.(ex: cButtonUpload, cGridPerson, cGridViewPerson)
- Always use logical names on the controls
- When having many details with separate dataobjects you can gain performance by setting DisableAutoLoad = true on the dataobjects. Then force a RefreshDataSource on active object by listening to the ActiveTabChanged event
Steps to implement functionallity for changing between detailed view and datasheet view
- Add a splitterpane to the master/detail area.
- Add the master/detail data to splitterpane 1.
- Add the datasheet to splitterpane 2.
- Hide the splitterpane 2.
- Add a button for switching.
- When going to datasheetview, hide splitter1 and the parent splitterpane to the NavGrid, and show splitter 2.
- When going to formview, hide splitter 2 and show splitter1 and the parent splitterpane to the navgrid.
Upgrading to Current Main Client Build (R3Currentbuild service in TeamDev)
When upgrading to latest current build you need to do some manual work. The dll's are in most cases straight forward. You just need to add them as references and set the Copy Local property to true before publishing the main client to the site.
Unless you are using the Main Client without doing any customizing, some manual comparison is necessary. WinMerge is a good tool for comparing and merging files. You can download this free of charge from this link: http://winmerge.org/downloads/index.php
When this is done, and the new client is published, the last thing to do is upload the latest client runtime. By going into CR3Projects and searching for sys.winclient.clientruntime, you should upload the system dll's there.