⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classmsg.aspx.cs

📁 校友录的总体功能分为三个子功能模块:管理功能模块,用户注册功能模块,用户个性化服务
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Data;
using System.Data.SqlClient;
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.Text;
using System.Text.RegularExpressions;

public partial class classmsg : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (Session["UserID"] == null)
        //    Response.Redirect("index.aspx");

        if (Session["UserID"] == null)
            Response.Redirect("index.aspx");

        if (!this.IsPostBack)
        {
            BindView();
        }

    }
    protected void GridView1_DataBound(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        ImageButton ibtn = ((ImageButton)e.Row.FindControl("Msgsend"));
        if (ibtn == null)
        {
            return;
        }
        ibtn.Enabled = true;
        //switch   (Convert.ToInt32((e.Row.Cells[4].Text.Trim())))   
        //{   
        //        case   1:   
        ibtn.CommandArgument = e.Row.DataItemIndex.ToString();
        //---------------------------------------------------------------------------------------- 
        // DelBtn
        ImageButton btn = ((ImageButton)e.Row.FindControl("DelBtn"));
        if (btn == null)
        {
            return;
        }
        btn.CommandArgument = e.Row.DataItemIndex.ToString();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {

            case "smsg":
                {
                    int index = Convert.ToInt32(e.CommandArgument) - this.GridView1.PageIndex * 10;
                    //获取行的位置
                    GridViewRow row = GridView1.Rows[index];
                    //获取选定行的列的位置,比如第三列,付给你自己的变量表达式,这里是全局变量varImpID
                    //  Session["MailTo"] = row.Cells[0].Text;

                    //Label lb = (Label)row.FindControl("UserLab");

                    ////   this.testtext.Text = row.Cells[4].Text;
                    //String StrTemp = lb.Text;
                    Session["MsgTo"] = Session["classname"].ToString().Trim();
                    Response.Redirect("SendMsg.aspx");

                    ///////MsgBtn  ImageButton2
                    //ImageButton ibtn = ((ImageButton)e.Row.FindControl("MsgBtn"));
                    //if (ibtn == null)
                    //{
                    //    return;
                    //}
                    //ibtn.Enabled = true;
                    ////switch   (Convert.ToInt32((e.Row.Cells[4].Text.Trim())))   
                    ////{   
                    ////        case   1:   
                    //ibtn.CommandArgument = e.Row.DataItemIndex.ToString();





                } break;
            case "DelMsg":
                {
                    int index = Convert.ToInt32(e.CommandArgument) - this.GridView1.PageIndex * 10;
                    //获取行的位置
                    GridViewRow row = GridView1.Rows[index];
                    //获取选定行的列的位置,比如第三列,付给你自己的变量表达式,这里是全局变量varImpID
                    //  Session["MailTo"] = row.Cells[0].Text;

                    Label lb = (Label)row.FindControl("Accept");
                    String StrTemp = lb.Text;

                    //ViewLab
                    Label lb2 = (Label)row.FindControl("BBsNum");
                    String Strcontent = lb2.Text;



                    delMsg(StrTemp, Strcontent);


                    ////////////////////////////////

                    BindView();


                } break;





            default: break;

        }


    }
    public void delMsg(string strsql, string Strcontent)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);

        //  cmdUpdateB=new SqlCommand("update data set Datas='"+this.TextBox3.Text+"'where ID=2 ",con);
        string sql;

        sql = "delete   from MsgInfo where AcceptMan='" + strsql + "' and BBSNum='" + Strcontent + "'";



        SqlCommand cmd = new SqlCommand(sql, conn);
        cmd.Connection.Open();

        cmd.ExecuteNonQuery();

        cmd.Connection.Close();

        ////   this.selspan.InnerHtml =







    }
    public void BindView()
    {

        //SELECT UserInfo.PicName, MsgInfo.Title, MsgInfo.Content, MsgInfo.SubTime, MsgInfo.AcceptMan, MsgInfo.UserID FROM UserInfo INNER JOIN MsgInfo ON UserInfo.UserID = MsgInfo.UserID
        //  string cmd = " SELECT [UserID], [Email], [Tele], [MobilePh], [PicName], [QQ], [StudentID] FROM [UserInfo] where StudentID IN (select StudentID from StudentInfo where Name  LIKE '" + "%" + this.SerchText.Text.ToString() + "%" + "')";//"+this.Province.Text.ToString()+" ; //设置SQL命令
        string cmd = "SELECT UserInfo.PicName, MsgInfo.Title, MsgInfo.Content, MsgInfo.SubTime, MsgInfo.AcceptMan, MsgInfo.UserID , MsgInfo.BBSNum FROM UserInfo INNER JOIN MsgInfo ON UserInfo.UserID = MsgInfo.UserID where MsgInfo.AcceptMan ='" + Session["classname"].ToString().Trim() + "'";

        this.SqlDataSource1.SelectCommand = cmd;
        this.SqlDataSource1.DataBind();   //将SqlDataSource重新绑定
        this.GridView1.DataBind();
        //  this.countlab.Text=this.GridView1.
    }             //对GridView进行绑定

    protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {

    }
    public string UToH(object source)
    {
        string str = source.ToString();

        return UBBToHTML(str);
    }
    public string UBBToHTML(string sDetail)
    {
        Regex r;
        Match m;

        //#region 处理空格
        //  sDetail = sDetail.Replace(" ", " ");
        //  #endregion
        #region 处理单引号
        sDetail = sDetail.Replace("'", "’");
        #endregion
        #region 处理双引号
        sDetail = sDetail.Replace("\"", """);
        #endregion
        #region html标记符
        sDetail = sDetail.Replace("<", "&lt;");
        sDetail = sDetail.Replace(">", "&gt;");
        #endregion




        //     处理换行,在每个新行的前面添加两个全角空格
        r = new Regex(@"(\r\n((&nbsp;)| )+)(?<正文> +)", RegexOptions.IgnoreCase);

        #region 处理换行
        for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
        {
            sDetail = sDetail.Replace(m.Groups[0].ToString(), "<BR>  " + m.Groups["正文"].ToString());
        }
        //   处理换行,在每个新行的前面添加两个全角空格
        sDetail = sDetail.Replace("\r\n", "<BR>");
        #endregion
        #region 处[b][/b]标记
        r = new Regex(@"(\[B\])([^\t]*?)(\[\/B\])", RegexOptions.IgnoreCase);
        for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
        {
            sDetail = sDetail.Replace(m.Groups[0].ToString(), "<b>" + m.Groups[2].ToString() + "</b>");
        }
        #endregion
        #region 处[i][/i]标记
        r = new Regex(@"(\[I\])([^\t]*?)(\[\/I\])", RegexOptions.IgnoreCase);
        for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
        {
            sDetail = sDetail.Replace(m.Groups[0].ToString(), "<i>" + m.Groups[2].ToString() + "</i>");
        }

        #endregion
        #region 处[u][/u]标记
        r = new Regex(@"(\[U\])([^\t]*?)(\[\/U\])", RegexOptions.IgnoreCase);
        for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
        {
            sDetail = sDetail.Replace(m.Groups[0].ToString(), "<u>" + m.Groups[2].ToString() + "</u>");
        }
        #endregion
        #region 处[p][/p]标记
        //   处[p][/p]标记
        r = new Regex(@"((\r\n)*\[p\])(.*?)((\r\n)*\[\/p\])", RegexOptions.IgnoreCase | RegexOptions.Singleline);
        for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
        {
            sDetail = sDetail.Replace(m.Groups[0].ToString(), "<P class=\"pstyle\">" + m.Groups[3].ToString() + "</P>");
        }
        #endregion
        #region 处[sup][/sup]标记
        //   处[sup][/sup]标记
        r = new Regex(@"(\[sup\])([ \t]*?)(\[\/sup\])", RegexOptions.IgnoreCase);
        for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
        {
            sDetail = sDetail.Replace(m.Groups[0].ToString(), "<SUP>" + m.Groups[2].ToString() + "</SUP>");
        }
        #endregion
        #region 处[sub][/sub]标记
        ///  处[sub][/sub]标记
        r = new Regex(@"(\[sub\])([ \t]*?)(\[\/sub\])", RegexOptions.IgnoreCase);
        for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
        {
            sDetail = sDetail.Replace(m.Groups[0].ToString(), "<SUB>" + m.Groups[2].ToString() + "</SUB>");
        }
        #endregion
        //#region 处[url][/url]标记
        ///// 处[url][/url]标记
        ////处[url][/url]标记
        //r = new Regex(@"(\[URL\])([^\t]*?)(\[\/URL\])", RegexOptions.IgnoreCase);
        //for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
        //{
        //    sDetail = sDetail.Replace(m.Groups[0].ToString(),
        //     "<a href=\"" + m.Groups[2].ToString() + "\" target=\"_blank\">" +
        //     m.Groups[2].ToString() + "</a>");
        //}
        //#endregion
        //#region 处[url=xxx][/url]标记
        ////  处[url=xxx][/url]标记
        ////处[url=xxx][/url]标记
        //r = new Regex(@"(\[URL=([^\t]+)\])([^\t]*?)(\[\/URL\])", RegexOptions.IgnoreCase);
        //for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
        //{
        //    sDetail = sDetail.Replace(m.Groups[0].ToString(),
        //     "<a href=\"" + m.Groups[2].ToString() + "\" target=\"_blank\">" +
        //     m.Groups[3].ToString() + "</a>");
        //}

        //#endregion
        //////////////////////////////////
        r = new Regex(@"(\[URL\])(.[^\[]*)(\[\/URL\])", RegexOptions.IgnoreCase);
        sDetail = r.Replace(sDetail, @"<A HREF=""http://$2"" TARGET=_blank>$2</A>");

        r = new Regex(@"(\[URL=(http:\/\/.[^\[]*)\])(.[^\[]*)(\[\/URL\])", RegexOptions.IgnoreCase);
        sDetail = r.Replace(sDetail, @"<A HREF=""$2"" TARGET=_blank>$3</A>");

        r = new Regex(@"(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])", RegexOptions.IgnoreCase);
        sDetail = r.Replace(sDetail, @"<A HREF=""http://$2"" TARGET=_blank>$3</A>");
        ////////////////////////////////////////////////
        #region 处[email][/email]标记
        //   处[email][/email]标记
        r = new Regex(@"(\[email\])([ \t]*?)(\[\/email\])", RegexOptions.IgnoreCase);
        for (m = r.Match(sDetail); m.Success; m = m.NextMatch())
        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -