Business Rules: RowBuilder Attribute and Existing Rows

Similar documents
Calculated Fields in Data Controllers

Upload / Download of BLOB in AJAX Applications

GETTING STARTED WITH CODE ON TIME Got data? Generate modern web apps in minutes. Learn to create sophisticated web apps with Code On Time application

Programming Concepts and Skills. ASCII and other codes

COOKBOOK Creating an Order Form

USER GUIDE Conditional Visibility of Fields and Categories

Graphical Joins in More Detail

COOKBOOK Sending an in Response to Actions

Visual C# 2012 How to Program by Pe ars on Ed uc ati on, Inc. All Ri ght s Re ser ve d.

BIRT Report Object Model Base Elements

CSE 530A SQL. Washington University Fall 2013

Grouping and Sorting

.NET, C#, and ASP.NET p. 1 What Is.NET? p. 2 The Common Language Runtime p. 2 Introducing C# p. 3 Introducing ASP.NET p. 4 Getting Started p.

Getting Information from a Table

Activating AspxCodeGen 4.0

Module 5: Implementing Data Integrity

CS 1301 Ch 8, Handout 3

Handling hierarchical data

Eyes of the Dragon - XNA Part 33 Non-Player Character Conversations

Spring 2016 Programming Languages Qualifying Exam

chapter 2 G ETTING I NFORMATION FROM A TABLE

Exploring Code with Microsoft Pex

Introduction to Databases and SQL

Supplementary material for Bimodal Modelling of Source Code and Natural Language

IMPORTING DATA IN PYTHON I. Introduction to relational databases

A Summoner's Tale MonoGame Tutorial Series. Chapter 15. Saving Game State

A506 / C201 Computer Programming II Placement Exam Sample Questions. For each of the following, choose the most appropriate answer (2pts each).

Arrays: Higher Dimensional Arrays. CS0007: Introduction to Computer Programming

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

Introduction. What is Recursive Data? Reporting on Hierarchical Recursive data using MS Reporting Services Asif Sayed

Database Logical Design

Informatica PIM. Data Lookup via Java Transformations. Version: Date:

Database Programming with SQL

Manipulating Data. Copyright 2004, Oracle. All rights reserved.

Oracle Database 10g Express

SECTION 1 DBMS LAB 1.0 INTRODUCTION 1.1 OBJECTIVES 1.2 INTRODUCTION TO MS-ACCESS. Structure Page No.

INHERITANCE. Spring 2019

DC69 C# &.NET DEC 2015

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

