|
<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= "blue"> public class</font> HierarchicalReport
<font color= "blue"> </font>{
<font color= "blue"> private </font>string _territoryDescription;
<font color= "blue"> private </font>decimal _salesTotals;
<font color= "blue"> private </font>int _employeeID;
<font color= "blue"> private </font>string _employeeName;
<font color= "blue"> private </font>string _employeeTitle;
<font color= "blue"> private </font>string _employeeAddress;
<font color= "blue"> private </font>string _employeeCity;
<font color= "blue"> private </font>string _employeeRegion;
<font color= "blue"> private </font>string _employeePostalCode;
<font color= "blue"> private </font>string _employeeCountry;
<font color= "blue"> private </font>string _employeePhone;
<font color= "blue"></font>
<font color= "blue"> public </font>string TerritoryDescription
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _territoryDescription; }
<font color= "blue"> set</font> { _territoryDescription = value; }
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"> public </font>decimal SalesTotals
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _salesTotals; }
<font color= "blue"> set</font> { _salesTotals = value; }
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"> public </font>int EmployeeID
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _employeeID; }
<font color= "blue"> set</font> { _employeeID = value; }
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"> public </font>string EmployeeName
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _employeeName; }
<font color= "blue"> set</font> { _employeeName = value; }
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"> public </font>string EmployeeTitle
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _employeeTitle; }
<font color= "blue"> set</font> { _employeeTitle = value; }
<font color= "blue"> </font>}
<font color= "blue"> </font>
<font color= "blue"> public </font>string EmployeeAddress
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _employeeAddress; }
<font color= "blue"> set</font> { _employeeAddress = value; }
<font color= "blue"> </font>}
<font color= "blue"> </font>
<font color= "blue"> public </font>string EmployeeCity
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _employeeCity; }
<font color= "blue"> set</font> { _employeeCity = value; }
<font color= "blue"> </font>}
<font color= "blue"> </font>
<font color= "blue"> public </font>string EmployeeRegion
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _employeeRegion; }
<font color= "blue"> set</font> { _employeeRegion = value; }
<font color= "blue"> </font>}
<font color= "blue"> </font>
<font color= "blue"> public </font>string EmployeePostalCode
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _employeePostalCode; }
<font color= "blue"> set</font> { _employeePostalCode = value; }
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"> public </font>string EmployeeCountry
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _employeeCountry; }
<font color= "blue"> set</font> { _employeeCountry = value; }
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"> public </font>string EmployeePhone
<font color= "blue"> </font>{
<font color= "blue"> get</font> { return _employeePhone; }
<font color= "blue"> set</font> { _employeePhone = value; }
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "green"> //*********************************************************************</font>
<font color= "green"> //</font>
<font color= "green"> // GetSalesByTerritory()</font>
<font color= "green"> //</font>
<font color= "green"> // This function calls the "GetSalesByTerritory" which retrieves the</font>
<font color= "green"> // sales totals for 1996, 1997, and 1998, grouped by Territory.</font>
<font color= "green"> // The items are added to the Array List and returned in the custom</font>
<font color= "green"> // thin class HierarchicalReportCollection.</font>
<font color= "green"> //</font>
<font color= "green"> //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue"> public </font>static HierarchicalReportCollection GetSalesByTerritory(int year)
<font color= "blue"> </font>{
<font color= "blue"> </font>DataSet dsData = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings[Global.CfgKeyConnString], "Reports_GetSalesByTerritory", year);
<font color= "blue"> </font>HierarchicalReportCollection items = new HierarchicalReportCollection();
<font color= "blue"></font>
<font color= "blue"> </font>foreach(DataRow row in dsData.Tables[0].Rows)
<font color= "blue"> </font>{
<font color= "blue"> </font>HierarchicalReport item = new HierarchicalReport();
<font color= "blue"> </font>item.TerritoryDescription = row["TerritoryDescription"].ToString();
<font color= "blue"></font>
<font color= "green"> // Check for nulls, as they may not have any sales for this period</font>
<font color= "blue"></font><font color= "blue"> if</font>(row["SalesTotals"] != System.DBNull.Value)<font color= "blue"></font>
<font color= "blue"> </font>item.SalesTotals = Convert.ToDecimal(row["SalesTotals"]);
<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"> // GetEmployeeSalesByTerritory()</font>
<font color= "green"> //</font>
<font color= "green"> // This function calls the "GetSalesByTerritory" which retrieves the</font>
<font color= "green"> // sales totals for 1996, 1997, and 1998, grouped by Employee, for</font>
<font color= "green"> // a particular Territory.</font>
<font color= "green"> //</font>
<font color= "green"> // The items are added to the Array List and returned in the custom</font>
<font color= "green"> // thin class HierarchicalReportCollection.</font>
<font color= "green"> //</font>
<font color= "green"> //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue"> public </font>static HierarchicalReportCollection GetEmployeeSalesByTerritory(string TerritoryName, int year)
<font color= "blue"> </font>{
<font color= "blue"> </font>DataSet dsData = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings[Global.CfgKeyConnString], "Reports_GetEmployeeSalesByTerritory", TerritoryName, year);
<font color= "blue"> </font>HierarchicalReportCollection items = new HierarchicalReportCollection();
<font color= "blue"></font>
<font color= "blue"> </font>foreach(DataRow row in dsData.Tables[0].Rows)
<font color= "blue"> </font>{
<font color= "blue"> </font>HierarchicalReport item = new HierarchicalReport();
<font color= "blue"> </font>item.EmployeeID = Convert.ToInt32(row["EmployeeID"]);
<font color= "blue"> </font>item.EmployeeName = row["EmployeeName"].ToString();
<font color= "blue"></font>
<font color= "green"> // Check for nulls, as they may not have any sales for this period</font>
<font color= "blue"></font><font color= "blue"> if</font>(row["SalesTotals"] != System.DBNull.Value)<font color= "blue"></font>
<font color= "blue"> </font>item.SalesTotals = Convert.ToDecimal(row["SalesTotals"]);
<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"> // GetEmployeeInfo()</font>
<font color= "green"> //</font>
<font color= "green"> // This function calls the "GetSalesByTerritory" which retrieves the</font>
<font color= "green"> // sales totals for 1996, 1997, and 1998, grouped by Employee, for</font>
<font color= "green"> // a particular Territory.</font>
<font color= "green"> //</font>
<font color= "green"> // The items are added to the Array List and returned in the custom</font>
<font color= "green"> // thin class HierarchicalReportCollection.</font>
<font color= "green"> //</font>
<font color= "green"> //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue"> public </font>static HierarchicalReportCollection GetEmployeeInfo(int employeeID)
<font color= "blue"> </font>{
<font color= "blue"> </font>DataSet dsData = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings[Global.CfgKeyConnString], "Reports_GetEmployeeByID", employeeID);
<font color= "blue"> </font>HierarchicalReportCollection items = new HierarchicalReportCollection();
<font color= "blue"></font>
<font color= "blue"> </font>foreach(DataRow row in dsData.Tables[0].Rows)
<font color= "blue"> </font>{
<font color= "blue"> </font>HierarchicalReport item = new HierarchicalReport();
<font color= "blue"> </font>item.EmployeeID = Convert.ToInt32(row["EmployeeID"]);
<font color= "blue"> </font>item.EmployeeTitle = row["Title"].ToString();
<font color= "blue"> </font>item.EmployeeAddress = row["Address"].ToString();
<font color= "blue"> </font>item.EmployeeCity = row["City"].ToString();
<font color= "blue"> </font>item.EmployeeRegion = row["Region"].ToString();
<font color= "blue"> </font>item.EmployeePostalCode = row["PostalCode"].ToString();
<font color= "blue"> </font>item.EmployeeCountry = row["Country"].ToString();
<font color= "blue"> </font>item.EmployeePhone = row["HomePhone"].ToString();
<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= "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.
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
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.