| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4647 人关注过本帖
标题:[求助]哪位大神帮忙翻译一下这段代码
只看楼主 加入收藏
ouyuheng123
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2016-5-12
收藏
 问题点数:0 回复次数:3 
[求助]哪位大神帮忙翻译一下这段代码
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));
        }
    }
    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'");
        }
    }
    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;
        }
        }
搜索更多相关主题的帖子: 管理员 null 
2016-05-12 20:06
ouyuheng123
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2016-5-12
收藏
得分:0 
江湖救急 !!求大神帮忙!
2016-05-12 20:07
ouyuheng123
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2016-5-12
收藏
得分:0 
特别是单击添加按钮那段,我的留言板点击留言  显示false。。
2016-05-12 20:16
ouyuheng123
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2016-5-12
收藏
得分:0 
没人。。??
2016-05-13 11:28
快速回复:[求助]哪位大神帮忙翻译一下这段代码
数据加载中...
 
   



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

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