| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3538 人关注过本帖
标题:各位大哥、恩公、帮帮忙吧、翻译一下、
只看楼主 加入收藏
sanguine_11
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-6-4
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
各位大哥、恩公、帮帮忙吧、翻译一下、
  private void getdatasss(string sql)  
    {
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {
            if (result.Tables[0].Rows.Count > 0)
            {
                //ntitle = result.Tables[0].Rows[0]["addby"].ToString().Trim();
                ncontent = result.Tables[0].Rows[0][0].ToString().Trim().ToString();
            }
        }
    }
-----------------------------
protected void Page_Load(object sender, EventArgs e)  //页面初始化时执行的操作
    {
        if (!IsPostBack)
        {
            leibie.Items.Add("所有");  //给下拉框leibie赋值
            addxiala("shuleixinxi", "leibie", "kehubianhao");
            string sql;
            sql = "select * from shumingxinxi order by id desc"; //查找所有书名信息
            getdata(sql);
        }
    }

    private void getdata(string sql)
    {
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {

            if (result.Tables[0].Rows.Count > 0)
            {
                DataGrid1.DataSource = result.Tables[0];
                DataGrid1.DataBind();
                Label1.Text = "以上数据中共" + result.Tables[0].Rows.Count+"条";
            }
            else
            {
                DataGrid1.DataSource = null;
                DataGrid1.DataBind();
                Label1.Text = "暂无任何数据";
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e) //单击查询按时时执行的查询操作
    {
        string sql;
        sql = "select * from shumingxinxi where 1=1"; //要执行的查询语句
        if (bianhao.Text.ToString().Trim()!="" ){ sql=sql+" and bianhao like '%" + bianhao.Text.ToString().Trim() + "%'";}if (mingcheng.Text.ToString().Trim()!="" ){ sql=sql+" and mingcheng like '%" + mingcheng.Text.ToString().Trim() + "%'";}if (leibie.Text.ToString().Trim()!="所有" ){ sql=sql+" and leibie like '%" + leibie.Text.ToString().Trim() + "%'";}if (chubanshe.Text.ToString().Trim()!="" ){ sql=sql+" and chubanshe like '%" + chubanshe.Text.ToString().Trim() + "%'";}
//按照条件依次加上筛选条件
        sql = sql + " order by id desc";

        getdata(sql);
    }

    protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e) //datagrid的分页按钮
    {
        string sql;
        sql = "select * from shumingxinxi order by id desc";
        getdata(sql);
        DataGrid1.CurrentPageIndex = e.NewPageIndex; // 读取当前页码
        DataGrid1.DataBind();
    }
    public string riqigeshi(object str) //自定义函数,设置日期格式
    {
        string strTmp = str.ToString();
        DateTime dt = Convert.ToDateTime(strTmp);
        string ss = dt.ToShortDateString();
        return ss;
        
    }
    private void addxiala(string ntable, string nzd, string nxlk) //自定义函数,用于给下拉框赋值
    {
        string sql;
        sql = "select " + nzd + " from " + ntable + " order by id desc";
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {
            if (result.Tables[0].Rows.Count > 0)
            {
                int i = 0;
                for (i = 0; i < result.Tables[0].Rows.Count; i++)
                {
                    leibie.Items.Add(result.Tables[0].Rows[i][0].ToString().Trim());
                }
            }
        }
        }
    -------------------------
public string nbianhao, nmingcheng, nleibie, nfengmian, nchubanshe, njianjie;
//定义全局变量名
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            string sql;
            sql = "select * from shumingxinxi where id=" + Request.QueryString["id"].ToString().Trim();
            getdata(sql);
            sql = "select * from zhangjiexinxi where bianhao='" + nbianhao + "'";

            sql = sql + " order by id desc";
            getdata2(sql);
        }
    }



    private void getdata(string sql) //自定义函数getdata,用于读取数据,并将其赋值给全局变量
    {
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {
            if (result.Tables[0].Rows.Count > 0)
            {
                nbianhao = result.Tables[0].Rows[0]["bianhao"].ToString().Trim(); nmingcheng = result.Tables[0].Rows[0]["mingcheng"].ToString().Trim(); nleibie = result.Tables[0].Rows[0]["leibie"].ToString().Trim(); nfengmian = result.Tables[0].Rows[0]["fengmian"].ToString().Trim(); nchubanshe = result.Tables[0].Rows[0]["chubanshe"].ToString().Trim(); njianjie = result.Tables[0].Rows[0]["jianjie"].ToString().Trim();

            }
        }
    }
    private void getdata2(string sql)
    {
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {

            if (result.Tables[0].Rows.Count > 0)
            {
                DataGrid1.DataSource = result.Tables[0];
                DataGrid1.DataBind();
               // Label1.Text = "以上数据中共" + result.Tables[0].Rows.Count + "条";
            }
            else
            {
                DataGrid1.DataSource = null;
                DataGrid1.DataBind();
                //Label1.Text = "暂无任何数据";
            }
        }
        }