/* Copyright 2012 Robert C. Ilardi

JSUGA Tech Tips. Christoph Pickl,

Ad Hoc Reports. 1. Click on Reports. 2. Select Ad Hoc Reports from the menu. 3. To start a new report, Click on the at the top of the screen.

COMPUTER APPLICATION

Appendix A. Using DML to Modify Data. Contents: Lesson 1: Adding Data to Tables A-3. Lesson 2: Modifying and Removing Data A-8

Hands-On Lab. Lab 05: LINQ to SharePoint. Lab version: Last updated: 2/23/2011

Representing Recursive Relationships Using REP++ TreeView

Module 1: Creating an ASP.NET 2.0 Application

Including Dynamic Images in Your Report

Using DbVisualizer Variables

Creating Other Schema Objects

User Guide. Product Design. Version 2.2.2

RESTRICTING AND SORTING DATA

Exception/Error Handling in ASP.Net

Managing Your Database Using Oracle SQL Developer

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved.

Databases - Classic Models

User Guide Product Design Version 1.7

You can use Dreamweaver to build master and detail Web pages, which

CS 327E Lecture 2. Shirley Cohen. January 27, 2016

Center for Computation & Louisiana State University -

Let's explore these events by creating master-detail AJAX grid views that link Products to Suppliers in Northwind database.

Topics. Class Basics and Benefits Creating Objects.NET Architecture and Base Class Libraries 3-2

Database Foundations. 6-4 Data Manipulation Language (DML) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Peak ETA Developers Guide

ITCertMaster. Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way!

1- Differentiate between extends and implements keywords in java? 2- What is wrong with this code:

Concurrency and High Performance Reloaded

USER GUIDE Conversion and Validation of User Input

Generics in VB.net. Generic Class: The following example shows a skeleton definition of a generic class.

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Sun Certified MySQL Associate

Oracle 1Z Oracle Database 11g SQL Fundamentals I. Download Full Version :

Northwind Database. Sample Output from TechWriter 2007 for Databases

Chapter 2. DB2 concepts

Assignment Grading Rubric

Andrey Zavadskiy. Database Modeling In Practice

Hands-On Lab. Introduction to SQL Azure. Lab version: Last updated: 11/16/2010

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA

Lecture 10 OOP and VB.Net

Welcome to the Introduction to the Modeling Process for SAP Business One, version for SAP HANA.

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Report Designer Report Types Table Report Multi-Column Report Label Report Parameterized Report Cross-Tab Report Drill-Down Report Chart with Static

Volume CREATIVE DATA TECHNOLOGIES, INC. DATALAYER.NET. Getting Started Guide

Creating Tables, Defining Constraints. Rose-Hulman Institute of Technology Curt Clifton

Figure 1: Relationship among Three Entities/Tables

CS708 Lecture Notes. Visual Basic.NET Object-Oriented Programming. Implementing Client/Server Architectures. Part (I of?) (Lecture Notes 5A)

Recipe 4. In/Out Dashboard

Functions. CS111 Lab Queens College, CUNY Instructor: Kent Chin

Understanding GROUP BY and how ROLLUP/CUBE functions work

JavaScript Functions, Objects and Array

NEOGRID USER MANUAL (VERSION )

Introduction to C++ with content from

MATHCAD'S PROGRAMMING LANGUAGE The for Loop

Three types of sub queries are supported in SQL are Scalar, Row and Table sub queries.

Business Rule Builder


Oracle MOOC: SQL Fundamentals

Algorithms & Data Structures

CF SQLite Code Generator User Manual V

Transaction Management Chapter 11. Class 9: Transaction Management 1

Transcription:

Business Rules: RowBuilder Attribute and Existing Rows Northwind database has a cross-reference table EmployeeTerritories that link together an employee and a territory. Here is a user interface generated for this table by Data Aquarium premium project. List of employee territories is filtered by a region. Employee territory is displayed in edit form. 1 P a g e

While completely function this type of user interface will still benefit if we display a collection of all territories right on the employee screen and allow user to check mark territories that is user is responsible for. C R E A T I N G A P L A C E H O L D E R F I E L D F O R A L I S T O F T E R R I T O R I E S Open ~/Controllers/Employees.xml data controller and modify the text of command1 as shown below. Notice the new field Territories just before the from clause. This field is used just as placeholder and an actual value is going to be provided by a business rule. <command id="command1" type="text"> <text> <![CDATA[ select "Employees"."EmployeeID" "EmployeeID","Employees"."LastName" "LastName","Employees"."FirstName" "FirstName" 2 P a g e

,"Employees"."Title" "Title","Employees"."TitleOfCourtesy" "TitleOfCourtesy","Employees"."BirthDate" "BirthDate","Employees"."HireDate" "HireDate","Employees"."Address" "Address","Employees"."City" "City","Employees"."Region" "Region","Employees"."PostalCode" "PostalCode","Employees"."Country" "Country","Employees"."HomePhone" "HomePhone","Employees"."Extension" "Extension","Employees"."Photo" "Photo","Employees"."Notes" "Notes","Employees"."ReportsTo" "ReportsTo","ReportsTo"."LastName" "ReportsToLastName","Employees"."PhotoPath" "PhotoPath",,null "Territories" from "dbo"."employees" "Employees" left join "dbo"."employees" "ReportsTo" on "Employees"."ReportsTo" = "ReportsTo"."EmployeeID" ]]> </text> </command> Add new field to the list of fields. <field name="territories" type="string"> <items style="checkboxlist" datacontroller="territories" datatextfield="territorydescription"/> </field> Modify editform1 to include a reference to the field in the user interface of the form right after the FirstName field. We have specified 3 as number of columns for the field, which is supposed to be displayed as a check box list. 3 P a g e

<datafield fieldname="lastname" columns="20" /> <datafield fieldname="firstname" columns="10" /> <datafield fieldname="territories" columns="3"/> Run the sample application and start editing any employee record in form mode. Here is what you will likely see. None of the check boxes is checked. We will add a business rule to populate the check boxes. C R E A T I N G A B U S I N E S S R U L E T O P O P U L A T E A N E X I S T I N G R O W Open business rules class ~/App_Code/Class1.cs(.vb) that was created as described in the RowBuilder attribute introduction. Add the following method to the class. C#: 4 P a g e

[RowBuilder("Employees", "editform1", RowKind.Existing)] protected void PrepareExistingEmployeeRow() { int employeeid = Convert.ToInt32(SelectFieldValue("EmployeeID")); List<EmployeeTerritories> territories = EmployeeTerritories.Select(employeeId, null, null, null, null); StringBuilder sb = new StringBuilder(); foreach (EmployeeTerritories et in territories) { if (sb.length > 0) sb.append(","); sb.append(et.territoryid); } UpdateFieldValue("Territories", sb.tostring()); } VB: Protected Sub PrepareExistingEmployeeRow() Dim employeeid As Integer = Convert.ToInt32(SelectFieldValue("EmployeeID")) Dim territories As List(Of EmployeeTerritories) = _ EmployeeTerritories.Select(employeeId, Nothing, Nothing, Nothing, Nothing) Dim sb As StringBuilder = New StringBuilder() For Each et As EmployeeTerritories In territories If sb.length > 0 Then sb.append(",") End If sb.append(et.territoryid) Next UpdateFieldValue("Territories", sb.tostring()) End Sub 5 P a g e

The name of the business rule method is irrelevant. The rule will be automatically invoked when data controller Employees is preparing data for editform1 view and the form will be displaying an existing row. This method is called for each row returned to the client. Data Aquarium Framework only returns the exact number of rows that are requested by a client view. Method SelectFieldValue is inherited from the base class BusinessRules and allows to access values that will be returned for a row that is being built at this moment. We are obtaining a list of employee territories via business object EmployeeTerritories. Next we are creating a comma-separated list of territory IDs and update the value of the Territories field with the result accumulated in an instance of System.Text.StringBuilder. Please make sure to add System.Text namespace in the list of imported namespaces. Lookup item style CheckBoxList is designed to automatically handle comma separated lists of values. Here is how editform1 looks when we select a row. Text corresponding to each territory of selected employee is automatically matched to an ID of each employee territory. Here is how eidtform1 is transformed when user clicks on Edit button. 6 P a g e

C O N C L U S I O N RowBuilder attribute allows providing calculated field values for new and existing rows returned to a client script running in a browser. You can create fields that don't actually exist in your database and figure their values on-the-fly. There is still work to do when you need to save values of calculated fields. We will review this in the next post dedicated to ControllerAction attribute. Code OnTime LLC http://www.codeontime.com 7 P a g e