RISE to Bloome Software
Log In    
Home
RISE
Marshal
Download
 
 
Site Map Site Map
Link to Us Link to Us
r2bsoftware.se r2bsoftware.se
 
 
RISE Version 4.5RISE Version 4.5
RISE Visual ModelingRISE Visual Modeling
AJAX Code GeneratorAJAX Code Generator
 
 
Bookmark and Share
 
Click to hide navigation tree
Developing a Windows Client Application
In this example we show how to build a Windows Client Application for a RISE information solution. We assume that you are fairly accustomed to Visual Studio and Windows client programming so we'll focus on the RISE parts. Our example is a minimalistic inventory application with products and goods.
 
Sample solution
You may choose to follow this example by downloading the Visual Studio sample solution. The Visual Studio solution contains two projects; InventorySample and InventoryServer. The InventorySample contains our client. The InventoryServer contains the web service, generated by RISE, for the Inventory information model and is provided here for convenience. The Solution Items folder contains the RISE information model, Inventory.rise, and a SQL Server SQL script, generated by RISE, for setting up the inventory database model.
 
 
Prerequisited for running sample application:
  1. Create a SQL Server database, named InventorySample, and run the Inventory.sql script in the database to setup the database model.
  2. If the SQL Server isn't on your local machine (or you used another database name) modify the connection string found in Web.config of the InventoryServer project.
The Inventory model
Using RISE a small inventory has been modelled. It contains Products, categorized using Category and Producer, and Goods that represents the actual instances of a Product placed in one or more Locations.
 
 
The model is also provided with views, for combining information, and interfaces to publish entities and views. The below images shows the view, VProducts, needed to list the products together with their categorization and the interface, IProducts, added to expose the Product entity and the VProducts view to applications.
 
 
Building our Windows Client
Now let's build our client application. We envision it as a trivial spreadsheet for listing and working with products and goods, i.e. we skip any administrative functionality. Note that the RISE Editor can handle data - not only data models - so you may add configuration data such as categories, producers etc directly into the model and have it installed with your data model. That's a feature that will spare you considerable efforts in the early stages of implementation.
 
Step 1. Create a Windows Client project
Select File | New | Project in the menu of Visual Studio. This will display the New Project dialog. Select project type Windows and the project template Wndows Forms Application and give your application a suitable name, in this case InventorySample, and click OK.
 
Step 2. Add web references
Right-click on the project in the solution explorer in Visual Studio (upper right corner) and select "Add Web Reference...". This will display a dialog for creating a web reference. The dialog assists you in finding the web services.
  • If the web services are part of the solution, as they are in our sample project, simply click "Browse to web services in this solution".
  • If the web services are installed separately on the local machine click "Browse to web services on the local machine".
  • Otherwise, if installed on another sever, type in the URL to the web service manually.
Once a web service has been selected in the dialog type in an acceptable name. For some reason Visual Studio suggest a name based on the location of the web service rather than its name. Finally, click "Add Reference" to make Visual Studio setup the web reference as part of your project.
 
 
 
Step 3. Create your user interface
The user interface is created using drag and drop. We place a tab control on the form (dialog) and adds two tabs, Goods and Products, to it. On each of the tabs we place a data grid view control and adds the columns we're interested in to each data grid.
 
Step 4. Write your code behind
Here we just provide some limited snippets of code to display the principles. For more code samples look in the InventorySample project.
 
The following code is added to the Load method of the form to populate the data grid on the Goods tab with all existing goods. To do this we load the web reference named WS_IGoods pointing to the IGoods web service. Notice that we set the UseDefaultCredentials flag of the web reference. It is needed to support Windows Integrated Authentication. We then call the method VGoods that lists the view with same name. The loop creates a row in the data grid for each row returned by the VGoods methods. We set the Tag member of each row to the ID of the Goods to able easily identify the goods instance in other operations.
WS_IGoods.IGoods iGoods = new InventorySample.WS_IGoods.IGoods();
iGoods.UseDefaultCredentials = true;
foreach(WS_IGoods.returnVGoods goods in iGoods.VGoods(32768))
{
DataGridViewRow row = newDataGridViewRow();
row.Tag = goods.ID;
DataGridViewTextBoxCell volume = newDataGridViewTextBoxCell();
volume.Value = goods.Volume.ToString();
row.Cells.Add(volume);
// ASSIGN THE OTHER COLUMNS HERE
dataGridView1.Rows.Add(row);
}
iGoods.Dispose();
 
The below code is added in response to the user deleting a row in the Goods spreadsheet. The deletes the goods from the database as well. It's safe to do since, as seen in the model earlier in this article, no other table has a foreign key referencing Goods. What goods to delete is obtained from Tag member of the delete spreadsheet row (see previous code snippet).
int id = (int)e.Row.Tag;
WS_IGoods.IGoods iGoods = new InventorySample.WS_IGoods.IGoods();
iGoods.UseDefaultCredentials = true;
iGoods.DeleteGoods(id);
iGoods.Dispose();
When deleting products the code first needs to check that no goods are based on the product or handle the fact that the delete operation might fail.