--------------------------------
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;
        }
        }
    -----------------------------------
public string sql, lbtxt, lb,nkeyword;
    protected void Page_Load(object sender, EventArgs e)
    {
        lb = Request.QueryString["lb"].ToString().Trim();  
        switch (lb)
        {
            case "1":
                lbtxt = "站内新闻";
                break;
         }
        sql = "select id,title,addtime,leibie,dianjilv from allgonggao where leibie='" + lbtxt + "' ";
        nkeyword = Request.QueryString["keyword"];
        if (nkeyword != null)
        {
            sql = sql + " and title like '%" + nkeyword.ToString().Trim() + "%'";
        }
        sql=sql+"order by id desc";
        
        getdata(sql);
        
        
    }
    private void getdata(string sql)
    {
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {
            if (result.Tables[0].Rows.Count > 0)
            {
                DataGrid1.DataSource = result.Tables[0];
                DataGrid1.DataBind();
            }
            else
            {
                DataGrid1.DataSource = null;
                DataGrid1.DataBind();
            }
        }
    }
    protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {

        sql = "select id,title,addtime,leibie,dianjilv from allgonggao where leibie='" + lbtxt + "' order by id desc";
        getdata(sql);
        DataGrid1.CurrentPageIndex = e.NewPageIndex;
        DataGrid1.DataBind();
    }
--------------------------------------
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            xingbie.Items.Add("male");
            xingbie.Items.Add("female");
            //addxiala("kehuxinxi", "bianhao", "kehubianhao");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (new Class1().IsTelephone(dianhua.Text.ToString().Trim()))
        { }
        else
        {
            Response.Write("<script>javascript:alert('电话格式不正确');history.back();</script>");
            Response.End();
        }
        if (new Class1().IsEmail(youxiang.Text.ToString().Trim()))
        { }
        else
        {
            Response.Write("<script>javascript:alert('邮相格式不正确');history.back();</script>");
            Response.End();
        }
        string sql;
        sql = "insert into yonghuzhuce(yonghuming,mima,xingming,dianhua,youxiang,QQ,touxiang,jiguan,dizhi,xingbie,beizhu) values('" + yonghuming.Text.ToString().Trim() + "','" + mima.Text.ToString().Trim() + "','" + xingming.Text.ToString().Trim() + "','" + dianhua.Text.ToString().Trim() + "','" + youxiang.Text.ToString().Trim() + "','" + QQ.Text.ToString().Trim() + "','" + touxiang.Text.ToString().Trim() + "','" + jiguan.Text.ToString().Trim() + "','" + dizhi.Text.ToString().Trim() + "','" + xingbie.Text.ToString().Trim() + "','" + beizhu.Text.ToString().Trim() + "') ";
        int result;
        result = new Class1().hsgexucute(sql);
        if (result == 1)
        {
            Response.Write("<script>javascript:alert('注册成功,您可以去首页登陆了!');location.href='default.aspx';</script>");
            Response.End();
        }
        else
        {
            Response.Write("<script>javascript:alert('系统错误,请检查数据库设置问题');</script>");
        }
    }
--------------------------------------
if (!IsPostBack)
        {
            yonghuming.ReadOnly = true;
             xingbie.Items.Add("male");
             xingbie.Items.Add("female");
            string sql;
            sql = "select * from yonghuzhuce where yonghuming='" + Session["username"].ToString().Trim() + "'";
            getdata(sql);
        }
    }



    private void getdata(string sql)
    {
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {
            if (result.Tables[0].Rows.Count > 0)
            {
                yonghuming.Text = result.Tables[0].Rows[0]["yonghuming"].ToString().Trim();mima.Text = result.Tables[0].Rows[0]["mima"].ToString().Trim();xingming.Text = result.Tables[0].Rows[0]["xingming"].ToString().Trim();dianhua.Text = result.Tables[0].Rows[0]["dianhua"].ToString().Trim();youxiang.Text = result.Tables[0].Rows[0]["youxiang"].ToString().Trim();QQ.Text = result.Tables[0].Rows[0]["QQ"].ToString().Trim();touxiang.Text = result.Tables[0].Rows[0]["touxiang"].ToString().Trim();jiguan.Text = result.Tables[0].Rows[0]["jiguan"].ToString().Trim();dizhi.Text = result.Tables[0].Rows[0]["dizhi"].ToString().Trim();xingbie.Text = result.Tables[0].Rows[0]["xingbie"].ToString().Trim();beizhu.Text = result.Tables[0].Rows[0]["beizhu"].ToString().Trim();
               
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        
        string sql;
        
        sql = "update yonghuzhuce set yonghuming='" + yonghuming.Text.ToString().Trim() + "',mima='" + mima.Text.ToString().Trim() + "',xingming='" + xingming.Text.ToString().Trim() + "',dianhua='" + dianhua.Text.ToString().Trim() + "',youxiang='" + youxiang.Text.ToString().Trim() + "',QQ='" + QQ.Text.ToString().Trim() + "',touxiang='" + touxiang.Text.ToString().Trim() + "',jiguan='" + jiguan.Text.ToString().Trim() + "',dizhi='" + dizhi.Text.ToString().Trim() + "',xingbie='" + xingbie.Text.ToString().Trim() + "',beizhu='" + beizhu.Text.ToString().Trim() + "' where yonghuming='" + Session["username"].ToString().Trim() + "'";
        int result;
        result = new Class1().hsgexucute(sql);
        if (result == 1)
        {
            Response.Write("<script>javascript:alert('修改成功');</script>");
        }
        else
        {
            Response.Write("<script>javascript:alert('系统错误');</script>");
        }
    }
-------------------------------------
if (TextBox2.Text.ToString().Trim() == "" || TextBox1.Text.ToString().Trim() == "")
        {
            Response.Write("<script>javascript:alert('请输入完整');history.back();</script>");
            Response.End();
        }
//如果未填满信息,则给出提示
        string sql;
        sql = "";
        if (cx.Text.ToString().Trim() == "管理员")
        {
            sql = "select * from allusers where username='" + TextBox1.Text.ToString().Trim() + "' and pwd='" + TextBox2.Text.ToString().Trim() + "'";
//sql查询操作,即查询allusers表中用户名为当前输入用户名,密码为当前输入密码的是否有匹配存在
        }
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {
            if (result.Tables[0].Rows.Count > 0) //如果查询结果不为空,即有找到匹配对象
            {
                Session["username"] = TextBox1.Text.ToString().Trim();
            //给session[“username”]赋值,记录当前登陆人的用户名

                Session["cx"] = result.Tables[0].Rows[0]["cx"].ToString().Trim();
//给session[“cx”]赋值,记录当前登陆人的权限


                Response.Redirect("main.aspx");//跳转到后台主页面
            }
            else
            {
//如果查不到匹配数据,即登陆失改,给出相应提示
                Response.Write("<script>javascript:alert('对不起,用户名或密码不正确!');history.back();</script>");
            }
        }
        else
        {
//如果出现异常情况,即非法操作时,给出相应提示
            Response.Write("<script>javascript:alert('对不起,系统错误,请不要越权操作!');</script>");
        }
--------------------------------------
public string lb, lbtxt, sql; //定义全局变量
    protected void Page_Load(object sender, EventArgs e)
    {
        lb = Request.QueryString["lb"].ToString().Trim();  //类别为提交来的参数,即分为新闻中心和网站规章
        switch (lb)
        {
            case "1":
                lbtxt = "站内新闻";
                break;
            case "2":
                lbtxt = "校园快讯";
                break;
        }
        leibie.Text = lbtxt;
         Random rnd = new Random();
         int n = rnd.Next(1, 100);
         dianjilv.Text = n.ToString().Trim();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sql;
        sql="insert into allgonggao(title,content,leibie,shouyetupian,dianjilv) values('"+title.Text.ToString().Trim()+"','"+content.Text.ToString()+"','"+leibie.Text.ToString().Trim()+"','"+shouyetupian.Text.ToString().Trim()+"','"+dianjilv.Text.ToString().Trim()+"') ";
        int result;
        result = new Class1().hsgexucute(sql);
        if (result == 1)
        {
            Response.Write("<script>javascript:alert('添加成功');</script>");
        }
        else
        {
            Response.Write("<script>javascript:alert('系统错误,请检查数据库设置问题');</script>");
        }
    }
    ----------------------------------
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            leibie.Items.Add("所有");
            addxiala("shuleixinxi", "leibie", "kehubianhao");
            string sql;
            sql = "select * from shumingxinxi order by id desc";
            getdata(sql);
        }
    }

    private void getdata(string sql)
    {
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {

            if (result.Tables[0].Rows.Count > 0)
            {
                DataGrid1.DataSource = result.Tables[0];
                DataGrid1.DataBind();
                Label1.Text = "以上数据中共" + result.Tables[0].Rows.Count+"条";
            }
            else
            {
                DataGrid1.DataSource = null;
                DataGrid1.DataBind();
                Label1.Text = "暂无任何数据";
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sql;
        sql = "select * from shumingxinxi where 1=1";
        if (bianhao.Text.ToString().Trim()!="" ){ sql=sql+" and bianhao like '%" + bianhao.Text.ToString().Trim() + "%'";}if (mingcheng.Text.ToString().Trim()!="" ){ sql=sql+" and mingcheng like '%" + mingcheng.Text.ToString().Trim() + "%'";}if (leibie.Text.ToString().Trim()!="所有" ){ sql=sql+" and leibie like '%" + leibie.Text.ToString().Trim() + "%'";}if (chubanshe.Text.ToString().Trim()!="" ){ sql=sql+" and chubanshe like '%" + chubanshe.Text.ToString().Trim() + "%'";}
        sql = sql + " order by id desc";

        getdata(sql);
    }

    protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
        string sql;
        sql = "select * from shumingxinxi order by id desc";
        getdata(sql);
        DataGrid1.CurrentPageIndex = e.NewPageIndex;
        DataGrid1.DataBind();
    }
    public string riqigeshi(object str)
    {
        string strTmp = str.ToString();
        DateTime dt = Convert.ToDateTime(strTmp);
        string ss = dt.ToShortDateString();
        return ss;
        
    }
    private void addxiala(string ntable, string nzd, string nxlk)
    {
        string sql;
        sql = "select " + nzd + " from " + ntable + " order by id desc";
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {
            if (result.Tables[0].Rows.Count > 0)
            {
                int i = 0;
                for (i = 0; i < result.Tables[0].Rows.Count; i++)
                {
                    leibie.Items.Add(result.Tables[0].Rows[i][0].ToString().Trim());
                }
            }
        }
    }
---------------------------------
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            string sql;
            sql = "select * from yonghuzhuce order by id desc";
            getdata(sql);
        }
    }

    private void getdata(string sql)
    {
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {

            if (result.Tables[0].Rows.Count > 0)
            {
                DataGrid1.DataSource = result.Tables[0];
                DataGrid1.DataBind();
                Label1.Text = "以上数据中共" + result.Tables[0].Rows.Count+"条";
            }
            else
            {
                DataGrid1.DataSource = null;
                DataGrid1.DataBind();
                Label1.Text = "暂无任何数据";
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sql;
        sql = "select * from yonghuzhuce where 1=1";
        if (bh.Text.ToString().Trim() != "")
        {
            sql = sql + " and yonghuming like '%" + bh.Text.ToString().Trim() + "%'";
        }
        if (mc.Text.ToString().Trim() != "")
        {
            sql = sql + " and xingming like '%" + mc.Text.ToString().Trim() + "%'";
        }

        sql = sql + " order by id desc";

        getdata(sql);
    }

    protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
        string sql;
        sql = "select * from yonghuzhuce order by id desc";
        getdata(sql);
        DataGrid1.CurrentPageIndex = e.NewPageIndex;
        DataGrid1.DataBind();
        }
-------------------------------
protected void Page_Load(object sender, EventArgs e)
    {
        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));
        }
        if (!IsPostBack)
        {
            string sql;
            sql = "select * from book order by id desc";
            getdata(sql);
        }
    }
    private void getdata(string sql)
    {
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        if (result != null)
        {
            if (result.Tables[0].Rows.Count > 0)
            {
                rpt1.DataSource = result.Tables[0];
                rpt1.DataBind();
            }
            else
            {
                rpt1.DataSource = null;
                rpt1.DataBind();
            }
        }
    }

    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["username"] != 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["username"] != null)
        {
            return "" + "&nbsp;&nbsp;&nbsp;<a href=dellyb.aspx?id=" + id + ">删除</a>";
        }
        else
        {
            return null;
        }
        }
