我希望使用 microsoft Visual Studio 2010 创建一个图表,但我不知道该怎么做。尝试用谷歌搜索答案,但没有一个是 3 层的。
这是我的数据访问层代码
public List<AdvertisementDAL> displayChart()
{
List<AdvertisementDAL> dal = new List<AdvertisementDAL>();
string sql = "Select * From AdvertisementRecord";
SqlConnection conn = new SqlConnection(_connStr);
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
_recordID = int.Parse(dr["RecordID"].ToString());
_recordDate = dr["RecordDate"].ToString();
_noOfClick = int.Parse(dr["NoOfClick"].ToString());
_noOfView = int.Parse(dr["NoOfView"].ToString());
_advertisementID = int.Parse(dr["FK_AdvertisementID"].ToString());
dal.Add(new AdvertisementDAL(_recordID, _recordDate, _noOfClick, _noOfView, _advertisementID));
}
conn.Close();
dr.Close();
dr.Dispose();
return dal;
}
}
这是我的业务逻辑层
public List<AdvertisementDAL> pieChart()
{
AdvertisementDAL dal = new AdvertisementDAL();
List<AdvertisementDAL> dll = new List<AdvertisementDAL>();
dll = dal.displayChart();
return dll;
}
这是我的表示层(我只知道将数据绑定在一起)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
AdvertisementBLL bll = new AdvertisementBLL();
Chart1.DataSource = bll.pieChart();
Chart1.DataBind();
}
}
我想我被困在表示层有什么帮助吗?酒吧看起来像这样