• 分布式框架开发代码片段一


    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserExt.aspx.cs" Inherits="DistributedWeb.Sql.User.UserExt" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:GridView ID="GridView1" runat="server">
            </asp:GridView>
            <%if (mmodel != null)
              {
                  Response.Write(mmodel.ID + "<br/>");
                  Response.Write(mmodel.UserName + "<br/>");
              }
              if (emodel != null)
              {
                  Response.Write(emodel.CityId + "<br/>");
                  Response.Write(emodel.GetCity() + "<br/>");
                  Response.Write(emodel.GetNation() + "<br/>");
                  Response.Write(emodel.AddTime + "<br/>");
              }
            %>
        </div>
        </form>
    </body>
    </html>
    

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using DistributedModel.User;
    using DistributedBLL.User;
    
    namespace DistributedWeb.Sql.User
    {
        public partial class UserExt : System.Web.UI.Page
        {
            public DistributedModel.User.LoginUserInfo mmodel = null;
            public DistributedModel.User.UserInfo emodel = null;
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    BindData();
                }
            }
    
            protected void BindData()
            {
                LoginUserBLL bll = new LoginUserBLL();
                //根据条件获取主数据
                int totalCount = 0;
                List<LoginUserInfo> mainList = bll.FindListPage("id='1001'", 1, 1, 
                    out totalCount);            
                mmodel = mainList[0];
                //获取某信息的扩展数据泛型集合(可能多个扩展信息类)
                emodel = mmodel.GetExData<DistributedModel.User.UserInfo>("UserInfo");
    
                /*
                string userId = "1001";
                DistributedBLL.User.LoginUserBLL bll = new DistributedBLL.User.LoginUserBLL();
                //根据条件获取主数据
                mmodel = bll.FindById(userId);
                //获取某信息的扩展数据泛型集合(可能多个扩展信息类)
                DistributedBLL.User.UserBLL bll1 = new DistributedBLL.User.UserBLL();
                emodel = bll1.FindById(userId);
                */
            }
        }
    }
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AspNetPagerList.aspx.cs" Inherits="DistributedWeb.AspNetPagerList" %>
    
    <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
        <title>分页例子</title>
        <link href="/css/default.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td>
                    <asp:GridView ID="GridView1" runat="server" Width="100%">
                    </asp:GridView>
                </td>
            </tr>
        </table>
        <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td height="33">
                    <webdiyer:AspNetPager ID="AspNetPager1" runat="server" CustomInfoTextAlign="Left"
                        FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" NumericButtonTextFormatString="{0}"
                        OnPageChanged="AspNetPager1_PageChanged" PageSize="3" PagingButtonSpacing="8px"
                        PrevPageText="上一页" ShowCustomInfoSection="Left" LayoutType="Table" CssClass="pages"
                        AlwaysShow="true" CurrentPageButtonClass="cpb" NumericButtonCount="5" CustomInfoHTML="第<b>%CurrentPageIndex%</b>页/共%PageCount%页 每页显示%PageSize%条">
                    </webdiyer:AspNetPager>
                </td>
            </tr>
        </table>
        </form>
    </body>
    </html>
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using DistributedBLL.User;
    using DistributedModel.User;
    using DistributedUtil.Helper;
    using DistributedBLL;
    using DistributedWeb.BasePage;
    
    namespace DistributedWeb
    {
        public partial class AspNetPagerList : System.Web.UI.Page
        {
            LoginUserBLL loginbll = new LoginUserBLL();
            UserBLL userbll = new UserBLL();
            public List<LoginUserInfo> ulist = null;
            protected void Page_Load(object sender, EventArgs e)
            {
                LoginUser.IsLogin();
                if (!IsPostBack)
                {
                    GetData();
                }
            }
            public void GetData()
            {
                int RecordCount = 0;
                string strWhere = GetWhereString();
                ulist = loginbll.FindListPage(strWhere, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out RecordCount);
                AspNetPager1.RecordCount = RecordCount;
    
                GridView1.DataSource = ulist;
                GridView1.DataBind();
            }
    
            protected void AspNetPager1_PageChanged(object sender, EventArgs e)
            {
                GetData();
            }
            
            protected void btnsearch_Click(object sender, EventArgs e)
            {
                GetData();
            }
    
            protected string GetWhereString()
            {
                //拼接查询语句
                string strWhere = "1=1 ";
                return strWhere;
            }
    
        }
    }


  • 相关阅读:
    4.24成果(冲刺1.7)
    4.23成果(冲刺1.6)
    4.22成果(冲刺1.5)
    4.21成果(冲刺1.4)
    4.20成果(冲刺1.3)
    4.19成果(冲刺1.2)
    4.18成果(冲刺1.1)
    计划会议
    需求评审
    电梯演讲
  • 原文地址:https://www.cnblogs.com/smartsmile/p/6234108.html
Copyright © 2020-2023  润新知