Click here to Skip to main content
15,892,746 members
Articles / Web Development / ASP.NET

Race to Linux - Race 3: Reports Starter Kit using Mono SqlServer/Firebird

Rate me:
Please Sign up or sign in to vote.
2.33/5 (2 votes)
30 Sep 20052 min read 53.1K   328   15  
Reports Starter Kit port to Linux using Mono
<html><head><link rel=stylesheet href=style.css></head><body><div class=SourcePanel style='font-size:12'><pre style='background-color:white'>
<font color= "blue">using</font> System;
<font color= "blue">using</font> System.Data;
<font color= "blue">using</font> System.Configuration;
<font color= "blue">using</font> ASPNET.StarterKit.Reports.DataAccessLayer;
<font color= "blue">using</font> System.Collections;
<font color= "blue"></font>
<font color= "blue">namespace</font> ASPNET.StarterKit.Reports.Components
<font color= "blue"></font>{
<font color= "green">    //*********************************************************************</font>
<font color= "green">    //</font>
<font color= "green">    // TabularReport Class</font>
<font color= "green">    //</font>
<font color= "green">    // The TabularReport class is used to represent a data item for Tabular </font>
<font color= "green">    // Report and is mainly used to retrieve data from the database.</font>
<font color= "green">    //</font>
<font color= "green">    //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">    public class</font> TabularReport
<font color= "blue">    </font>{
<font color= "blue">        private </font>int            _categoryID;
<font color= "blue">        private </font>string        _categoryName;
<font color= "blue">        private </font>string        _productName;
<font color= "blue">        private </font>string        _quantityPerUnit;
<font color= "blue">        private </font>int            _totalInStock;
<font color= "blue">        private </font>decimal        _unitPrice;
<font color= "blue">        private </font>int            _unitsInStock;
<font color= "blue">        </font>
<font color= "blue">        public </font>int CategoryID
<font color= "blue">        </font>{
<font color= "blue">            get</font> { return _categoryID; }
<font color= "blue">            set</font> { _categoryID = value; }
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "blue">        public </font>string CategoryName
<font color= "blue">        </font>{
<font color= "blue">            get</font> { return _categoryName; }
<font color= "blue">            set</font> { _categoryName = value; }
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "blue">        public </font>string ProductName
<font color= "blue">        </font>{
<font color= "blue">            get</font> { return _productName; }
<font color= "blue">            set</font> { _productName = value; }
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "blue">        public </font>string QuantityPerUnit
<font color= "blue">        </font>{
<font color= "blue">            get</font> { return _quantityPerUnit; }
<font color= "blue">            set</font> { _quantityPerUnit = value; }
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "blue">        public </font>int TotalInStock
<font color= "blue">        </font>{
<font color= "blue">            get</font> { return _totalInStock; }
<font color= "blue">            set</font> { _totalInStock = value; }
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "blue">        public </font>decimal UnitPrice
<font color= "blue">        </font>{
<font color= "blue">            get</font> { return _unitPrice; }
<font color= "blue">            set</font> { _unitPrice = value; }
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "blue">        public </font>int UnitsInStock
<font color= "blue">        </font>{
<font color= "blue">            get</font> { return _unitsInStock; }
<font color= "blue">            set</font> { _unitsInStock = value; }
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "green">        //*********************************************************************</font>
<font color= "green">        //</font>
<font color= "green">        // GetCategories method retrieves all available category names with total </font>
<font color= "green">        // unit in stock information from the database and transforms the result </font>
<font color= "green">        // to a TabularReportCollection custom colletion before returning it to </font>
<font color= "green">        // the calling function.</font>
<font color= "green">        //</font>
<font color= "green">        // This method is called to get header information for the Tabular Report.</font>
<font color= "green">        //</font>
<font color= "green">        //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">        public </font>static TabularReportCollection GetCategories()
<font color= "blue">        </font>{
<font color= "blue">            </font>DataSet dsData = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings[Global.CfgKeyConnString], "Reports_GetCategories");
<font color= "blue">            </font>TabularReportCollection items = new TabularReportCollection();
<font color= "blue"></font>
<font color= "blue">            </font>foreach(DataRow row in dsData.Tables[0].Rows)
<font color= "blue">            </font>{
<font color= "blue">                </font>TabularReport item = new TabularReport();
<font color= "blue">                </font>item.CategoryID = Convert.ToInt32(row["CategoryID"]);
<font color= "blue">                </font>item.CategoryName = row["CategoryName"].ToString();
<font color= "blue">                </font>item.TotalInStock = Convert.ToInt32(row["TotalInStock"]);
<font color= "blue"></font>
<font color= "blue">                </font>items.Add(item);
<font color= "blue">            </font>}
<font color= "blue"></font>
<font color= "blue">            return</font> items;
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "green">        //*********************************************************************</font>
<font color= "green">        //</font>
<font color= "green">        // GetProducts method retrieves all product details for the specified  </font>
<font color= "green">        // category from the database and transforms the result </font>
<font color= "green">        // to a TabularReportCollection custom colletion before returning it to </font>
<font color= "green">        // the calling function.</font>
<font color= "green">        //</font>
<font color= "green">        // This method is used to get detail information for each category in </font>
<font color= "green">        // Tabular Report.</font>
<font color= "green">        //</font>
<font color= "green">        //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">        public </font>static TabularReportCollection GetProducts(int categoryID)
<font color= "blue">        </font>{
<font color= "blue">            </font>DataSet dsData = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings[Global.CfgKeyConnString], "Reports_GetProductsByCategory", categoryID);
<font color= "blue">            </font>TabularReportCollection items = new TabularReportCollection();
<font color= "blue"></font>
<font color= "blue">            </font>foreach(DataRow row in dsData.Tables[0].Rows)
<font color= "blue">            </font>{
<font color= "blue">                </font>TabularReport item = new TabularReport();
<font color= "blue">                </font>item.CategoryID = Convert.ToInt32(row["CategoryID"]);
<font color= "blue">                </font>item.ProductName = row["ProductName"].ToString();
<font color= "blue">                </font>item.QuantityPerUnit = row["QuantityPerUnit"].ToString();
<font color= "blue">                </font>item.UnitsInStock = Convert.ToInt32(row["UnitsInStock"]);
<font color= "blue">                </font>item.UnitPrice = Convert.ToDecimal(row["UnitPrice"]);
<font color= "blue"></font>
<font color= "blue">                </font>items.Add(item);
<font color= "blue">            </font>}
<font color= "blue">            return</font> items;
<font color= "blue">        </font>}
<font color= "blue">    </font>}
<font color= "blue"></font>}
</pre>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Uruguay Uruguay
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions