| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 855 人关注过本帖
标题:C#代码解释!专业人士进!
只看楼主 加入收藏
wandy001
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2009-11-24
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
C#代码解释!专业人士进!

各位大哥大姐,请帮帮忙吧,老婆叫我帮忙解释这段代码,要求演讲解说,可是我业余人士,实在无能为力,小弟再次谢过了,真的很急,在线等!跪谢!
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class lyb : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["admin"] != null)
        {
            admin_go.Text = "退出管理";
            admin_go.NavigateUrl = "exit.aspx";
        }
        if (!this.IsPostBack)
        {
            string ToPage = Request.QueryString["ToPage"];
            if (ToPage == null)
            {
                ToPage = "1";
            }
            if (!StrRegExp.IsID(ToPage))
            {
                ToPage = "1";
            }
            this.Bind_rptList(Convert.ToInt32(ToPage));
        }
    }
    private void Bind_rptList(int ToPage)
    {
        int CurrentPage = ToPage;
        int PageSize = 5;
        int PageCount;
        int RecordCount;
        string PageSQL;
        string DataTable = "book";
        string DataFiled = "ID";
        string DataFileds = "ID,UserName,Face,Sex,QQ,HomePage,Email,IsHidden,Adddate,body,isrely,rebody";
        string DataOrders = "ID Desc";
        SqlConnection Conn = DB.createdb();
       //  string connstring = ConfigurationManager.AppSettings["cn"];
       // SqlConnection Conn = new SqlConnection();
      //  Conn.ConnectionString = connstring;
      //  conn.Open();
        Conn.Open();
        //* 取得记录总数,计算总页数
        SqlCommand cmd = new SqlCommand("Select Count(" + DataFiled + ") From " + DataTable, Conn);
        RecordCount = Convert.ToInt32(cmd.ExecuteScalar());
        if ((RecordCount % PageSize) != 0)
        {
            PageCount = RecordCount / PageSize + 1;
        }
        else
        {
            PageCount = RecordCount / PageSize;
        }
        if (ToPage > PageCount)
        {
            CurrentPage = PageCount;
        }
        if (CurrentPage <= 1)
        {
            PageSQL = "Select Top " + PageSize + " " + DataFileds + " From " + DataTable + " Order By " + DataOrders;
        }
        else
        {
            PageSQL = "Select Top " + PageSize + " " + DataFileds + " From " + DataTable + " Where " + DataFiled + " Not In ( Select Top " + PageSize * (CurrentPage - 1) + " " + DataFiled + " From " + DataTable + " Order By " + DataOrders + " ) Order By " + DataOrders;
        }
        SqlDataAdapter oda = new SqlDataAdapter(PageSQL, Conn);
        DataSet ds = new DataSet();
        oda.Fill(ds, "infList");
        this.lbTotalPage.Text = Convert.ToString(PageCount);
        this.hlkFirstPage.NavigateUrl = "?ToPage=1";
        this.hlkLastPage.NavigateUrl = "?ToPage=" + PageCount;
        this.lbCurrentPage.Text = Convert.ToString(CurrentPage);
        if (CurrentPage <= 1)
        {
            this.hlkPrevPage.Enabled = false;
            CurrentPage = 1;
        }
        else
        {
            this.hlkPrevPage.Enabled = true;
            this.hlkPrevPage.NavigateUrl = "?ToPage=" + (ToPage - 1);
        }
        if (CurrentPage >= PageCount)
        {
            this.hlkNextPage.Enabled = false;
            CurrentPage = PageCount;
        }
        else
        {
            this.hlkNextPage.Enabled = true;
            this.hlkNextPage.NavigateUrl = "?ToPage=" + (ToPage + 1);
        }
        rpt1.DataSource = ds.Tables["infList"].DefaultView;
        rpt1.DataBind();
        Conn.Close();
    }
    protected string showrely(bool isrely, string rebody)
    {
        if (isrely)
        {
            return "<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='#2CB421'>管理员回复:&nbsp;&nbsp;</font><font color='#000099'>" + Server.HtmlEncode(rebody) + "</font>";
        }
        else
        {
            return null;
        }
    }

    protected string showbody(bool ishidden, string str_body)
    {
        if (!ishidden || Session["admin"] != null)
        {
            return str_body.Replace("\r\n", "<br>");

        }

        else
        {
            return "<br>&nbsp;&nbsp;<font color=red>此留言为悄悄话!只有管理员可见!</font>";
        }
    }

    protected string show_admin(int id)
    {
        if (Session["admin"] != null)
        {
            return "<a href=re.aspx?id=" + id + ">回复</a>" + "&nbsp;&nbsp;&nbsp;<a href=del.aspx?id=" + id + ">删除</a>";
        }
        else
        {
            return null;
        }
    }
    protected void addly_Click(object sender, EventArgs e)
    {
        book binbin = new book();
        binbin.username = Server.HtmlEncode(this.username.Text);
        binbin.email = this.email.Text;
        binbin.qq = this.qq.Text;
        binbin.homepage = this.homepage.Text;
        if (this.Radboy.Checked)
        {
            binbin.sex = "男";
            binbin.face = "boy";
        }
        else
        {
            binbin.sex = "女";
            binbin.face = "gril";
        }
        binbin.body = this.lybody.Text;
        if (this.ishde.Checked)
        {
            binbin.ishide = true;
        }
        else
        {
            binbin.ishide = false;
        }
        Label1.Text = binbin.ishide.ToString();
        if (saveinfo.savely(binbin))
        {
            Response.Redirect("lyb.aspx");
        }
        else
        {
            Response.Write("<script>alert('留言失败,服务器错误!');location.herf='lyb.aspx'");
        }
    }
    protected void rpt1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {

    }
}
搜索更多相关主题的帖子: 代码 解释 专业 
2009-11-24 18:15
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
收藏
得分:10 
太长了,还是asp的代码,无能为力

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2009-11-24 19:25
athenalux
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:河北石家庄
等 级:小飞侠
威 望:8
帖 子:975
专家分:2514
注 册:2008-11-26
收藏
得分:10 
问问

QQ:81704464
2009-11-25 07:35
快速回复:C#代码解释!专业人士进!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036761 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved