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

📄 message_read.aspx.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
字号:
//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
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 NetCMS.Content;
using System.IO;
public partial class user_Message_read : NetCMS.Web.UI.UserPage
{
    public string Userfiles = NetCMS.Config.UIConfig.UserdirFile;
    Message mes = new Message();
    NetCMS.Content.Common.rootPublic pd = new NetCMS.Content.Common.rootPublic();
     protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string Mids = Request.QueryString["Mid"];
            MidID.Value = Mids;
            
            Response.CacheControl = "no-cache";
            string UserNum = NetCMS.Global.Current.UserNum;
            DataTable dts1 = mes.sel_userMessage(UserNum,1);
            this.DropDownList1.DataSource = dts1;
            this.DropDownList1.DataTextField = "UserName";
            this.DropDownList1.DataValueField = "FriendUserNum";
            this.DropDownList1.DataBind();
            DropDownList1.Items.Insert(0, new ListItem("请选择", "0"));

            //查找会员所属会员组
            string u_meGroupNumber = mes.sel_userInfo(UserNum);
            //是否可以群发
            DataTable u_MG = mes.sel_userMessage(u_meGroupNumber,2);

            string[] MessageGroupNum = u_MG.Rows[0]["MessageGroupNum"].ToString().Split('|');
            int MessageGroupNum1 = int.Parse(MessageGroupNum[0].ToString());
            int MessageGroupNum2 = int.Parse(MessageGroupNum[1].ToString());

                if (MessageGroupNum1 == 1)
                {
                    this.FileTFLabel.Text = "本站支持群发多个会员之间用逗号分割开,最多只能发" + MessageGroupNum2 + "个";
                }
                else
                {
                    this.FileTFLabel.Text = "本站不支持群发";
                }

            string Mid = Request.QueryString["Mid"];
            if (mes.sel_msgInfo(Mid,1) == 0)
            {
                PageError("参数错误", "Message_box.aspx?Id=1");
            }
            mes.update_msgInfo(Mid,1);
            DataTable read = mes.sel_userMessage(Mid,0);
            this.TitleBox.Text = read.Rows[0]["Title"].ToString();
            this.ContentBox.Value = read.Rows[0]["Content"].ToString();
            int sp = int.Parse(read.Rows[0]["FileTF"].ToString());
            if (sp == 1)
            {
                //this.FileTFLabelp.Text = "下载附件";
                FileTFLabelp.InnerHtml = "<a href=\"Message_file.aspx?Mid=" + Mids + "\"  class=\"\" target=\"_self\">下载附件</a>";
            }
            else
            {
                //this.FileTFLabelp.Enabled = false;
                //this.FileTFLabelp.Text = "无附件";
                FileTFLabelp.InnerHtml = "无附件";

            }
            int lf = int.Parse(read.Rows[0]["LevelFlag"].ToString());
            if (lf == 0)
            {
                this.LevelFlagLabel.Text = "普通";
            }
            else if (lf == 1)
            {
                this.LevelFlagLabel.Text = "加急";
            }
            else
            {
                this.LevelFlagLabel.Text = "紧急";
            }
            this.Rec_UserNumBox.Text = mes.sel_userInfo(read.Rows[0]["Rec_UserNum"].ToString());

        }
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            string UserNum = NetCMS.Global.Current.UserNum;
            string u_meGroupNumbero = mes.sel_userInfo(UserNum);
            //可以发送多少条
            DataTable u_MGo = mes.sel_userMessage(u_meGroupNumbero,2);
            int MessageNumo = 1;
            if (u_MGo.Rows[0]["MessageNum"].ToString() != "")
            {
                string[] MessageNumfgo = u_MGo.Rows[0]["MessageNum"].ToString().Split('|');
                MessageNumo = int.Parse(MessageNumfgo[0].ToString());
            }
            //查询会员已经发送多少条短信
            int cuto = mes.sel_msgInfo(UserNum,1);
            if (cuto >= MessageNumo)
            {
                PageError("您发送的邮件已经超过最大的发送数<br>", "Message_write.aspx");
            }
            else
            {
                string Midw = Request.QueryString["Mid"];
                int FileTF = Convert.ToInt32(mes.sel_msgInfo(Midw,2));
                string fileName = "";
                string FileUrl = "";
                if (FileTF == 1)
                {
                    DataTable reada = mes.sel_userMessage(Midw,4);
                    fileName = reada.Rows[0]["FileName"].ToString();
                    FileUrl = reada.Rows[0]["FileUrl"].ToString();
                }
                string copyfilelist = FileUrl.Substring(FileUrl.LastIndexOf(".") + 1).ToUpper();
                string filenum = NetCMS.Common.Rand.Number(12);//产生12位随机字符
                string UserNumfile = NetCMS.Global.Current.UserNum;
                string Dir = System.Web.HttpContext.Current.Server.MapPath("~/" + Userfiles + "/" + UserNumfile + "/").ToString();
                string copyFileUrl = Dir + filenum + "." + copyfilelist;
                //查找会员所属会员组
                string u_meGroupNumber1 = mes.sel_userInfo(UserNum);
                //是否可以群发
                DataTable u_MG1 = mes.sel_userMessage(u_meGroupNumber1,2);
                string[] MessageGroupNums = u_MG1.Rows[0]["MessageGroupNum"].ToString().Split('|');
                int MessageGroupNums1 = int.Parse(MessageGroupNums[0].ToString());
                int MessageGroupNums2 = int.Parse(MessageGroupNums[1].ToString());
                DateTime CreatTime = DateTime.Now;//邮件撰写时间
                DateTime Send_DateTime = DateTime.Now;//邮件发送时间

                string Midp = NetCMS.Common.Rand.Number(12,true);//产生12位随机字符
                int SortType = 0;
                string Title = Request.Form["TitleBox"].ToString();
                string Content = NetCMS.Common.Input.Htmls(this.ContentBox.Value);
                int LevelFlagp = 0;
                if (this.LevelFlagLabel.Text == "加急"){LevelFlagp = 1;}
                else if (this.LevelFlagLabel.Text == "紧急"){LevelFlagp = 2;}
                if (MessageGroupNums1 == 1)
                {
                    bool sc = true;
                    string[] i = this.Rec_UserNumBox.Text.Split(',');
                    for (int s = 0; s < i.Length; s++)
                    {
                        DataTable dts = mes.sel_userMessage(i[s],3);
                        int cuts = dts.Rows.Count;
                        if (cuts == 0){continue;}
                        string Rec_UserNum = dts.Rows[0]["UserNum"].ToString();
                        NetCMS.Model.message uc = new NetCMS.Model.message();
                        uc.Mid = Midp;
                        uc.UserNum = UserNum;
                        uc.Title = Title;
                        uc.Content = Content;
                        uc.CreatTime = CreatTime;
                        uc.Send_DateTime = Send_DateTime;
                        uc.SortType = SortType;
                        uc.Rec_UserNum = Rec_UserNum;
                        uc.FileTF = FileTF;
                        uc.LevelFlag = LevelFlagp;
                        mes.Add(uc);
                    }
                    if (FileTF == 1)
                    {
                        string MfID = NetCMS.Common.Rand.Number(12,true);//产生12位随机字符
                        if (mes.add_userMsg(MfID, Midp, UserNum, fileName, FileUrl, CreatTime) != 0) { sc = true; }
                        else{sc = false;}
                    }
                    if (sc){PageRight("发送成功", "Message_box.aspx?Id=1");}
                    else{PageRight("发送成功.但附件未发送成功", "Message_box.aspx?Id=1");}
                }
                else
                {
                    string Rec_UserNuma = this.Rec_UserNumBox.Text;
                    if (Rec_UserNuma == NetCMS.Global.Current.UserName)
                    {
                        PageError("不能给自己转发信息!", "Message_box.aspx?Id=1");
                    }
                    DataTable dts = mes.sel_userMessage(Rec_UserNuma,3);
                    int cuts = dts.Rows.Count;
                    if (cuts == 0){PageError("收件用户不存在", "Message_box.aspx?Id=1");}
                    string Rec_UserNum = dts.Rows[0]["UserNum"].ToString();
                    string MfID = NetCMS.Common.Rand.Number(12,true);//产生12位随机字符
                    NetCMS.Model.message uc = new NetCMS.Model.message();
                    uc.Mid = Midp;
                    uc.UserNum = UserNum;
                    uc.Title = Title;
                    uc.Content = Content;
                    uc.CreatTime = CreatTime;
                    uc.Send_DateTime = Send_DateTime;
                    uc.SortType = SortType;
                    uc.Rec_UserNum = Rec_UserNum;
                    uc.FileTF = FileTF;
                    uc.LevelFlag = LevelFlagp;
                    if (FileTF == 1)
                    {
                        if (!File.Exists(FileUrl))
                        {
                            FileTF = 0;
                        }
                        mes.Add(uc);
                        if (mes.add_userMsg(MfID, Midp, UserNum, filenum, copyFileUrl, CreatTime) != 0)
                        {
                            if (!File.Exists(FileUrl))
                            {
                                PageRight("转发送成功。<li>但因为附件已经被删除或者不存在,附件未转发成功!</li>", "Message_box.aspx?Id=1");
                            }
                            else
                            {
                                System.IO.File.Copy(FileUrl, copyFileUrl, false);
                                PageRight("转发送成功", "Message_box.aspx?Id=1");
                            }
                        }
                        else
                        {
                            PageRight("转发送失败", "Message_box.aspx?Id=1");
                        }                   
                    }
                    else
                    {
                        mes.Add(uc);
                        PageRight("转发送成功", "Message_box.aspx?Id=1");
                    }
                }
            }
        } 
    }
}

⌨️ 快捷键说明

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