------------------------------
string sql;
//sql为插入数据库的语句,即添加新数据
        sql="insert into youqinglianjie(wangzhanmingcheng,wangzhi) values('"+wangzhanmingcheng.Text.ToString().Trim()+"','"+wangzhi.Text.ToString().Trim()+"') ";
        int result;
        result = new Class1().hsgexucute(sql);
//执行该sql语句
        if (result == 1)  //如果执行成功,则给出提示
        {
            Response.Write("<script>javascript:alert('添加成功');</script>");
        }
        Else //如果执行失败,也给出相应提示
        {
            Response.Write("<script>javascript:alert('系统错误,请检查数据库的连?);</script>");
        }
---------------------------------




麻烦哪位好人能帮我把这些所有能加备注的地方都加上、(尽量把每一行都加上)
十分感谢、9号要答辩了、、别人给做了一份、、什么也看不懂、、好人一生平安啊、、、


[ 本帖最后由 sanguine_11 于 2012-6-4 22:15 编辑 ]
搜索更多相关主题的帖子: result private sql void 
2012-06-04 22:14
sanguine_11
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-6-4
收藏
得分:0 
如果不够的话、、可以再加、、、反正有能力的大哥、、一定要帮帮我啊、、要出人命了
2012-06-04 22:18
wumingchenxi
Rank: 6Rank: 6
等 级:侠之大者
威 望:6
帖 子:96
专家分:457
注 册:2012-6-6
收藏
得分:20 
强,拉苦力来了。
2012-06-06 09:31
小小高高手
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-6-14
收藏
得分:0 
未免太多了吧
2012-06-14 12:01
ouyuheng123
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2016-5-12
收藏
得分:0 
我想知道  你的代码是哪来的,。。我有个系统留言板代码  跟你一模一样。。
2016-05-12 20:02
快速回复:各位大哥、恩公、帮帮忙吧、翻译一下、
数据加载中...
 
   



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

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