MessageRead.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:10k
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using qminoa.Common.Data;
- using System.Data.SqlClient;
- using qminoa.DA;
- namespace qminoa.Webs.Msg
- {
- public class MessageRead : qminoa.Webs.PageBase
- {
- private string msgid = null;
- private string status = null;
- protected System.Web.UI.WebControls.Label LblCopyTo;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrCopyTo;
- protected System.Web.UI.WebControls.Label lblNext;
- protected System.Web.UI.WebControls.Label lblPre;
- protected System.Web.UI.WebControls.Label LblCont;
- protected System.Web.UI.WebControls.Label LblAcc;
- protected System.Web.UI.WebControls.Label LblTitle;
- protected System.Web.UI.WebControls.Label LblTime;
- protected System.Web.UI.WebControls.Label LblTotal;
- protected System.Web.UI.WebControls.Label LblSecretTo;
- protected System.Web.UI.WebControls.Label LblRece;
- protected System.Web.UI.WebControls.Label LblSender;
- protected System.Web.UI.HtmlControls.HtmlTable TblMain;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrSender;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrRece;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrSecretTo;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrTotal;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrInfo;
- protected System.Web.UI.HtmlControls.HtmlTable TblInfo;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrInfoTitle;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrTime;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrTitle;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrAcc;
- protected System.Web.UI.HtmlControls.HtmlTableRow TrCont;
- private void Page_Load(object sender, System.EventArgs e)
- {
- this.PageBegin("发送信息",false);
- msgid = Request.Params["MessageID"];
- status = Request.Params["Status"];
- if(status != "2")
- {
- MessageData msgobj = (new MsgObj()).SeeAllMessage(msgid,status);
- if(status == "4")
- {
- string reid = null;
- for(int i = 0; i < msgobj.Tables[MessageData.MESSAGE_TABLE].Rows.Count; i++)
- {
- string personid = msgobj.Tables[MessageData.MESSAGE_TABLE].Rows[i][MessageData.RESIVEID_FIELD].ToString();
- if(personid == this.Empid)
- {
- reid = msgobj.Tables[MessageData.MESSAGE_TABLE].Rows[i][MessageData.REID_FIELD].ToString();
- (new MsgObj()).WatchTimesAdd(reid);
- string times = msgobj.Tables[MessageData.MESSAGE_TABLE].Rows[i][MessageData.WATCHTIMES_FIELD].ToString();
- int i_times = Convert.ToInt32(times,10) + 1;
- msgobj.Tables[MessageData.MESSAGE_TABLE].Rows[i][MessageData.WATCHTIMES_FIELD] = i_times;
- msgobj.Tables[MessageData.MESSAGE_TABLE].Rows[i][MessageData.MESSAGESEETIME_FIELD] = DateTime.Now;
- }
- }
- }
- ShowMsg(msgid,status,msgobj);
- }
- else
- {
- Response.Redirect("SendMessage.aspx?flag=2&MessageID=" + msgid);
- }
- }
- public void ShowMsg(string msgid,string status,MessageData msgobj)
- {
- DataView MsgView = msgobj.Tables[MessageData.MESSAGE_TABLE].DefaultView;
- MsgView.Sort = MessageData.MESSAGEID_FIELD + " Desc";
- int index = MsgView.Find(Convert.ToInt16(msgid));
- if ( index != -1)
- {
- LblSender.Text = MsgView[index].Row[MessageData.MESSAGEPERSON_FIELD].ToString();
- LblRece.Text = MsgView[index].Row[MessageData.SENDTO_FIELD].ToString();
- LblSecretTo.Text = MsgView[index].Row[MessageData.SECRETTO_FIELD].ToString();
- LblTitle.Text = MsgView[index].Row[MessageData.TITLE_FIELD].ToString();
- if(MsgView[index].Row[MessageData.ACCESSORYID_FIELD].ToString() == "")
- {
- LblAcc.Text = "无附件";
- }
- else
- {
- string [] AccList;
- string [] AccIDList;
- char [] seprator = new Char[1];
- seprator[0] = ',';
- AccIDList = MsgView[index].Row[MessageData.ACCESSORYID_FIELD].ToString().Split(seprator,10);
- AccList = MsgView[index].Row[MessageData.ACCESSORY_FIELD].ToString().Split(seprator,10);
- for(int i = 0; i < AccIDList.Length; i ++)
- {
- LblAcc.Text += "<a href="file/"
- + AccIDList[i]
- + "" target="_blank">"
- + AccList[i]
- + "</a>" +"<br>";
- }
- }
- LblCont.Text = MsgView[index].Row[MessageData.CONTENT_FIELD].ToString();
- if(LblCont.Text == "")
- LblCont.Text = "无具体内容";
- LblTime.Text = MsgView[index].Row[MessageData.MESSAGESENDTIME_FIELD].ToString();
- if(status != "3")
- {
- int count = MsgView.Count;
- for(int i = 0; i < count; i ++)
- {
- HtmlTableRow row = new HtmlTableRow();
- HtmlTableCell [] cell = { new HtmlTableCell(),
- new HtmlTableCell(),
- new HtmlTableCell(),
- new HtmlTableCell()
- };
- switch(MsgView[i].Row[MessageData.Level_FIELD].ToString())
- {
- case "0":
- cell[0].InnerText = "发送";
- break;
- case "1":
- cell[0].InnerText = "密送";
- break;
- }
- row.Cells.Add(cell[0]);
- cell[1].InnerText = MsgView[i].Row[MessageData.RESIVE_FIELD].ToString();
- row.Cells.Add(cell[1]);
- if(MsgView[i].Row[MessageData.WATCHTIMES_FIELD].ToString() == "0")
- {
- cell[2].InnerText = "未读";
- }
- else
- {
- cell[2].InnerText = "已读" + MsgView[i].Row[MessageData.WATCHTIMES_FIELD].ToString()+ "次";
- }
- row.Cells.Add(cell[2]);
- cell[3].InnerText = MsgView[i].Row[MessageData.MESSAGESEETIME_FIELD].ToString();
- row.Cells.Add(cell[3]);
- TblInfo.Rows.Add(row);
- }
- LblTotal.Text = "该条信息共发送给" + count + "个用户";
- }
- else
- {
- string person = MsgView[index].Row[MessageData.SENDTO_FIELD].ToString()
- + ","+ MsgView[index].Row[MessageData.SECRETTO_FIELD].ToString();
- char [] separator = new char[1];
- separator[0] = ',';
- string [] person_list = person.Split(separator,10);
- int personcount = person_list.Length;
- for( int i = 0; i < personcount; i ++)
- {
- HtmlTableRow row = new HtmlTableRow();
- HtmlTableCell [] cells = { new HtmlTableCell(),
- new HtmlTableCell(),
- new HtmlTableCell(),
- new HtmlTableCell()
- };
- cells[0].InnerText = "";
- cells[1].InnerText = person_list[i];
- cells[2].InnerText = "未发送";
- cells[3].InnerText = "";
- foreach(HtmlTableCell cell in cells)
- row.Cells.Add(cell);
- TblInfo.Rows.Add(row);
- }
- LblTotal.Text = "该条信息接收人有" + personcount + "个";
- }
- FineNextPre(Convert.ToInt32(msgid));
- }
- }
-
- public void FineNextPre(int msgid)
- {
- DataSet data = new DataSet();
- if(status == "4")
- {
- data = (new MsgObj()).SeeMessage("recnote",Convert.ToInt16(this.Empid));
- }
- else if(status == "0")
- {
- data = (new MsgObj()).SeeMessage("sendnote",Convert.ToInt16(this.Empid));
- }
- else
- {
- data = (new MsgObj()).SeeMessage("lanote",Convert.ToInt16(this.Empid));
- }
- DataView SimpleView = data.Tables["simpleobj"].DefaultView;
- SimpleView.Sort = MessageData.MESSAGEID_FIELD;
- int CurrentID = SimpleView.Find(msgid);
- int [] ID = new int[2];
- int TotalRow = SimpleView.Count;
- string [] next_status = new string [2];
- if( 0 < CurrentID && CurrentID < TotalRow - 1)
- {
- ID[0] = CurrentID - 1;
- ID[1] = CurrentID + 1;
- next_status[0] = SimpleView[ ID[0] ].Row[MessageData.STATUS_FIELD].ToString();
- next_status[1] = SimpleView[ ID[1] ].Row[MessageData.STATUS_FIELD].ToString();
- ID[0] = Convert.ToInt32(SimpleView[ ID[0] ].Row[MessageData.MESSAGEID_FIELD].ToString(),10);
- ID[1] = Convert.ToInt32(SimpleView[ ID[1] ].Row[MessageData.MESSAGEID_FIELD].ToString(),10);
- }
- else if ( 0 == CurrentID )
- {
- ID[0] = -1;
- ID[1] = CurrentID + 1;
- if( TotalRow != 1)
- {
- next_status[1] = SimpleView[ ID[1] ].Row[MessageData.STATUS_FIELD].ToString();
- ID[1] = Convert.ToInt32(SimpleView[ ID[1] ].Row[MessageData.MESSAGEID_FIELD].ToString(),10);
- }
- else
- {
- ID[1] = -1;
- }
- }
- else
- {
- ID[0] = CurrentID - 1;
- ID[1] = -1;
- next_status[0] = SimpleView[ ID[0] ].Row[MessageData.STATUS_FIELD].ToString();
- ID[0] = Convert.ToInt32(SimpleView[ ID[0] ].Row[MessageData.MESSAGEID_FIELD].ToString(),10);
- }
- string [] MessageID = new string [2];
- MessageID[0] = ID[0].ToString();
- MessageID[1] = ID[1].ToString();
- if(ID[0] != -1)
- {
- lblPre.Text = "<a href="MessageRead.aspx?MessageID="
- + MessageID[0]
- + "&Status="
- + next_status[0]
- +"""
- + "target="_self">"
- +"上一条"
- +"</a>";
- }
- else
- {
- lblPre.Text = "上一条";
- }
- if (ID[1] != -1 )
- {
- lblNext.Text = "<a href="MessageRead.aspx?"
- + "&MessageID="
- + MessageID[1]
- + "&Status="
- + next_status[1]
- +"""
- + "target="_self">"
- + "下一条"
- + "</a>";
- }
- else
- {
- lblNext.Text = "下一条";
- }
- }
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
-
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- }
- }