📄 tabularreport.cs
字号:
using System;
using System.Data;
using System.Configuration;
using ASPNET.StarterKit.Reports.DataAccessLayer;
using System.Collections;
namespace ASPNET.StarterKit.Reports.Components
{
//*********************************************************************
//
// TabularReport Class
//
// The TabularReport class is used to represent a data item for Tabular
// Report and is mainly used to retrieve data from the database.
//
//*********************************************************************
public class TabularReport
{
private int _categoryID;
private string _categoryName;
private string _productName;
private string _quantityPerUnit;
private int _totalInStock;
private decimal _unitPrice;
private int _unitsInStock;
public int CategoryID
{
get { return _categoryID; }
set { _categoryID = value; }
}
public string CategoryName
{
get { return _categoryName; }
set { _categoryName = value; }
}
public string ProductName
{
get { return _productName; }
set { _productName = value; }
}
public string QuantityPerUnit
{
get { return _quantityPerUnit; }
set { _quantityPerUnit = value; }
}
public int TotalInStock
{
get { return _totalInStock; }
set { _totalInStock = value; }
}
public decimal UnitPrice
{
get { return _unitPrice; }
set { _unitPrice = value; }
}
public int UnitsInStock
{
get { return _unitsInStock; }
set { _unitsInStock = value; }
}
//*********************************************************************
//
// GetCategories method retrieves all available category names with total
// unit in stock information from the database and transforms the result
// to a TabularReportCollection custom colletion before returning it to
// the calling function.
//
// This method is called to get header information for the Tabular Report.
//
//*********************************************************************
public static TabularReportCollection GetCategories()
{
DataSet dsData = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings[Global.CfgKeyConnString], "Reports_GetCategories");
TabularReportCollection items = new TabularReportCollection();
foreach(DataRow row in dsData.Tables[0].Rows)
{
TabularReport item = new TabularReport();
item.CategoryID = Convert.ToInt32(row["CategoryID"]);
item.CategoryName = row["CategoryName"].ToString();
item.TotalInStock = Convert.ToInt32(row["TotalInStock"]);
items.Add(item);
}
return items;
}
//*********************************************************************
//
// GetProducts method retrieves all product details for the specified
// category from the database and transforms the result
// to a TabularReportCollection custom colletion before returning it to
// the calling function.
//
// This method is used to get detail information for each category in
// Tabular Report.
//
//*********************************************************************
public static TabularReportCollection GetProducts(int categoryID)
{
DataSet dsData = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings[Global.CfgKeyConnString], "Reports_GetProductsByCategory", categoryID);
TabularReportCollection items = new TabularReportCollection();
foreach(DataRow row in dsData.Tables[0].Rows)
{
TabularReport item = new TabularReport();
item.CategoryID = Convert.ToInt32(row["CategoryID"]);
item.ProductName = row["ProductName"].ToString();
item.QuantityPerUnit = row["QuantityPerUnit"].ToString();
item.UnitsInStock = Convert.ToInt32(row["UnitsInStock"]);
item.UnitPrice = Convert.ToDecimal(row["UnitPrice"]);
items.Add(item);
}
return items;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -