面向接口开发的一个架构(四)

Web展现层

1、PageBase.cs

ContractedBlock.gif ExpandedBlockStart.gif PageBase
 1ExpandedBlockStart.gifContractedBlock.gif/**//// <summary>
 2/// Summary description for PageBase
 3/// </summary>

 4public class PageBase : System.Web.UI.Page
 5ExpandedBlockStart.gifContractedBlock.gif{
 6    public IBusinessBase business = new BaseBusiness();
 7    public PageBase()
 8ExpandedSubBlockStart.gifContractedSubBlock.gif    {
 9       
10    }

11}

 

2、Log.aspx

ContractedBlock.gif ExpandedBlockStart.gif Log.aspx
 1ExpandedBlockStart.gifContractedBlock.gif<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Log.aspx.cs" Inherits="Log" %>
 2
 3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 4<html xmlns="http://www.w3.org/1999/xhtml">
 5<head runat="server">
 6    <title>Log Test</title>
 7</head>
 8<body>
 9    <form id="form1" runat="server">
10    <div>
11        <asp:GridView runat="server" ID="gvLogList" AutoGenerateColumns="True" CellPadding="4"
12            ForeColor="#333333" GridLines="None" ondatabound="gvLogList_DataBound">
13            <RowStyle BackColor="#EFF3FB" />
14            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
15            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
16            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
17            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
18            <EditRowStyle BackColor="#2461BF" />
19            <AlternatingRowStyle BackColor="White" />
20        </asp:GridView>
21    </div>
22    </form>
23</body>
24</html>

 

3、Log.aspx.cs

ContractedBlock.gif ExpandedBlockStart.gif Log.aspx.cs
 1public partial class Log : PageBase
 2ExpandedBlockStart.gifContractedBlock.gif{
 3    LogBusiness logBusiness = new LogBusiness();
 4
 5    protected void Page_Load(object sender, EventArgs e)
 6ExpandedSubBlockStart.gifContractedSubBlock.gif    {
 7        business.Init("Log");
 8        AddLog();
 9        GetLog();
10    }

11
12    private void AddLog()
13ExpandedSubBlockStart.gifContractedSubBlock.gif    {
14        Random rand = new Random();
15        int number = rand.Next();
16        DataSet ds = business.Get(0);
17        if (ds.Tables.Count > 0)
18ExpandedSubBlockStart.gifContractedSubBlock.gif        {
19            ds.Tables[0].Rows.Add(null"Name" + number, "Content" + number, DateTime.Now);
20            business.Add(ds);
21        }

22        else
23ExpandedSubBlockStart.gifContractedSubBlock.gif        {
24            Response.Write("Failed get table scheme,maybe database connect failed");
25        }

26    }

27
28    private void GetLog()
29ExpandedSubBlockStart.gifContractedSubBlock.gif    {
30        DataSet ds = business.Get();
31        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
32ExpandedSubBlockStart.gifContractedSubBlock.gif        {
33            gvLogList.DataSource = ds;            
34            gvLogList.DataBind();
35        }

36        else
37ExpandedSubBlockStart.gifContractedSubBlock.gif        {
38            Response.Write("No data in database");
39        }

40    }

41    protected void gvLogList_DataBound(object sender, EventArgs e)
42ExpandedSubBlockStart.gifContractedSubBlock.gif    {
43        gvLogList.HeaderRow.Cells[0].Text = "序号";
44        gvLogList.HeaderRow.Cells[1].Text = "名称";
45        gvLogList.HeaderRow.Cells[2].Text = "内容";
46        gvLogList.HeaderRow.Cells[3].Text = "时间";
47    }

48}

 

转载于:https://www.cnblogs.com/disappearwind/archive/2009/10/21/1587423.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值